diff --git a/.gitignore b/.gitignore index 58a45545939..8d05f8f3337 100644 --- a/.gitignore +++ b/.gitignore @@ -21,15 +21,16 @@ tests/services/baselines/local/* tests/baselines/prototyping/local/* tests/baselines/rwc/* tests/baselines/test262/* -tests/baselines/reference/projectOutput/* +tests/baselines/reference/projectOutput/* tests/baselines/local/projectOutput/* tests/services/baselines/prototyping/local/* tests/services/browser/typescriptServices.js scripts/configureNightly.js scripts/processDiagnosticMessages.d.ts scripts/processDiagnosticMessages.js -scripts/importDefinitelyTypedTests.js +scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js src/harness/*.js +src/compiler/diagnosticInformationMap.generated.ts rwc-report.html *.swp build.json @@ -45,8 +46,10 @@ scripts/run.bat scripts/word2md.js scripts/ior.js scripts/*.js.map +scripts/typings/ coverage/ internal/ **/.DS_Store -.settings/* -!.settings/tasks.json +.settings +.vscode/* +!.vscode/tasks.json diff --git a/.npmignore b/.npmignore index 2b75d37f70a..3af34bded4a 100644 --- a/.npmignore +++ b/.npmignore @@ -3,6 +3,11 @@ doc scripts src tests -Jakefile +internal +tslint.json +Jakefile.js +.editorconfig +.gitattributes +.settings/ .travis.yml -.settings/ \ No newline at end of file +.vscode/ \ No newline at end of file diff --git a/.settings/tasks.json b/.settings/tasks.json deleted file mode 100644 index e617f228378..00000000000 --- a/.settings/tasks.json +++ /dev/null @@ -1,23 +0,0 @@ -// Available variables which can be used inside of strings. -// ${workspaceRoot}: the root folder of the team -// ${file}: the current opened file -// ${fileBasename}: the current opened file's basename -// ${fileDirname}: the current opened file's dirname -// ${fileExtname}: the current opened file's extension -// ${cwd}: the current working directory of the spawned process -{ - "version": "0.1.0", - "command": "jake", - "isShellCommand": true, - "showOutput": "silent", - "tasks": [ - { - "taskName": "local", - "isBuildCommand": true, - "showOutput": "silent", - "problemMatcher": [ - "$tsc" - ] - } - ] -} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000000..9cf1c9d8f3f --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,42 @@ +// Available variables which can be used inside of strings. +// ${workspaceRoot}: the root folder of the team +// ${file}: the current opened file +// ${fileBasename}: the current opened file's basename +// ${fileDirname}: the current opened file's dirname +// ${fileExtname}: the current opened file's extension +// ${cwd}: the current working directory of the spawned process +{ + "version": "0.1.0", + "command": "jake", + "isShellCommand": true, + "showOutput": "silent", + "tasks": [ + { + "taskName": "local", + "isBuildCommand": true, + "showOutput": "silent", + "problemMatcher": [ + "$tsc" + ] + }, + { + "taskName": "lint-server", + "args": [], + "problemMatcher": { + "owner": "typescript", + "fileLocation": ["relative", "${workspaceRoot}"], + "pattern": { + "regexp": "^(warning|error)\\s+([^(]+)\\s+\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(.*)$", + "severity": 1, + "file": 2, + "location": 3, + "message": 4 + }, + "watchedTaskBeginsRegExp": "^\\*\\*\\*Lint failure\\*\\*\\*$", + "watchedTaskEndsRegExp": "^\\*\\*\\* Total \\d+ failures\\.$" + }, + "showOutput": "always", + "isWatching": true + } + ] +} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 41a16fff3eb..c2865280f44 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,7 @@ Design changes will not be accepted at this time. If you have a design change pr ## Legal You will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you are granting us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under appropriate copyright. -Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit https://cla.microsoft.com to sign digitally. Alternatively, download the agreement ([Microsoft Contribution License Agreement.docx](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=822190) or [Microsoft Contribution License Agreement.pdf](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=921298)), sign, scan, and email it back to . Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request. Please note that we're currently only accepting pull requests of bug fixes rather than new features. +Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit https://cla.microsoft.com to sign digitally. Alternatively, download the agreement ([Microsoft Contribution License Agreement.docx](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=822190) or [Microsoft Contribution License Agreement.pdf](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=921298)), sign, scan, and email it back to . Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request. ## Housekeeping Your pull request should: diff --git a/Jakefile.js b/Jakefile.js index 396f15e2730..5b93462d855 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -4,6 +4,7 @@ var fs = require("fs"); var os = require("os"); var path = require("path"); var child_process = require("child_process"); +var Linter = require("tslint"); // Variables var compilerDirectory = "src/compiler/"; @@ -143,7 +144,8 @@ var harnessSources = harnessCoreSources.concat([ "convertToBase64.ts", "transpile.ts", "reuseProgramStructure.ts", - "cachingInServerLSHost.ts" + "cachingInServerLSHost.ts", + "moduleResolution.ts" ].map(function (f) { return path.join(unittestsDirectory, f); })).concat([ @@ -157,10 +159,10 @@ var harnessSources = harnessCoreSources.concat([ var librarySourceMap = [ { target: "lib.core.d.ts", sources: ["core.d.ts"] }, - { target: "lib.dom.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts"], }, - { target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "intl.d.ts", "webworker.generated.d.ts"], }, + { target: "lib.dom.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "dom.generated.d.ts"], }, + { target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "webworker.generated.d.ts"], }, { target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], }, - { target: "lib.d.ts", sources: ["core.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], }, + { target: "lib.d.ts", sources: ["core.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], }, { target: "lib.core.es6.d.ts", sources: ["core.d.ts", "es6.d.ts"]}, { target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] }, ]; @@ -205,6 +207,9 @@ function concatenateFiles(destinationFile, sourceFiles) { var useDebugMode = true; var host = (process.env.host || process.env.TYPESCRIPT_HOST || "node"); var compilerFilename = "tsc.js"; +var LKGCompiler = path.join(LKGDirectory, compilerFilename); +var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename); + /* Compiles a file from a list of sources * @param outFile: the target file name * @param sources: an array of the names of the source files @@ -219,7 +224,7 @@ var compilerFilename = "tsc.js"; */ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) { file(outFile, prereqs, function() { - var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory; + var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler; var options = "--module commonjs --noImplicitAny --noEmitOnError"; // Keep comments when specifically requested @@ -256,7 +261,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu options += " --stripInternal" } - var cmd = host + " " + dir + compilerFilename + " " + options + " "; + var cmd = host + " " + compilerPath + " " + options + " "; cmd = cmd + sources.join(" "); console.log(cmd + "\n"); @@ -327,7 +332,7 @@ compileFile(processDiagnosticMessagesJs, // The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], function () { - var cmd = "node " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson; + var cmd = host + " " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson; console.log(cmd); var ex = jake.createExec([cmd]); // Add listeners for output and error @@ -373,7 +378,7 @@ task("setDebugMode", function() { }); task("configure-nightly", [configureNightlyJs], function() { - var cmd = "node " + configureNightlyJs + " " + packageJson + " " + programTs; + var cmd = host + " " + configureNightlyJs + " " + packageJson + " " + programTs; console.log(cmd); exec(cmd); }, { async: true }); @@ -385,6 +390,32 @@ task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "r exec(cmd); }); +var scriptsTsdJson = path.join(scriptsDirectory, "tsd.json"); +file(scriptsTsdJson); + +task("tsd-scripts", [scriptsTsdJson], function () { + var cmd = "tsd --config " + scriptsTsdJson + " install"; + console.log(cmd) + exec(cmd); +}, { async: true }) + +var importDefinitelyTypedTestsDirectory = path.join(scriptsDirectory, "importDefinitelyTypedTests"); +var importDefinitelyTypedTestsJs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.js"); +var importDefinitelyTypedTestsTs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.ts"); + +file(importDefinitelyTypedTestsTs); +file(importDefinitelyTypedTestsJs, ["tsd-scripts", importDefinitelyTypedTestsTs], function () { + var cmd = host + " " + LKGCompiler + " -p " + importDefinitelyTypedTestsDirectory; + console.log(cmd); + exec(cmd); +}, { async: true }); + +task("importDefinitelyTypedTests", [importDefinitelyTypedTestsJs], function () { + var cmd = host + " " + importDefinitelyTypedTestsJs + " ./ ../DefinitelyTyped"; + console.log(cmd); + exec(cmd); +}, { async: true }); + // Local target to build the compiler and services var tscFile = path.join(builtLocalDirectory, compilerFilename); compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false); @@ -393,6 +424,7 @@ var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js"); var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts"); var nodePackageFile = path.join(builtLocalDirectory, "typescript.js"); var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts"); +var nodeStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescript_standalone.d.ts"); compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources), /*prefixes*/ [copyright], @@ -409,11 +441,19 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca prependFile(copyright, standaloneDefinitionsFile); - // Create the node definition file by replacing 'ts' module with '"typescript"' as a module. + // Stanalone/web definition file using global 'ts' namespace jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true}); var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString(); - definitionFileContents = definitionFileContents.replace(/declare (namespace|module) ts/g, 'declare module "typescript"'); - fs.writeFileSync(nodeDefinitionsFile, definitionFileContents); + + // Official node package definition file, pointed to by 'typings' in package.json + // Created by appending 'export = ts;' at the end of the standalone file to turn it into an external module + var nodeDefinitionsFileContents = definitionFileContents + "\r\nexport = ts;"; + fs.writeFileSync(nodeDefinitionsFile, nodeDefinitionsFileContents); + + // Node package definition file to be distributed without the package. Created by replacing + // 'ts' namespace with '"typescript"' as a module. + var nodeStandaloneDefinitionsFileContents = definitionFileContents.replace(/declare (namespace|module) ts/g, 'declare module "typescript"'); + fs.writeFileSync(nodeStandaloneDefinitionsFile, nodeStandaloneDefinitionsFileContents); }); @@ -587,10 +627,10 @@ function deleteTemporaryProjectOutput() { } var testTimeout = 20000; -desc("Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|]'."); -task("runtests", ["tests", builtLocalDirectory], function() { +desc("Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|]', debug=true."); +task("runtests", ["build-rules", "tests", builtLocalDirectory], function() { cleanTestDirs(); - host = "mocha" + var debug = process.env.debug || process.env.d; tests = process.env.test || process.env.tests || process.env.t; var light = process.env.light || false; var testConfigFile = 'test.config'; @@ -612,9 +652,16 @@ task("runtests", ["tests", builtLocalDirectory], function() { reporter = process.env.reporter || process.env.r || 'mocha-fivemat-progress-reporter'; // 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 cmd = host + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run; + var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run; console.log(cmd); - exec(cmd, deleteTemporaryProjectOutput); + exec(cmd, function() { + deleteTemporaryProjectOutput(); + var lint = jake.Task['lint']; + lint.addListener('complete', function () { + complete(); + }); + lint.invoke(); + }); }, {async: true}); desc("Generates code coverage data via instanbul"); @@ -769,17 +816,109 @@ task("update-sublime", ["local", serverFile], function() { jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/"); }); -// if the codebase were free of linter errors we could make jake runtests -// run this task automatically -desc("Runs tslint on the compiler sources"); -task("lint", [], function() { - function success(f) { return function() { console.log('SUCCESS: No linter errors in ' + f + '\n'); }}; - function failure(f) { return function() { console.log('FAILURE: Please fix linting errors in ' + f + '\n') }}; +var tslintRuleDir = "scripts/tslint"; +var tslintRules = ([ + "nextLineRule", + "noNullRule", + "booleanTriviaRule" +]); +var tslintRulesFiles = tslintRules.map(function(p) { + return path.join(tslintRuleDir, p + ".ts"); +}); +var tslintRulesOutFiles = tslintRules.map(function(p) { + return path.join(builtLocalDirectory, "tslint", p + ".js"); +}); +desc("Compiles tslint rules to js"); +task("build-rules", tslintRulesOutFiles); +tslintRulesFiles.forEach(function(ruleFile, i) { + compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false, /*noOutFile*/ true, /*generateDeclarations*/ false, path.join(builtLocalDirectory, "tslint")); +}); - var lintTargets = compilerSources.concat(harnessCoreSources); +function getLinterOptions() { + return { + configuration: require("./tslint.json"), + formatter: "prose", + formattersDirectory: undefined, + rulesDirectory: "built/local/tslint" + }; +} + +function lintFileContents(options, path, contents) { + var ll = new Linter(path, contents, options); + return ll.lint(); +} + +function lintFile(options, path) { + var contents = fs.readFileSync(path, "utf8"); + return lintFileContents(options, path, contents); +} + +function lintFileAsync(options, path, cb) { + fs.readFile(path, "utf8", function(err, contents) { + if (err) { + return cb(err); + } + var result = lintFileContents(options, path, contents); + cb(undefined, result); + }); +} + +var lintTargets = compilerSources.concat(harnessCoreSources); + +desc("Runs tslint on the compiler sources"); +task("lint", ["build-rules"], function() { + var lintOptions = getLinterOptions(); for (var i in lintTargets) { - var f = lintTargets[i]; - var cmd = 'tslint -c tslint.json ' + f; - exec(cmd, success(f), failure(f)); + var result = lintFile(lintOptions, lintTargets[i]); + if (result.failureCount > 0) { + console.log(result.output); + fail('Linter errors.', result.failureCount); + } } -}, { async: true }); +}); + +/** + * This is required because file watches on Windows get fires _twice_ + * when a file changes on some node/windows version configuations + * (node v4 and win 10, for example). By not running a lint for a file + * which already has a pending lint, we avoid duplicating our work. + * (And avoid printing duplicate results!) + */ +var lintSemaphores = {}; + +function lintWatchFile(filename) { + fs.watch(filename, {persistent: true}, function(event) { + if (event !== "change") { + return; + } + + if (!lintSemaphores[filename]) { + lintSemaphores[filename] = true; + lintFileAsync(getLinterOptions(), filename, function(err, result) { + delete lintSemaphores[filename]; + if (err) { + console.log(err); + return; + } + if (result.failureCount > 0) { + console.log("***Lint failure***"); + for (var i = 0; i < result.failures.length; i++) { + var failure = result.failures[i]; + var start = failure.startPosition.lineAndCharacter; + var end = failure.endPosition.lineAndCharacter; + console.log("warning " + filename + " (" + (start.line + 1) + "," + (start.character + 1) + "," + (end.line + 1) + "," + (end.character + 1) + "): " + failure.failure); + } + console.log("*** Total " + result.failureCount + " failures."); + } + }); + } + }); +} + +desc("Watches files for changes to rerun a lint pass"); +task("lint-server", ["build-rules"], function() { + console.log("Watching ./src for changes to linted files"); + for (var i = 0; i < lintTargets.length; i++) { + lintWatchFile(lintTargets[i]); + } +}); diff --git a/README.md b/README.md index c8bc5936c24..e27e7a99fa7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Join the chat at https://gitter.im/Microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [twitter account](https://twitter.com/typescriptlang). +[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [Twitter account](https://twitter.com/typescriptlang). ## Installing @@ -30,7 +30,7 @@ There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob * Engage with other TypeScript users and developers on [StackOverflow](http://stackoverflow.com/questions/tagged/typescript). * Join the [#typescript](http://twitter.com/#!/search/realtime/%23typescript) discussion on Twitter. * [Contribute bug fixes](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md). -* Read the language specification ([docx](http://go.microsoft.com/fwlink/?LinkId=267121), [pdf](http://go.microsoft.com/fwlink/?LinkId=267238)). +* Read the language specification ([docx](https://github.com/Microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification.docx?raw=true), [pdf](https://github.com/Microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification.pdf?raw=true), [md](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md)). ## Documentation diff --git a/lib/lib.core.d.ts b/lib/lib.core.d.ts index a265b5c2a95..b588c9fdb77 100644 --- a/lib/lib.core.d.ts +++ b/lib/lib.core.d.ts @@ -331,31 +331,31 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A string that represents the regular expression. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. + * @param searchValue A string that represents the regular expression. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. @@ -986,14 +986,14 @@ interface JSON { * @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: any): 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 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: any): string; + stringify(value: any, replacer: any[], space: string | number): string; } /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. @@ -1196,4 +1196,2645 @@ interface PromiseLike { */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} +} + +interface ArrayLike { + length: number; + [n: number]: T; +} + + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin:number, end?:number): ArrayBuffer; +} + +interface ArrayBufferConstructor { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): boolean; +} +declare var ArrayBuffer: ArrayBufferConstructor; + +interface ArrayBufferView { + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; +} + +interface DataView { + buffer: ArrayBuffer; + byteLength: number; + byteOffset: number; + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian?: boolean): number; + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; +} + +interface DataViewConstructor { + new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; +} +declare var DataView: DataViewConstructor; + +/** + * 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 { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Int8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Int8Array; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} +interface Int8ArrayConstructor { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: ArrayLike): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + +} +declare var Int8Array: Int8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint8Array; + + /** + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ArrayConstructor { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: ArrayLike): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + +} +declare var Uint8Array: Uint8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: ArrayLike): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Int16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Int16Array; + + /** + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int16ArrayConstructor { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: ArrayLike): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + +} +declare var Int16Array: Int16ArrayConstructor; + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint16Array; + + /** + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint16ArrayConstructor { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: ArrayLike): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + +} +declare var Uint16Array: Uint16ArrayConstructor; +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Int32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Int32Array; + + /** + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int32ArrayConstructor { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: ArrayLike): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} +declare var Int32Array: Int32ArrayConstructor; + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint32Array; + + /** + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint32ArrayConstructor { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: ArrayLike): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} +declare var Uint32Array: Uint32ArrayConstructor; + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Float32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Float32Array; + + /** + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float32ArrayConstructor { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: ArrayLike): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + +} +declare var Float32Array: Float32ArrayConstructor; + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Float64Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float64Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Float64Array; + + /** + * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float64ArrayConstructor { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: ArrayLike): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} +declare var Float64Array: Float64ArrayConstructor; diff --git a/lib/lib.core.es6.d.ts b/lib/lib.core.es6.d.ts index 48d02ec1465..6d6a68559f8 100644 --- a/lib/lib.core.es6.d.ts +++ b/lib/lib.core.es6.d.ts @@ -331,31 +331,31 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A string that represents the regular expression. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. + * @param searchValue A string that represents the regular expression. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. @@ -986,14 +986,14 @@ interface JSON { * @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: any): 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 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: any): string; + stringify(value: any, replacer: any[], space: string | number): string; } /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. @@ -1196,7 +1196,2648 @@ interface PromiseLike { */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} +} + +interface ArrayLike { + length: number; + [n: number]: T; +} + + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin:number, end?:number): ArrayBuffer; +} + +interface ArrayBufferConstructor { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): boolean; +} +declare var ArrayBuffer: ArrayBufferConstructor; + +interface ArrayBufferView { + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; +} + +interface DataView { + buffer: ArrayBuffer; + byteLength: number; + byteOffset: number; + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian?: boolean): number; + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; +} + +interface DataViewConstructor { + new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; +} +declare var DataView: DataViewConstructor; + +/** + * 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 { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Int8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Int8Array; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} +interface Int8ArrayConstructor { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: ArrayLike): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + +} +declare var Int8Array: Int8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint8Array; + + /** + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ArrayConstructor { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: ArrayLike): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + +} +declare var Uint8Array: Uint8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: ArrayLike): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Int16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Int16Array; + + /** + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int16ArrayConstructor { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: ArrayLike): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + +} +declare var Int16Array: Int16ArrayConstructor; + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint16Array; + + /** + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint16ArrayConstructor { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: ArrayLike): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + +} +declare var Uint16Array: Uint16ArrayConstructor; +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Int32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Int32Array; + + /** + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int32ArrayConstructor { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: ArrayLike): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} +declare var Int32Array: Int32ArrayConstructor; + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint32Array; + + /** + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint32ArrayConstructor { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: ArrayLike): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} +declare var Uint32Array: Uint32ArrayConstructor; + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Float32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Float32Array; + + /** + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float32ArrayConstructor { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: ArrayLike): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + +} +declare var Float32Array: Float32ArrayConstructor; + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Float64Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float64Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Float64Array; + + /** + * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float64ArrayConstructor { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: ArrayLike): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} +declare var Float64Array: Float64ArrayConstructor; declare type PropertyKey = string | number | symbol; interface Symbol { @@ -1286,8 +3927,8 @@ interface SymbolConstructor { split: symbol; /** - * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive - * abstract operation. + * A method that converts an object to a corresponding primitive value. + * Called by the ToPrimitive abstract operation. */ toPrimitive: symbol; @@ -1297,8 +3938,8 @@ interface SymbolConstructor { */ toStringTag: symbol; - /** - * An Object whose own property names are property names that are excluded from the with + /** + * An Object whose own property names are property names that are excluded from the 'with' * environment bindings of the associated objects. */ unscopables: symbol; @@ -1324,7 +3965,34 @@ interface ObjectConstructor { * 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 to copy properties from. + * @param source The source object from which to copy properties. + */ + assign(target: T, source: U): T & U; + + /** + * 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. + * @param source2 The second source object from which to copy properties. + */ + assign(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 + * 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. + * @param source2 The second source object from which to copy properties. + * @param source3 The third source object from which to copy properties. + */ + assign(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 + * 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 */ assign(target: any, ...sources: any[]): any; @@ -1369,16 +4037,19 @@ interface ObjectConstructor { } interface Function { - /** - * Returns a new function object that is identical to the argument object in all ways except - * for its identity and the value of its HomeObject internal slot. - */ - toMethod(newHome: Object): Function; - /** * Returns the name of the function. Function names are read-only and can not be changed. */ name: string; + + /** + * Determines whether the given value inherits from this function if this function was used + * as a constructor function. + * + * A constructor function can control which objects are recognized as its instances by + * 'instanceof' by overriding this method. + */ + [Symbol.hasInstance](value: any): boolean; } interface NumberConstructor { @@ -1447,15 +4118,24 @@ interface NumberConstructor { parseInt(string: string, radix?: number): number; } -interface ArrayLike { - length: number; - [n: number]: T; -} - interface Array { /** Iterator */ [Symbol.iterator](): IterableIterator; + /** + * Returns an object whose properties have the value 'true' + * when they will be absent when used in a 'with' statement. + */ + [Symbol.unscopables](): { + copyWithin: boolean; + entries: boolean; + fill: boolean; + find: boolean; + findIndex: boolean; + keys: boolean; + values: boolean; + }; + /** * Returns an array of key, value pairs for every entry in the array */ @@ -1576,7 +4256,7 @@ interface String { * @param searchString search string * @param position If position is undefined, 0 is assumed, so as to search all of the String. */ - contains(searchString: string, position?: number): boolean; + includes(searchString: string, position?: number): boolean; /** * Returns true if the sequence of elements of searchString converted to a String is the @@ -1607,6 +4287,41 @@ interface String { */ startsWith(searchString: string, position?: number): boolean; + // Overloads for objects with methods of well-known symbols. + + /** + * 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. + */ + match(matcher: { [Symbol.match](string: string): RegExpMatchArray; }): RegExpMatchArray; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replacer A function that returns the replacement text. + */ + replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param searcher An object which supports searching within a string. + */ + search(searcher: { [Symbol.search](string: string): number; }): number; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param splitter An object that can split a string. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; + /** * Returns an HTML anchor element and sets the name attribute to the text value * @param name @@ -1818,37 +4533,76 @@ interface Math { [Symbol.toStringTag]: string; } +interface Date { + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "default"): string; + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "string"): string; + /** + * Converts a Date object to a number. + */ + [Symbol.toPrimitive](hint: "number"): number; + /** + * Converts a Date object to a string or number. + * + * @param hint The strings "number", "string", or "default" to specify what primitive to return. + * + * @throws {TypeError} If 'hint' was given something other than "number", "string", or "default". + * @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default". + */ + [Symbol.toPrimitive](hint: string): string | number; +} + interface RegExp { - /** - * Matches a string with a regular expression, and returns an array containing the results of + /** + * Matches a string with this regular expression, and returns an array containing the results of * that search. * @param string A string to search within. */ - match(string: string): string[]; + [Symbol.match](string: string): RegExpMatchArray; /** - * Replaces text in a string, using a regular expression. - * @param searchValue A String object or string literal that represents the regular expression + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced * @param replaceValue A String object or string literal containing the text to replace for every - * successful match of rgExp in stringObj. + * successful match of this regular expression. */ - replace(string: string, replaceValue: string): string; - - search(string: string): number; + [Symbol.replace](string: string, replaceValue: string): string; /** - * Returns an Array object into which substrings of the result of converting string to a String - * have been stored. The substrings are determined by searching from left to right for matches - * of the this value regular expression; these occurrences are not part of any substring in the - * returned array, but serve to divide up the String value. - * - * If the regular expression that contains capturing parentheses, then each time separator is - * matched the results (including any undefined results) of the capturing parentheses are spliced. - * @param string string value to split - * @param limit if not undefined, the output array is truncated so that it contains no more - * than limit elements. + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replacer A function that returns the replacement text. */ - split(string: string, limit?: number): string[]; + [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the position beginning first substring match in a regular expression search + * using this regular expression. + * + * @param string The string to search within. + */ + [Symbol.search](string: string): number; + + /** + * Returns an array of substrings that were delimited by strings in the original input that + * match against this regular expression. + * + * If the regular expression contains capturing parentheses, then each time this + * regular expression matches, the results (including any undefined results) of the + * capturing parentheses are spliced. + * + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than 'limit' elements. + */ + [Symbol.split](string: string, limit?: number): string[]; /** * Returns a string indicating the flags of the regular expression in question. This field is read-only. @@ -1877,6 +4631,10 @@ interface RegExp { unicode: boolean; } +interface RegExpConstructor { + [Symbol.species](): RegExpConstructor; +} + interface Map { clear(): void; delete(key: K): boolean; @@ -1966,440 +4724,35 @@ interface JSON { * buffer as needed. */ interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; - - /** - * Returns a section of an ArrayBuffer. - */ - slice(begin: number, end?: number): ArrayBuffer; - [Symbol.toStringTag]: string; } -interface ArrayBufferConstructor { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; - isView(arg: any): boolean; -} -declare var ArrayBuffer: ArrayBufferConstructor; - interface DataView { - buffer: ArrayBuffer; - byteLength: number; - byteOffset: number; - /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat64(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt8(byteOffset: number): number; - - /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt16(byteOffset: number, littleEndian: boolean): number; - /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint8(byteOffset: number): number; - - /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint16(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint32(byteOffset: number, littleEndian: boolean): number; - - /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setInt8(byteOffset: number, value: number): void; - - /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setUint8(byteOffset: number, value: number): void; - - /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint32(byteOffset: number, value: number, littleEndian: boolean): void; - [Symbol.toStringTag]: string; } -interface DataViewConstructor { - new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; -} -declare var DataView: DataViewConstructor; - /** * 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 { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int8Array; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Int8ArrayConstructor { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int8Array; + new (elements: Iterable): Int8Array; /** * Creates an array from an array-like or iterable object. @@ -2407,289 +4760,31 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -declare var Int8Array: Int8ArrayConstructor; /** * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint8Array; - - /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint8ArrayConstructor { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8Array; + new (elements: Iterable): Uint8Array; /** * Creates an array from an array-like or iterable object. @@ -2697,289 +4792,35 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -declare var Uint8Array: Uint8ArrayConstructor; /** * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. * If the requested number of bytes could not be allocated an exception is raised. */ interface Uint8ClampedArray { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8ClampedArray; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8ClampedArray; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8ClampedArray, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8ClampedArray; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint8ClampedArray; - - /** - * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8ClampedArray; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint8ClampedArrayConstructor { - prototype: Uint8ClampedArray; - new (length: number): Uint8ClampedArray; - new (array: Uint8ClampedArray): Uint8ClampedArray; - new (array: number[]): Uint8ClampedArray; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + new (elements: Iterable): Uint8ClampedArray; - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8ClampedArray; /** * Creates an array from an array-like or iterable object. @@ -2987,289 +4828,35 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int16Array; - - /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - [index: number]: number; + [Symbol.iterator](): IterableIterator; } interface Int16ArrayConstructor { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int16Array; + new (elements: Iterable): Int16Array; /** * Creates an array from an array-like or iterable object. @@ -3277,289 +4864,31 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -declare var Int16Array: Int16ArrayConstructor; /** * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint16Array; - - /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint16ArrayConstructor { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint16Array; + new (elements: Iterable): Uint16Array; /** * Creates an array from an array-like or iterable object. @@ -3567,289 +4896,31 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -declare var Uint16Array: Uint16ArrayConstructor; /** * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int32Array; - - /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Int32ArrayConstructor { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int32Array; + new (elements: Iterable): Int32Array; /** * Creates an array from an array-like or iterable object. @@ -3857,289 +4928,31 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -declare var Int32Array: Int32ArrayConstructor; /** * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint32Array; - - /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint32ArrayConstructor { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint32Array; + new (elements: Iterable): Uint32Array; /** * Creates an array from an array-like or iterable object. @@ -4147,289 +4960,31 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -declare var Uint32Array: Uint32ArrayConstructor; /** * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number * of bytes could not be allocated an exception is raised. */ interface Float32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Float32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Float32Array; - - /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Float32ArrayConstructor { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float32Array; + new (elements: Iterable): Float32Array; /** * Creates an array from an array-like or iterable object. @@ -4437,289 +4992,31 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -declare var Float32Array: Float32ArrayConstructor; /** * A typed array of 64-bit float values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Float64Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Float64Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float64Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Float64Array; - - /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Float64ArrayConstructor { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float64Array; + new (elements: Iterable): Float64Array; /** * Creates an array from an array-like or iterable object. @@ -4727,9 +5024,8 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -declare var Float64Array: Float64ArrayConstructor; interface ProxyHandler { getPrototypeOf? (target: T): any; @@ -4754,9 +5050,9 @@ interface ProxyConstructor { } declare var Proxy: ProxyConstructor; -declare module Reflect { +declare namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; - function construct(target: Function, argumentsList: ArrayLike): any; + function construct(target: Function, argumentsList: ArrayLike, newTarget?: any): any; function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; function deleteProperty(target: any, propertyKey: PropertyKey): boolean; function enumerate(target: any): IterableIterator; @@ -4857,20 +5153,3 @@ interface PromiseConstructor { } declare var Promise: PromiseConstructor; - -interface ArrayBufferView { - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; -} \ No newline at end of file diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 430d8279de4..a65fc96e43f 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -331,31 +331,31 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A string that represents the regular expression. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. + * @param searchValue A string that represents the regular expression. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. @@ -986,14 +986,14 @@ interface JSON { * @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: any): 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 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: any): string; + stringify(value: any, replacer: any[], space: string | number): string; } /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. @@ -1196,11 +1196,13 @@ interface PromiseLike { */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} +} + +interface ArrayLike { + length: number; + [n: number]: T; +} -///////////////////////////// -/// IE10 ECMAScript Extensions -///////////////////////////// /** * Represents a raw buffer of binary data, which is used to store data for the @@ -1253,14 +1255,14 @@ interface DataView { * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getFloat32(byteOffset: number, littleEndian: boolean): number; + getFloat32(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Float64 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getFloat64(byteOffset: number, littleEndian: boolean): number; + getFloat64(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Int8 value at the specified byte offset from the start of the view. There is @@ -1274,13 +1276,13 @@ interface DataView { * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getInt16(byteOffset: number, littleEndian: boolean): number; + getInt16(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Int32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getInt32(byteOffset: number, littleEndian: boolean): number; + getInt32(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Uint8 value at the specified byte offset from the start of the view. There is @@ -1294,14 +1296,14 @@ interface DataView { * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getUint16(byteOffset: number, littleEndian: boolean): number; + getUint16(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Uint32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ - getUint32(byteOffset: number, littleEndian: boolean): number; + getUint32(byteOffset: number, littleEndian?: boolean): number; /** * Stores an Float32 value at the specified byte offset from the start of the view. @@ -1310,7 +1312,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; + setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Float64 value at the specified byte offset from the start of the view. @@ -1319,7 +1321,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; + setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Int8 value at the specified byte offset from the start of the view. @@ -1335,7 +1337,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setInt16(byteOffset: number, value: number, littleEndian: boolean): void; + setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Int32 value at the specified byte offset from the start of the view. @@ -1344,7 +1346,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setInt32(byteOffset: number, value: number, littleEndian: boolean): void; + setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Uint8 value at the specified byte offset from the start of the view. @@ -1360,7 +1362,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setUint16(byteOffset: number, value: number, littleEndian: boolean): void; + setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; /** * Stores an Uint32 value at the specified byte offset from the start of the view. @@ -1369,7 +1371,7 @@ interface DataView { * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ - setUint32(byteOffset: number, value: number, littleEndian: boolean): void; + setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; } interface DataViewConstructor { @@ -1576,7 +1578,7 @@ interface Int8Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Int8Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -1625,8 +1627,7 @@ interface Int8Array { interface Int8ArrayConstructor { prototype: Int8Array; new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; + new (array: ArrayLike): Int8Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; /** @@ -1639,6 +1640,15 @@ interface Int8ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + } declare var Int8Array: Int8ArrayConstructor; @@ -1841,7 +1851,7 @@ interface Uint8Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Uint8Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -1891,8 +1901,7 @@ interface Uint8Array { interface Uint8ArrayConstructor { prototype: Uint8Array; new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; + new (array: ArrayLike): Uint8Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; /** @@ -1905,9 +1914,291 @@ interface Uint8ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + } declare var Uint8Array: Uint8ArrayConstructor; +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: ArrayLike): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. @@ -2107,7 +2398,7 @@ interface Int16Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Int16Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2157,8 +2448,7 @@ interface Int16Array { interface Int16ArrayConstructor { prototype: Int16Array; new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; + new (array: ArrayLike): Int16Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; /** @@ -2171,6 +2461,15 @@ interface Int16ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + } declare var Int16Array: Int16ArrayConstructor; @@ -2373,7 +2672,7 @@ interface Uint16Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Uint16Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2423,8 +2722,7 @@ interface Uint16Array { interface Uint16ArrayConstructor { prototype: Uint16Array; new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; + new (array: ArrayLike): Uint16Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; /** @@ -2437,6 +2735,15 @@ interface Uint16ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + } declare var Uint16Array: Uint16ArrayConstructor; /** @@ -2638,7 +2945,7 @@ interface Int32Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Int32Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2688,8 +2995,7 @@ interface Int32Array { interface Int32ArrayConstructor { prototype: Int32Array; new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; + new (array: ArrayLike): Int32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; /** @@ -2702,6 +3008,14 @@ interface Int32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } declare var Int32Array: Int32ArrayConstructor; @@ -2904,7 +3218,7 @@ interface Uint32Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Uint32Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2954,8 +3268,7 @@ interface Uint32Array { interface Uint32ArrayConstructor { prototype: Uint32Array; new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; + new (array: ArrayLike): Uint32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; /** @@ -2968,6 +3281,14 @@ interface Uint32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } declare var Uint32Array: Uint32ArrayConstructor; @@ -3170,7 +3491,7 @@ interface Float32Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Float32Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -3220,8 +3541,7 @@ interface Float32Array { interface Float32ArrayConstructor { prototype: Float32Array; new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; + new (array: ArrayLike): Float32Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; /** @@ -3234,6 +3554,15 @@ interface Float32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + } declare var Float32Array: Float32ArrayConstructor; @@ -3436,7 +3765,7 @@ interface Float64Array { * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ - set(array: Float64Array, offset?: number): void; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -3486,8 +3815,7 @@ interface Float64Array { interface Float64ArrayConstructor { prototype: Float64Array; new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; + new (array: ArrayLike): Float64Array; new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; /** @@ -3500,8 +3828,17 @@ interface Float64ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -declare var Float64Array: Float64ArrayConstructor;///////////////////////////// +declare var Float64Array: Float64ArrayConstructor; +///////////////////////////// /// ECMAScript Internationalization API ///////////////////////////// @@ -3544,7 +3881,7 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; - minimumintegerDigits?: number; + minimumIntegerDigits?: number; minimumFractionDigits?: number; maximumFractionDigits?: number; minimumSignificantDigits?: number; @@ -3557,7 +3894,7 @@ declare module Intl { style: string; currency?: string; currencyDisplay?: string; - minimumintegerDigits: number; + minimumIntegerDigits: number; minimumFractionDigits: number; maximumFractionDigits: number; minimumSignificantDigits?: number; @@ -3591,6 +3928,7 @@ declare module Intl { timeZoneName?: string; formatMatcher?: string; hour12?: boolean; + timeZone?: string; } interface ResolvedDateTimeFormatOptions { @@ -3660,18 +3998,45 @@ interface Number { interface Date { /** - * Converts a date to a string by using the current or specified locale. + * Converts a date and time to a string by using the current or specified locale. * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + /** + * Converts a date to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + /** + * Converts a time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a date and time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + /** * Converts a date to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ - toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locale?: string, options?: Intl.DateTimeFormatOptions): string; } @@ -6135,7 +6500,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. * @param replace Specifies whether the existing entry for the document is replaced in the history list. */ - open(url?: string, name?: string, features?: string, replace?: boolean): Document | Window; + open(url?: string, name?: string, features?: string, replace?: boolean): Document; /** * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. * @param commandId Specifies a command identifier. @@ -6592,6 +6957,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitMatchesSelector(selectors: string): boolean; webkitRequestFullScreen(): void; webkitRequestFullscreen(): void; + getElementsByClassName(classNames: string): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -6706,7 +7072,7 @@ interface File extends Blob { declare var File: { prototype: File; - new(): File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; } interface FileList { @@ -7579,7 +7945,6 @@ interface HTMLElement extends Element { contains(child: HTMLElement): boolean; dragDrop(): boolean; focus(): void; - getElementsByClassName(classNames: string): NodeListOf; insertAdjacentElement(position: string, insertedElement: Element): Element; insertAdjacentHTML(where: string, html: string): void; insertAdjacentText(where: string, text: string): void; @@ -10541,7 +10906,7 @@ interface IDBDatabase extends EventTarget { createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10662,7 +11027,7 @@ interface IDBTransaction extends EventTarget { READ_ONLY: string; READ_WRITE: string; VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -10692,11 +11057,14 @@ interface ImageData { width: number; } -declare var ImageData: { +interface ImageDataConstructor { prototype: ImageData; - new(): ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +declare var ImageData: ImageDataConstructor; + interface KeyboardEvent extends UIEvent { altKey: boolean; char: string; @@ -11379,7 +11747,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -12121,7 +12489,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface Range { @@ -15638,7 +16006,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window onvolumechange: (ev: Event) => any; onwaiting: (ev: Event) => any; opener: Window; - orientation: string; + orientation: string | number; outerHeight: number; outerWidth: number; pageXOffset: number; @@ -15845,7 +16213,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { LOADING: number; OPENED: number; UNSENT: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -16115,7 +16483,7 @@ interface MSBaseReader { DONE: number; EMPTY: number; LOADING: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -16271,7 +16639,7 @@ interface XMLHttpRequestEventTarget { onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -16293,12 +16661,32 @@ interface BlobPropertyBag { endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -16453,7 +16841,7 @@ declare var onunload: (ev: Event) => any; declare var onvolumechange: (ev: Event) => any; declare var onwaiting: (ev: Event) => any; declare var opener: Window; -declare var orientation: string; +declare var orientation: string | number; declare var outerHeight: number; declare var outerWidth: number; declare var pageXOffset: number; diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 5ec268b2fd5..849560ac0d2 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -14,2311 +14,7 @@ and limitations under the License. ***************************************************************************** */ /// - ///////////////////////////// -/// IE10 ECMAScript Extensions -///////////////////////////// - -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ -interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; - - /** - * Returns a section of an ArrayBuffer. - */ - slice(begin:number, end?:number): ArrayBuffer; -} - -interface ArrayBufferConstructor { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; - isView(arg: any): boolean; -} -declare var ArrayBuffer: ArrayBufferConstructor; - -interface ArrayBufferView { - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; -} - -interface DataView { - buffer: ArrayBuffer; - byteLength: number; - byteOffset: number; - /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat64(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt8(byteOffset: number): number; - - /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt16(byteOffset: number, littleEndian: boolean): number; - /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint8(byteOffset: number): number; - - /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint16(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint32(byteOffset: number, littleEndian: boolean): number; - - /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setInt8(byteOffset: number, value: number): void; - - /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setUint8(byteOffset: number, value: number): void; - - /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint32(byteOffset: number, value: number, littleEndian: boolean): void; -} - -interface DataViewConstructor { - new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; -} -declare var DataView: DataViewConstructor; - -/** - * 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 { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int8Array; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} -interface Int8ArrayConstructor { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int8Array; -} -declare var Int8Array: Int8ArrayConstructor; - -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint8Array; - - /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint8ArrayConstructor { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8Array; -} -declare var Uint8Array: Uint8ArrayConstructor; - -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Int16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int16Array; - - /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Int16ArrayConstructor { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int16Array; -} -declare var Int16Array: Int16ArrayConstructor; - -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint16Array; - - /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint16ArrayConstructor { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint16Array; -} -declare var Uint16Array: Uint16ArrayConstructor; -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Int32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int32Array; - - /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Int32ArrayConstructor { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int32Array; -} -declare var Int32Array: Int32ArrayConstructor; - -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint32Array; - - /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint32ArrayConstructor { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint32Array; -} -declare var Uint32Array: Uint32ArrayConstructor; - -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ -interface Float32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Float32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Float32Array; - - /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Float32ArrayConstructor { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float32Array; -} -declare var Float32Array: Float32ArrayConstructor; - -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ -interface Float64Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Float64Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float64Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Float64Array; - - /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Float64ArrayConstructor { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float64Array; -} -declare var Float64Array: Float64ArrayConstructor;///////////////////////////// /// ECMAScript Internationalization API ///////////////////////////// @@ -2361,7 +57,7 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; - minimumintegerDigits?: number; + minimumIntegerDigits?: number; minimumFractionDigits?: number; maximumFractionDigits?: number; minimumSignificantDigits?: number; @@ -2374,7 +70,7 @@ declare module Intl { style: string; currency?: string; currencyDisplay?: string; - minimumintegerDigits: number; + minimumIntegerDigits: number; minimumFractionDigits: number; maximumFractionDigits: number; minimumSignificantDigits?: number; @@ -2408,6 +104,7 @@ declare module Intl { timeZoneName?: string; formatMatcher?: string; hour12?: boolean; + timeZone?: string; } interface ResolvedDateTimeFormatOptions { @@ -2477,18 +174,45 @@ interface Number { interface Date { /** - * Converts a date to a string by using the current or specified locale. + * Converts a date and time to a string by using the current or specified locale. * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + /** + * Converts a date to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + /** + * Converts a time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a date and time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + /** * Converts a date to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ - toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locale?: string, options?: Intl.DateTimeFormatOptions): string; } @@ -4952,7 +2676,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. * @param replace Specifies whether the existing entry for the document is replaced in the history list. */ - open(url?: string, name?: string, features?: string, replace?: boolean): Document | Window; + open(url?: string, name?: string, features?: string, replace?: boolean): Document; /** * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. * @param commandId Specifies a command identifier. @@ -5409,6 +3133,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitMatchesSelector(selectors: string): boolean; webkitRequestFullScreen(): void; webkitRequestFullscreen(): void; + getElementsByClassName(classNames: string): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -5523,7 +3248,7 @@ interface File extends Blob { declare var File: { prototype: File; - new(): File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; } interface FileList { @@ -6396,7 +4121,6 @@ interface HTMLElement extends Element { contains(child: HTMLElement): boolean; dragDrop(): boolean; focus(): void; - getElementsByClassName(classNames: string): NodeListOf; insertAdjacentElement(position: string, insertedElement: Element): Element; insertAdjacentHTML(where: string, html: string): void; insertAdjacentText(where: string, text: string): void; @@ -9358,7 +7082,7 @@ interface IDBDatabase extends EventTarget { createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -9479,7 +7203,7 @@ interface IDBTransaction extends EventTarget { READ_ONLY: string; READ_WRITE: string; VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -9509,11 +7233,14 @@ interface ImageData { width: number; } -declare var ImageData: { +interface ImageDataConstructor { prototype: ImageData; - new(): ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +declare var ImageData: ImageDataConstructor; + interface KeyboardEvent extends UIEvent { altKey: boolean; char: string; @@ -10196,7 +7923,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -10938,7 +8665,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface Range { @@ -14455,7 +12182,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window onvolumechange: (ev: Event) => any; onwaiting: (ev: Event) => any; opener: Window; - orientation: string; + orientation: string | number; outerHeight: number; outerWidth: number; pageXOffset: number; @@ -14662,7 +12389,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { LOADING: number; OPENED: number; UNSENT: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -14932,7 +12659,7 @@ interface MSBaseReader { DONE: number; EMPTY: number; LOADING: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -15088,7 +12815,7 @@ interface XMLHttpRequestEventTarget { onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -15110,12 +12837,32 @@ interface BlobPropertyBag { endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -15270,7 +13017,7 @@ declare var onunload: (ev: Event) => any; declare var onvolumechange: (ev: Event) => any; declare var onwaiting: (ev: Event) => any; declare var opener: Window; -declare var orientation: string; +declare var orientation: string | number; declare var outerHeight: number; declare var outerWidth: number; declare var pageXOffset: number; diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 6c06cc08dc7..75ba647a128 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -331,31 +331,31 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A string that represents the regular expression. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. + * @param searchValue A string that represents the regular expression. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. @@ -986,14 +986,14 @@ interface JSON { * @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: any): 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 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: any): string; + stringify(value: any, replacer: any[], space: string | number): string; } /** * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. @@ -1196,7 +1196,2648 @@ interface PromiseLike { */ then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} +} + +interface ArrayLike { + length: number; + [n: number]: T; +} + + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin:number, end?:number): ArrayBuffer; +} + +interface ArrayBufferConstructor { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): boolean; +} +declare var ArrayBuffer: ArrayBufferConstructor; + +interface ArrayBufferView { + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; +} + +interface DataView { + buffer: ArrayBuffer; + byteLength: number; + byteOffset: number; + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian?: boolean): number; + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; +} + +interface DataViewConstructor { + new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; +} +declare var DataView: DataViewConstructor; + +/** + * 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 { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Int8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Int8Array; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} +interface Int8ArrayConstructor { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: ArrayLike): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + +} +declare var Int8Array: Int8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint8Array; + + /** + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ArrayConstructor { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: ArrayLike): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + +} +declare var Uint8Array: Uint8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: ArrayLike): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Int16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Int16Array; + + /** + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int16ArrayConstructor { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: ArrayLike): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + +} +declare var Int16Array: Int16ArrayConstructor; + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint16Array; + + /** + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint16ArrayConstructor { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: ArrayLike): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + +} +declare var Uint16Array: Uint16ArrayConstructor; +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Int32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Int32Array; + + /** + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int32ArrayConstructor { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: ArrayLike): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} +declare var Int32Array: Int32ArrayConstructor; + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint32Array; + + /** + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint32ArrayConstructor { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: ArrayLike): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} +declare var Uint32Array: Uint32ArrayConstructor; + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Float32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Float32Array; + + /** + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float32ArrayConstructor { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: ArrayLike): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + +} +declare var Float32Array: Float32ArrayConstructor; + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Float64Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float64Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Float64Array; + + /** + * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float64ArrayConstructor { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: ArrayLike): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} +declare var Float64Array: Float64ArrayConstructor; declare type PropertyKey = string | number | symbol; interface Symbol { @@ -1286,8 +3927,8 @@ interface SymbolConstructor { split: symbol; /** - * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive - * abstract operation. + * A method that converts an object to a corresponding primitive value. + * Called by the ToPrimitive abstract operation. */ toPrimitive: symbol; @@ -1297,8 +3938,8 @@ interface SymbolConstructor { */ toStringTag: symbol; - /** - * An Object whose own property names are property names that are excluded from the with + /** + * An Object whose own property names are property names that are excluded from the 'with' * environment bindings of the associated objects. */ unscopables: symbol; @@ -1324,7 +3965,34 @@ interface ObjectConstructor { * 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 to copy properties from. + * @param source The source object from which to copy properties. + */ + assign(target: T, source: U): T & U; + + /** + * 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. + * @param source2 The second source object from which to copy properties. + */ + assign(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 + * 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. + * @param source2 The second source object from which to copy properties. + * @param source3 The third source object from which to copy properties. + */ + assign(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 + * 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 */ assign(target: any, ...sources: any[]): any; @@ -1369,16 +4037,19 @@ interface ObjectConstructor { } interface Function { - /** - * Returns a new function object that is identical to the argument object in all ways except - * for its identity and the value of its HomeObject internal slot. - */ - toMethod(newHome: Object): Function; - /** * Returns the name of the function. Function names are read-only and can not be changed. */ name: string; + + /** + * Determines whether the given value inherits from this function if this function was used + * as a constructor function. + * + * A constructor function can control which objects are recognized as its instances by + * 'instanceof' by overriding this method. + */ + [Symbol.hasInstance](value: any): boolean; } interface NumberConstructor { @@ -1447,15 +4118,24 @@ interface NumberConstructor { parseInt(string: string, radix?: number): number; } -interface ArrayLike { - length: number; - [n: number]: T; -} - interface Array { /** Iterator */ [Symbol.iterator](): IterableIterator; + /** + * Returns an object whose properties have the value 'true' + * when they will be absent when used in a 'with' statement. + */ + [Symbol.unscopables](): { + copyWithin: boolean; + entries: boolean; + fill: boolean; + find: boolean; + findIndex: boolean; + keys: boolean; + values: boolean; + }; + /** * Returns an array of key, value pairs for every entry in the array */ @@ -1576,7 +4256,7 @@ interface String { * @param searchString search string * @param position If position is undefined, 0 is assumed, so as to search all of the String. */ - contains(searchString: string, position?: number): boolean; + includes(searchString: string, position?: number): boolean; /** * Returns true if the sequence of elements of searchString converted to a String is the @@ -1607,6 +4287,41 @@ interface String { */ startsWith(searchString: string, position?: number): boolean; + // Overloads for objects with methods of well-known symbols. + + /** + * 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. + */ + match(matcher: { [Symbol.match](string: string): RegExpMatchArray; }): RegExpMatchArray; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replacer A function that returns the replacement text. + */ + replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param searcher An object which supports searching within a string. + */ + search(searcher: { [Symbol.search](string: string): number; }): number; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param splitter An object that can split a string. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; + /** * Returns an HTML anchor element and sets the name attribute to the text value * @param name @@ -1818,37 +4533,76 @@ interface Math { [Symbol.toStringTag]: string; } +interface Date { + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "default"): string; + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "string"): string; + /** + * Converts a Date object to a number. + */ + [Symbol.toPrimitive](hint: "number"): number; + /** + * Converts a Date object to a string or number. + * + * @param hint The strings "number", "string", or "default" to specify what primitive to return. + * + * @throws {TypeError} If 'hint' was given something other than "number", "string", or "default". + * @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default". + */ + [Symbol.toPrimitive](hint: string): string | number; +} + interface RegExp { - /** - * Matches a string with a regular expression, and returns an array containing the results of + /** + * Matches a string with this regular expression, and returns an array containing the results of * that search. * @param string A string to search within. */ - match(string: string): string[]; + [Symbol.match](string: string): RegExpMatchArray; /** - * Replaces text in a string, using a regular expression. - * @param searchValue A String object or string literal that represents the regular expression + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced * @param replaceValue A String object or string literal containing the text to replace for every - * successful match of rgExp in stringObj. + * successful match of this regular expression. */ - replace(string: string, replaceValue: string): string; - - search(string: string): number; + [Symbol.replace](string: string, replaceValue: string): string; /** - * Returns an Array object into which substrings of the result of converting string to a String - * have been stored. The substrings are determined by searching from left to right for matches - * of the this value regular expression; these occurrences are not part of any substring in the - * returned array, but serve to divide up the String value. - * - * If the regular expression that contains capturing parentheses, then each time separator is - * matched the results (including any undefined results) of the capturing parentheses are spliced. - * @param string string value to split - * @param limit if not undefined, the output array is truncated so that it contains no more - * than limit elements. + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replacer A function that returns the replacement text. */ - split(string: string, limit?: number): string[]; + [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the position beginning first substring match in a regular expression search + * using this regular expression. + * + * @param string The string to search within. + */ + [Symbol.search](string: string): number; + + /** + * Returns an array of substrings that were delimited by strings in the original input that + * match against this regular expression. + * + * If the regular expression contains capturing parentheses, then each time this + * regular expression matches, the results (including any undefined results) of the + * capturing parentheses are spliced. + * + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than 'limit' elements. + */ + [Symbol.split](string: string, limit?: number): string[]; /** * Returns a string indicating the flags of the regular expression in question. This field is read-only. @@ -1877,6 +4631,10 @@ interface RegExp { unicode: boolean; } +interface RegExpConstructor { + [Symbol.species](): RegExpConstructor; +} + interface Map { clear(): void; delete(key: K): boolean; @@ -1966,440 +4724,35 @@ interface JSON { * buffer as needed. */ interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; - - /** - * Returns a section of an ArrayBuffer. - */ - slice(begin: number, end?: number): ArrayBuffer; - [Symbol.toStringTag]: string; } -interface ArrayBufferConstructor { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; - isView(arg: any): boolean; -} -declare var ArrayBuffer: ArrayBufferConstructor; - interface DataView { - buffer: ArrayBuffer; - byteLength: number; - byteOffset: number; - /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat64(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt8(byteOffset: number): number; - - /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt16(byteOffset: number, littleEndian: boolean): number; - /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint8(byteOffset: number): number; - - /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint16(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint32(byteOffset: number, littleEndian: boolean): number; - - /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setInt8(byteOffset: number, value: number): void; - - /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setUint8(byteOffset: number, value: number): void; - - /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint32(byteOffset: number, value: number, littleEndian: boolean): void; - [Symbol.toStringTag]: string; } -interface DataViewConstructor { - new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; -} -declare var DataView: DataViewConstructor; - /** * 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 { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int8Array; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Int8ArrayConstructor { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int8Array; + new (elements: Iterable): Int8Array; /** * Creates an array from an array-like or iterable object. @@ -2407,289 +4760,31 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -declare var Int8Array: Int8ArrayConstructor; /** * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint8Array; - - /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint8ArrayConstructor { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8Array; + new (elements: Iterable): Uint8Array; /** * Creates an array from an array-like or iterable object. @@ -2697,289 +4792,35 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -declare var Uint8Array: Uint8ArrayConstructor; /** * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. * If the requested number of bytes could not be allocated an exception is raised. */ interface Uint8ClampedArray { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8ClampedArray; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8ClampedArray; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8ClampedArray, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8ClampedArray; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint8ClampedArray; - - /** - * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8ClampedArray; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint8ClampedArrayConstructor { - prototype: Uint8ClampedArray; - new (length: number): Uint8ClampedArray; - new (array: Uint8ClampedArray): Uint8ClampedArray; - new (array: number[]): Uint8ClampedArray; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + new (elements: Iterable): Uint8ClampedArray; - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8ClampedArray; /** * Creates an array from an array-like or iterable object. @@ -2987,289 +4828,35 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int16Array; - - /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - [index: number]: number; + [Symbol.iterator](): IterableIterator; } interface Int16ArrayConstructor { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int16Array; + new (elements: Iterable): Int16Array; /** * Creates an array from an array-like or iterable object. @@ -3277,289 +4864,31 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -declare var Int16Array: Int16ArrayConstructor; /** * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint16Array; - - /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint16ArrayConstructor { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint16Array; + new (elements: Iterable): Uint16Array; /** * Creates an array from an array-like or iterable object. @@ -3567,289 +4896,31 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -declare var Uint16Array: Uint16ArrayConstructor; /** * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int32Array; - - /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Int32ArrayConstructor { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int32Array; + new (elements: Iterable): Int32Array; /** * Creates an array from an array-like or iterable object. @@ -3857,289 +4928,31 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -declare var Int32Array: Int32ArrayConstructor; /** * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint32Array; - - /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint32ArrayConstructor { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint32Array; + new (elements: Iterable): Uint32Array; /** * Creates an array from an array-like or iterable object. @@ -4147,289 +4960,31 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -declare var Uint32Array: Uint32ArrayConstructor; /** * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number * of bytes could not be allocated an exception is raised. */ interface Float32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Float32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Float32Array; - - /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Float32ArrayConstructor { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float32Array; + new (elements: Iterable): Float32Array; /** * Creates an array from an array-like or iterable object. @@ -4437,289 +4992,31 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -declare var Float32Array: Float32ArrayConstructor; /** * A typed array of 64-bit float values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Float64Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Float64Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float64Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Float64Array; - - /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Float64ArrayConstructor { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float64Array; + new (elements: Iterable): Float64Array; /** * Creates an array from an array-like or iterable object. @@ -4727,9 +5024,8 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -declare var Float64Array: Float64ArrayConstructor; interface ProxyHandler { getPrototypeOf? (target: T): any; @@ -4754,9 +5050,9 @@ interface ProxyConstructor { } declare var Proxy: ProxyConstructor; -declare module Reflect { +declare namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; - function construct(target: Function, argumentsList: ArrayLike): any; + function construct(target: Function, argumentsList: ArrayLike, newTarget?: any): any; function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; function deleteProperty(target: any, propertyKey: PropertyKey): boolean; function enumerate(target: any): IterableIterator; @@ -4857,23 +5153,7 @@ interface PromiseConstructor { } declare var Promise: PromiseConstructor; - -interface ArrayBufferView { - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; -}///////////////////////////// +///////////////////////////// /// ECMAScript Internationalization API ///////////////////////////// @@ -4916,7 +5196,7 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; - minimumintegerDigits?: number; + minimumIntegerDigits?: number; minimumFractionDigits?: number; maximumFractionDigits?: number; minimumSignificantDigits?: number; @@ -4929,7 +5209,7 @@ declare module Intl { style: string; currency?: string; currencyDisplay?: string; - minimumintegerDigits: number; + minimumIntegerDigits: number; minimumFractionDigits: number; maximumFractionDigits: number; minimumSignificantDigits?: number; @@ -4963,6 +5243,7 @@ declare module Intl { timeZoneName?: string; formatMatcher?: string; hour12?: boolean; + timeZone?: string; } interface ResolvedDateTimeFormatOptions { @@ -5032,18 +5313,45 @@ interface Number { interface Date { /** - * Converts a date to a string by using the current or specified locale. + * Converts a date and time to a string by using the current or specified locale. * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + /** + * Converts a date to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + /** + * Converts a time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a date and time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + /** * Converts a date to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ - toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locale?: string, options?: Intl.DateTimeFormatOptions): string; } @@ -7507,7 +7815,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. * @param replace Specifies whether the existing entry for the document is replaced in the history list. */ - open(url?: string, name?: string, features?: string, replace?: boolean): Document | Window; + open(url?: string, name?: string, features?: string, replace?: boolean): Document; /** * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. * @param commandId Specifies a command identifier. @@ -7964,6 +8272,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitMatchesSelector(selectors: string): boolean; webkitRequestFullScreen(): void; webkitRequestFullscreen(): void; + getElementsByClassName(classNames: string): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -8078,7 +8387,7 @@ interface File extends Blob { declare var File: { prototype: File; - new(): File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; } interface FileList { @@ -8951,7 +9260,6 @@ interface HTMLElement extends Element { contains(child: HTMLElement): boolean; dragDrop(): boolean; focus(): void; - getElementsByClassName(classNames: string): NodeListOf; insertAdjacentElement(position: string, insertedElement: Element): Element; insertAdjacentHTML(where: string, html: string): void; insertAdjacentText(where: string, text: string): void; @@ -11913,7 +12221,7 @@ interface IDBDatabase extends EventTarget { createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -12034,7 +12342,7 @@ interface IDBTransaction extends EventTarget { READ_ONLY: string; READ_WRITE: string; VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -12064,11 +12372,14 @@ interface ImageData { width: number; } -declare var ImageData: { +interface ImageDataConstructor { prototype: ImageData; - new(): ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +declare var ImageData: ImageDataConstructor; + interface KeyboardEvent extends UIEvent { altKey: boolean; char: string; @@ -12751,7 +13062,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -13493,7 +13804,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface Range { @@ -17010,7 +17321,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window onvolumechange: (ev: Event) => any; onwaiting: (ev: Event) => any; opener: Window; - orientation: string; + orientation: string | number; outerHeight: number; outerWidth: number; pageXOffset: number; @@ -17217,7 +17528,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { LOADING: number; OPENED: number; UNSENT: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -17487,7 +17798,7 @@ interface MSBaseReader { DONE: number; EMPTY: number; LOADING: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -17643,7 +17954,7 @@ interface XMLHttpRequestEventTarget { onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -17665,12 +17976,32 @@ interface BlobPropertyBag { endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -17825,7 +18156,7 @@ declare var onunload: (ev: Event) => any; declare var onvolumechange: (ev: Event) => any; declare var onwaiting: (ev: Event) => any; declare var opener: Window; -declare var orientation: string; +declare var orientation: string | number; declare var outerHeight: number; declare var outerWidth: number; declare var pageXOffset: number; @@ -18011,6 +18342,7 @@ interface NodeList { interface NodeListOf { [Symbol.iterator](): IterableIterator } + ///////////////////////////// /// WorkerGlobalScope APIs ///////////////////////////// diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index d9e8a2ab333..85bcfb1498e 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -14,2311 +14,7 @@ and limitations under the License. ***************************************************************************** */ /// - ///////////////////////////// -/// IE10 ECMAScript Extensions -///////////////////////////// - -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ -interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; - - /** - * Returns a section of an ArrayBuffer. - */ - slice(begin:number, end?:number): ArrayBuffer; -} - -interface ArrayBufferConstructor { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; - isView(arg: any): boolean; -} -declare var ArrayBuffer: ArrayBufferConstructor; - -interface ArrayBufferView { - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; -} - -interface DataView { - buffer: ArrayBuffer; - byteLength: number; - byteOffset: number; - /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat64(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt8(byteOffset: number): number; - - /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt16(byteOffset: number, littleEndian: boolean): number; - /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint8(byteOffset: number): number; - - /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint16(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint32(byteOffset: number, littleEndian: boolean): number; - - /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setInt8(byteOffset: number, value: number): void; - - /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setUint8(byteOffset: number, value: number): void; - - /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint32(byteOffset: number, value: number, littleEndian: boolean): void; -} - -interface DataViewConstructor { - new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; -} -declare var DataView: DataViewConstructor; - -/** - * 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 { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int8Array; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} -interface Int8ArrayConstructor { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int8Array; -} -declare var Int8Array: Int8ArrayConstructor; - -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint8Array; - - /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint8ArrayConstructor { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8Array; -} -declare var Uint8Array: Uint8ArrayConstructor; - -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Int16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int16Array; - - /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Int16ArrayConstructor { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int16Array; -} -declare var Int16Array: Int16ArrayConstructor; - -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint16Array; - - /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint16ArrayConstructor { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint16Array; -} -declare var Uint16Array: Uint16ArrayConstructor; -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Int32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int32Array; - - /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Int32ArrayConstructor { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int32Array; -} -declare var Int32Array: Int32ArrayConstructor; - -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint32Array; - - /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint32ArrayConstructor { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint32Array; -} -declare var Uint32Array: Uint32ArrayConstructor; - -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ -interface Float32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Float32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Float32Array; - - /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Float32ArrayConstructor { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float32Array; -} -declare var Float32Array: Float32ArrayConstructor; - -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ -interface Float64Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Float64Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float64Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Float64Array; - - /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Float64ArrayConstructor { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float64Array; -} -declare var Float64Array: Float64ArrayConstructor;///////////////////////////// /// ECMAScript Internationalization API ///////////////////////////// @@ -2361,7 +57,7 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; - minimumintegerDigits?: number; + minimumIntegerDigits?: number; minimumFractionDigits?: number; maximumFractionDigits?: number; minimumSignificantDigits?: number; @@ -2374,7 +70,7 @@ declare module Intl { style: string; currency?: string; currencyDisplay?: string; - minimumintegerDigits: number; + minimumIntegerDigits: number; minimumFractionDigits: number; maximumFractionDigits: number; minimumSignificantDigits?: number; @@ -2408,6 +104,7 @@ declare module Intl { timeZoneName?: string; formatMatcher?: string; hour12?: boolean; + timeZone?: string; } interface ResolvedDateTimeFormatOptions { @@ -2477,18 +174,45 @@ interface Number { interface Date { /** - * Converts a date to a string by using the current or specified locale. + * Converts a date and time to a string by using the current or specified locale. * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + /** + * Converts a date to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + /** + * Converts a time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a date and time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + /** * Converts a date to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ - toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locale?: string, options?: Intl.DateTimeFormatOptions): string; } @@ -2496,10 +220,28 @@ interface Date { /// IE Worker APIs ///////////////////////////// +interface EventInit { + bubbles?: boolean; + cancelable?: boolean; +} + interface EventListener { (evt: Event): void; } +interface AudioBuffer { + duration: number; + length: number; + numberOfChannels: number; + sampleRate: number; + getChannelData(channel: number): any; +} + +declare var AudioBuffer: { + prototype: AudioBuffer; + new(): AudioBuffer; +} + interface Blob { size: number; type: string; @@ -2553,6 +295,21 @@ declare var Console: { new(): Console; } +interface Coordinates { + accuracy: number; + altitude: number; + altitudeAccuracy: number; + heading: number; + latitude: number; + longitude: number; + speed: number; +} + +declare var Coordinates: { + prototype: Coordinates; + new(): Coordinates; +} + interface DOMError { name: string; toString(): string; @@ -2703,7 +460,7 @@ interface File extends Blob { declare var File: { prototype: File; - new(): File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; } interface FileList { @@ -2774,7 +531,7 @@ interface IDBDatabase extends EventTarget { createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -2895,7 +652,7 @@ interface IDBTransaction extends EventTarget { READ_ONLY: string; READ_WRITE: string; VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -2925,11 +682,14 @@ interface ImageData { width: number; } -declare var ImageData: { +interface ImageDataConstructor { prototype: ImageData; - new(): ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +declare var ImageData: ImageDataConstructor; + interface MSApp { clearTemporaryWebDataAsync(): MSAppAsyncOperation; createBlobFromRandomAccessStream(type: string, seeker: any): Blob; @@ -2953,6 +713,29 @@ interface MSApp { } declare var MSApp: MSApp; +interface MSAppAsyncOperation extends EventTarget { + error: DOMError; + oncomplete: (ev: Event) => any; + onerror: (ev: Event) => any; + readyState: number; + result: any; + start(): void; + COMPLETED: number; + ERROR: number; + STARTED: number; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSAppAsyncOperation: { + prototype: MSAppAsyncOperation; + new(): MSAppAsyncOperation; + COMPLETED: number; + ERROR: number; + STARTED: number; +} + interface MSBlobBuilder { append(data: any, endings?: string): void; getBlob(contentType?: string): Blob; @@ -2989,6 +772,18 @@ declare var MSStreamReader: { new(): MSStreamReader; } +interface MediaQueryList { + matches: boolean; + media: string; + addListener(listener: MediaQueryListListener): void; + removeListener(listener: MediaQueryListListener): void; +} + +declare var MediaQueryList: { + prototype: MediaQueryList; + new(): MediaQueryList; +} + interface MessageChannel { port1: MessagePort; port2: MessagePort; @@ -3009,7 +804,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -3026,6 +821,33 @@ declare var MessagePort: { new(): MessagePort; } +interface Position { + coords: Coordinates; + timestamp: number; +} + +declare var Position: { + prototype: Position; + new(): Position; +} + +interface PositionError { + code: number; + message: string; + toString(): string; + PERMISSION_DENIED: number; + POSITION_UNAVAILABLE: number; + TIMEOUT: number; +} + +declare var PositionError: { + prototype: PositionError; + new(): PositionError; + PERMISSION_DENIED: number; + POSITION_UNAVAILABLE: number; + TIMEOUT: number; +} + interface ProgressEvent extends Event { lengthComputable: boolean; loaded: number; @@ -3035,7 +857,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface WebSocket extends EventTarget { @@ -3113,7 +935,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { LOADING: number; OPENED: number; UNSENT: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -3135,6 +957,15 @@ declare var XMLHttpRequest: { create(): XMLHttpRequest; } +interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var XMLHttpRequestUpload: { + prototype: XMLHttpRequestUpload; + new(): XMLHttpRequestUpload; +} + interface AbstractWorker { onerror: (ev: Event) => any; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; @@ -3154,7 +985,7 @@ interface MSBaseReader { DONE: number; EMPTY: number; LOADING: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -3195,7 +1026,7 @@ interface XMLHttpRequestEventTarget { onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -3281,25 +1112,39 @@ interface WorkerUtils extends Object, WindowBase64 { } -interface NodeListOf extends NodeList { - length: number; - item(index: number): TNode; - [index: number]: TNode; -} - interface BlobPropertyBag { type?: string; endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + interface ErrorEventHandler { - (event: Event | string, source?: string, fileno?: number, columnNumber?: number): void; + (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } interface PositionCallback { (position: Position): void; @@ -3313,11 +1158,11 @@ interface MediaQueryListListener { interface MSLaunchUriCallback { (): void; } -interface FrameRequestCallback { - (time: number): void; +interface MSUnsafeFunctionCallback { + (): any; } -interface MutationCallback { - (mutations: MutationRecord[], observer: MutationObserver): void; +interface MSExecAtPriorityFunctionCallback { + (...args: any[]): any; } interface DecodeSuccessCallback { (decodedData: AudioBuffer): void; diff --git a/lib/tsc.js b/lib/tsc.js index 185aca1ef44..3d2b7f3956a 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -47,7 +47,6 @@ var ts; })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); var DiagnosticCategory = ts.DiagnosticCategory; })(ts || (ts = {})); -/// var ts; (function (ts) { function createFileMap(getCanonicalFileName) { @@ -57,6 +56,7 @@ var ts; set: set, contains: contains, remove: remove, + clear: clear, forEachValue: forEachValueInMap }; function set(fileName, value) { @@ -78,6 +78,9 @@ var ts; function normalizeKey(key) { return getCanonicalFileName(normalizeSlashes(key)); } + function clear() { + files = {}; + } } ts.createFileMap = createFileMap; function forEach(array, callback) { @@ -495,7 +498,7 @@ var ts; if (path.lastIndexOf("file:///", 0) === 0) { return "file:///".length; } - var idx = path.indexOf('://'); + var idx = path.indexOf("://"); if (idx !== -1) { return idx + "://".length; } @@ -565,9 +568,6 @@ var ts; } ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; function getNormalizedPathComponentsOfUrl(url) { - // Get root length of http://www.website.com/folder1/foler2/ - // In this example the root is: http://www.website.com/ - // normalized path components should be ["http://www.website.com/", "folder1", "folder2"] var urlLength = url.length; var rootLength = url.indexOf("://") + "://".length; while (rootLength < urlLength) { @@ -649,7 +649,7 @@ var ts; return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; } ts.fileExtensionIs = fileExtensionIs; - ts.supportedExtensions = [".tsx", ".ts", ".d.ts"]; + ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -727,7 +727,6 @@ var ts; Debug.fail = fail; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { ts.sys = (function () { @@ -864,7 +863,7 @@ var ts; function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); - var _os = require('os'); + var _os = require("os"); var platform = _os.platform(); var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; function readFile(fileName, encoding) { @@ -892,7 +891,7 @@ var ts; } function writeFile(fileName, data, writeByteOrderMark) { if (writeByteOrderMark) { - data = '\uFEFF' + data; + data = "\uFEFF" + data; } _fs.writeFileSync(fileName, data, "utf8"); } @@ -933,7 +932,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, 'utf8'); + var buffer = new Buffer(s, "utf8"); var offset = 0; var toWrite = buffer.length; var written = 0; @@ -955,7 +954,6 @@ var ts; } callback(fileName); } - ; }, resolvePath: function (path) { return _path.resolve(path); @@ -992,7 +990,7 @@ var ts; if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { return getWScriptSystem(); } - else if (typeof module !== "undefined" && module.exports) { + else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { return getNodeSystem(); } else { @@ -1000,7 +998,6 @@ var ts; } })(); })(ts || (ts = {})); -/// var ts; (function (ts) { ts.Diagnostics = { @@ -1245,7 +1242,7 @@ var ts; Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." }, @@ -1255,6 +1252,7 @@ var ts; Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, @@ -1294,7 +1292,7 @@ var ts; Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, @@ -1415,6 +1413,7 @@ var ts; The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, + Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -1425,6 +1424,12 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, + Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, + Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, + Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." }, + Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -1504,20 +1509,12 @@ var ts; Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, - Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, - Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, - Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, - Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, - Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, - Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -1566,13 +1563,17 @@ var ts; Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, + Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -1613,131 +1614,134 @@ var ts; JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." } + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } }; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { + function tokenIsIdentifierOrKeyword(token) { + return token >= 67; + } + ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = { - "abstract": 112, - "any": 114, - "as": 113, - "boolean": 117, - "break": 67, - "case": 68, - "catch": 69, - "class": 70, - "continue": 72, - "const": 71, - "constructor": 118, - "debugger": 73, - "declare": 119, - "default": 74, - "delete": 75, - "do": 76, - "else": 77, - "enum": 78, - "export": 79, - "extends": 80, - "false": 81, - "finally": 82, - "for": 83, - "from": 130, - "function": 84, - "get": 120, - "if": 85, - "implements": 103, - "import": 86, - "in": 87, - "instanceof": 88, - "interface": 104, - "is": 121, - "let": 105, - "module": 122, - "namespace": 123, - "new": 89, - "null": 90, - "number": 125, - "package": 106, - "private": 107, - "protected": 108, - "public": 109, - "require": 124, - "return": 91, - "set": 126, - "static": 110, - "string": 127, - "super": 92, - "switch": 93, - "symbol": 128, - "this": 94, - "throw": 95, - "true": 96, - "try": 97, - "type": 129, - "typeof": 98, - "var": 99, - "void": 100, - "while": 101, - "with": 102, - "yield": 111, - "async": 115, - "await": 116, - "of": 131, - "{": 14, - "}": 15, - "(": 16, - ")": 17, - "[": 18, - "]": 19, - ".": 20, - "...": 21, - ";": 22, - ",": 23, - "<": 24, - ">": 26, - "<=": 27, - ">=": 28, - "==": 29, - "!=": 30, - "===": 31, - "!==": 32, - "=>": 33, - "+": 34, - "-": 35, - "*": 36, - "/": 37, - "%": 38, - "++": 39, - "--": 40, - "<<": 41, - ">": 42, - ">>>": 43, - "&": 44, - "|": 45, - "^": 46, - "!": 47, - "~": 48, - "&&": 49, - "||": 50, - "?": 51, - ":": 52, - "=": 54, - "+=": 55, - "-=": 56, - "*=": 57, - "/=": 58, - "%=": 59, - "<<=": 60, - ">>=": 61, - ">>>=": 62, - "&=": 63, - "|=": 64, - "^=": 65, - "@": 53 + "abstract": 113, + "any": 115, + "as": 114, + "boolean": 118, + "break": 68, + "case": 69, + "catch": 70, + "class": 71, + "continue": 73, + "const": 72, + "constructor": 119, + "debugger": 74, + "declare": 120, + "default": 75, + "delete": 76, + "do": 77, + "else": 78, + "enum": 79, + "export": 80, + "extends": 81, + "false": 82, + "finally": 83, + "for": 84, + "from": 131, + "function": 85, + "get": 121, + "if": 86, + "implements": 104, + "import": 87, + "in": 88, + "instanceof": 89, + "interface": 105, + "is": 122, + "let": 106, + "module": 123, + "namespace": 124, + "new": 90, + "null": 91, + "number": 126, + "package": 107, + "private": 108, + "protected": 109, + "public": 110, + "require": 125, + "return": 92, + "set": 127, + "static": 111, + "string": 128, + "super": 93, + "switch": 94, + "symbol": 129, + "this": 95, + "throw": 96, + "true": 97, + "try": 98, + "type": 130, + "typeof": 99, + "var": 100, + "void": 101, + "while": 102, + "with": 103, + "yield": 112, + "async": 116, + "await": 117, + "of": 132, + "{": 15, + "}": 16, + "(": 17, + ")": 18, + "[": 19, + "]": 20, + ".": 21, + "...": 22, + ";": 23, + ",": 24, + "<": 25, + ">": 27, + "<=": 28, + ">=": 29, + "==": 30, + "!=": 31, + "===": 32, + "!==": 33, + "=>": 34, + "+": 35, + "-": 36, + "*": 37, + "/": 38, + "%": 39, + "++": 40, + "--": 41, + "<<": 42, + ">": 43, + ">>>": 44, + "&": 45, + "|": 46, + "^": 47, + "!": 48, + "~": 49, + "&&": 50, + "||": 51, + "?": 52, + ":": 53, + "=": 55, + "+=": 56, + "-=": 57, + "*=": 58, + "/=": 59, + "%=": 60, + "<<=": 61, + ">>=": 62, + ">>>=": 63, + "&=": 64, + "|=": 65, + "^=": 66, + "@": 54 }; var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -1838,6 +1842,7 @@ var ts; var lineNumber = ts.binarySearch(lineStarts, position); if (lineNumber < 0) { lineNumber = ~lineNumber - 1; + ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); } return { line: lineNumber, @@ -1866,16 +1871,6 @@ var ts; } ts.isWhiteSpace = isWhiteSpace; function isLineBreak(ch) { - // ES5 7.3: - // The ECMAScript line terminator characters are listed in Table 3. - // Table 3: Line Terminator Characters - // Code Unit Value Name Formal Name - // \u000A Line Feed - // \u000D Carriage Return - // \u2028 Line separator - // \u2029 Paragraph separator - // Only the characters in Table 3 are treated as line terminators. Other new line or line - // breaking characters are treated as white space but not as line terminators. return ch === 10 || ch === 13 || ch === 8232 || @@ -1903,6 +1898,8 @@ var ts; case 61: case 62: return true; + case 35: + return pos === 0; default: return ch > 127; } @@ -1959,6 +1956,12 @@ var ts; continue; } break; + case 35: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; default: if (ch > 127 && (isWhiteSpace(ch) || isLineBreak(ch))) { pos++; @@ -2010,6 +2013,16 @@ var ts; } return pos; } + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + ts.Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); + } + function scanShebangTrivia(text, pos) { + var shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; + } function getCommentRanges(text, pos, trailing) { var result; var collecting = trailing || pos === 0; @@ -2091,6 +2104,12 @@ var ts; return getCommentRanges(text, pos, true); } ts.getTrailingCommentRanges = getTrailingCommentRanges; + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch === 36 || ch === 95 || @@ -2124,8 +2143,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 66 || token > 102; }, - isReservedWord: function () { return token >= 67 && token <= 102; }, + isIdentifier: function () { return token === 67 || token > 103; }, + isReservedWord: function () { return token >= 68 && token <= 103; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -2265,20 +2284,20 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 10 : 13; + resultingToken = startedWithBacktick ? 11 : 14; break; } var currChar = text.charCodeAt(pos); if (currChar === 96) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 10 : 13; + resultingToken = startedWithBacktick ? 11 : 14; break; } if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 11 : 12; + resultingToken = startedWithBacktick ? 12 : 13; break; } if (currChar === 92) { @@ -2439,7 +2458,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 66; + return token = 67; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2471,6 +2490,15 @@ var ts; return token = 1; } var ch = text.charCodeAt(pos); + if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6; + } + } switch (ch) { case 10: case 13: @@ -2505,66 +2533,66 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 32; + return pos += 3, token = 33; } - return pos += 2, token = 30; + return pos += 2, token = 31; } - return pos++, token = 47; + return pos++, token = 48; case 34: case 39: tokenValue = scanString(); - return token = 8; + return token = 9; case 96: return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 60; } - return pos++, token = 38; + return pos++, token = 39; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 49; + return pos += 2, token = 50; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } - return pos++, token = 44; + return pos++, token = 45; case 40: - return pos++, token = 16; - case 41: return pos++, token = 17; + case 41: + return pos++, token = 18; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } - return pos++, token = 36; + return pos++, token = 37; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 39; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 55; - } - return pos++, token = 34; - case 44: - return pos++, token = 23; - case 45: - if (text.charCodeAt(pos + 1) === 45) { return pos += 2, token = 40; } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 56; } return pos++, token = 35; + case 44: + return pos++, token = 24; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 41; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 57; + } + return pos++, token = 36; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); - return token = 7; + return token = 8; } if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 21; + return pos += 3, token = 22; } - return pos++, token = 20; + return pos++, token = 21; case 47: if (text.charCodeAt(pos + 1) === 47) { pos += 2; @@ -2608,9 +2636,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; + return pos += 2, token = 59; } - return pos++, token = 37; + return pos++, token = 38; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -2620,7 +2648,7 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { pos += 2; @@ -2630,7 +2658,7 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { pos += 2; @@ -2640,11 +2668,11 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - return token = 7; + return token = 8; } case 49: case 50: @@ -2656,11 +2684,11 @@ var ts; case 56: case 57: tokenValue = "" + scanNumber(); - return token = 7; + return token = 8; case 58: - return pos++, token = 52; + return pos++, token = 53; case 59: - return pos++, token = 22; + return pos++, token = 23; case 60: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2668,22 +2696,22 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; + return pos += 3, token = 61; } - return pos += 2, token = 41; + return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 27; + return pos += 2, token = 28; } if (text.charCodeAt(pos + 1) === 47 && languageVariant === 1) { - return pos += 2, token = 25; + return pos += 2, token = 26; } - return pos++, token = 24; + return pos++, token = 25; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2691,19 +2719,19 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 31; + return pos += 3, token = 32; } - return pos += 2, token = 29; + return pos += 2, token = 30; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 33; + return pos += 2, token = 34; } - return pos++, token = 54; + return pos++, token = 55; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2711,37 +2739,37 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } - return pos++, token = 26; + return pos++, token = 27; case 63: - return pos++, token = 51; + return pos++, token = 52; case 91: - return pos++, token = 18; - case 93: return pos++, token = 19; + case 93: + return pos++, token = 20; case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 66; + } + return pos++, token = 47; + case 123: + return pos++, token = 15; + case 124: + if (text.charCodeAt(pos + 1) === 124) { + return pos += 2, token = 51; + } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 65; } return pos++, token = 46; - case 123: - return pos++, token = 14; - case 124: - if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 50; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; - } - return pos++, token = 45; case 125: - return pos++, token = 15; + return pos++, token = 16; case 126: - return pos++, token = 48; + return pos++, token = 49; case 64: - return pos++, token = 53; + return pos++, token = 54; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -2777,27 +2805,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 26) { + if (token === 27) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 62; + return pos += 3, token = 63; } - return pos += 2, token = 43; + return pos += 2, token = 44; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 62; } - return pos++, token = 42; + return pos++, token = 43; } if (text.charCodeAt(pos) === 61) { - return pos++, token = 28; + return pos++, token = 29; } } return token; } function reScanSlashToken() { - if (token === 37 || token === 58) { + if (token === 38 || token === 59) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -2836,12 +2864,12 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 9; + token = 10; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 15, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 16, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -2858,14 +2886,14 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 25; + return token = 26; } pos++; - return token = 24; + return token = 25; } if (char === 123) { pos++; - return token = 14; + return token = 15; } while (pos < end) { pos++; @@ -2874,10 +2902,10 @@ var ts; break; } } - return token = 233; + return token = 234; } function scanJsxIdentifier() { - if (token === 66) { + if (tokenIsIdentifierOrKeyword(token)) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); @@ -2944,21 +2972,20 @@ var ts; } ts.createScanner = createScanner; })(ts || (ts = {})); -/// var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 212 || node.kind === 213) { + if (node.kind === 213 || node.kind === 214) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 219 || node.kind === 218) && !(node.flags & 1)) { + else if ((node.kind === 220 || node.kind === 219) && !(node.flags & 1)) { return 0; } - else if (node.kind === 216) { + else if (node.kind === 217) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -2974,7 +3001,7 @@ var ts; }); return state; } - else if (node.kind === 215) { + else if (node.kind === 216) { return getModuleInstanceState(node.body); } else { @@ -3026,10 +3053,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 215 && node.name.kind === 8) { - return '"' + node.name.text + '"'; + if (node.kind === 216 && node.name.kind === 9) { + return "\"" + node.name.text + "\""; } - if (node.name.kind === 133) { + if (node.name.kind === 134) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -3037,22 +3064,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 141: + case 142: return "__constructor"; - case 149: - case 144: - return "__call"; case 150: case 145: - return "__new"; + return "__call"; + case 151: case 146: + return "__new"; + case 147: return "__index"; - case 225: + case 226: return "__export"; - case 224: + case 225: return node.isExportEquals ? "export=" : "default"; - case 210: case 211: + case 212: return node.flags & 1024 ? "default" : undefined; } } @@ -3094,7 +3121,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 227 || (node.kind === 218 && hasExportModifier)) { + if (node.kind === 228 || (node.kind === 219 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -3140,37 +3167,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 183: - case 211: + case 184: case 212: - case 214: - case 152: - case 162: + case 213: + case 215: + case 153: + case 163: return 1; - case 144: case 145: case 146: - case 140: - case 139: - case 210: + case 147: case 141: + case 140: + case 211: case 142: case 143: - case 149: + case 144: case 150: - case 170: + case 151: case 171: - case 215: - case 245: - case 213: + case 172: + case 216: + case 246: + case 214: return 5; - case 241: - case 196: + case 242: case 197: case 198: - case 217: + case 199: + case 218: return 2; - case 189: + case 190: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -3186,33 +3213,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 215: + case 216: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 245: + case 246: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 183: - case 211: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 214: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 152: - case 162: + case 184: case 212: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 215: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 153: + case 163: + case 213: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 149: case 150: - case 144: + case 151: case 145: case 146: - case 140: - case 139: + case 147: case 141: + case 140: case 142: case 143: - case 210: - case 170: + case 144: + case 211: case 171: - case 213: + case 172: + case 214: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -3236,11 +3263,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 245 ? node : node.body; - if (body.kind === 245 || body.kind === 216) { + var body = node.kind === 246 ? node : node.body; + if (body.kind === 246 || body.kind === 217) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 225 || stat.kind === 224) { + if (stat.kind === 226 || stat.kind === 225) { return true; } } @@ -3257,7 +3284,7 @@ var ts; } function bindModuleDeclaration(node) { setExportContextFlag(node); - if (node.name.kind === 8) { + if (node.name.kind === 9) { declareSymbolAndAddToSymbolTable(node, 512, 106639); } else { @@ -3267,12 +3294,17 @@ var ts; } else { declareSymbolAndAddToSymbolTable(node, 512, 106639); - var currentModuleIsConstEnumOnly = state === 2; - if (node.symbol.constEnumOnlyModule === undefined) { - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + if (node.symbol.flags & (16 | 32 | 256)) { + node.symbol.constEnumOnlyModule = false; } else { - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + var currentModuleIsConstEnumOnly = state === 2; + if (node.symbol.constEnumOnlyModule === undefined) { + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } } } } @@ -3290,11 +3322,11 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 66) { + if (prop.name.kind !== 67) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 242 || prop.kind === 243 || prop.kind === 140 + var currentKind = prop.kind === 243 || prop.kind === 244 || prop.kind === 141 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -3316,10 +3348,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 215: + case 216: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 245: + case 246: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -3337,8 +3369,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 103 && - node.originalKeywordKind <= 111 && + node.originalKeywordKind >= 104 && + node.originalKeywordKind <= 112 && !ts.isIdentifierName(node)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -3365,17 +3397,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 66) { + if (inStrictMode && node.expression.kind === 67) { var span = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 && + return node.kind === 67 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 66) { + if (name && name.kind === 67) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -3409,7 +3441,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 39 || node.operator === 40) { + if (node.operator === 40 || node.operator === 41) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -3438,17 +3470,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 245: - case 216: + case 246: + case 217: updateStrictModeStatementList(node.statements); return; - case 189: + case 190: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 211: - case 183: + case 212: + case 184: inStrictMode = true; return; } @@ -3467,106 +3499,106 @@ var ts; } function isUseStrictPrologueDirective(node) { var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); - return nodeText === '"use strict"' || nodeText === "'use strict'"; + return nodeText === "\"use strict\"" || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 66: + case 67: return checkStrictModeIdentifier(node); - case 178: + case 179: return checkStrictModeBinaryExpression(node); - case 241: - return checkStrictModeCatchClause(node); - case 172: - return checkStrictModeDeleteExpression(node); - case 7: - return checkStrictModeNumericLiteral(node); - case 177: - return checkStrictModePostfixUnaryExpression(node); - case 176: - return checkStrictModePrefixUnaryExpression(node); - case 202: - return checkStrictModeWithStatement(node); - case 134: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 135: - return bindParameter(node); - case 208: - case 160: - return bindVariableDeclarationOrBindingElement(node); - case 138: - case 137: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); case 242: + return checkStrictModeCatchClause(node); + case 173: + return checkStrictModeDeleteExpression(node); + case 8: + return checkStrictModeNumericLiteral(node); + case 178: + return checkStrictModePostfixUnaryExpression(node); + case 177: + return checkStrictModePrefixUnaryExpression(node); + case 203: + return checkStrictModeWithStatement(node); + case 135: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); + case 136: + return bindParameter(node); + case 209: + case 161: + return bindVariableDeclarationOrBindingElement(node); + case 139: + case 138: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); case 243: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); case 244: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 245: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 144: case 145: case 146: + case 147: return declareSymbolAndAddToSymbolTable(node, 131072, 0); + case 141: case 140: - case 139: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 210: + case 211: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16, 106927); - case 141: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 142: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 143: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 144: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 149: case 150: + case 151: return bindFunctionOrConstructorType(node); - case 152: + case 153: return bindAnonymousDeclaration(node, 2048, "__type"); - case 162: + case 163: return bindObjectLiteralExpression(node); - case 170: case 171: + case 172: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16, bindingName); - case 183: - case 211: - return bindClassLikeDeclaration(node); + case 184: case 212: - return bindBlockScopedDeclaration(node, 64, 792960); + return bindClassLikeDeclaration(node); case 213: - return bindBlockScopedDeclaration(node, 524288, 793056); + return bindBlockScopedDeclaration(node, 64, 792960); case 214: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793056); case 215: + return bindEnumDeclaration(node); + case 216: return bindModuleDeclaration(node); - case 218: - case 221: - case 223: - case 227: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 220: - return bindImportClause(node); - case 225: - return bindExportDeclaration(node); + case 219: + case 222: case 224: + case 228: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 221: + return bindImportClause(node); + case 226: + return bindExportDeclaration(node); + case 225: return bindExportAssignment(node); - case 245: + case 246: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512, '"' + ts.removeFileExtension(file.fileName) + '"'); + bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); } } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } - else if (node.expression.kind === 66) { + else if (node.expression.kind === 67) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -3587,12 +3619,15 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 211) { + if (node.kind === 212) { bindBlockScopedDeclaration(node, 32, 899519); } else { var bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, 32, bindingName); + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } } var symbol = node.symbol; var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); @@ -3637,7 +3672,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 141 && + node.parent.kind === 142 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); @@ -3650,7 +3685,6 @@ var ts; } } })(ts || (ts = {})); -/// var ts; (function (ts) { function getDeclarationOfKind(symbol, kind) { @@ -3699,6 +3733,37 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(arr1, arr2, comparer) { + if (!arr1 || !arr2) { + return arr1 === arr2; + } + if (arr1.length !== arr2.length) { + return false; + } + for (var i = 0; i < arr1.length; ++i) { + var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModule(sourceFile, moduleNameText) { + return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); + } + ts.hasResolvedModule = hasResolvedModule; + function getResolvedModule(sourceFile, moduleNameText) { + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModule = getResolvedModule; + function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + sourceFile.resolvedModules[moduleNameText] = resolvedModule; + } + ts.setResolvedModule = setResolvedModule; function containsParseError(node) { aggregateChildData(node); return (node.parserContextFlags & 64) !== 0; @@ -3715,7 +3780,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 245) { + while (node && node.kind !== 246) { node = node.parent; } return node; @@ -3791,7 +3856,7 @@ var ts; } ts.unescapeIdentifier = unescapeIdentifier; function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/\W/g, "_"); + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { @@ -3806,15 +3871,15 @@ var ts; return current; } switch (current.kind) { - case 245: - case 217: - case 241: - case 215: - case 196: + case 246: + case 218: + case 242: + case 216: case 197: case 198: + case 199: return current; - case 189: + case 190: if (!isFunctionLike(current.parent)) { return current; } @@ -3825,9 +3890,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 208 && + declaration.kind === 209 && declaration.parent && - declaration.parent.kind === 241; + declaration.parent.kind === 242; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3863,22 +3928,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 245: + case 246: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 208: - case 160: - case 211: - case 183: + case 209: + case 161: case 212: + case 184: + case 213: + case 216: case 215: - case 214: - case 244: - case 210: - case 170: + case 245: + case 211: + case 171: errorNode = node.name; break; } @@ -3900,11 +3965,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 214 && isConst(node); + return node.kind === 215 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 160 || isBindingPattern(node))) { + while (node && (node.kind === 161 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3912,14 +3977,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 208) { + if (node.kind === 209) { node = node.parent; } - if (node && node.kind === 209) { + if (node && node.kind === 210) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 190) { + if (node && node.kind === 191) { flags |= node.flags; } return flags; @@ -3934,20 +3999,18 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 192 && node.expression.kind === 8; + return node.kind === 193 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - if (node.kind === 135 || node.kind === 134) { - return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); - } - else { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); + var commentRanges = (node.kind === 136 || node.kind === 135) ? + ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return ts.filter(commentRanges, isJsDocComment); function isJsDocComment(comment) { return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 && sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 && @@ -3956,69 +4019,70 @@ var ts; } ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (148 <= node.kind && node.kind <= 157) { + if (149 <= node.kind && node.kind <= 158) { return true; } switch (node.kind) { - case 114: - case 125: - case 127: - case 117: + case 115: + case 126: case 128: + case 118: + case 129: return true; - case 100: - return node.parent.kind !== 174; - case 8: - return node.parent.kind === 135; - case 185: + case 101: + return node.parent.kind !== 175; + case 9: + return node.parent.kind === 136; + case 186: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 66: - if (node.parent.kind === 132 && node.parent.right === node) { + case 67: + if (node.parent.kind === 133 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 163 && node.parent.name === node) { + else if (node.parent.kind === 164 && node.parent.name === node) { node = node.parent; } - case 132: - case 163: - ts.Debug.assert(node.kind === 66 || node.kind === 132 || node.kind === 163, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 133: + case 164: + ts.Debug.assert(node.kind === 67 || node.kind === 133 || node.kind === 164, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 151) { + if (parent_1.kind === 152) { return false; } - if (148 <= parent_1.kind && parent_1.kind <= 157) { + if (149 <= parent_1.kind && parent_1.kind <= 158) { return true; } switch (parent_1.kind) { - case 185: + case 186: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 134: - return node === parent_1.constraint; - case 138: - case 137: case 135: - case 208: + return node === parent_1.constraint; + case 139: + case 138: + case 136: + case 209: return node === parent_1.type; - case 210: - case 170: + case 211: case 171: + case 172: + case 142: case 141: case 140: - case 139: - case 142: case 143: - return node === parent_1.type; case 144: + return node === parent_1.type; case 145: case 146: + case 147: return node === parent_1.type; - case 168: + case 169: return node === parent_1.type; - case 165: case 166: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 167: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 168: return false; } } @@ -4029,23 +4093,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 201: + case 202: return visitor(node); - case 217: - case 189: - case 193: + case 218: + case 190: case 194: case 195: case 196: case 197: case 198: - case 202: + case 199: case 203: - case 238: - case 239: case 204: - case 206: - case 241: + case 239: + case 240: + case 205: + case 207: + case 242: return ts.forEachChild(node, traverse); } } @@ -4055,23 +4119,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 181: + case 182: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 214: - case 212: case 215: case 213: - case 211: - case 183: + case 216: + case 214: + case 212: + case 184: return; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 133) { + if (name_5 && name_5.kind === 134) { traverse(name_5.expression); return; } @@ -4086,14 +4150,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 160: - case 244: - case 135: - case 242: - case 138: - case 137: + case 161: + case 245: + case 136: case 243: - case 208: + case 139: + case 138: + case 244: + case 209: return true; } } @@ -4101,41 +4165,55 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 142 || node.kind === 143); + return node && (node.kind === 143 || node.kind === 144); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 211 || node.kind === 183); + return node && (node.kind === 212 || node.kind === 184); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 141: - case 170: - case 210: - case 171: - case 140: - case 139: case 142: + case 171: + case 211: + case 172: + case 141: + case 140: case 143: case 144: case 145: case 146: - case 149: + case 147: case 150: + case 151: return true; } } return false; } ts.isFunctionLike = isFunctionLike; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 141: + case 140: + case 142: + case 143: + case 144: + case 211: + case 171: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 189 && isFunctionLike(node.parent); + return node && node.kind === 190 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 140 && node.parent.kind === 162; + return node && node.kind === 141 && node.parent.kind === 163; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -4163,36 +4241,36 @@ var ts; return undefined; } switch (node.kind) { - case 133: + case 134: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 136: - if (node.parent.kind === 135 && isClassElement(node.parent.parent)) { + case 137: + if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 171: + case 172: if (!includeArrowFunctions) { continue; } - case 210: - case 170: - case 215: - case 138: - case 137: - case 140: + case 211: + case 171: + case 216: case 139: + case 138: case 141: + case 140: case 142: case 143: - case 214: - case 245: + case 144: + case 215: + case 246: return node; } } @@ -4204,33 +4282,33 @@ var ts; if (!node) return node; switch (node.kind) { - case 133: + case 134: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 136: - if (node.parent.kind === 135 && isClassElement(node.parent.parent)) { + case 137: + if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 210: - case 170: + case 211: case 171: + case 172: if (!includeFunctions) { continue; } - case 138: - case 137: - case 140: case 139: + case 138: case 141: + case 140: case 142: case 143: + case 144: return node; } } @@ -4239,12 +4317,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 148: + case 149: return node.typeName; - case 185: + case 186: return node.expression; - case 66: - case 132: + case 67: + case 133: return node; } } @@ -4252,7 +4330,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 167) { + if (node.kind === 168) { return node.tag; } return node.expression; @@ -4260,40 +4338,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 211: + case 212: return true; - case 138: - return node.parent.kind === 211; - case 135: - return node.parent.body && node.parent.parent.kind === 211; - case 142: + case 139: + return node.parent.kind === 212; + case 136: + return node.parent.body && node.parent.parent.kind === 212; case 143: - case 140: - return node.body && node.parent.kind === 211; + case 144: + case 141: + return node.body && node.parent.kind === 212; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 211: + case 212: if (node.decorators) { return true; } return false; - case 138: - case 135: + case 139: + case 136: if (node.decorators) { return true; } return false; - case 142: + case 143: if (node.body && node.decorators) { return true; } return false; - case 140: - case 143: + case 141: + case 144: if (node.body && node.decorators) { return true; } @@ -4304,10 +4382,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 211: + case 212: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 140: - case 143: + case 141: + case 144: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -4319,92 +4397,93 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 94: - case 92: - case 90: - case 96: - case 81: - case 9: - case 161: + case 95: + case 93: + case 91: + case 97: + case 82: + case 10: case 162: case 163: case 164: case 165: case 166: case 167: - case 186: case 168: + case 187: case 169: case 170: - case 183: case 171: - case 174: + case 184: case 172: + case 175: case 173: - case 176: + case 174: case 177: case 178: case 179: - case 182: case 180: - case 10: - case 184: - case 230: - case 231: + case 183: case 181: + case 11: + case 185: + case 231: + case 232: + case 182: return true; - case 132: - while (node.parent.kind === 132) { + case 133: + while (node.parent.kind === 133) { node = node.parent; } - return node.parent.kind === 151; - case 66: - if (node.parent.kind === 151) { + return node.parent.kind === 152; + case 67: + if (node.parent.kind === 152) { return true; } - case 7: case 8: + case 9: var parent_2 = node.parent; switch (parent_2.kind) { - case 208: - case 135: + case 209: + case 136: + case 139: case 138: - case 137: - case 244: - case 242: - case 160: + case 245: + case 243: + case 161: return parent_2.initializer === node; - case 192: case 193: case 194: case 195: - case 201: + case 196: case 202: case 203: - case 238: - case 205: - case 203: + case 204: + case 239: + case 206: + case 204: return parent_2.expression === node; - case 196: + case 197: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 209) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 210) || forStatement.condition === node || forStatement.incrementor === node; - case 197: case 198: + case 199: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 209) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210) || forInStatement.expression === node; - case 168: - case 186: - return node === parent_2.expression; + case 169: case 187: return node === parent_2.expression; - case 133: + case 188: return node === parent_2.expression; - case 136: + case 134: + return node === parent_2.expression; + case 137: + case 238: return true; - case 185: + case 186: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4422,7 +4501,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 && node.moduleReference.kind === 229; + return node.kind === 219 && node.moduleReference.kind === 230; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4431,20 +4510,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 && node.moduleReference.kind !== 229; + return node.kind === 219 && node.moduleReference.kind !== 230; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 219) { + if (node.kind === 220) { return node.moduleSpecifier; } - if (node.kind === 218) { + if (node.kind === 219) { var reference = node.moduleReference; - if (reference.kind === 229) { + if (reference.kind === 230) { return reference.expression; } } - if (node.kind === 225) { + if (node.kind === 226) { return node.moduleSpecifier; } } @@ -4452,15 +4531,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 135: - return node.questionToken !== undefined; + case 136: + case 141: case 140: - case 139: - return node.questionToken !== undefined; + case 244: case 243: - case 242: + case 139: case 138: - case 137: return node.questionToken !== undefined; } } @@ -4468,9 +4545,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 258 && + return node.kind === 259 && node.parameters.length > 0 && - node.parameters[0].type.kind === 260; + node.parameters[0].type.kind === 261; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4484,24 +4561,24 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 266); + return getJSDocTag(node, 267); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 265); + return getJSDocTag(node, 266); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 267); + return getJSDocTag(node, 268); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 66) { + if (parameter.name && parameter.name.kind === 67) { var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 264) { + if (t.kind === 265) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -4520,12 +4597,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 259) { + if (node.type && node.type.kind === 260) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 259; + return paramTag.typeExpression.type.kind === 260; } } return node.dotDotDotToken !== undefined; @@ -4534,19 +4611,19 @@ var ts; } ts.isRestParameter = isRestParameter; function isLiteralKind(kind) { - return 7 <= kind && kind <= 10; + return 8 <= kind && kind <= 11; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 8 || kind === 10; + return kind === 9 || kind === 11; } ts.isTextualLiteralKind = isTextualLiteralKind; function isTemplateLiteralKind(kind) { - return 10 <= kind && kind <= 13; + return 11 <= kind && kind <= 14; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 159 || node.kind === 158); + return !!node && (node.kind === 160 || node.kind === 159); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4561,34 +4638,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 171: - case 160: - case 211: - case 183: - case 141: - case 214: - case 244: - case 227: - case 210: - case 170: - case 142: - case 220: - case 218: - case 223: + case 172: + case 161: case 212: - case 140: - case 139: + case 184: + case 142: case 215: - case 221: - case 135: - case 242: - case 138: - case 137: + case 245: + case 228: + case 211: + case 171: case 143: - case 243: + case 221: + case 219: + case 224: case 213: - case 134: - case 208: + case 141: + case 140: + case 216: + case 222: + case 136: + case 243: + case 139: + case 138: + case 144: + case 244: + case 214: + case 135: + case 209: return true; } return false; @@ -4596,25 +4673,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 200: - case 199: - case 207: - case 194: - case 192: - case 191: - case 197: - case 198: - case 196: - case 193: - case 204: case 201: - case 203: - case 95: - case 206: - case 190: + case 200: + case 208: case 195: + case 193: + case 192: + case 198: + case 199: + case 197: + case 194: + case 205: case 202: - case 224: + case 204: + case 96: + case 207: + case 191: + case 196: + case 203: + case 225: return true; default: return false; @@ -4623,13 +4700,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 141: - case 138: - case 140: case 142: - case 143: case 139: - case 146: + case 141: + case 143: + case 144: + case 140: + case 147: return true; default: return false; @@ -4637,11 +4714,11 @@ var ts; } ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 66 && name.kind !== 8 && name.kind !== 7) { + if (name.kind !== 67 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 223 || parent.kind === 227) { + if (parent.kind === 224 || parent.kind === 228) { if (parent.propertyName) { return true; } @@ -4655,54 +4732,54 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 138: - case 137: - case 140: case 139: - case 142: + case 138: + case 141: + case 140: case 143: - case 244: - case 242: - case 163: + case 144: + case 245: + case 243: + case 164: return parent.name === node; - case 132: + case 133: if (parent.right === node) { - while (parent.kind === 132) { + while (parent.kind === 133) { parent = parent.parent; } - return parent.kind === 151; + return parent.kind === 152; } return false; - case 160: - case 223: + case 161: + case 224: return parent.propertyName === node; - case 227: + case 228: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 218 || - node.kind === 220 && !!node.name || - node.kind === 221 || - node.kind === 223 || - node.kind === 227 || - node.kind === 224 && node.expression.kind === 66; + return node.kind === 219 || + node.kind === 221 && !!node.name || + node.kind === 222 || + node.kind === 224 || + node.kind === 228 || + node.kind === 225 && node.expression.kind === 67; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80); + var heritageClause = getHeritageClause(node.heritageClauses, 81); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 103); + var heritageClause = getHeritageClause(node.heritageClauses, 104); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80); + var heritageClause = getHeritageClause(node.heritageClauses, 81); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -4771,11 +4848,11 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 67 <= token && token <= 131; + return 68 <= token && token <= 132; } ts.isKeyword = isKeyword; function isTrivia(token) { - return 2 <= token && token <= 6; + return 2 <= token && token <= 7; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { @@ -4784,19 +4861,19 @@ var ts; ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 133 && + declaration.name.kind === 134 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 163 && isESSymbolIdentifier(node.expression); + return node.kind === 164 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 66 || name.kind === 8 || name.kind === 7) { + if (name.kind === 67 || name.kind === 9 || name.kind === 8) { return name.text; } - if (name.kind === 133) { + if (name.kind === 134) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4811,21 +4888,21 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 66 && node.text === "Symbol"; + return node.kind === 67 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 112: - case 115: - case 71: - case 119: - case 74: - case 79: - case 109: - case 107: - case 108: + case 113: + case 116: + case 72: + case 120: + case 75: + case 80: case 110: + case 108: + case 109: + case 111: return true; } return false; @@ -4833,20 +4910,36 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 135; + return root.kind === 136; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 160) { + while (node.kind === 161) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 215 || n.kind === 245; + return isFunctionLike(n) || n.kind === 216 || n.kind === 246; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function cloneEntityName(node) { + if (node.kind === 67) { + var clone_1 = createSynthesizedNode(67); + clone_1.text = node.text; + return clone_1; + } + else { + var clone_2 = createSynthesizedNode(133); + clone_2.left = cloneEntityName(node.left); + clone_2.left.parent = clone_2; + clone_2.right = cloneEntityName(node.right); + clone_2.right.parent = clone_2; + return clone_2; + } + } + ts.cloneEntityName = cloneEntityName; function nodeIsSynthesized(node) { return node.pos === -1; } @@ -4873,11 +4966,21 @@ var ts; add: add, getGlobalDiagnostics: getGlobalDiagnostics, getDiagnostics: getDiagnostics, - getModificationCount: getModificationCount + getModificationCount: getModificationCount, + reattachFileDiagnostics: reattachFileDiagnostics }; function getModificationCount() { return modificationCount; } + function reattachFileDiagnostics(newFile) { + if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { + return; + } + for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { + var diagnostic = _a[_i]; + diagnostic.file = newFile; + } + } function add(diagnostic) { var diagnostics; if (diagnostic.file) { @@ -5071,7 +5174,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 141 && nodeIsPresent(member.body)) { + if (member.kind === 142 && nodeIsPresent(member.body)) { return member; } }); @@ -5083,7 +5186,7 @@ var ts; ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); } return false; @@ -5098,10 +5201,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 142) { + if (accessor.kind === 143) { getAccessor = accessor; } - else if (accessor.kind === 143) { + else if (accessor.kind === 144) { setAccessor = accessor; } else { @@ -5110,7 +5213,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 142 || member.kind === 143) + if ((member.kind === 143 || member.kind === 144) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -5121,10 +5224,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 142 && !getAccessor) { + if (member.kind === 143 && !getAccessor) { getAccessor = member; } - if (member.kind === 143 && !setAccessor) { + if (member.kind === 144 && !setAccessor) { setAccessor = member; } } @@ -5203,7 +5306,7 @@ var ts; } function writeTrimmedCurrentLine(pos, nextLineStart) { var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { writer.write(currentLineText); if (end !== comment.end) { @@ -5230,16 +5333,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 110: return 128; - case 109: return 16; - case 108: return 64; - case 107: return 32; - case 112: return 256; - case 79: return 1; - case 119: return 2; - case 71: return 32768; - case 74: return 1024; - case 115: return 512; + case 111: return 128; + case 110: return 16; + case 109: return 64; + case 108: return 32; + case 113: return 256; + case 80: return 1; + case 120: return 2; + case 72: return 32768; + case 75: return 1024; + case 116: return 512; } return 0; } @@ -5247,29 +5350,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 163: case 164: - case 166: case 165: - case 230: - case 231: case 167: - case 161: - case 169: + case 166: + case 231: + case 232: + case 168: case 162: - case 183: case 170: - case 66: - case 9: - case 7: - case 8: + case 163: + case 184: + case 171: + case 67: case 10: - case 180: - case 81: - case 90: - case 94: - case 96: - case 92: + case 8: + case 9: + case 11: + case 181: + case 82: + case 91: + case 95: + case 97: + case 93: return true; } } @@ -5277,12 +5380,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 54 && token <= 65; + return token >= 55 && token <= 66; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 185 && - node.parent.token === 80 && + return node.kind === 186 && + node.parent.token === 81 && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -5291,10 +5394,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 66) { + if (node.kind === 67) { return true; } - else if (node.kind === 163) { + else if (node.kind === 164) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -5302,10 +5405,21 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 132 && node.parent.right === node) || - (node.parent.kind === 163 && node.parent.name === node); + return (node.parent.kind === 133 && node.parent.right === node) || + (node.parent.kind === 164 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 163) { + return expression.properties.length === 0; + } + if (kind === 162) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -5509,9 +5623,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 134) { + if (d && d.kind === 135) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 212) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213) { return current; } } @@ -5519,11 +5633,9 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { - var nodeConstructors = new Array(269); + var nodeConstructors = new Array(270); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5561,20 +5673,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 132: + case 133: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 134: + case 135: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 135: + case 136: + case 139: case 138: - case 137: - case 242: case 243: - case 208: - case 160: + case 244: + case 209: + case 161: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5583,24 +5695,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 149: case 150: - case 144: + case 151: case 145: case 146: + case 147: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 140: - case 139: case 141: + case 140: case 142: case 143: - case 170: - case 210: + case 144: case 171: + case 211: + case 172: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5611,160 +5723,153 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 148: + case 149: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 147: + case 148: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 151: - return visitNode(cbNode, node.exprName); case 152: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 153: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 154: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 155: + return visitNodes(cbNodes, node.elementTypes); case 156: - return visitNodes(cbNodes, node.types); case 157: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); case 158: + return visitNode(cbNode, node.type); case 159: - return visitNodes(cbNodes, node.elements); - case 161: + case 160: return visitNodes(cbNodes, node.elements); case 162: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 163: + return visitNodes(cbNodes, node.properties); + case 164: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 164: + case 165: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 165: case 166: + case 167: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 167: + case 168: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 168: + case 169: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 169: - return visitNode(cbNode, node.expression); - case 172: + case 170: return visitNode(cbNode, node.expression); case 173: return visitNode(cbNode, node.expression); case 174: return visitNode(cbNode, node.expression); - case 176: - return visitNode(cbNode, node.operand); - case 181: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 175: return visitNode(cbNode, node.expression); case 177: return visitNode(cbNode, node.operand); + case 182: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 176: + return visitNode(cbNode, node.expression); case 178: + return visitNode(cbNode, node.operand); + case 179: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 186: + case 187: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 179: + case 180: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 182: + case 183: return visitNode(cbNode, node.expression); - case 189: - case 216: + case 190: + case 217: return visitNodes(cbNodes, node.statements); - case 245: + case 246: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 190: + case 191: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 209: + case 210: return visitNodes(cbNodes, node.declarations); - case 192: - return visitNode(cbNode, node.expression); case 193: + return visitNode(cbNode, node.expression); + case 194: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 194: + case 195: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 195: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 196: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 197: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 198: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 199: - case 200: - return visitNode(cbNode, node.label); - case 201: - return visitNode(cbNode, node.expression); - case 202: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 200: + case 201: + return visitNode(cbNode, node.label); + case 202: + return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 217: + case 218: return visitNodes(cbNodes, node.clauses); - case 238: + case 239: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 239: + case 240: return visitNodes(cbNodes, node.statements); - case 204: + case 205: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 205: - return visitNode(cbNode, node.expression); case 206: + return visitNode(cbNode, node.expression); + case 207: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 241: + case 242: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 136: + case 137: return visitNode(cbNode, node.expression); - case 211: - case 183: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); case 212: + case 184: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -5776,125 +5881,132 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 214: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 244: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 215: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 245: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 216: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 218: + case 219: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 219: + case 220: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 220: + case 221: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 221: - return visitNode(cbNode, node.name); case 222: - case 226: + return visitNode(cbNode, node.name); + case 223: + case 227: return visitNodes(cbNodes, node.elements); - case 225: + case 226: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 223: - case 227: + case 224: + case 228: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 224: + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 180: + case 181: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 187: + case 188: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 133: + case 134: return visitNode(cbNode, node.expression); - case 240: + case 241: return visitNodes(cbNodes, node.types); - case 185: + case 186: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 229: - return visitNode(cbNode, node.expression); - case 228: - return visitNodes(cbNodes, node.decorators); case 230: + return visitNode(cbNode, node.expression); + case 229: + return visitNodes(cbNodes, node.decorators); + case 231: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 231: case 232: + case 233: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 235: + case 236: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 236: - return visitNode(cbNode, node.expression); case 237: return visitNode(cbNode, node.expression); - case 234: + case 238: + return visitNode(cbNode, node.expression); + case 235: return visitNode(cbNode, node.tagName); - case 246: + case 247: return visitNode(cbNode, node.type); - case 250: - return visitNodes(cbNodes, node.types); case 251: return visitNodes(cbNodes, node.types); - case 249: + case 252: + return visitNodes(cbNodes, node.types); + case 250: return visitNode(cbNode, node.elementType); + case 254: + return visitNode(cbNode, node.type); case 253: return visitNode(cbNode, node.type); - case 252: - return visitNode(cbNode, node.type); - case 254: + case 255: return visitNodes(cbNodes, node.members); - case 256: + case 257: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 257: - return visitNode(cbNode, node.type); case 258: + return visitNode(cbNode, node.type); + case 259: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 259: - return visitNode(cbNode, node.type); case 260: return visitNode(cbNode, node.type); case 261: return visitNode(cbNode, node.type); - case 255: + case 262: + return visitNode(cbNode, node.type); + case 256: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 262: + case 263: return visitNodes(cbNodes, node.tags); - case 264: + case 265: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 265: - return visitNode(cbNode, node.typeExpression); case 266: return visitNode(cbNode, node.typeExpression); case 267: + return visitNode(cbNode, node.typeExpression); + case 268: return visitNodes(cbNodes, node.typeParameters); } } @@ -5990,9 +6102,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 190: - case 210: - case 135: + case 191: + case 211: + case 136: addJSDocComment(node); } forEachChild(node, visit); @@ -6011,10 +6123,6 @@ var ts; } } function fixupParentReferences(sourceFile) { - // normally parent references are set during binding. However, for clients that only need - // a syntax tree, and no semantic features, then the binding process is an unnecessary - // overhead. This functions allows us to set all the parents, without all the expense of - // binding. var parent = sourceFile; forEachChild(sourceFile, visitNode); return; @@ -6030,7 +6138,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(245, 0); + var sourceFile = createNode(246, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -6163,6 +6271,9 @@ var ts; function scanJsxIdentifier() { return token = scanner.scanJsxIdentifier(); } + function scanJsxText() { + return token = scanner.scanJsxToken(); + } function speculationHelper(callback, isLookAhead) { var saveToken = token; var saveParseDiagnosticsLength = parseDiagnostics.length; @@ -6186,20 +6297,23 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 66) { + if (token === 67) { return true; } - if (token === 111 && inYieldContext()) { + if (token === 112 && inYieldContext()) { return false; } - if (token === 116 && inAwaitContext()) { + if (token === 117 && inAwaitContext()) { return false; } - return token > 102; + return token > 103; } - function parseExpected(kind, diagnosticMessage) { + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } if (token === kind) { - nextToken(); + if (shouldAdvance) { + nextToken(); + } return true; } if (diagnosticMessage) { @@ -6233,20 +6347,20 @@ var ts; return finishNode(node); } function canParseSemicolon() { - if (token === 22) { + if (token === 23) { return true; } - return token === 15 || token === 1 || scanner.hasPrecedingLineBreak(); + return token === 16 || token === 1 || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token === 22) { + if (token === 23) { nextToken(); } return true; } else { - return parseExpected(22); + return parseExpected(23); } } function createNode(kind, pos) { @@ -6288,32 +6402,32 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(66); - if (token !== 66) { + var node = createNode(67); + if (token !== 67) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(66, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(67, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); } function parseIdentifierName() { - return createIdentifier(isIdentifierOrKeyword()); + return createIdentifier(ts.tokenIsIdentifierOrKeyword(token)); } function isLiteralPropertyName() { - return isIdentifierOrKeyword() || - token === 8 || - token === 7; + return ts.tokenIsIdentifierOrKeyword(token) || + token === 9 || + token === 8; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token === 8 || token === 7) { + if (token === 9 || token === 8) { return parseLiteralNode(true); } - if (allowComputedPropertyNames && token === 18) { + if (allowComputedPropertyNames && token === 19) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -6325,30 +6439,30 @@ var ts; return parsePropertyNameWorker(false); } function isSimplePropertyName() { - return token === 8 || token === 7 || isIdentifierOrKeyword(); + return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token); } function parseComputedPropertyName() { - var node = createNode(133); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(134); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); return finishNode(node); } function parseContextualModifier(t) { return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 71) { - return nextToken() === 78; + if (token === 72) { + return nextToken() === 79; } - if (token === 79) { + if (token === 80) { nextToken(); - if (token === 74) { + if (token === 75) { return lookAhead(nextTokenIsClassOrFunction); } - return token !== 36 && token !== 14 && canFollowModifier(); + return token !== 37 && token !== 15 && canFollowModifier(); } - if (token === 74) { + if (token === 75) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -6358,14 +6472,14 @@ var ts; return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token === 18 - || token === 14 - || token === 36 + return token === 19 + || token === 15 + || token === 37 || isLiteralPropertyName(); } function nextTokenIsClassOrFunction() { nextToken(); - return token === 70 || token === 84; + return token === 71 || token === 85; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -6376,21 +6490,21 @@ var ts; case 0: case 1: case 3: - return !(token === 22 && inErrorRecovery) && isStartOfStatement(); + return !(token === 23 && inErrorRecovery) && isStartOfStatement(); case 2: - return token === 68 || token === 74; + return token === 69 || token === 75; case 4: return isStartOfTypeMember(); case 5: - return lookAhead(isClassMemberStart) || (token === 22 && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token === 23 && !inErrorRecovery); case 6: - return token === 18 || isLiteralPropertyName(); + return token === 19 || isLiteralPropertyName(); case 12: - return token === 18 || token === 36 || isLiteralPropertyName(); + return token === 19 || token === 37 || isLiteralPropertyName(); case 9: return isLiteralPropertyName(); case 7: - if (token === 14) { + if (token === 15) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -6402,23 +6516,23 @@ var ts; case 8: return isIdentifierOrPattern(); case 10: - return token === 23 || token === 21 || isIdentifierOrPattern(); + return token === 24 || token === 22 || isIdentifierOrPattern(); case 17: return isIdentifier(); case 11: case 15: - return token === 23 || token === 21 || isStartOfExpression(); + return token === 24 || token === 22 || isStartOfExpression(); case 16: return isStartOfParameter(); case 18: case 19: - return token === 23 || isStartOfType(); + return token === 24 || isStartOfType(); case 20: return isHeritageClause(); case 21: - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); case 13: - return isIdentifierOrKeyword() || token === 14; + return ts.tokenIsIdentifierOrKeyword(token) || token === 15; case 14: return true; case 22: @@ -6431,10 +6545,10 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token === 14); - if (nextToken() === 15) { + ts.Debug.assert(token === 15); + if (nextToken() === 16) { var next = nextToken(); - return next === 23 || next === 14 || next === 80 || next === 103; + return next === 24 || next === 15 || next === 81 || next === 104; } return true; } @@ -6444,11 +6558,11 @@ var ts; } function nextTokenIsIdentifierOrKeyword() { nextToken(); - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 103 || - token === 80) { + if (token === 104 || + token === 81) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -6470,39 +6584,39 @@ var ts; case 12: case 9: case 21: - return token === 15; + return token === 16; case 3: - return token === 15 || token === 68 || token === 74; + return token === 16 || token === 69 || token === 75; case 7: - return token === 14 || token === 80 || token === 103; + return token === 15 || token === 81 || token === 104; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token === 26 || token === 16 || token === 14 || token === 80 || token === 103; + return token === 27 || token === 17 || token === 15 || token === 81 || token === 104; case 11: - return token === 17 || token === 22; + return token === 18 || token === 23; case 15: case 19: case 10: - return token === 19; + return token === 20; case 16: - return token === 17 || token === 19; + return token === 18 || token === 20; case 18: - return token === 26 || token === 16; + return token === 27 || token === 17; case 20: - return token === 14 || token === 15; + return token === 15 || token === 16; case 13: - return token === 26 || token === 37; + return token === 27 || token === 38; case 14: - return token === 24 && lookAhead(nextTokenIsSlash); + return token === 25 && lookAhead(nextTokenIsSlash); case 22: - return token === 17 || token === 52 || token === 15; + return token === 18 || token === 53 || token === 16; case 23: - return token === 26 || token === 15; + return token === 27 || token === 16; case 25: - return token === 19 || token === 15; + return token === 20 || token === 16; case 24: - return token === 15; + return token === 16; } } function isVariableDeclaratorListTerminator() { @@ -6512,7 +6626,7 @@ var ts; if (isInOrOfKeyword(token)) { return true; } - if (token === 33) { + if (token === 34) { return true; } return false; @@ -6617,17 +6731,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 141: - case 146: case 142: + case 147: case 143: - case 138: - case 188: + case 144: + case 139: + case 189: return true; - case 140: + case 141: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 66 && - methodDeclaration.name.originalKeywordKind === 118; + var nameIsConstructor = methodDeclaration.name.kind === 67 && + methodDeclaration.name.originalKeywordKind === 119; return !nameIsConstructor; } } @@ -6636,8 +6750,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 238: case 239: + case 240: return true; } } @@ -6646,65 +6760,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 210: + case 211: + case 191: case 190: - case 189: + case 194: case 193: - case 192: - case 205: + case 206: + case 202: + case 204: case 201: - case 203: case 200: + case 198: case 199: case 197: - case 198: case 196: - case 195: - case 202: - case 191: - case 206: - case 204: - case 194: + case 203: + case 192: case 207: + case 205: + case 195: + case 208: + case 220: case 219: - case 218: + case 226: case 225: - case 224: - case 215: - case 211: + case 216: case 212: - case 214: case 213: + case 215: + case 214: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 244; + return node.kind === 245; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 145: - case 139: case 146: - case 137: - case 144: + case 140: + case 147: + case 138: + case 145: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 208) { + if (node.kind !== 209) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 135) { + if (node.kind !== 136) { return false; } var parameter = node; @@ -6759,15 +6873,15 @@ var ts; if (isListElement(kind, false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(23)) { + if (parseOptional(24)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - parseExpected(23); - if (considerSemicolonAsDelimeter && token === 22 && !scanner.hasPrecedingLineBreak()) { + parseExpected(24); + if (considerSemicolonAsDelimeter && token === 23 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -6803,8 +6917,8 @@ var ts; } function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(20)) { - var node = createNode(132, entity.pos); + while (parseOptional(21)) { + var node = createNode(133, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6812,37 +6926,37 @@ var ts; return entity; } function parseRightSideOfDot(allowIdentifierNames) { - if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { + if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(66, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(67, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(180); + var template = createNode(181); template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 12); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 13); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(187); + var span = createNode(188); span.expression = allowInAnd(parseExpression); var literal; - if (token === 15) { + if (token === 16) { reScanTemplateToken(); literal = parseLiteralNode(); } else { - literal = parseExpectedToken(13, false, ts.Diagnostics._0_expected, ts.tokenToString(15)); + literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); } span.literal = literal; return finishNode(span); @@ -6860,7 +6974,7 @@ var ts; var tokenPos = scanner.getTokenPos(); nextToken(); finishNode(node); - if (node.kind === 7 + if (node.kind === 8 && sourceText.charCodeAt(tokenPos) === 48 && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { node.flags |= 65536; @@ -6869,30 +6983,30 @@ var ts; } function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 66 && token === 121 && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 67 && token === 122 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(147, typeName.pos); + var node_1 = createNode(148, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(148, typeName.pos); + var node = createNode(149, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token === 24) { - node.typeArguments = parseBracketedList(18, parseType, 24, 26); + if (!scanner.hasPrecedingLineBreak() && token === 25) { + node.typeArguments = parseBracketedList(18, parseType, 25, 27); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(151); - parseExpected(98); + var node = createNode(152); + parseExpected(99); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(134); + var node = createNode(135); node.name = parseIdentifier(); - if (parseOptional(80)) { + if (parseOptional(81)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -6903,20 +7017,20 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token === 24) { - return parseBracketedList(17, parseTypeParameter, 24, 26); + if (token === 25) { + return parseBracketedList(17, parseTypeParameter, 25, 27); } } function parseParameterType() { - if (parseOptional(52)) { - return token === 8 + if (parseOptional(53)) { + return token === 9 ? parseLiteralNode(true) : parseType(); } return undefined; } function isStartOfParameter() { - return token === 21 || isIdentifierOrPattern() || ts.isModifier(token) || token === 53; + return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 54; } function setModifiers(node, modifiers) { if (modifiers) { @@ -6925,15 +7039,15 @@ var ts; } } function parseParameter() { - var node = createNode(135); + var node = createNode(136); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(21); + node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - node.questionToken = parseOptionalToken(51); + node.questionToken = parseOptionalToken(52); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return finishNode(node); @@ -6945,7 +7059,7 @@ var ts; return parseInitializer(true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 33; + var returnTokenRequired = returnToken === 34; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -6957,7 +7071,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(16)) { + if (parseExpected(17)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -6965,7 +7079,7 @@ var ts; var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(17) && requireCompleteParameterList) { + if (!parseExpected(18) && requireCompleteParameterList) { return undefined; } return result; @@ -6973,29 +7087,29 @@ var ts; return requireCompleteParameterList ? undefined : createMissingList(); } function parseTypeMemberSemicolon() { - if (parseOptional(23)) { + if (parseOptional(24)) { return; } parseSemicolon(); } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 145) { - parseExpected(89); + if (kind === 146) { + parseExpected(90); } - fillSignature(52, false, false, false, node); + fillSignature(53, false, false, false, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - if (token !== 18) { + if (token !== 19) { return false; } return lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { nextToken(); - if (token === 21 || token === 19) { + if (token === 22 || token === 20) { return true; } if (ts.isModifier(token)) { @@ -7010,20 +7124,20 @@ var ts; else { nextToken(); } - if (token === 52 || token === 23) { + if (token === 53 || token === 24) { return true; } - if (token !== 51) { + if (token !== 52) { return false; } nextToken(); - return token === 52 || token === 23 || token === 19; + return token === 53 || token === 24 || token === 20; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(146, fullStart); + var node = createNode(147, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(16, parseParameter, 18, 19); + node.parameters = parseBracketedList(16, parseParameter, 19, 20); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -7031,17 +7145,17 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (token === 16 || token === 24) { - var method = createNode(139, fullStart); + var questionToken = parseOptionalToken(52); + if (token === 17 || token === 25) { + var method = createNode(140, fullStart); method.name = name; method.questionToken = questionToken; - fillSignature(52, false, false, false, method); + fillSignature(53, false, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(137, fullStart); + var property = createNode(138, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -7051,9 +7165,9 @@ var ts; } function isStartOfTypeMember() { switch (token) { - case 16: - case 24: - case 18: + case 17: + case 25: + case 19: return true; default: if (ts.isModifier(token)) { @@ -7073,27 +7187,27 @@ var ts; } function isTypeMemberWithLiteralPropertyName() { nextToken(); - return token === 16 || - token === 24 || - token === 51 || + return token === 17 || + token === 25 || token === 52 || + token === 53 || canParseSemicolon(); } function parseTypeMember() { switch (token) { - case 16: - case 24: - return parseSignatureMember(144); - case 18: + case 17: + case 25: + return parseSignatureMember(145); + case 19: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 89: + case 90: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(145); + return parseSignatureMember(146); } + case 9: case 8: - case 7: return parsePropertyOrMethodSignature(); default: if (ts.isModifier(token)) { @@ -7102,7 +7216,7 @@ var ts; return result; } } - if (isIdentifierOrKeyword()) { + if (ts.tokenIsIdentifierOrKeyword(token)) { return parsePropertyOrMethodSignature(); } } @@ -7117,18 +7231,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token === 16 || token === 24; + return token === 17 || token === 25; } function parseTypeLiteral() { - var node = createNode(152); + var node = createNode(153); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(14)) { + if (parseExpected(15)) { members = parseList(4, parseTypeMember); - parseExpected(15); + parseExpected(16); } else { members = createMissingList(); @@ -7136,47 +7250,47 @@ var ts; return members; } function parseTupleType() { - var node = createNode(154); - node.elementTypes = parseBracketedList(19, parseType, 18, 19); + var node = createNode(155); + node.elementTypes = parseBracketedList(19, parseType, 19, 20); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(157); - parseExpected(16); - node.type = parseType(); + var node = createNode(158); parseExpected(17); + node.type = parseType(); + parseExpected(18); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 150) { - parseExpected(89); + if (kind === 151) { + parseExpected(90); } - fillSignature(33, false, false, false, node); + fillSignature(34, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token === 20 ? undefined : node; + return token === 21 ? undefined : node; } function parseNonArrayType() { switch (token) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: + case 126: + case 118: + case 129: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 100: + case 101: return parseTokenNode(); - case 98: + case 99: return parseTypeQuery(); - case 14: + case 15: return parseTypeLiteral(); - case 18: + case 19: return parseTupleType(); - case 16: + case 17: return parseParenthesizedType(); default: return parseTypeReferenceOrTypePredicate(); @@ -7184,19 +7298,19 @@ var ts; } function isStartOfType() { switch (token) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: - case 98: - case 14: - case 18: - case 24: - case 89: + case 126: + case 118: + case 129: + case 101: + case 99: + case 15: + case 19: + case 25: + case 90: return true; - case 16: + case 17: return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); @@ -7204,13 +7318,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token === 17 || isStartOfParameter() || isStartOfType(); + return token === 18 || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { - parseExpected(19); - var node = createNode(153, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { + parseExpected(20); + var node = createNode(154, type.pos); node.elementType = type; type = finishNode(node); } @@ -7232,32 +7346,32 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(156, parseArrayTypeOrHigher, 44); + return parseUnionOrIntersectionType(157, parseArrayTypeOrHigher, 45); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(155, parseIntersectionTypeOrHigher, 45); + return parseUnionOrIntersectionType(156, parseIntersectionTypeOrHigher, 46); } function isStartOfFunctionType() { - if (token === 24) { + if (token === 25) { return true; } - return token === 16 && lookAhead(isUnambiguouslyStartOfFunctionType); + return token === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token === 17 || token === 21) { + if (token === 18 || token === 22) { return true; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 52 || token === 23 || - token === 51 || token === 54 || + if (token === 53 || token === 24 || + token === 52 || token === 55 || isIdentifier() || ts.isModifier(token)) { return true; } - if (token === 17) { + if (token === 18) { nextToken(); - if (token === 33) { + if (token === 34) { return true; } } @@ -7269,36 +7383,36 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(149); - } - if (token === 89) { return parseFunctionOrConstructorType(150); } + if (token === 90) { + return parseFunctionOrConstructorType(151); + } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(52) ? parseType() : undefined; + return parseOptional(53) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token) { - case 94: - case 92: - case 90: - case 96: - case 81: - case 7: + case 95: + case 93: + case 91: + case 97: + case 82: case 8: - case 10: + case 9: case 11: - case 16: - case 18: - case 14: - case 84: - case 70: - case 89: - case 37: - case 58: - case 66: + case 12: + case 17: + case 19: + case 15: + case 85: + case 71: + case 90: + case 38: + case 59: + case 67: return true; default: return isIdentifier(); @@ -7309,18 +7423,18 @@ var ts; return true; } switch (token) { - case 34: case 35: + case 36: + case 49: case 48: - case 47: - case 75: - case 98: - case 100: - case 39: + case 76: + case 99: + case 101: case 40: - case 24: - case 116: - case 111: + case 41: + case 25: + case 117: + case 112: return true; default: if (isBinaryOperator()) { @@ -7330,26 +7444,23 @@ var ts; } } function isStartOfExpressionStatement() { - return token !== 14 && - token !== 84 && - token !== 70 && - token !== 53 && + return token !== 15 && + token !== 85 && + token !== 71 && + token !== 54 && isStartOfExpression(); } function allowInAndParseExpression() { return allowInAnd(parseExpression); } function parseExpression() { - // Expression[in]: - // AssignmentExpression[in] - // Expression[in] , AssignmentExpression[in] var saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { setDecoratorContext(false); } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(23))) { + while ((operatorToken = parseOptionalToken(24))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -7358,24 +7469,15 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 54) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14) || !isStartOfExpression()) { + if (token !== 55) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15) || !isStartOfExpression()) { return undefined; } } - parseExpected(54); + parseExpected(55); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { - // AssignmentExpression[in,yield]: - // 1) ConditionalExpression[?in,?yield] - // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] - // 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield] - // 4) ArrowFunctionExpression[?in,?yield] - // 5) [+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). if (isYieldExpression()) { return parseYieldExpression(); } @@ -7384,7 +7486,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 66 && token === 33) { + if (expr.kind === 67 && token === 34) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -7393,7 +7495,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 111) { + if (token === 112) { if (inYieldContext()) { return true; } @@ -7406,11 +7508,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(181); + var node = createNode(182); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token === 36 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(36); + (token === 37 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(37); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7419,15 +7521,15 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 33, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(171, identifier.pos); - var parameter = createNode(135, identifier.pos); + ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(172, identifier.pos); + var parameter = createNode(136, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(33, false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(false); return finishNode(node); } @@ -7444,78 +7546,78 @@ var ts; } var isAsync = !!(arrowFunction.flags & 512); var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(33, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 33 || lastToken === 14) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 34 || lastToken === 15) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token === 16 || token === 24 || token === 115) { + if (token === 17 || token === 25 || token === 116) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 33) { + if (token === 34) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 115) { + if (token === 116) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token !== 16 && token !== 24) { + if (token !== 17 && token !== 25) { return 0; } } var first = token; var second = nextToken(); - if (first === 16) { - if (second === 17) { + if (first === 17) { + if (second === 18) { var third = nextToken(); switch (third) { - case 33: - case 52: - case 14: + case 34: + case 53: + case 15: return 1; default: return 0; } } - if (second === 18 || second === 14) { + if (second === 19 || second === 15) { return 2; } - if (second === 21) { + if (second === 22) { return 1; } if (!isIdentifier()) { return 0; } - if (nextToken() === 52) { + if (nextToken() === 53) { return 1; } return 2; } else { - ts.Debug.assert(first === 24); + ts.Debug.assert(first === 25); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 80) { + if (third === 81) { var fourth = nextToken(); switch (fourth) { - case 54: - case 26: + case 55: + case 27: return false; default: return true; } } - else if (third === 23) { + else if (third === 24) { return true; } return false; @@ -7532,25 +7634,25 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(171); + var node = createNode(172); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512); - fillSignature(52, false, isAsync, !allowAmbiguity, node); + fillSignature(53, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token !== 33 && token !== 14) { + if (!allowAmbiguity && token !== 34 && token !== 15) { return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token === 14) { + if (token === 15) { return parseFunctionBlock(false, isAsync, false); } - if (token !== 22 && - token !== 84 && - token !== 70 && + if (token !== 23 && + token !== 85 && + token !== 71 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -7560,15 +7662,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(51); + var questionToken = parseOptionalToken(52); if (!questionToken) { return leftOperand; } - var node = createNode(179, leftOperand.pos); + var node = createNode(180, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(52, false, ts.Diagnostics._0_expected, ts.tokenToString(52)); + node.colonToken = parseExpectedToken(53, false, ts.Diagnostics._0_expected, ts.tokenToString(53)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7577,7 +7679,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 87 || t === 131; + return t === 88 || t === 132; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -7586,10 +7688,10 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 87 && inDisallowInContext()) { + if (token === 88 && inDisallowInContext()) { break; } - if (token === 113) { + if (token === 114) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -7605,90 +7707,90 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 87) { + if (inDisallowInContext() && token === 88) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 50: + case 51: return 1; - case 49: + case 50: return 2; - case 45: - return 3; case 46: + return 3; + case 47: return 4; - case 44: + case 45: return 5; - case 29: case 30: case 31: case 32: + case 33: return 6; - case 24: - case 26: + case 25: case 27: case 28: + case 29: + case 89: case 88: - case 87: - case 113: + case 114: return 7; - case 41: case 42: case 43: + case 44: return 8; - case 34: case 35: - return 9; case 36: + return 9; case 37: case 38: + case 39: return 10; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(178, left.pos); + var node = createNode(179, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(186, left.pos); + var node = createNode(187, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(176); + var node = createNode(177); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(172); - nextToken(); - node.expression = parseUnaryExpressionOrHigher(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(173); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(174); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(175); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } function isAwaitExpression() { - if (token === 116) { + if (token === 117) { if (inAwaitContext()) { return true; } @@ -7697,7 +7799,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(175); + var node = createNode(176); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -7707,25 +7809,25 @@ var ts; return parseAwaitExpression(); } switch (token) { - case 34: case 35: + case 36: + case 49: case 48: - case 47: - case 39: case 40: + case 41: return parsePrefixUnaryExpression(); - case 75: + case 76: return parseDeleteExpression(); - case 98: + case 99: return parseTypeOfExpression(); - case 100: + case 101: return parseVoidExpression(); - case 24: + case 25: if (sourceFile.languageVariant !== 1) { return parseTypeAssertion(); } if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(); + return parseJsxElementOrSelfClosingElement(true); } default: return parsePostfixExpressionOrHigher(); @@ -7734,8 +7836,8 @@ var ts; function parsePostfixExpressionOrHigher() { var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 39 || token === 40) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(177, expression.pos); + if ((token === 40 || token === 41) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(178, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7744,7 +7846,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 92 + var expression = token === 93 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -7755,44 +7857,44 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token === 16 || token === 20) { + if (token === 17 || token === 21 || token === 19) { return expression; } - var node = createNode(163, expression.pos); + var node = createNode(164, expression.pos); node.expression = expression; - node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } - function parseJsxElementOrSelfClosingElement() { - var opening = parseJsxOpeningOrSelfClosingElement(); - if (opening.kind === 232) { - var node = createNode(230, opening.pos); + function parseJsxElementOrSelfClosingElement(inExpressionContext) { + var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + if (opening.kind === 233) { + var node = createNode(231, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(); + node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 231); + ts.Debug.assert(opening.kind === 232); return opening; } } function parseJsxText() { - var node = createNode(233, scanner.getStartPos()); + var node = createNode(234, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 233: + case 234: return parseJsxText(); - case 14: - return parseJsxExpression(); - case 24: - return parseJsxElementOrSelfClosingElement(); + case 15: + return parseJsxExpression(false); + case 25: + return parseJsxElementOrSelfClosingElement(false); } - ts.Debug.fail('Unknown JSX child kind ' + token); + ts.Debug.fail("Unknown JSX child kind " + token); } function parseJsxChildren(openingTagName) { var result = []; @@ -7801,7 +7903,7 @@ var ts; parsingContext |= 1 << 14; while (true) { token = scanner.reScanJsxToken(); - if (token === 25) { + if (token === 26) { break; } else if (token === 1) { @@ -7814,19 +7916,26 @@ var ts; parsingContext = saveParsingContext; return result; } - function parseJsxOpeningOrSelfClosingElement() { + function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(24); + parseExpected(25); var tagName = parseJsxElementName(); var attributes = parseList(13, parseJsxAttribute); var node; - if (parseOptional(26)) { - node = createNode(232, fullStart); + if (token === 27) { + node = createNode(233, fullStart); + scanJsxText(); } else { - parseExpected(37); - parseExpected(26); - node = createNode(231, fullStart); + parseExpected(38); + if (inExpressionContext) { + parseExpected(27); + } + else { + parseExpected(27, undefined, false); + scanJsxText(); + } + node = createNode(232, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -7835,95 +7944,107 @@ var ts; function parseJsxElementName() { scanJsxIdentifier(); var elementName = parseIdentifierName(); - while (parseOptional(20)) { + while (parseOptional(21)) { scanJsxIdentifier(); - var node = createNode(132, elementName.pos); + var node = createNode(133, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); } return elementName; } - function parseJsxExpression() { - var node = createNode(237); - parseExpected(14); - if (token !== 15) { + function parseJsxExpression(inExpressionContext) { + var node = createNode(238); + parseExpected(15); + if (token !== 16) { node.expression = parseExpression(); } - parseExpected(15); + if (inExpressionContext) { + parseExpected(16); + } + else { + parseExpected(16, undefined, false); + scanJsxText(); + } return finishNode(node); } function parseJsxAttribute() { - if (token === 14) { + if (token === 15) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(235); + var node = createNode(236); node.name = parseIdentifierName(); - if (parseOptional(54)) { + if (parseOptional(55)) { switch (token) { - case 8: + case 9: node.initializer = parseLiteralNode(); break; default: - node.initializer = parseJsxExpression(); + node.initializer = parseJsxExpression(true); break; } } return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(236); - parseExpected(14); - parseExpected(21); - node.expression = parseExpression(); + var node = createNode(237); parseExpected(15); + parseExpected(22); + node.expression = parseExpression(); + parseExpected(16); return finishNode(node); } - function parseJsxClosingElement() { - var node = createNode(234); - parseExpected(25); - node.tagName = parseJsxElementName(); + function parseJsxClosingElement(inExpressionContext) { + var node = createNode(235); parseExpected(26); + node.tagName = parseJsxElementName(); + if (inExpressionContext) { + parseExpected(27); + } + else { + parseExpected(27, undefined, false); + scanJsxText(); + } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(168); - parseExpected(24); + var node = createNode(169); + parseExpected(25); node.type = parseType(); - parseExpected(26); + parseExpected(27); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(20); + var dotToken = parseOptionalToken(21); if (dotToken) { - var propertyAccess = createNode(163, expression.pos); + var propertyAccess = createNode(164, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (!inDecoratorContext() && parseOptional(18)) { - var indexedAccess = createNode(164, expression.pos); + if (!inDecoratorContext() && parseOptional(19)) { + var indexedAccess = createNode(165, expression.pos); indexedAccess.expression = expression; - if (token !== 19) { + if (token !== 20) { indexedAccess.argumentExpression = allowInAnd(parseExpression); - if (indexedAccess.argumentExpression.kind === 8 || indexedAccess.argumentExpression.kind === 7) { + if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(19); + parseExpected(20); expression = finishNode(indexedAccess); continue; } - if (token === 10 || token === 11) { - var tagExpression = createNode(167, expression.pos); + if (token === 11 || token === 12) { + var tagExpression = createNode(168, expression.pos); tagExpression.tag = expression; - tagExpression.template = token === 10 + tagExpression.template = token === 11 ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -7935,20 +8056,20 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token === 24) { + if (token === 25) { var typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; } - var callExpr = createNode(165, expression.pos); + var callExpr = createNode(166, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token === 16) { - var callExpr = createNode(165, expression.pos); + else if (token === 17) { + var callExpr = createNode(166, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -7958,17 +8079,17 @@ var ts; } } function parseArgumentList() { - parseExpected(16); - var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(17); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(18); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(24)) { + if (!parseOptional(25)) { return undefined; } var typeArguments = parseDelimitedList(18, parseType); - if (!parseExpected(26)) { + if (!parseExpected(27)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -7977,108 +8098,108 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token) { - case 16: - case 20: case 17: - case 19: + case 21: + case 18: + case 20: + case 53: + case 23: case 52: - case 22: - case 51: - case 29: - case 31: case 30: case 32: - case 49: + case 31: + case 33: case 50: - case 46: - case 44: + case 51: + case 47: case 45: - case 15: + case 46: + case 16: case 1: return true; - case 23: - case 14: + case 24: + case 15: default: return false; } } function parsePrimaryExpression() { switch (token) { - case 7: case 8: - case 10: + case 9: + case 11: return parseLiteralNode(); - case 94: - case 92: - case 90: - case 96: - case 81: + case 95: + case 93: + case 91: + case 97: + case 82: return parseTokenNode(); - case 16: + case 17: return parseParenthesizedExpression(); - case 18: + case 19: return parseArrayLiteralExpression(); - case 14: + case 15: return parseObjectLiteralExpression(); - case 115: + case 116: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 70: + case 71: return parseClassExpression(); - case 84: + case 85: return parseFunctionExpression(); - case 89: + case 90: return parseNewExpression(); - case 37: - case 58: - if (reScanSlashToken() === 9) { + case 38: + case 59: + if (reScanSlashToken() === 10) { return parseLiteralNode(); } break; - case 11: + case 12: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(169); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(170); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); return finishNode(node); } function parseSpreadElement() { - var node = createNode(182); - parseExpected(21); + var node = createNode(183); + parseExpected(22); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(184) : + return token === 22 ? parseSpreadElement() : + token === 24 ? createNode(185) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(161); - parseExpected(18); + var node = createNode(162); + parseExpected(19); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048; node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(19); + parseExpected(20); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(120)) { - return parseAccessorDeclaration(142, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(126)) { + if (parseContextualModifier(121)) { return parseAccessorDeclaration(143, fullStart, decorators, modifiers); } + else if (parseContextualModifier(127)) { + return parseAccessorDeclaration(144, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -8089,37 +8210,37 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(36); + var asteriskToken = parseOptionalToken(37); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (asteriskToken || token === 16 || token === 24) { + var questionToken = parseOptionalToken(52); + if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(243, fullStart); + if ((token === 24 || token === 16) && tokenIsIdentifier) { + var shorthandDeclaration = createNode(244, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(242, fullStart); + var propertyAssignment = createNode(243, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(52); + parseExpected(53); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(162); - parseExpected(14); + var node = createNode(163); + parseExpected(15); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(15); + parseExpected(16); return finishNode(node); } function parseFunctionExpression() { @@ -8127,10 +8248,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(170); + var node = createNode(171); setModifiers(node, parseModifiers()); - parseExpected(84); - node.asteriskToken = parseOptionalToken(36); + parseExpected(85); + node.asteriskToken = parseOptionalToken(37); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); node.name = @@ -8138,7 +8259,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(52, isGenerator, isAsync, false, node); + fillSignature(53, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -8149,20 +8270,20 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(166); - parseExpected(89); + var node = createNode(167); + parseExpected(90); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 16) { + if (node.typeArguments || token === 17) { node.arguments = parseArgumentList(); } return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(189); - if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(190); + if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); - parseExpected(15); + parseExpected(16); } else { node.statements = createMissingList(); @@ -8187,47 +8308,47 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(191); - parseExpected(22); + var node = createNode(192); + parseExpected(23); return finishNode(node); } function parseIfStatement() { - var node = createNode(193); - parseExpected(85); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(194); + parseExpected(86); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(77) ? parseStatement() : undefined; + node.elseStatement = parseOptional(78) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(194); - parseExpected(76); + var node = createNode(195); + parseExpected(77); node.statement = parseStatement(); - parseExpected(101); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + parseExpected(102); parseExpected(17); - parseOptional(22); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + parseOptional(23); return finishNode(node); } function parseWhileStatement() { - var node = createNode(195); - parseExpected(101); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(196); + parseExpected(102); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(83); - parseExpected(16); + parseExpected(84); + parseExpected(17); var initializer = undefined; - if (token !== 22) { - if (token === 99 || token === 105 || token === 71) { + if (token !== 23) { + if (token === 100 || token === 106 || token === 72) { initializer = parseVariableDeclarationList(true); } else { @@ -8235,32 +8356,32 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(87)) { - var forInStatement = createNode(197, pos); + if (parseOptional(88)) { + var forInStatement = createNode(198, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(131)) { - var forOfStatement = createNode(198, pos); + else if (parseOptional(132)) { + var forOfStatement = createNode(199, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(196, pos); + var forStatement = createNode(197, pos); forStatement.initializer = initializer; - parseExpected(22); - if (token !== 22 && token !== 17) { + parseExpected(23); + if (token !== 23 && token !== 18) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(22); - if (token !== 17) { + parseExpected(23); + if (token !== 18) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -8268,7 +8389,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 200 ? 67 : 72); + parseExpected(kind === 201 ? 68 : 73); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -8276,8 +8397,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(201); - parseExpected(91); + var node = createNode(202); + parseExpected(92); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -8285,151 +8406,146 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(202); - parseExpected(102); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(203); + parseExpected(103); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(238); - parseExpected(68); + var node = createNode(239); + parseExpected(69); node.expression = allowInAnd(parseExpression); - parseExpected(52); + parseExpected(53); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(239); - parseExpected(74); - parseExpected(52); + var node = createNode(240); + parseExpected(75); + parseExpected(53); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 68 ? parseCaseClause() : parseDefaultClause(); + return token === 69 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(203); - parseExpected(93); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(204); + parseExpected(94); parseExpected(17); - var caseBlock = createNode(217, scanner.getStartPos()); - parseExpected(14); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + var caseBlock = createNode(218, scanner.getStartPos()); parseExpected(15); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(16); node.caseBlock = finishNode(caseBlock); return finishNode(node); } function parseThrowStatement() { - // ThrowStatement[Yield] : - // throw [no LineTerminator here]Expression[In, ?Yield]; - var node = createNode(205); - parseExpected(95); + var node = createNode(206); + parseExpected(96); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(206); - parseExpected(97); + var node = createNode(207); + parseExpected(98); node.tryBlock = parseBlock(false); - node.catchClause = token === 69 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 82) { - parseExpected(82); + node.catchClause = token === 70 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 83) { + parseExpected(83); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(241); - parseExpected(69); - if (parseExpected(16)) { + var result = createNode(242); + parseExpected(70); + if (parseExpected(17)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(17); + parseExpected(18); result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(207); - parseExpected(73); + var node = createNode(208); + parseExpected(74); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 66 && parseOptional(52)) { - var labeledStatement = createNode(204, fullStart); + if (expression.kind === 67 && parseOptional(53)) { + var labeledStatement = createNode(205, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(192, fullStart); + var expressionStatement = createNode(193, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } - function isIdentifierOrKeyword() { - return token >= 66; - } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); - return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); + return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 84 && !scanner.hasPrecedingLineBreak(); + return token === 85 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); - return (isIdentifierOrKeyword() || token === 7) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token) || token === 8) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token) { - case 99: - case 105: + case 100: + case 106: + case 72: + case 85: case 71: - case 84: - case 70: - case 78: + case 79: return true; - case 104: - case 129: + case 105: + case 130: return nextTokenIsIdentifierOnSameLine(); - case 122: case 123: + case 124: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115: - case 119: + case 116: + case 120: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 86: + case 87: nextToken(); - return token === 8 || token === 36 || - token === 14 || isIdentifierOrKeyword(); - case 79: + return token === 9 || token === 37 || + token === 15 || ts.tokenIsIdentifierOrKeyword(token); + case 80: nextToken(); - if (token === 54 || token === 36 || - token === 14 || token === 74) { + if (token === 55 || token === 37 || + token === 15 || token === 75) { return true; } continue; - case 109: - case 107: - case 108: case 110: - case 112: + case 108: + case 109: + case 111: + case 113: nextToken(); continue; default: @@ -8442,44 +8558,44 @@ var ts; } function isStartOfStatement() { switch (token) { - case 53: - case 22: - case 14: - case 99: - case 105: - case 84: - case 70: - case 78: + case 54: + case 23: + case 15: + case 100: + case 106: case 85: - case 76: - case 101: - case 83: - case 72: - case 67: - case 91: - case 102: - case 93: - case 95: - case 97: - case 73: - case 69: - case 82: - return true; case 71: case 79: case 86: + case 77: + case 102: + case 84: + case 73: + case 68: + case 92: + case 103: + case 94: + case 96: + case 98: + case 74: + case 70: + case 83: + return true; + case 72: + case 80: + case 87: return isStartOfDeclaration(); - case 115: - case 119: - case 104: - case 122: + case 116: + case 120: + case 105: case 123: - case 129: + case 124: + case 130: return true; - case 109: - case 107: - case 108: case 110: + case 108: + case 109: + case 111: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -8487,71 +8603,71 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token === 14 || token === 18; + return isIdentifier() || token === 15 || token === 19; } function isLetDeclaration() { return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token) { - case 22: + case 23: return parseEmptyStatement(); - case 14: + case 15: return parseBlock(false); - case 99: + case 100: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 105: + case 106: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 84: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 70: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 85: - return parseIfStatement(); - case 76: - return parseDoStatement(); - case 101: - return parseWhileStatement(); - case 83: - return parseForOrForInOrForOfStatement(); - case 72: - return parseBreakOrContinueStatement(199); - case 67: - return parseBreakOrContinueStatement(200); - case 91: - return parseReturnStatement(); - case 102: - return parseWithStatement(); - case 93: - return parseSwitchStatement(); - case 95: - return parseThrowStatement(); - case 97: - case 69: - case 82: - return parseTryStatement(); - case 73: - return parseDebuggerStatement(); - case 53: - return parseDeclaration(); - case 115: - case 104: - case 129: - case 122: - case 123: - case 119: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 71: - case 78: - case 79: + return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 86: - case 107: + return parseIfStatement(); + case 77: + return parseDoStatement(); + case 102: + return parseWhileStatement(); + case 84: + return parseForOrForInOrForOfStatement(); + case 73: + return parseBreakOrContinueStatement(200); + case 68: + return parseBreakOrContinueStatement(201); + case 92: + return parseReturnStatement(); + case 103: + return parseWithStatement(); + case 94: + return parseSwitchStatement(); + case 96: + return parseThrowStatement(); + case 98: + case 70: + case 83: + return parseTryStatement(); + case 74: + return parseDebuggerStatement(); + case 54: + return parseDeclaration(); + case 116: + case 105: + case 130: + case 123: + case 124: + case 120: + case 72: + case 79: + case 80: + case 87: case 108: case 109: - case 112: case 110: + case 113: + case 111: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -8564,33 +8680,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 99: - case 105: - case 71: + case 100: + case 106: + case 72: return parseVariableStatement(fullStart, decorators, modifiers); - case 84: + case 85: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 70: + case 71: return parseClassDeclaration(fullStart, decorators, modifiers); - case 104: + case 105: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 129: + case 130: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 78: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 122: - case 123: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 86: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); case 79: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 123: + case 124: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 87: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 80: nextToken(); - return token === 74 || token === 54 ? + return token === 75 || token === 55 ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(228, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(229, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -8600,34 +8716,34 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token !== 14 && canParseSemicolon()) { + if (token !== 15 && canParseSemicolon()) { parseSemicolon(); return; } return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { - if (token === 23) { - return createNode(184); + if (token === 24) { + return createNode(185); } - var node = createNode(160); - node.dotDotDotToken = parseOptionalToken(21); + var node = createNode(161); + node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(160); + var node = createNode(161); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 52) { + if (tokenIsIdentifier && token !== 53) { node.name = propertyName; } else { - parseExpected(52); + parseExpected(53); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -8635,33 +8751,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(158); - parseExpected(14); - node.elements = parseDelimitedList(9, parseObjectBindingElement); + var node = createNode(159); parseExpected(15); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(16); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(159); - parseExpected(18); - node.elements = parseDelimitedList(10, parseArrayBindingElement); + var node = createNode(160); parseExpected(19); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(20); return finishNode(node); } function isIdentifierOrPattern() { - return token === 14 || token === 18 || isIdentifier(); + return token === 15 || token === 19 || isIdentifier(); } function parseIdentifierOrPattern() { - if (token === 18) { + if (token === 19) { return parseArrayBindingPattern(); } - if (token === 14) { + if (token === 15) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(208); + var node = createNode(209); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -8670,21 +8786,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(209); + var node = createNode(210); switch (token) { - case 99: + case 100: break; - case 105: + case 106: node.flags |= 16384; break; - case 71: + case 72: node.flags |= 32768; break; default: ts.Debug.fail(); } nextToken(); - if (token === 131 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 132 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -8696,10 +8812,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 17; + return nextTokenIsIdentifier() && nextToken() === 18; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(190, fullStart); + var node = createNode(191, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -8707,29 +8823,29 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(210, fullStart); + var node = createNode(211, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(84); - node.asteriskToken = parseOptionalToken(36); + parseExpected(85); + node.asteriskToken = parseOptionalToken(37); node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); - fillSignature(52, isGenerator, isAsync, false, node); + fillSignature(53, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(141, pos); + var node = createNode(142, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(118); - fillSignature(52, false, false, false, node); + parseExpected(119); + fillSignature(53, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(140, fullStart); + var method = createNode(141, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -8737,12 +8853,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512); - fillSignature(52, isGenerator, isAsync, false, method); + fillSignature(53, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(138, fullStart); + var property = createNode(139, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -8755,10 +8871,10 @@ var ts; return finishNode(property); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(36); + var asteriskToken = parseOptionalToken(37); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (asteriskToken || token === 16 || token === 24) { + var questionToken = parseOptionalToken(52); + if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -8773,16 +8889,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(52, false, false, false, node); + fillSignature(53, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 109: - case 107: - case 108: case 110: + case 108: + case 109: + case 111: return true; default: return false; @@ -8790,7 +8906,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 53) { + if (token === 54) { return true; } while (ts.isModifier(token)) { @@ -8800,26 +8916,26 @@ var ts; } nextToken(); } - if (token === 36) { + if (token === 37) { return true; } if (isLiteralPropertyName()) { idToken = token; nextToken(); } - if (token === 18) { + if (token === 19) { return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 126 || idToken === 120) { + if (!ts.isKeyword(idToken) || idToken === 127 || idToken === 121) { return true; } switch (token) { - case 16: - case 24: + case 17: + case 25: + case 53: + case 55: case 52: - case 54: - case 51: return true; default: return canParseSemicolon(); @@ -8831,14 +8947,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(53)) { + if (!parseOptional(54)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(136, decoratorStart); + var decorator = createNode(137, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8872,7 +8988,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 115) { + if (token === 116) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -8886,8 +9002,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token === 22) { - var result = createNode(188); + if (token === 23) { + var result = createNode(189); nextToken(); return finishNode(result); } @@ -8898,42 +9014,42 @@ var ts; if (accessor) { return accessor; } - if (token === 118) { + if (token === 119) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); } - if (isIdentifierOrKeyword() || + if (ts.tokenIsIdentifierOrKeyword(token) || + token === 9 || token === 8 || - token === 7 || - token === 36 || - token === 18) { + token === 37 || + token === 19) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_7 = createMissingNode(66, true, ts.Diagnostics.Declaration_expected); + var name_7 = createMissingNode(67, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 183); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 184); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 211); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(70); + parseExpected(71); node.name = parseOptionalIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(14)) { + if (parseExpected(15)) { node.members = parseClassMembers(); - parseExpected(15); + parseExpected(16); } else { node.members = createMissingList(); @@ -8941,8 +9057,6 @@ var ts; return finishNode(node); } function parseHeritageClauses(isClassHeritageClause) { - // ClassTail[Yield,Await] : (Modified) See 14.5 - // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { return parseList(20, parseHeritageClause); } @@ -8952,8 +9066,8 @@ var ts; return parseList(20, parseHeritageClause); } function parseHeritageClause() { - if (token === 80 || token === 103) { - var node = createNode(240); + if (token === 81 || token === 104) { + var node = createNode(241); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -8962,24 +9076,24 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(185); + var node = createNode(186); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token === 24) { - node.typeArguments = parseBracketedList(18, parseType, 24, 26); + if (token === 25) { + node.typeArguments = parseBracketedList(18, parseType, 25, 27); } return finishNode(node); } function isHeritageClause() { - return token === 80 || token === 103; + return token === 81 || token === 104; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(212, fullStart); + var node = createNode(213, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(104); + parseExpected(105); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); @@ -8987,32 +9101,32 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213, fullStart); + var node = createNode(214, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(129); + parseExpected(130); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(54); + parseExpected(55); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(244, scanner.getStartPos()); + var node = createNode(245, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(78); + parseExpected(79); node.name = parseIdentifier(); - if (parseExpected(14)) { + if (parseExpected(15)) { node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(15); + parseExpected(16); } else { node.members = createMissingList(); @@ -9020,10 +9134,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(216, scanner.getStartPos()); - if (parseExpected(14)) { + var node = createNode(217, scanner.getStartPos()); + if (parseExpected(15)) { node.statements = parseList(1, parseStatement); - parseExpected(15); + parseExpected(16); } else { node.statements = createMissingList(); @@ -9031,18 +9145,19 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); + var namespaceFlag = flags & 131072; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(20) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1) + node.body = parseOptional(21) + ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -9051,76 +9166,70 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(123)) { + if (parseOptional(124)) { flags |= 131072; } else { - parseExpected(122); - if (token === 8) { + parseExpected(123); + if (token === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 124 && + return token === 125 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 16; + return nextToken() === 17; } function nextTokenIsSlash() { - return nextToken() === 37; + return nextToken() === 38; } function nextTokenIsCommaOrFromKeyword() { nextToken(); - return token === 23 || - token === 130; + return token === 24 || + token === 131; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(86); + parseExpected(87); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 130) { - var importEqualsDeclaration = createNode(218, fullStart); + if (token !== 24 && token !== 131) { + var importEqualsDeclaration = createNode(219, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(54); + parseExpected(55); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(219, fullStart); + var importDeclaration = createNode(220, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || - token === 36 || - token === 14) { + token === 37 || + token === 15) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(130); + parseExpected(131); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - // ImportClause: - // ImportedDefaultBinding - // NameSpaceImport - // NamedImports - // ImportedDefaultBinding, NameSpaceImport - // ImportedDefaultBinding, NamedImports - var importClause = createNode(220, fullStart); + var importClause = createNode(221, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || - parseOptional(23)) { - importClause.namedBindings = token === 36 ? parseNamespaceImport() : parseNamedImportsOrExports(222); + parseOptional(24)) { + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(223); } return finishNode(importClause); } @@ -9130,37 +9239,37 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(229); - parseExpected(124); - parseExpected(16); - node.expression = parseModuleSpecifier(); + var node = createNode(230); + parseExpected(125); parseExpected(17); + node.expression = parseModuleSpecifier(); + parseExpected(18); return finishNode(node); } function parseModuleSpecifier() { var result = parseExpression(); - if (result.kind === 8) { + if (result.kind === 9) { internIdentifier(result.text); } return result; } function parseNamespaceImport() { - var namespaceImport = createNode(221); - parseExpected(36); - parseExpected(113); + var namespaceImport = createNode(222); + parseExpected(37); + parseExpected(114); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 222 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(21, kind === 223 ? parseImportSpecifier : parseExportSpecifier, 15, 16); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(227); + return parseImportOrExportSpecifier(228); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(223); + return parseImportOrExportSpecifier(224); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -9168,9 +9277,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 113) { + if (token === 114) { node.propertyName = identifierName; - parseExpected(113); + parseExpected(114); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -9179,23 +9288,23 @@ var ts; else { node.name = identifierName; } - if (kind === 223 && checkIdentifierIsKeyword) { + if (kind === 224 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(36)) { - parseExpected(130); + if (parseOptional(37)) { + parseExpected(131); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(226); - if (token === 130 || (token === 8 && !scanner.hasPrecedingLineBreak())) { - parseExpected(130); + node.exportClause = parseNamedImportsOrExports(227); + if (token === 131 || (token === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(131); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -9203,14 +9312,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(54)) { + if (parseOptional(55)) { node.isExportEquals = true; } else { - parseExpected(74); + parseExpected(75); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -9273,10 +9382,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 218 && node.moduleReference.kind === 229 - || node.kind === 219 - || node.kind === 224 + || node.kind === 219 && node.moduleReference.kind === 230 + || node.kind === 220 || node.kind === 225 + || node.kind === 226 ? node : undefined; }); @@ -9285,19 +9394,19 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token) { - case 36: - case 51: - case 16: - case 18: - case 47: - case 14: - case 84: - case 21: - case 89: - case 94: + case 37: + case 52: + case 17: + case 19: + case 48: + case 15: + case 85: + case 22: + case 90: + case 95: return true; } - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { @@ -9311,23 +9420,23 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(246); - parseExpected(14); - result.type = parseJSDocTopLevelType(); + var result = createNode(247); parseExpected(15); + result.type = parseJSDocTopLevelType(); + parseExpected(16); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 45) { - var unionType = createNode(250, type.pos); + if (token === 46) { + var unionType = createNode(251, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 54) { - var optionalType = createNode(257, type.pos); + if (token === 55) { + var optionalType = createNode(258, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -9337,21 +9446,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token === 18) { - var arrayType = createNode(249, type.pos); + if (token === 19) { + var arrayType = createNode(250, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(19); + parseExpected(20); type = finishNode(arrayType); } - else if (token === 51) { - var nullableType = createNode(252, type.pos); + else if (token === 52) { + var nullableType = createNode(253, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 47) { - var nonNullableType = createNode(253, type.pos); + else if (token === 48) { + var nonNullableType = createNode(254, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -9364,85 +9473,85 @@ var ts; } function parseBasicTypeExpression() { switch (token) { - case 36: + case 37: return parseJSDocAllType(); - case 51: + case 52: return parseJSDocUnknownOrNullableType(); - case 16: + case 17: return parseJSDocUnionType(); - case 18: + case 19: return parseJSDocTupleType(); - case 47: + case 48: return parseJSDocNonNullableType(); - case 14: + case 15: return parseJSDocRecordType(); - case 84: + case 85: return parseJSDocFunctionType(); - case 21: + case 22: return parseJSDocVariadicType(); - case 89: + case 90: return parseJSDocConstructorType(); - case 94: + case 95: return parseJSDocThisType(); - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: + case 126: + case 118: + case 129: + case 101: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(261); + var result = createNode(262); nextToken(); - parseExpected(52); + parseExpected(53); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(260); + var result = createNode(261); nextToken(); - parseExpected(52); + parseExpected(53); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(259); + var result = createNode(260); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(258); + var result = createNode(259); nextToken(); - parseExpected(16); + parseExpected(17); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(17); - if (token === 52) { + parseExpected(18); + if (token === 53) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(135); + var parameter = createNode(136); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(257, type.pos); + var result = createNode(258, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(256); + var result = createNode(257); result.name = parseSimplePropertyName(); - while (parseOptional(20)) { - if (token === 24) { + while (parseOptional(21)) { + if (token === 25) { result.typeArguments = parseTypeArguments(); break; } @@ -9457,7 +9566,7 @@ var ts; var typeArguments = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(26); + parseExpected(27); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -9468,40 +9577,40 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(132, left.pos); + var result = createNode(133, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(254); + var result = createNode(255); nextToken(); result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); - parseExpected(15); + parseExpected(16); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(255); + var result = createNode(256); result.name = parseSimplePropertyName(); - if (token === 52) { + if (token === 53) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(253); + var result = createNode(254); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(251); + var result = createNode(252); nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(19); + parseExpected(20); return finishNode(result); } function checkForTrailingComma(list) { @@ -9511,10 +9620,10 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(250); + var result = createNode(251); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(17); + parseExpected(18); return finishNode(result); } function parseJSDocTypeList(firstType) { @@ -9522,31 +9631,31 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(45)) { + while (parseOptional(46)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(247); + var result = createNode(248); nextToken(); return finishNode(result); } function parseJSDocUnknownOrNullableType() { var pos = scanner.getStartPos(); nextToken(); - if (token === 23 || - token === 15 || - token === 17 || - token === 26 || - token === 54 || - token === 45) { - var result = createNode(248, pos); + if (token === 24 || + token === 16 || + token === 18 || + token === 27 || + token === 55 || + token === 46) { + var result = createNode(249, pos); return finishNode(result); } else { - var result = createNode(252, pos); + var result = createNode(253, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -9617,7 +9726,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(262, start); + var result = createNode(263, start); result.tags = tags; return finishNode(result, end); } @@ -9628,7 +9737,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(53, pos - 1); + var atToken = createNode(54, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -9654,7 +9763,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(263, atToken.pos); + var result = createNode(264, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -9694,7 +9803,6 @@ var ts; } if (!name) { parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); - return undefined; } var preName, postName; if (typeExpression) { @@ -9706,7 +9814,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(264, atToken.pos); + var result = createNode(265, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -9716,16 +9824,6 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 265; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(265, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); - } - function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 266; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } @@ -9735,10 +9833,20 @@ var ts; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } - function handleTemplateTag(atToken, tagName) { + function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 267; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } + var result = createNode(267, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result, pos); + } + function handleTemplateTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 268; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } var typeParameters = []; typeParameters.pos = pos; while (true) { @@ -9749,7 +9857,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(134, name_8.pos); + var typeParameter = createNode(135, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -9760,7 +9868,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(267, atToken.pos); + var result = createNode(268, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9781,7 +9889,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(66, startPos); + var result = createNode(67, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -9825,7 +9933,7 @@ var ts; } return; function visitNode(node) { - var text = ''; + var text = ""; if (aggressiveChecks && shouldCheckNode(node)) { text = oldText.substring(node.pos, node.end); } @@ -9855,9 +9963,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { + case 9: case 8: - case 7: - case 66: + case 67: return true; } return false; @@ -10071,7 +10179,6 @@ var ts; } })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var nextSymbolId = 1; @@ -10113,17 +10220,18 @@ var ts; isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, + getBaseTypes: getBaseTypes, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeAtLocation, + getTypeAtLocation: getTypeOfNode, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -10140,7 +10248,8 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getJsxElementAttributesType: getJsxElementAttributesType, - getJsxIntrinsicTagNames: getJsxIntrinsicTagNames + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, + isOptionalParameter: isOptionalParameter }; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); @@ -10148,16 +10257,17 @@ var ts; var stringType = createIntrinsicType(2, "string"); var numberType = createIntrinsicType(4, "number"); var booleanType = createIntrinsicType(8, "boolean"); - var esSymbolType = createIntrinsicType(4194304, "symbol"); + var esSymbolType = createIntrinsicType(16777216, "symbol"); var voidType = createIntrinsicType(16, "void"); - var undefinedType = createIntrinsicType(32 | 1048576, "undefined"); - var nullType = createIntrinsicType(64 | 1048576, "null"); + var undefinedType = createIntrinsicType(32 | 2097152, "undefined"); + var nullType = createIntrinsicType(64 | 2097152, "null"); var unknownType = createIntrinsicType(1, "unknown"); var circularType = createIntrinsicType(1, "__circular__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + anyFunctionType.flags |= 8388608; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); @@ -10201,6 +10311,7 @@ var ts; var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; + var resolutionPropertyNames = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -10222,7 +10333,7 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 4194304 + flags: 16777216 } }; var JsxNames = { @@ -10235,6 +10346,7 @@ var ts; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; + var _displayBuilder; initializeTypeChecker(); return checker; function getEmitResolver(sourceFile, cancellationToken) { @@ -10376,10 +10488,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 245); + return ts.getAncestor(node, 246); } function isGlobalSourceFile(node) { - return node.kind === 245 && !ts.isExternalModule(node); + return node.kind === 246 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -10402,7 +10514,7 @@ var ts; if (file1 === file2) { return node1.pos <= node2.pos; } - if (!compilerOptions.out) { + if (!compilerOptions.outFile && !compilerOptions.out) { return true; } var sourceFiles = host.getSourceFiles(); @@ -10427,16 +10539,16 @@ var ts; } } switch (location.kind) { - case 245: + case 246: if (!ts.isExternalModule(location)) break; - case 215: + case 216: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 245 || - (location.kind === 215 && location.name.kind === 8)) { + if (location.kind === 246 || + (location.kind === 216 && location.name.kind === 9)) { if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 227)) { + ts.getDeclarationOfKind(moduleExports[name], 228)) { break; } result = moduleExports["default"]; @@ -10450,13 +10562,13 @@ var ts; break loop; } break; - case 214: + case 215: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 139: case 138: - case 137: if (ts.isClassLike(location.parent) && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -10466,9 +10578,9 @@ var ts; } } break; - case 211: - case 183: case 212: + case 184: + case 213: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 128) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -10476,7 +10588,7 @@ var ts; } break loop; } - if (location.kind === 183 && meaning & 32) { + if (location.kind === 184 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -10484,28 +10596,28 @@ var ts; } } break; - case 133: + case 134: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 212) { + if (ts.isClassLike(grandparent) || grandparent.kind === 213) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 140: - case 139: case 141: + case 140: case 142: case 143: - case 210: - case 171: + case 144: + case 211: + case 172: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 170: + case 171: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -10518,8 +10630,8 @@ var ts; } } break; - case 136: - if (location.parent && location.parent.kind === 135) { + case 137: + if (location.parent && location.parent.kind === 136) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -10545,7 +10657,7 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (result.flags & 2) { + if (meaning & 2 && result.flags & 2) { checkResolvedBlockScopedVariable(result, errorLocation); } } @@ -10557,14 +10669,14 @@ var ts; ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 208); + var variableDeclaration = ts.getAncestor(declaration, 209); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 190 || - variableDeclaration.parent.parent.kind === 196) { + if (variableDeclaration.parent.parent.kind === 191 || + variableDeclaration.parent.parent.kind === 197) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 198 || - variableDeclaration.parent.parent.kind === 197) { + else if (variableDeclaration.parent.parent.kind === 199 || + variableDeclaration.parent.parent.kind === 198) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -10586,10 +10698,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 218) { + if (node.kind === 219) { return node; } - while (node && node.kind !== 219) { + while (node && node.kind !== 220) { node = node.parent; } return node; @@ -10599,7 +10711,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 229) { + if (node.moduleReference.kind === 230) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -10688,17 +10800,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 218: + case 219: return getTargetOfImportEqualsDeclaration(node); - case 220: - return getTargetOfImportClause(node); case 221: + return getTargetOfImportClause(node); + case 222: return getTargetOfNamespaceImport(node); - case 223: - return getTargetOfImportSpecifier(node); - case 227: - return getTargetOfExportSpecifier(node); case 224: + return getTargetOfImportSpecifier(node); + case 228: + return getTargetOfExportSpecifier(node); + case 225: return getTargetOfExportAssignment(node); } } @@ -10740,10 +10852,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 224) { + if (node.kind === 225) { checkExpressionCached(node.expression); } - else if (node.kind === 227) { + else if (node.kind === 228) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -10753,17 +10865,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 218); + importDeclaration = ts.getAncestor(entityName, 219); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 66 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 67 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 66 || entityName.parent.kind === 132) { + if (entityName.kind === 67 || entityName.parent.kind === 133) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 218); + ts.Debug.assert(entityName.parent.kind === 219); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -10775,16 +10887,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 66) { + if (name.kind === 67) { var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 132 || name.kind === 163) { - var left = name.kind === 132 ? name.left : name.expression; - var right = name.kind === 132 ? name.right : name.name; + else if (name.kind === 133 || name.kind === 164) { + var left = name.kind === 133 ? name.left : name.expression; + var right = name.kind === 133 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -10807,35 +10919,24 @@ var ts; return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; } function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 8) { + if (moduleReferenceExpression.kind !== 9) { return; } var moduleReferenceLiteral = moduleReferenceExpression; var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName); var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) + if (moduleName === undefined) { return; + } var isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512); + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); if (symbol) { return symbol; } } - var fileName; - var sourceFile; - while (true) { - fileName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - sourceFile = ts.forEach(ts.supportedExtensions, function (extension) { return host.getSourceFile(fileName + extension); }); - if (sourceFile || isRelative) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } + var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); + var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { return sourceFile.symbol; @@ -10931,7 +11032,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 141 && ts.nodeIsPresent(member.body)) { + if (member.kind === 142 && ts.nodeIsPresent(member.body)) { return member; } } @@ -10996,17 +11097,17 @@ var ts; } } switch (location_1.kind) { - case 245: + case 246: if (!ts.isExternalModule(location_1)) { break; } - case 215: + case 216: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 211: case 212: + case 213: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -11039,7 +11140,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -11068,7 +11169,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -11123,8 +11224,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 215 && declaration.name.kind === 8) || - (declaration.kind === 245 && ts.isExternalModule(declaration)); + return (declaration.kind === 216 && declaration.name.kind === 9) || + (declaration.kind === 246 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -11156,11 +11257,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 151) { + if (entityName.parent.kind === 152) { meaning = 107455 | 1048576; } - else if (entityName.kind === 132 || entityName.kind === 163 || - entityName.parent.kind === 218) { + else if (entityName.kind === 133 || entityName.kind === 164 || + entityName.parent.kind === 219) { meaning = 1536; } else { @@ -11211,16 +11312,15 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 157) { + while (node.kind === 158) { node = node.parent; } - if (node.kind === 213) { + if (node.kind === 214) { return getSymbolOfNode(node); } } return undefined; } - var _displayBuilder; function getSymbolDisplayBuilder() { function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { @@ -11229,10 +11329,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 183: + case 184: return "(Anonymous class)"; - case 170: case 171: + case 172: return "(Anonymous function)"; } } @@ -11253,7 +11353,7 @@ var ts; buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -11295,7 +11395,7 @@ var ts; var globalFlagsToPass = globalFlags & 16; return writeType(type, globalFlags); function writeType(type, flags) { - if (type.flags & 4194431) { + if (type.flags & 16777343) { writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) ? "any" : type.intrinsicName); @@ -11319,23 +11419,23 @@ var ts; writer.writeStringLiteral(type.text); } else { - writePunctuation(writer, 14); - writeSpace(writer); - writePunctuation(writer, 21); - writeSpace(writer); writePunctuation(writer, 15); + writeSpace(writer); + writePunctuation(writer, 22); + writeSpace(writer); + writePunctuation(writer, 16); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 23) { + if (delimiter !== 24) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 23 ? 0 : 64); + writeType(types[i], delimiter === 24 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end) { @@ -11343,22 +11443,22 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056); } if (pos < end) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeType(typeArguments[pos++], 0); while (pos < end) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); writeType(typeArguments[pos++], 0); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); - writePunctuation(writer, 18); writePunctuation(writer, 19); + writePunctuation(writer, 20); } else { var outerTypeParameters = type.target.outerTypeParameters; @@ -11373,7 +11473,7 @@ var ts; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_3, typeArguments, start, i); - writePunctuation(writer, 20); + writePunctuation(writer, 21); } } } @@ -11381,18 +11481,18 @@ var ts; } } function writeTupleType(type) { - writePunctuation(writer, 18); - writeTypeList(type.elementTypes, 23); writePunctuation(writer, 19); + writeTypeList(type.elementTypes, 24); + writePunctuation(writer, 20); } function writeUnionOrIntersectionType(type, flags) { - if (flags & 64) { - writePunctuation(writer, 16); - } - writeTypeList(type.types, type.flags & 16384 ? 45 : 44); if (flags & 64) { writePunctuation(writer, 17); } + writeTypeList(type.types, type.flags & 16384 ? 46 : 45); + if (flags & 64) { + writePunctuation(writer, 18); + } } function writeAnonymousType(type, flags) { var symbol = type.symbol; @@ -11409,7 +11509,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 114); + writeKeyword(writer, 115); } } else { @@ -11430,7 +11530,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 245 || declaration.parent.kind === 216; + return declaration.parent.kind === 246 || declaration.parent.kind === 217; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -11439,7 +11539,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 98); + writeKeyword(writer, 99); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -11455,74 +11555,74 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 14); writePunctuation(writer, 15); + writePunctuation(writer, 16); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { if (flags & 64) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); } - writeKeyword(writer, 89); + writeKeyword(writer, 90); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } return; } } - writePunctuation(writer, 14); + writePunctuation(writer, 15); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 89); + writeKeyword(writer, 90); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } if (resolved.stringIndexType) { - writePunctuation(writer, 18); - writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 52); - writeSpace(writer); - writeKeyword(writer, 127); writePunctuation(writer, 19); - writePunctuation(writer, 52); + writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); + writePunctuation(writer, 53); + writeSpace(writer); + writeKeyword(writer, 128); + writePunctuation(writer, 20); + writePunctuation(writer, 53); writeSpace(writer); writeType(resolved.stringIndexType, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } if (resolved.numberIndexType) { - writePunctuation(writer, 18); - writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 52); - writeSpace(writer); - writeKeyword(writer, 125); writePunctuation(writer, 19); - writePunctuation(writer, 52); + writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); + writePunctuation(writer, 53); + writeSpace(writer); + writeKeyword(writer, 126); + writePunctuation(writer, 20); + writePunctuation(writer, 53); writeSpace(writer); writeType(resolved.numberIndexType, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { @@ -11534,32 +11634,32 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } } else { buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } - writePunctuation(writer, 52); + writePunctuation(writer, 53); writeSpace(writer); writeType(t, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 15); + writePunctuation(writer, 16); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 || targetSymbol.flags & 64) { + if (targetSymbol.flags & 32 || targetSymbol.flags & 64 || targetSymbol.flags & 524288) { buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } @@ -11568,7 +11668,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 80); + writeKeyword(writer, 81); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -11576,67 +11676,67 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 21); + writePunctuation(writer, 22); } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } - writePunctuation(writer, 52); + writePunctuation(writer, 53); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); for (var i = 0; i < parameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 17); + writePunctuation(writer, 18); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 33); + writePunctuation(writer, 34); } else { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 121); + writeKeyword(writer, 122); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -11656,15 +11756,12 @@ var ts; buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { - symbolToString: symbolToString, - typeToString: typeToString, buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildDisplayForTypeArgumentsAndDelimiters: buildDisplayForTypeArgumentsAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay @@ -11673,12 +11770,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 215) { - if (node.name.kind === 8) { + if (node.kind === 216) { + if (node.name.kind === 9) { return node; } } - else if (node.kind === 245) { + else if (node.kind === 246) { return ts.isExternalModule(node) ? node : undefined; } } @@ -11721,60 +11818,60 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 160: + case 161: return isDeclarationVisible(node.parent.parent); - case 208: + case 209: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 215: - case 211: + case 216: case 212: case 213: - case 210: case 214: - case 218: + case 211: + case 215: + case 219: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 218 && parent_4.kind !== 245 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 219 && parent_4.kind !== 246 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 138: - case 137: - case 142: - case 143: - case 140: case 139: + case 138: + case 143: + case 144: + case 141: + case 140: if (node.flags & (32 | 64)) { return false; } - case 141: - case 145: - case 144: + case 142: case 146: - case 135: - case 216: - case 149: + case 145: + case 147: + case 136: + case 217: case 150: - case 152: - case 148: + case 151: case 153: + case 149: case 154: case 155: case 156: case 157: + case 158: return isDeclarationVisible(node.parent); - case 220: case 221: - case 223: - return false; - case 134: - case 245: - return true; + case 222: case 224: return false; + case 135: + case 246: + return true; + case 225: + return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); } @@ -11789,11 +11886,14 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 224) { - exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); + if (node.parent && node.parent.kind === 225) { + exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 227) { - exportSymbol = getTargetOfExportSpecifier(node.parent); + else if (node.parent.kind === 228) { + var exportSpecifier = node.parent; + exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 | 793056 | 1536 | 8388608); } var result = []; if (exportSymbol) { @@ -11816,29 +11916,55 @@ var ts; }); } } - function pushTypeResolution(target) { - var i = 0; - var count = resolutionTargets.length; - while (i < count && resolutionTargets[i] !== target) { - i++; - } - if (i < count) { - do { - resolutionResults[i++] = false; - } while (i < count); + function pushTypeResolution(target, propertyName) { + var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + var length_2 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_2; i++) { + resolutionResults[i] = false; + } return false; } resolutionTargets.push(target); resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); return true; } + function findResolutionCycleStartIndex(target, propertyName) { + for (var i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + return -1; + } + function hasType(target, propertyName) { + if (propertyName === 0) { + return getSymbolLinks(target).type; + } + if (propertyName === 2) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === 1) { + ts.Debug.assert(!!(target.flags & 1024)); + return target.resolvedBaseConstructorType; + } + if (propertyName === 3) { + return target.resolvedReturnType; + } + ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } function popTypeResolution() { resolutionTargets.pop(); + resolutionPropertyNames.pop(); return resolutionResults.pop(); } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 208 ? node.parent.parent.parent : node.parent; + return node.kind === 209 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -11864,7 +11990,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 158) { + if (pattern.kind === 159) { var name_10 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_10.text) || isNumericLiteralName(name_10.text) && getIndexTypeOfType(parentType, 1) || @@ -11877,9 +12003,6 @@ var ts; else { var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); if (!declaration.dotDotDotToken) { - if (isTypeAny(elementType)) { - return elementType; - } var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) ? getTypeOfPropertyOfType(parentType, propName) @@ -11901,10 +12024,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 197) { + if (declaration.parent.parent.kind === 198) { return anyType; } - if (declaration.parent.parent.kind === 198) { + if (declaration.parent.parent.kind === 199) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -11913,10 +12036,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135) { + if (declaration.kind === 136) { var func = declaration.parent; - if (func.kind === 143 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 142); + if (func.kind === 144 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -11929,53 +12052,56 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 243) { + if (declaration.kind === 244) { return checkIdentifier(declaration.name); } + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name, false); + } return undefined; } - function getTypeFromBindingElement(element) { + function getTypeFromBindingElement(element, includePatternInType) { if (element.initializer) { return getWidenedType(checkExpressionCached(element.initializer)); } if (ts.isBindingPattern(element.name)) { - return getTypeFromBindingPattern(element.name); + return getTypeFromBindingPattern(element.name, includePatternInType); } return anyType; } - function getTypeFromObjectBindingPattern(pattern) { + function getTypeFromObjectBindingPattern(pattern, includePatternInType) { var members = {}; ts.forEach(pattern.elements, function (e) { var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); var name = e.propertyName || e.name; var symbol = createSymbol(flags, name.text); - symbol.type = getTypeFromBindingElement(e); + symbol.type = getTypeFromBindingElement(e, includePatternInType); + symbol.bindingElement = e; members[symbol.name] = symbol; }); - return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + if (includePatternInType) { + result.pattern = pattern; + } + return result; } - function getTypeFromArrayBindingPattern(pattern) { - var hasSpreadElement = false; - var elementTypes = []; - ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 184 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); - if (e.dotDotDotToken) { - hasSpreadElement = true; - } - }); - if (!elementTypes.length) { + function getTypeFromArrayBindingPattern(pattern, includePatternInType) { + var elements = pattern.elements; + if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } - else if (hasSpreadElement) { - var unionOfElements = getUnionType(elementTypes); - return languageVersion >= 2 ? createIterableType(unionOfElements) : createArrayType(unionOfElements); + var elementTypes = ts.map(elements, function (e) { return e.kind === 185 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + if (includePatternInType) { + var result = createNewTupleType(elementTypes); + result.pattern = pattern; + return result; } return createTupleType(elementTypes); } - function getTypeFromBindingPattern(pattern) { - return pattern.kind === 158 - ? getTypeFromObjectBindingPattern(pattern) - : getTypeFromArrayBindingPattern(pattern); + function getTypeFromBindingPattern(pattern, includePatternInType) { + return pattern.kind === 159 + ? getTypeFromObjectBindingPattern(pattern, includePatternInType) + : getTypeFromArrayBindingPattern(pattern, includePatternInType); } function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { var type = getTypeForVariableLikeDeclaration(declaration); @@ -11983,15 +12109,12 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 242 ? getWidenedType(type) : type; - } - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return declaration.kind !== 243 ? getWidenedType(type) : type; } type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 135 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 136 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -12004,13 +12127,13 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 241) { + if (declaration.parent.kind === 242) { return links.type = anyType; } - if (declaration.kind === 224) { + if (declaration.kind === 225) { return links.type = checkExpression(declaration.expression); } - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -12032,7 +12155,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 142) { + if (accessor.kind === 143) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -12045,11 +12168,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 142); - var setter = ts.getDeclarationOfKind(symbol, 143); + var getter = ts.getDeclarationOfKind(symbol, 143); + var setter = ts.getDeclarationOfKind(symbol, 144); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -12075,7 +12198,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 142); + var getter_1 = ts.getDeclarationOfKind(symbol, 143); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -12164,9 +12287,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 211 || node.kind === 183 || - node.kind === 210 || node.kind === 170 || - node.kind === 140 || node.kind === 171) { + if (node.kind === 212 || node.kind === 184 || + node.kind === 211 || node.kind === 171 || + node.kind === 141 || node.kind === 172) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -12175,15 +12298,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 212); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 212 || node.kind === 211 || - node.kind === 183 || node.kind === 213) { + if (node.kind === 213 || node.kind === 212 || + node.kind === 184 || node.kind === 214) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -12219,7 +12342,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type)) { + if (!pushTypeResolution(type, 1)) { return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -12288,7 +12411,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 212 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 213 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -12332,10 +12455,10 @@ var ts; function getDeclaredTypeOfTypeAlias(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - if (!pushTypeResolution(links)) { + if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 213); + var declaration = ts.getDeclarationOfKind(symbol, 214); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -12366,7 +12489,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 134).constraint) { + if (!ts.getDeclarationOfKind(symbol, 135).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -12528,43 +12651,64 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); + var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, true))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } - function signatureListsIdentical(s, t) { - if (s.length !== t.length) { - return false; - } - for (var i = 0; i < s.length; i++) { - if (!compareSignatures(s[i], t[i], false, compareTypes)) { - return false; + function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { + for (var _i = 0; _i < signatureList.length; _i++) { + var s = signatureList[_i]; + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { + return s; } } - return true; + } + function findMatchingSignatures(signatureLists, signature, listIndex) { + if (signature.typeParameters) { + if (listIndex > 0) { + return undefined; + } + for (var i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, false, false)) { + return undefined; + } + } + return [signature]; + } + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, true); + if (!match) { + return undefined; + } + if (!ts.contains(result, match)) { + (result || (result = [])).push(match); + } + } + return result; } function getUnionSignatures(types, kind) { var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var signatures = signatureLists[0]; - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; - if (signature.typeParameters) { - return emptyArray; + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { + var signature = _a[_i]; + if (!result || !findMatchingSignature(result, signature, false, true)) { + var unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + var s = signature; + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } + } } } - for (var i_1 = 1; i_1 < signatureLists.length; i_1++) { - if (!signatureListsIdentical(signatures, signatureLists[i_1])) { - return emptyArray; - } - } - var result = ts.map(signatures, cloneSignature); - for (var i = 0; i < result.length; i++) { - var s = result[i]; - s.resolvedReturnType = undefined; - s.unionSignatures = ts.map(signatureLists, function (signatures) { return signatures[i]; }); - } - return result; + return result || emptyArray; } function getUnionIndexType(types, kind) { var indexTypes = []; @@ -12701,9 +12845,6 @@ var ts; return type.flags & 49152 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function getApparentType(type) { - if (type.flags & 16384) { - type = getReducedTypeOfUnionType(type); - } if (type.flags & 512) { do { type = getConstraintOfTypeParameter(type); @@ -12721,7 +12862,7 @@ var ts; else if (type.flags & 8) { type = globalBooleanType; } - else if (type.flags & 4194304) { + else if (type.flags & 16777216) { type = globalESSymbolType; } return type; @@ -12857,12 +12998,22 @@ var ts; return result; } function isOptionalParameter(node) { - return ts.hasQuestionToken(node) || !!node.initializer; + if (ts.hasQuestionToken(node)) { + return true; + } + if (node.initializer) { + var signatureDeclaration = node.parent; + var signature = getSignatureFromDeclaration(signatureDeclaration); + var parameterIndex = signatureDeclaration.parameters.indexOf(node); + ts.Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + return false; } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 141 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 142 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -12871,14 +13022,17 @@ var ts; for (var i = 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; parameters.push(param.symbol); - if (param.type && param.type.kind === 8) { + if (param.type && param.type.kind === 9) { hasStringLiterals = true; } - if (minArgumentCount < 0) { - if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { minArgumentCount = i; } } + else { + minArgumentCount = -1; + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length; @@ -12890,7 +13044,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 147) { + if (declaration.type.kind === 148) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -12900,8 +13054,8 @@ var ts; } } else { - if (declaration.kind === 142 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 143); + if (declaration.kind === 143 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 144); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -12919,19 +13073,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 149: case 150: - case 210: - case 140: - case 139: + case 151: + case 211: case 141: - case 144: + case 140: + case 142: case 145: case 146: - case 142: + case 147: case 143: - case 170: + case 144: case 171: + case 172: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -12945,7 +13099,7 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, 3)) { return unknownType; } var type; @@ -13001,7 +13155,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 141 || signature.declaration.kind === 145; + var isConstructor = signature.declaration.kind === 142 || signature.declaration.kind === 146; var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; @@ -13015,7 +13169,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 125 : 127; + var syntaxKind = kind === 1 ? 126 : 128; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -13044,13 +13198,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 134).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 134).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135).parent); } function getTypeListId(types) { switch (types.length) { @@ -13069,19 +13223,19 @@ var ts; return result; } } - function getWideningFlagsOfTypes(types) { + function getPropagatingFlagsOfTypes(types) { var result = 0; for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; result |= type.flags; } - return result & 3145728; + return result & 14680064; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 | getWideningFlagsOfTypes(typeArguments); + var flags = 4096 | getPropagatingFlagsOfTypes(typeArguments); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -13097,13 +13251,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 134; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 148 && n.typeName.kind === 66) { + if (n.kind === 149 && n.typeName.kind === 67) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -13170,7 +13324,7 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 148 ? node.typeName : + var typeNameOrExpression = node.kind === 149 ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; @@ -13196,9 +13350,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 211: case 212: - case 214: + case 213: + case 215: return declaration; } } @@ -13244,7 +13398,7 @@ var ts; } function createTypedPropertyDescriptorType(propertyType) { var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyObjectType + return globalTypedPropertyDescriptorType !== emptyGenericType ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } @@ -13269,11 +13423,11 @@ var ts; } function createTupleType(elementTypes) { var id = getTypeListId(elementTypes); - var type = tupleTypes[id]; - if (!type) { - type = tupleTypes[id] = createObjectType(8192 | getWideningFlagsOfTypes(elementTypes)); - type.elementTypes = elementTypes; - } + return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); + } + function createNewTupleType(elementTypes) { + var type = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes)); + type.elementTypes = elementTypes; return type; } function getTypeFromTupleTypeNode(node) { @@ -13298,9 +13452,8 @@ var ts; } } function isSubtypeOfAny(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - if (candidate !== type && isTypeSubtypeOf(candidate, type)) { + for (var i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { return true; } } @@ -13333,20 +13486,16 @@ var ts; } } } - function compareTypeIds(type1, type2) { - return type1.id - type2.id; - } function getUnionType(types, noSubtypeReduction) { if (types.length === 0) { return emptyObjectType; } var typeSet = []; addTypesToSet(typeSet, types, 16384); - typeSet.sort(compareTypeIds); + if (containsTypeAny(typeSet)) { + return anyType; + } if (noSubtypeReduction) { - if (containsTypeAny(typeSet)) { - return anyType; - } removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } @@ -13359,25 +13508,11 @@ var ts; var id = getTypeListId(typeSet); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 | getWideningFlagsOfTypes(typeSet)); + type = unionTypes[id] = createObjectType(16384 | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; - type.reducedType = noSubtypeReduction ? undefined : type; } return type; } - function getReducedTypeOfUnionType(type) { - if (!type.reducedType) { - type.reducedType = circularType; - var reducedType = getUnionType(type.types, false); - if (type.reducedType === circularType) { - type.reducedType = reducedType; - } - } - else if (type.reducedType === circularType) { - type.reducedType = type; - } - return type.reducedType; - } function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { @@ -13400,7 +13535,7 @@ var ts; var id = getTypeListId(typeSet); var type = intersectionTypes[id]; if (!type) { - type = intersectionTypes[id] = createObjectType(32768 | getWideningFlagsOfTypes(typeSet)); + type = intersectionTypes[id] = createObjectType(32768 | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; } return type; @@ -13436,45 +13571,45 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 114: + case 115: return anyType; - case 127: - return stringType; - case 125: - return numberType; - case 117: - return booleanType; case 128: - return esSymbolType; - case 100: - return voidType; - case 8: - return getTypeFromStringLiteral(node); - case 148: - return getTypeFromTypeReference(node); - case 147: + return stringType; + case 126: + return numberType; + case 118: return booleanType; - case 185: - return getTypeFromTypeReference(node); - case 151: - return getTypeFromTypeQueryNode(node); - case 153: - return getTypeFromArrayTypeNode(node); - case 154: - return getTypeFromTupleTypeNode(node); - case 155: - return getTypeFromUnionTypeNode(node); - case 156: - return getTypeFromIntersectionTypeNode(node); - case 157: - return getTypeFromTypeNode(node.type); + case 129: + return esSymbolType; + case 101: + return voidType; + case 9: + return getTypeFromStringLiteral(node); case 149: - case 150: + return getTypeFromTypeReference(node); + case 148: + return booleanType; + case 186: + return getTypeFromTypeReference(node); case 152: + return getTypeFromTypeQueryNode(node); + case 154: + return getTypeFromArrayTypeNode(node); + case 155: + return getTypeFromTupleTypeNode(node); + case 156: + return getTypeFromUnionTypeNode(node); + case 157: + return getTypeFromIntersectionTypeNode(node); + case 158: + return getTypeFromTypeNode(node.type); + case 150: + case 151: + case 153: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 66: - case 132: - var symbol = getSymbolInfo(node); + case 67: + case 133: + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: return unknownType; @@ -13533,7 +13668,7 @@ var ts; }; } function createInferenceMapper(context) { - return function (t) { + var mapper = function (t) { for (var i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { context.inferences[i].isFixed = true; @@ -13542,6 +13677,8 @@ var ts; } return t; }; + mapper.context = context; + return mapper; } function identityMapper(type) { return type; @@ -13597,6 +13734,15 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { + if (mapper.instantiations) { + var cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } var result = createObjectType(65536 | 131072, type.symbol); result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); result.members = createSymbolTable(result.properties); @@ -13608,6 +13754,7 @@ var ts; result.stringIndexType = instantiateType(stringIndexType, mapper); if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper); + mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { @@ -13635,27 +13782,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 170: case 171: + case 172: return isContextSensitiveFunctionLikeDeclaration(node); - case 162: + case 163: return ts.forEach(node.properties, isContextSensitive); - case 161: + case 162: return ts.forEach(node.elements, isContextSensitive); - case 179: + case 180: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 178: - return node.operatorToken.kind === 50 && + case 179: + return node.operatorToken.kind === 51 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 242: + case 243: return isContextSensitive(node.initializer); + case 141: case 140: - case 139: return isContextSensitiveFunctionLikeDeclaration(node); - case 169: + case 170: return isContextSensitive(node.expression); } return false; @@ -13729,99 +13876,158 @@ var ts; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } + function reportRelationError(message, source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, undefined, 128); + targetType = typeToString(target, undefined, 128); + } + reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } function isRelatedTo(source, target, reportErrors, headMessage) { var result; if (source === target) return -1; - if (relation !== identityRelation) { - if (isTypeAny(target)) + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + if (isTypeAny(target)) + return -1; + if (source === undefinedType) + return -1; + if (source === nullType && target !== undefinedType) + return -1; + if (source.flags & 128 && target === numberType) + return -1; + if (source.flags & 256 && target === stringType) + return -1; + if (relation === assignableRelation) { + if (isTypeAny(source)) return -1; - if (source === undefinedType) + if (source === numberType && target.flags & 128) return -1; - if (source === nullType && target !== undefinedType) - return -1; - if (source.flags & 128 && target === numberType) - return -1; - if (source.flags & 256 && target === stringType) - return -1; - if (relation === assignableRelation) { - if (isTypeAny(source)) - return -1; - if (source === numberType && target.flags & 128) - return -1; + } + if (source.flags & 1048576) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0; + } + if (target.flags & 49152) { + source = getRegularTypeOfObjectLiteral(source); } } var saveErrorInfo = errorInfo; - if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + if (source.flags & 16384) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { return result; } } - else if (source.flags & 512 && target.flags & 512) { - if (result = typeParameterRelatedTo(source, target, reportErrors)) { + else if (target.flags & 32768) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { return result; } } - else if (relation !== identityRelation) { - if (source.flags & 16384) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 32768) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - if (source.flags & 32768) { - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { - return result; - } - } - if (target.flags & 16384) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - } else { - if (source.flags & 16384 && target.flags & 16384 || - source.flags & 32768 && target.flags & 32768) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } + if (source.flags & 32768) { + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { + return result; + } + } + if (target.flags & 16384) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; } } } - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & (80896 | 32768) && target.flags & 80896) { - if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + if (source.flags & 512) { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 512 && sourceOrApparentType.flags & 49152) { - errorInfo = saveErrorInfo; - if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { - return result; + else { + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; + } + } + var apparentType = getApparentType(source); + if (apparentType.flags & (80896 | 32768) && target.flags & 80896) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } if (reportErrors) { - headMessage = headMessage || ts.Diagnostics.Type_0_is_not_assignable_to_type_1; - var sourceType = typeToString(source); - var targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, undefined, 128); - targetType = typeToString(target, undefined, 128); - } - reportError(headMessage, sourceType, targetType); + reportRelationError(headMessage, source, target); } return 0; } + function isIdenticalTo(source, target) { + var result; + if (source.flags & 80896 && target.flags & 80896) { + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, false)) { + return result; + } + } + return objectTypeRelatedTo(source, target, false); + } + if (source.flags & 512 && target.flags & 512) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & 16384 && target.flags & 16384 || + source.flags & 32768 && target.flags & 32768) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return 0; + } + function isKnownProperty(type, name) { + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); + if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || + resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + return true; + } + return false; + } + if (type.flags & 49152) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } + function hasExcessProperties(source, target, reportErrors) { + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + errorNode = prop.valueDeclaration; + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; @@ -13892,30 +14098,17 @@ var ts; } return result; } - function typeParameterRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - if (source.symbol.name !== target.symbol.name) { - return 0; - } - if (source.constraint === target.constraint) { - return -1; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0; - } - return isRelatedTo(source.constraint, target.constraint, reportErrors); - } - else { - while (true) { - var constraint = getConstraintOfTypeParameter(source); - if (constraint === target) - return -1; - if (!(constraint && constraint.flags & 512)) - break; - source = constraint; - } + function typeParameterIdenticalTo(source, target) { + if (source.symbol.name !== target.symbol.name) { return 0; } + if (source.constraint === target.constraint) { + return -1; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return 0; + } + return isIdenticalTo(source.constraint, target.constraint); } function objectTypeRelatedTo(source, target, reportErrors) { if (overflow) { @@ -14092,22 +14285,12 @@ var ts; var targetSignatures = getSignaturesOfType(target, kind); var result = -1; var saveErrorInfo = errorInfo; - var sourceSig = sourceSignatures[0]; - var targetSig = targetSignatures[0]; - if (sourceSig && targetSig) { - var sourceErasedSignature = getErasedSignature(sourceSig); - var targetErasedSignature = getErasedSignature(targetSig); - var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 211); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 211); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; - if (sourceIsAbstract && !targetIsAbstract) { - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return 0; + if (kind === 1) { + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== -1) { + return result; } } outer: for (var _i = 0; _i < targetSignatures.length; _i++) { @@ -14131,6 +14314,30 @@ var ts; } } return result; + function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { + if (sourceSig && targetSig) { + var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); + var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); + if (!sourceDecl) { + return -1; + } + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0; + } + } + return -1; + } } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { @@ -14219,7 +14426,7 @@ var ts; } var result = -1; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], false, false, isRelatedTo); if (!related) { return 0; } @@ -14232,7 +14439,7 @@ var ts; return indexTypesIdenticalTo(0, source, target); } var targetType = getIndexTypeOfType(target, 0); - if (targetType) { + if (targetType && !(targetType.flags & 1)) { var sourceType = getIndexTypeOfType(source, 0); if (!sourceType) { if (reportErrors) { @@ -14256,7 +14463,7 @@ var ts; return indexTypesIdenticalTo(1, source, target); } var targetType = getIndexTypeOfType(target, 1); - if (targetType) { + if (targetType && !(targetType.flags & 1)) { var sourceStringType = getIndexTypeOfType(source, 0); var sourceNumberType = getIndexTypeOfType(source, 1); if (!(sourceStringType || sourceNumberType)) { @@ -14333,14 +14540,18 @@ var ts; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } - function compareSignatures(source, target, compareReturnTypes, compareTypes) { + function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { if (source === target) { return -1; } if (source.parameters.length !== target.parameters.length || source.minArgumentCount !== target.minArgumentCount || source.hasRestParameter !== target.hasRestParameter) { - return 0; + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return 0; + } } var result = -1; if (source.typeParameters && target.typeParameters) { @@ -14360,16 +14571,18 @@ var ts; } source = getErasedSignature(source); target = getErasedSignature(target); - for (var i = 0, len = source.parameters.length; i < len; i++) { - var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var sourceLen = source.parameters.length; + var targetLen = target.parameters.length; + for (var i = 0; i < targetLen; i++) { + var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); var related = compareTypes(s, t); if (!related) { return 0; } result &= related; } - if (compareReturnTypes) { + if (!ignoreReturnTypes) { result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; @@ -14424,6 +14637,24 @@ var ts; function isTupleType(type) { return !!(type.flags & 8192); } + function getRegularTypeOfObjectLiteral(type) { + if (type.flags & 1048576) { + var regularType = type.regularType; + if (!regularType) { + regularType = createType(type.flags & ~1048576); + regularType.symbol = type.symbol; + regularType.members = type.members; + regularType.properties = type.properties; + regularType.callSignatures = type.callSignatures; + regularType.constructSignatures = type.constructSignatures; + regularType.stringIndexType = type.stringIndexType; + regularType.numberIndexType = type.numberIndexType; + type.regularType = regularType; + } + return regularType; + } + return type; + } function getWidenedTypeOfObjectLiteral(type) { var properties = getPropertiesOfObjectType(type); var members = {}; @@ -14451,7 +14682,7 @@ var ts; return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); } function getWidenedType(type) { - if (type.flags & 3145728) { + if (type.flags & 6291456) { if (type.flags & (32 | 64)) { return anyType; } @@ -14459,7 +14690,7 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 16384) { - return getUnionType(ts.map(type.types, getWidenedType)); + return getUnionType(ts.map(type.types, getWidenedType), true); } if (isArrayType(type)) { return createArrayType(getWidenedType(type.typeArguments[0])); @@ -14495,7 +14726,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 1048576) { + if (t.flags & 2097152) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -14509,22 +14740,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 139: case 138: - case 137: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 135: + case 136: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 210: + case 211: + case 141: case 140: - case 139: - case 142: case 143: - case 170: + case 144: case 171: + case 172: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -14537,7 +14768,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 1048576) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -14573,7 +14804,9 @@ var ts; var inferences = []; for (var _i = 0; _i < typeParameters.length; _i++) { var unused = typeParameters[_i]; - inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); + inferences.push({ + primary: undefined, secondary: undefined, isFixed: false + }); } return { typeParameters: typeParameters, @@ -14597,10 +14830,10 @@ var ts; return false; } function inferFromTypes(source, target) { - if (source === anyFunctionType) { - return; - } if (target.flags & 512) { + if (source.flags & 8388608) { + return; + } var typeParameters = context.typeParameters; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { @@ -14624,6 +14857,13 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 8192 && target.flags & 8192 && source.elementTypes.length === target.elementTypes.length) { + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } else if (target.flags & 49152) { var targetTypes = target.types; var typeParameterCount = 0; @@ -14767,10 +15007,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 151: + case 152: return true; - case 66: - case 132: + case 67: + case 133: node = node.parent; continue; default: @@ -14810,12 +15050,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 54 && node.operatorToken.kind <= 65) { + if (node.operatorToken.kind >= 55 && node.operatorToken.kind <= 66) { var n = node.left; - while (n.kind === 169) { + while (n.kind === 170) { n = n.expression; } - if (n.kind === 66 && getResolvedSymbol(n) === symbol) { + if (n.kind === 67 && getResolvedSymbol(n) === symbol) { return true; } } @@ -14829,82 +15069,60 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 178: + case 179: return isAssignedInBinaryExpression(node); - case 208: - case 160: - return isAssignedInVariableDeclaration(node); - case 158: - case 159: + case 209: case 161: + return isAssignedInVariableDeclaration(node); + case 159: + case 160: case 162: case 163: case 164: case 165: case 166: - case 168: - case 186: + case 167: case 169: - case 176: - case 172: - case 175: - case 173: - case 174: + case 187: + case 170: case 177: - case 181: - case 179: + case 173: + case 176: + case 174: + case 175: + case 178: case 182: - case 189: + case 180: + case 183: case 190: - case 192: + case 191: case 193: case 194: case 195: case 196: case 197: case 198: - case 201: + case 199: case 202: case 203: - case 238: - case 239: case 204: + case 239: + case 240: case 205: case 206: - case 241: - case 230: + case 207: + case 242: case 231: - case 235: - case 236: case 232: + case 236: case 237: + case 233: + case 238: return ts.forEachChild(node, isAssignedIn); } return false; } } - function resolveLocation(node) { - var containerNodes = []; - for (var parent_5 = node.parent; parent_5; parent_5 = parent_5.parent) { - if ((ts.isExpression(parent_5) || ts.isObjectLiteralMethod(node)) && - isContextSensitive(parent_5)) { - containerNodes.unshift(parent_5); - } - } - ts.forEach(containerNodes, function (node) { getTypeOfNode(node); }); - } - function getSymbolAtLocation(node) { - resolveLocation(node); - return getSymbolInfo(node); - } - function getTypeAtLocation(node) { - resolveLocation(node); - return getTypeOfNode(node); - } - function getTypeOfSymbolAtLocation(symbol, node) { - resolveLocation(node); - return getNarrowedTypeOfSymbol(symbol, node); - } function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); if (node && symbol.flags & 3) { @@ -14914,34 +15132,34 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 193: + case 194: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 179: + case 180: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 178: + case 179: if (child === node.right) { - if (node.operatorToken.kind === 49) { + if (node.operatorToken.kind === 50) { narrowedType = narrowType(type, node.left, true); } - else if (node.operatorToken.kind === 50) { + else if (node.operatorToken.kind === 51) { narrowedType = narrowType(type, node.left, false); } } break; - case 245: - case 215: - case 210: - case 140: - case 139: - case 142: - case 143: + case 246: + case 216: + case 211: case 141: + case 140: + case 143: + case 144: + case 142: break loop; } if (narrowedType !== type) { @@ -14955,21 +15173,21 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 173 || expr.right.kind !== 8) { + if (expr.left.kind !== 174 || expr.right.kind !== 9) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 66 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 67 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 32) { + if (expr.operatorToken.kind === 33) { assumeTrue = !assumeTrue; } if (assumeTrue) { if (!typeInfo) { - return removeTypesFromUnionType(type, 258 | 132 | 8 | 4194304, true, false); + return removeTypesFromUnionType(type, 258 | 132 | 8 | 16777216, true, false); } if (isTypeSubtypeOf(typeInfo.type, type)) { return typeInfo.type; @@ -15006,7 +15224,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 66 || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -15039,11 +15257,14 @@ var ts; return type; } function getNarrowedType(originalType, narrowedTypeCandidate) { - if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { - return narrowedTypeCandidate; - } if (originalType.flags & 16384) { - return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + return narrowedTypeCandidate; } return originalType; } @@ -15067,27 +15288,27 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 165: + case 166: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 169: + case 170: return narrowType(type, expr.expression, assumeTrue); - case 178: + case 179: var operator = expr.operatorToken.kind; - if (operator === 31 || operator === 32) { + if (operator === 32 || operator === 33) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 49) { + else if (operator === 50) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 50) { + else if (operator === 51) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 88) { + else if (operator === 89) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 176: - if (expr.operator === 47) { + case 177: + if (expr.operator === 48) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -15099,7 +15320,7 @@ var ts; var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 171) { + if (container.kind === 172) { if (languageVersion < 2) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -15130,15 +15351,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 241) { + symbol.valueDeclaration.parent.kind === 242) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 209) { + while (container.kind !== 210) { container = container.parent; } container = container.parent; - if (container.kind === 190) { + if (container.kind === 191) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -15156,7 +15377,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 138 || container.kind === 141) { + if (container.kind === 139 || container.kind === 142) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -15167,29 +15388,29 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 171) { + if (container.kind === 172) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 215: + case 216: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 214: + case 215: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 141: + case 142: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 139: case 138: - case 137: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 133: + case 134: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -15204,90 +15425,96 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 135) { + if (n.kind === 136) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 165 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 166 && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; + var container = ts.getSuperContainer(node, true); + var needToCaptureLexicalThis = false; + if (!isCallExpression) { + while (container && container.kind === 172) { + container = ts.getSuperContainer(container, true); + needToCaptureLexicalThis = languageVersion < 2; + } + } + var canUseSuperExpression = isLegalUsageOfSuperExpression(container); + var nodeCheckFlag = 0; + if (canUseSuperExpression) { + if ((container.flags & 128) || isCallExpression) { + nodeCheckFlag = 512; + } + else { + nodeCheckFlag = 256; + } + getNodeLinks(node).flags |= nodeCheckFlag; + if (needToCaptureLexicalThis) { + captureLexicalThis(node.parent, container); + } + } if (!baseClassType) { if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); } return unknownType; } - var container = ts.getSuperContainer(node, true); - if (container) { - var canUseSuperExpression = false; - var needToCaptureLexicalThis; + if (!canUseSuperExpression) { + if (container && container.kind === 134) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); + } + else if (isCallExpression) { + error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); + } + else { + error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; + } + if (container.kind === 142 && isInConstructorArgumentInitializer(node, container)) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + return nodeCheckFlag === 512 + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + function isLegalUsageOfSuperExpression(container) { + if (!container) { + return false; + } if (isCallExpression) { - canUseSuperExpression = container.kind === 141; + return container.kind === 142; } else { - needToCaptureLexicalThis = false; - while (container && container.kind === 171) { - container = ts.getSuperContainer(container, true); - needToCaptureLexicalThis = languageVersion < 2; - } if (container && ts.isClassLike(container.parent)) { if (container.flags & 128) { - canUseSuperExpression = + return container.kind === 141 || container.kind === 140 || - container.kind === 139 || - container.kind === 142 || - container.kind === 143; + container.kind === 143 || + container.kind === 144; } else { - canUseSuperExpression = + return container.kind === 141 || container.kind === 140 || - container.kind === 139 || - container.kind === 142 || - container.kind === 143 || - container.kind === 138 || - container.kind === 137 || - container.kind === 141; + container.kind === 143 || + container.kind === 144 || + container.kind === 139 || + container.kind === 138 || + container.kind === 142; } } } - if (canUseSuperExpression) { - var returnType; - if ((container.flags & 128) || isCallExpression) { - getNodeLinks(node).flags |= 512; - returnType = getBaseConstructorTypeOfClass(classType); - } - else { - getNodeLinks(node).flags |= 256; - returnType = baseClassType; - } - if (container.kind === 141 && isInConstructorArgumentInitializer(node, container)) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - returnType = unknownType; - } - if (!isCallExpression && needToCaptureLexicalThis) { - captureLexicalThis(node.parent, container); - } - return returnType; - } + return false; } - if (container && container.kind === 133) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); - } - else if (isCallExpression) { - error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); - } - else { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; } function getContextuallyTypedParameterType(parameter) { - if (isFunctionExpressionOrArrowFunction(parameter.parent)) { - var func = parameter.parent; + var func = parameter.parent; + if (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) { if (isContextSensitive(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -15312,14 +15539,14 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135) { + if (declaration.kind === 136) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; } } if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return getTypeFromBindingPattern(declaration.name, true); } } return undefined; @@ -15345,7 +15572,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 135 && node.parent.initializer === node) { + if (node.parent.kind === 136 && node.parent.initializer === node) { return true; } node = node.parent; @@ -15354,8 +15581,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 141 || - functionDecl.kind === 142 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 143))) { + functionDecl.kind === 142 || + functionDecl.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -15374,7 +15601,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 167) { + if (template.parent.kind === 168) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -15382,12 +15609,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 54 && operator <= 65) { + if (operator >= 55 && operator <= 66) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 50) { + else if (operator === 51) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -15474,7 +15701,7 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxExpression(expr) { - if (expr.parent.kind === 235) { + if (expr.parent.kind === 236) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -15484,7 +15711,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 236) { + if (expr.kind === 237) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -15502,38 +15729,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 208: - case 135: + case 209: + case 136: + case 139: case 138: - case 137: - case 160: - return getContextualTypeForInitializerExpression(node); - case 171: - case 201: - return getContextualTypeForReturnExpression(node); - case 181: - return getContextualTypeForYieldOperand(parent); - case 165: - case 166: - return getContextualTypeForArgument(parent, node); - case 168: - case 186: - return getTypeFromTypeNode(parent.type); - case 178: - return getContextualTypeForBinaryOperand(node); - case 242: - return getContextualTypeForObjectLiteralElement(parent); case 161: - return getContextualTypeForElementExpression(node); - case 179: - return getContextualTypeForConditionalOperand(node); - case 187: - ts.Debug.assert(parent.parent.kind === 180); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 172: + case 202: + return getContextualTypeForReturnExpression(node); + case 182: + return getContextualTypeForYieldOperand(parent); + case 166: + case 167: + return getContextualTypeForArgument(parent, node); case 169: + case 187: + return getTypeFromTypeNode(parent.type); + case 179: + return getContextualTypeForBinaryOperand(node); + case 243: + return getContextualTypeForObjectLiteralElement(parent); + case 162: + return getContextualTypeForElementExpression(node); + case 180: + return getContextualTypeForConditionalOperand(node); + case 188: + ts.Debug.assert(parent.parent.kind === 181); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 170: return getContextualType(parent); + case 238: case 237: - case 236: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -15548,7 +15775,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 170 || node.kind === 171; + return node.kind === 171 || node.kind === 172; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -15556,7 +15783,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -15570,16 +15797,12 @@ var ts; var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; - if (signatureList && - getSignaturesOfStructuredType(current, 0).length > 1) { - return undefined; - } var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { signatureList = [signature]; } - else if (!compareSignatures(signatureList[0], signature, false, compareTypes)) { + else if (!compareSignatures(signatureList[0], signature, false, true, compareTypes)) { return undefined; } else { @@ -15596,17 +15819,17 @@ var ts; return result; } function isInferentialContext(mapper) { - return mapper && mapper !== identityMapper; + return mapper && mapper.context; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 178 && parent.operatorToken.kind === 54 && parent.left === node) { + if (parent.kind === 179 && parent.operatorToken.kind === 55 && parent.left === node) { return true; } - if (parent.kind === 242) { + if (parent.kind === 243) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 161) { + if (parent.kind === 162) { return isAssignmentTarget(parent); } return false; @@ -15615,17 +15838,18 @@ var ts; var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } + function hasDefaultValue(node) { + return (node.kind === 161 && !!node.initializer) || + (node.kind === 179 && node.operatorToken.kind === 55); + } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; - if (!elements.length) { - return createArrayType(undefinedType); - } var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 182) { + if (inDestructuringPattern && e.kind === 183) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -15637,18 +15861,41 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 182; + hasSpreadElement = hasSpreadElement || e.kind === 183; } if (!hasSpreadElement) { + if (inDestructuringPattern && elementTypes.length) { + var type = createNewTupleType(elementTypes); + type.pattern = node; + return type; + } var contextualType = getContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) { - return createTupleType(elementTypes); + if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { + var pattern = contextualType.pattern; + if (pattern && (pattern.kind === 160 || pattern.kind === 162)) { + var patternElements = pattern.elements; + for (var i = elementTypes.length; i < patternElements.length; i++) { + var patternElement = patternElements[i]; + if (hasDefaultValue(patternElement)) { + elementTypes.push(contextualType.elementTypes[i]); + } + else { + if (patternElement.kind !== 185) { + error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + elementTypes.push(unknownType); + } + } + } + if (elementTypes.length) { + return createTupleType(elementTypes); + } } } - return createArrayType(getUnionType(elementTypes)); + return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 133 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 134 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -15663,7 +15910,7 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 4194304)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 16777216)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -15677,26 +15924,43 @@ var ts; var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); - var typeFlags; + var contextualTypeHasPattern = contextualType && contextualType.pattern && + (contextualType.pattern.kind === 159 || contextualType.pattern.kind === 163); + var inDestructuringPattern = isAssignmentTarget(node); + var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 242 || - memberDecl.kind === 243 || + if (memberDecl.kind === 243 || + memberDecl.kind === 244 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 242) { + if (memberDecl.kind === 243) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 140) { + else if (memberDecl.kind === 141) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 243); + ts.Debug.assert(memberDecl.kind === 244); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); + if (inDestructuringPattern) { + if (memberDecl.kind === 243 && hasDefaultValue(memberDecl.initializer)) { + prop.flags |= 536870912; + } + } + else if (contextualTypeHasPattern) { + var impliedProp = getPropertyOfType(contextualType, member.name); + if (impliedProp) { + prop.flags |= impliedProp.flags & 536870912; + } + else if (!compilerOptions.suppressExcessPropertyErrors) { + error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); + } + } prop.declarations = member.declarations; prop.parent = member.parent; if (member.valueDeclaration) { @@ -15707,7 +15971,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 142 || memberDecl.kind === 143); + ts.Debug.assert(memberDecl.kind === 143 || memberDecl.kind === 144); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -15715,10 +15979,26 @@ var ts; } propertiesArray.push(member); } + if (contextualTypeHasPattern) { + for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) { + var prop = _c[_b]; + if (!ts.hasProperty(propertiesTable, prop.name)) { + if (!(prop.flags & 536870912)) { + error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + propertiesTable[prop.name] = prop; + propertiesArray.push(prop); + } + } + } var stringIndexType = getIndexType(0); var numberIndexType = getIndexType(1); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 524288 | 2097152 | (typeFlags & 1048576); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; + result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); + if (inDestructuringPattern) { + result.pattern = node; + } return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -15747,31 +16027,34 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 66) { + if (lhs.kind === 67) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && tagNamesAreEquivalent(lhs.left, rhs.left); } function checkJsxElement(node) { + checkJsxOpeningLikeElement(node.openingElement); if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); } - checkJsxOpeningLikeElement(node.openingElement); + else { + getJsxElementTagSymbol(node.closingElement); + } for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 237: + case 238: checkJsxExpression(child); break; - case 230: + case 231: checkJsxElement(child); break; - case 231: + case 232: checkJsxSelfClosingElement(child); break; default: - ts.Debug.assert(child.kind === 233); + ts.Debug.assert(child.kind === 234); } } return jsxElementType || anyType; @@ -15780,7 +16063,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 132) { + if (tagName.kind === 133) { return false; } else { @@ -15795,9 +16078,17 @@ var ts; else if (elementAttributesType && !isTypeAny(elementAttributesType)) { var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; + if (isUnhyphenatedJsxName(node.name.text)) { + var indexerType = getIndexTypeOfType(elementAttributesType, 0); + if (indexerType) { + correspondingPropType = indexerType; + } + else { + if (!correspondingPropType) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } } } var exprType; @@ -15860,7 +16151,7 @@ var ts; links.jsxFlags |= 2; return intrinsicElementsType.symbol; } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, 'JSX.' + JsxNames.IntrinsicElements); + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); return unknownSymbol; } else { @@ -15870,26 +16161,26 @@ var ts; } } function lookupClassTag(node) { - var valueSymbol; - if (node.tagName.kind === 66) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - valueSymbol = sym.exportSymbol || sym; - } - else { - valueSymbol = checkQualifiedName(node.tagName).symbol; - } + var valueSymbol = resolveJsxTagName(node); if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4; getSymbolLinks(valueSymbol).referenced = true; } return valueSymbol || unknownSymbol; } + function resolveJsxTagName(node) { + if (node.tagName.kind === 67) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } } function getJsxElementInstanceType(node) { - if (!(getNodeLinks(node).jsxFlags & 4)) { - return undefined; - } + ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4), "Should not call getJsxElementInstanceType on non-class Element"); var classSymbol = getJsxElementTagSymbol(node); if (classSymbol === unknownSymbol) { return anyType; @@ -15903,14 +16194,10 @@ var ts; signatures = getSignaturesOfType(valueType, 0); if (signatures.length === 0) { error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); - return undefined; + return unknownType; } } - var returnType = getUnionType(signatures.map(function (s) { return getReturnTypeOfSignature(s); })); - if (!isTypeAny(returnType) && !(returnType.flags & 80896)) { - error(node.tagName, ts.Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); - return undefined; - } + var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); var elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); @@ -15945,7 +16232,7 @@ var ts; if (links.jsxFlags & 4) { var elemInstanceType = getJsxElementInstanceType(node); if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = anyType; + return links.resolvedJsxType = elemInstanceType; } var propsName = getJsxElementPropertiesName(); if (propsName === undefined) { @@ -16013,7 +16300,7 @@ var ts; checkGrammarJsxElement(node); checkJsxPreconditions(node); if (compilerOptions.jsx === 2) { - var reactSym = resolveName(node.tagName, 'React', 107455, ts.Diagnostics.Cannot_find_name_0, 'React'); + var reactSym = resolveName(node.tagName, "React", 107455, ts.Diagnostics.Cannot_find_name_0, "React"); if (reactSym) { getSymbolLinks(reactSym).referenced = true; } @@ -16022,11 +16309,11 @@ var ts; var nameTable = {}; var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 235) { + if (node.attributes[i].kind === 236) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 236); + ts.Debug.assert(node.attributes[i].kind === 237); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -16052,7 +16339,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 138; + return s.valueDeclaration ? s.valueDeclaration.kind : 139; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -16060,11 +16347,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 92) { - var errorNode = node.kind === 163 ? + if (left.kind === 93) { + var errorNode = node.kind === 164 ? node.name : node.right; - if (getDeclarationKindFromSymbol(prop) !== 140) { + if (getDeclarationKindFromSymbol(prop) !== 141) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -16085,7 +16372,7 @@ var ts; } return true; } - if (left.kind === 92) { + if (left.kind === 93) { return true; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -16130,7 +16417,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 163 + var left = node.kind === 164 ? node.expression : node.left; var type = checkExpression(left); @@ -16145,7 +16432,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 166 && node.parent.expression === node) { + if (node.parent.kind === 167 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -16163,7 +16450,7 @@ var ts; } var isConstEnum = isConstEnumObjectType(objectType); if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 8)) { + (!node.argumentExpression || node.argumentExpression.kind !== 9)) { error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } @@ -16181,7 +16468,7 @@ var ts; } } } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 4194304)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 16777216)) { if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132)) { var numberIndexType = getIndexTypeOfType(objectType, 1); if (numberIndexType) { @@ -16201,7 +16488,7 @@ var ts; return unknownType; } function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 8 || indexArgumentExpression.kind === 7) { + if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { @@ -16217,7 +16504,7 @@ var ts; if (!ts.isWellKnownSymbolSyntactically(expression)) { return false; } - if ((expressionType.flags & 4194304) === 0) { + if ((expressionType.flags & 16777216) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -16241,10 +16528,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 167) { + if (node.kind === 168) { checkExpression(node.template); } - else if (node.kind !== 136) { + else if (node.kind !== 137) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -16266,19 +16553,19 @@ var ts; for (var _i = 0; _i < signatures.length; _i++) { var signature = signatures[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_6 = signature.declaration && signature.declaration.parent; + var parent_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_6 === lastParent) { + if (lastParent && parent_5 === lastParent) { index++; } else { - lastParent = parent_6; + lastParent = parent_5; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_6; + lastParent = parent_5; } lastSymbol = symbol; if (signature.hasStringLiterals) { @@ -16295,7 +16582,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 182) { + if (arg && arg.kind === 183) { return i; } } @@ -16307,11 +16594,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 167) { + if (node.kind === 168) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 180) { + if (tagExpression.template.kind === 181) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -16319,11 +16606,11 @@ var ts; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 10); + ts.Debug.assert(templateLiteral.kind === 11); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 136) { + else if (node.kind === 137) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -16331,7 +16618,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 166); + ts.Debug.assert(callExpression.kind === 167); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -16384,7 +16671,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 184) { + if (arg === undefined || arg.kind !== 185) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -16431,11 +16718,11 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 184) { + if (arg === undefined || arg.kind !== 185) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { - argType = arg.kind === 8 && !reportErrors + argType = arg.kind === 9 && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -16450,16 +16737,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 167) { + if (node.kind === 168) { var template = node.template; args = [undefined]; - if (template.kind === 180) { + if (template.kind === 181) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 136) { + else if (node.kind === 137) { return undefined; } else { @@ -16468,18 +16755,18 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 136) { + if (node.kind === 137) { switch (node.parent.kind) { - case 211: - case 183: + case 212: + case 184: return 1; - case 138: + case 139: return 2; - case 140: - case 142: + case 141: case 143: + case 144: return signature.parameters.length >= 3 ? 3 : 2; - case 135: + case 136: return 3; } } @@ -16489,20 +16776,20 @@ var ts; } function getEffectiveDecoratorFirstArgumentType(node) { switch (node.kind) { - case 211: - case 183: + case 212: + case 184: var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 135: + case 136: node = node.parent; - if (node.kind === 141) { + if (node.kind === 142) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } - case 138: - case 140: - case 142: + case 139: + case 141: case 143: + case 144: return getParentTypeOfClassElement(node); default: ts.Debug.fail("Unsupported decorator target."); @@ -16511,27 +16798,27 @@ var ts; } function getEffectiveDecoratorSecondArgumentType(node) { switch (node.kind) { - case 211: + case 212: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 135: + case 136: node = node.parent; - if (node.kind === 141) { + if (node.kind === 142) { return anyType; } - case 138: - case 140: - case 142: + case 139: + case 141: case 143: + case 144: var element = node; switch (element.name.kind) { - case 66: - case 7: + case 67: case 8: + case 9: return getStringLiteralType(element.name); - case 133: + case 134: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 4194304)) { + if (allConstituentTypesHaveKind(nameType, 16777216)) { return nameType; } else { @@ -16548,17 +16835,17 @@ var ts; } function getEffectiveDecoratorThirdArgumentType(node) { switch (node.kind) { - case 211: + case 212: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 135: + case 136: return numberType; - case 138: + case 139: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 140: - case 142: + case 141: case 143: + case 144: var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); default: @@ -16580,26 +16867,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 136) { + if (node.kind === 137) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 167) { + else if (argIndex === 0 && node.kind === 168) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 136 || - (argIndex === 0 && node.kind === 167)) { + if (node.kind === 137 || + (argIndex === 0 && node.kind === 168)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 136) { + if (node.kind === 137) { return node.expression; } - else if (argIndex === 0 && node.kind === 167) { + else if (argIndex === 0 && node.kind === 168) { return node.template; } else { @@ -16607,12 +16894,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 167; - var isDecorator = node.kind === 136; + var isTaggedTemplate = node.kind === 168; + var isDecorator = node.kind === 137; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 92) { + if (node.expression.kind !== 93) { ts.forEach(typeArguments, checkSourceElement); } } @@ -16675,6 +16962,9 @@ var ts; for (var _i = 0; _i < candidates.length; _i++) { var candidate = candidates[_i]; if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); + } return candidate; } } @@ -16747,7 +17037,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -16792,7 +17082,7 @@ var ts; if (expressionType === unknownType) { return resolveErrorCall(node); } - var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 211); + var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); if (valueDecl && valueDecl.flags & 256) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); @@ -16836,16 +17126,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 211: - case 183: + case 212: + case 184: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 135: + case 136: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 138: + case 139: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 140: - case 142: + case 141: case 143: + case 144: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -16873,16 +17163,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 165) { + if (node.kind === 166) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 166) { + else if (node.kind === 167) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 167) { + else if (node.kind === 168) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 136) { + else if (node.kind === 137) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -16894,15 +17184,15 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { return voidType; } - if (node.kind === 166) { + if (node.kind === 167) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 141 && - declaration.kind !== 145 && - declaration.kind !== 150) { + declaration.kind !== 142 && + declaration.kind !== 146 && + declaration.kind !== 151) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -16915,7 +17205,7 @@ var ts; return getReturnTypeOfSignature(getResolvedSignature(node)); } function checkAssertion(node) { - var exprType = checkExpression(node.expression); + var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { var widenedType = getWidenedType(exprType); @@ -16934,18 +17224,27 @@ var ts; var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeAtPosition(context, i), mapper); + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { var parameter = ts.lastOrUndefined(signature.parameters); - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } + } + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + var links = getSymbolLinks(parameter); + if (!links.type) { + links.type = instantiateType(contextualType, mapper); + } + else if (isInferentialContext(mapper)) { + inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); } } function createPromiseType(promisedType) { var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyObjectType) { + if (globalPromiseType !== emptyGenericType) { promisedType = getAwaitedType(promisedType); return createTypeReference(globalPromiseType, [promisedType]); } @@ -16958,7 +17257,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 189) { + if (func.body.kind !== 190) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -17062,7 +17361,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 205); + return (body.statements.length === 1) && (body.statements[0].kind === 206); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -17071,7 +17370,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 189) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 190) { return; } var bodyBlock = func.body; @@ -17084,9 +17383,9 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 170) { + if (!hasGrammarError && node.kind === 171) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -17098,33 +17397,38 @@ var ts; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); - if (!(links.flags & 1024)) { + var contextSensitive = isContextSensitive(node); + var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + if (mightFixTypeParameters || !(links.flags & 1024)) { var contextualSignature = getContextualSignature(node); - if (!(links.flags & 1024)) { + var contextChecked = !!(links.flags & 1024); + if (mightFixTypeParameters || !contextChecked) { links.flags |= 1024; if (contextualSignature) { var signature = getSignaturesOfType(type, 0)[0]; - if (isContextSensitive(node)) { + if (contextSensitive) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type && !signature.resolvedReturnType) { + if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { var returnType = getReturnTypeFromBody(node, contextualMapper); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } } - checkSignatureDeclaration(node); + if (!contextChecked) { + checkSignatureDeclaration(node); + } } } - if (produceDiagnostics && node.kind !== 140 && node.kind !== 139) { + if (produceDiagnostics && node.kind !== 141 && node.kind !== 140) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -17141,7 +17445,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 189) { + if (node.body.kind === 190) { checkSourceElement(node.body); } else { @@ -17173,17 +17477,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 66: { + case 67: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 163: { + case 164: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 164: + case 165: return true; - case 169: + case 170: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -17191,22 +17495,22 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 66: - case 163: { + case 67: + case 164: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; } - case 164: { + case 165: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 8) { + if (symbol && index && index.kind === 9) { var name_12 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768) !== 0; } return false; } - case 169: + case 170: return isConstVariableReference(n.expression); default: return false; @@ -17249,17 +17553,17 @@ var ts; function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 34: case 35: - case 48: - if (someConstituentTypeHasKind(operandType, 4194304)) { + case 36: + case 49: + if (someConstituentTypeHasKind(operandType, 16777216)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 47: + case 48: return booleanType; - case 39: case 40: + case 41: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); @@ -17315,7 +17619,7 @@ var ts; return (symbol.flags & 128) !== 0; } function checkInstanceOfExpression(node, leftType, rightType) { - if (allConstituentTypesHaveKind(leftType, 4194814)) { + if (allConstituentTypesHaveKind(leftType, 16777726)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { @@ -17324,7 +17628,7 @@ var ts; return booleanType; } function checkInExpression(node, leftType, rightType) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 4194304)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 16777216)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { @@ -17336,7 +17640,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 242 || p.kind === 243) { + if (p.kind === 243 || p.kind === 244) { var name_13 = p.name; var type = isTypeAny(sourceType) ? sourceType @@ -17361,8 +17665,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184) { - if (e.kind !== 182) { + if (e.kind !== 185) { + if (e.kind !== 183) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -17387,7 +17691,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 178 && restExpression.operatorToken.kind === 54) { + if (restExpression.kind === 179 && restExpression.operatorToken.kind === 55) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -17400,14 +17704,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 178 && target.operatorToken.kind === 54) { + if (target.kind === 179 && target.operatorToken.kind === 55) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 162) { + if (target.kind === 163) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 161) { + if (target.kind === 162) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -17421,32 +17725,32 @@ var ts; } function checkBinaryExpression(node, contextualMapper) { var operator = node.operatorToken.kind; - if (operator === 54 && (node.left.kind === 162 || node.left.kind === 161)) { + if (operator === 55 && (node.left.kind === 163 || node.left.kind === 162)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 36: - case 57: case 37: case 58: case 38: case 59: - case 35: - case 56: - case 41: + case 39: case 60: + case 36: + case 57: case 42: case 61: case 43: case 62: - case 45: - case 64: - case 46: - case 65: case 44: case 63: + case 46: + case 65: + case 47: + case 66: + case 45: + case 64: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17465,8 +17769,8 @@ var ts; } } return numberType; - case 34: - case 55: + case 35: + case 56: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17490,42 +17794,42 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 55) { + if (operator === 56) { checkAssignmentOperator(resultType); } return resultType; - case 24: - case 26: + case 25: case 27: case 28: + case 29: if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - case 29: case 30: case 31: case 32: + case 33: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 88: + case 89: return checkInstanceOfExpression(node, leftType, rightType); - case 87: + case 88: return checkInExpression(node, leftType, rightType); - case 49: - return rightType; case 50: - return getUnionType([leftType, rightType]); - case 54: - checkAssignmentOperator(rightType); return rightType; - case 23: + case 51: + return getUnionType([leftType, rightType]); + case 55: + checkAssignmentOperator(rightType); + return getRegularTypeOfObjectLiteral(rightType); + case 24: return rightType; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 4194304) ? node.left : - someConstituentTypeHasKind(rightType, 4194304) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? node.left : + someConstituentTypeHasKind(rightType, 16777216) ? node.right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -17535,21 +17839,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 46: + case 65: + return 51; + case 47: + case 66: + return 33; case 45: case 64: return 50; - case 46: - case 65: - return 32; - case 44: - case 63: - return 49; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 54 && operator <= 65) { + if (produceDiagnostics && operator >= 55 && operator <= 66) { var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { checkTypeAssignableTo(valueType, leftType, node.left, undefined); @@ -17633,21 +17937,21 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (contextualMapper && contextualMapper !== identityMapper) { + if (isInferentialContext(contextualMapper)) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getContextualType(node); @@ -17663,7 +17967,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 132) { + if (node.kind === 133) { type = checkQualifiedName(node); } else { @@ -17671,9 +17975,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 163 && node.parent.expression === node) || - (node.parent.kind === 164 && node.parent.expression === node) || - ((node.kind === 66 || node.kind === 132) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 164 && node.parent.expression === node) || + (node.parent.kind === 165 && node.parent.expression === node) || + ((node.kind === 67 || node.kind === 133) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -17686,78 +17990,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 66: + case 67: return checkIdentifier(node); - case 94: + case 95: return checkThisExpression(node); - case 92: + case 93: return checkSuperExpression(node); - case 90: + case 91: return nullType; - case 96: - case 81: + case 97: + case 82: return booleanType; - case 7: - return checkNumericLiteral(node); - case 180: - return checkTemplateExpression(node); case 8: - case 10: - return stringType; - case 9: - return globalRegExpType; - case 161: - return checkArrayLiteral(node, contextualMapper); - case 162: - return checkObjectLiteral(node, contextualMapper); - case 163: - return checkPropertyAccessExpression(node); - case 164: - return checkIndexedAccess(node); - case 165: - case 166: - return checkCallExpression(node); - case 167: - return checkTaggedTemplateExpression(node); - case 169: - return checkExpression(node.expression, contextualMapper); - case 183: - return checkClassExpression(node); - case 170: - case 171: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 173: - return checkTypeOfExpression(node); - case 168: - case 186: - return checkAssertion(node); - case 172: - return checkDeleteExpression(node); - case 174: - return checkVoidExpression(node); - case 175: - return checkAwaitExpression(node); - case 176: - return checkPrefixUnaryExpression(node); - case 177: - return checkPostfixUnaryExpression(node); - case 178: - return checkBinaryExpression(node, contextualMapper); - case 179: - return checkConditionalExpression(node, contextualMapper); - case 182: - return checkSpreadElementExpression(node, contextualMapper); - case 184: - return undefinedType; + return checkNumericLiteral(node); case 181: + return checkTemplateExpression(node); + case 9: + case 11: + return stringType; + case 10: + return globalRegExpType; + case 162: + return checkArrayLiteral(node, contextualMapper); + case 163: + return checkObjectLiteral(node, contextualMapper); + case 164: + return checkPropertyAccessExpression(node); + case 165: + return checkIndexedAccess(node); + case 166: + case 167: + return checkCallExpression(node); + case 168: + return checkTaggedTemplateExpression(node); + case 170: + return checkExpression(node.expression, contextualMapper); + case 184: + return checkClassExpression(node); + case 171: + case 172: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 174: + return checkTypeOfExpression(node); + case 169: + case 187: + return checkAssertion(node); + case 173: + return checkDeleteExpression(node); + case 175: + return checkVoidExpression(node); + case 176: + return checkAwaitExpression(node); + case 177: + return checkPrefixUnaryExpression(node); + case 178: + return checkPostfixUnaryExpression(node); + case 179: + return checkBinaryExpression(node, contextualMapper); + case 180: + return checkConditionalExpression(node, contextualMapper); + case 183: + return checkSpreadElementExpression(node, contextualMapper); + case 185: + return undefinedType; + case 182: return checkYieldExpression(node); - case 237: + case 238: return checkJsxExpression(node); - case 230: - return checkJsxElement(node); case 231: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 232: + return checkJsxSelfClosingElement(node); + case 233: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -17773,16 +18077,12 @@ var ts; } } function checkParameter(node) { - // Grammar checking - // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the - // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code - // or if its FunctionBody is strict code(11.1.5). checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 141 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 142 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -17797,15 +18097,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 140 || - node.kind === 210 || - node.kind === 170; + return node.kind === 141 || + node.kind === 211 || + node.kind === 171; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 66 && + if (param.name.kind === 67 && param.name.text === parameter.text) { return i; } @@ -17815,30 +18115,30 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { + case 172: + case 145: + case 211: case 171: - case 144: - case 210: - case 170: - case 149: + case 150: + case 141: case 140: - case 139: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { - if (node.kind === 146) { + if (node.kind === 147) { checkGrammarIndexSignature(node); } - else if (node.kind === 149 || node.kind === 210 || node.kind === 150 || - node.kind === 144 || node.kind === 141 || - node.kind === 145) { + else if (node.kind === 150 || node.kind === 211 || node.kind === 151 || + node.kind === 145 || node.kind === 142 || + node.kind === 146) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 147) { + if (node.type.kind === 148) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -17847,7 +18147,7 @@ var ts; error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); } } else if (typePredicateNode.parameterName) { @@ -17857,19 +18157,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 158 || - param.name.kind === 159) { + if (param.name.kind === 159 || + param.name.kind === 160) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 66 && + if (element.name.kind === 67 && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 159 || - element.name.kind === 158) { + else if (element.name.kind === 160 || + element.name.kind === 159) { checkBindingPattern(element.name); } } @@ -17893,10 +18193,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 145: + case 146: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 144: + case 145: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -17918,7 +18218,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 212) { + if (node.kind === 213) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -17933,7 +18233,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 127: + case 128: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -17941,7 +18241,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 125: + case 126: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -17981,48 +18281,69 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 165 && n.expression.kind === 92; + return n.kind === 166 && n.expression.kind === 93; + } + function containsSuperCallAsComputedPropertyName(n) { + return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } - switch (n.kind) { - case 170: - case 210: - case 171: - case 162: return false; - default: return ts.forEachChild(n, containsSuperCall); + else if (ts.isFunctionLike(n)) { + return false; } + else if (ts.isClassLike(n)) { + return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); + } + return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 94) { + if (n.kind === 95) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 170 && n.kind !== 210) { + else if (n.kind !== 171 && n.kind !== 211) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 138 && + return n.kind === 139 && !(n.flags & 128) && !!n.initializer; } - if (ts.getClassExtendsHeritageClauseElement(node.parent)) { + var containingClassDecl = node.parent; + if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + var containingClassSymbol = getSymbolOfNode(containingClassDecl); + var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); if (containsSuperCall(node.body)) { + if (baseConstructorType === nullType) { + error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 192 || !isSuperCallExpression(statements[0].expression)) { + var superCallStatement; + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (statement.kind === 193 && isSuperCallExpression(statement.expression)) { + superCallStatement = statement; + break; + } + if (!ts.isPrologueDirective(statement)) { + break; + } + } + if (!superCallStatement) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { - markThisReferencesAsErrors(statements[0].expression); + markThisReferencesAsErrors(superCallStatement.expression); } } } - else { + else if (baseConstructorType !== nullType) { error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -18030,13 +18351,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 142) { + if (node.kind === 143) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 142 ? 143 : 142; + var otherKind = node.kind === 143 ? 144 : 143; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -18121,9 +18442,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 212) { - ts.Debug.assert(signatureDeclarationNode.kind === 144 || signatureDeclarationNode.kind === 145); - var signatureKind = signatureDeclarationNode.kind === 144 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213) { + ts.Debug.assert(signatureDeclarationNode.kind === 145 || signatureDeclarationNode.kind === 146); + var signatureKind = signatureDeclarationNode.kind === 145 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -18141,7 +18462,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 212 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 213 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -18217,7 +18538,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 140 || node.kind === 139); + ts.Debug.assert(node.kind === 141 || node.kind === 140); ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -18249,11 +18570,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 212 || node.parent.kind === 152 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 213 || node.parent.kind === 153 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 210 || node.kind === 140 || node.kind === 139 || node.kind === 141) { + if (node.kind === 211 || node.kind === 141 || node.kind === 140 || node.kind === 142) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -18332,35 +18653,50 @@ var ts; } var exportedDeclarationSpaces = 0; var nonExportedDeclarationSpaces = 0; - ts.forEach(symbol.declarations, function (d) { + var defaultExportedDeclarationSpaces = 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - if (getEffectiveDeclarationFlags(d, 1)) { - exportedDeclarationSpaces |= declarationSpaces; + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 1024); + if (effectiveDeclarationFlags & 1) { + if (effectiveDeclarationFlags & 1024) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } } else { nonExportedDeclarationSpaces |= declarationSpaces; } - }); - var commonDeclarationSpace = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - if (commonDeclarationSpace) { - ts.forEach(symbol.declarations, function (d) { - if (getDeclarationSpaces(d) & commonDeclarationSpace) { + } + var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declarationSpaces = getDeclarationSpaces(d); + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); } - }); + } } function getDeclarationSpaces(d) { switch (d.kind) { - case 212: + case 213: return 2097152; - case 215: - return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 + case 216: + return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 211: - case 214: + case 212: + case 215: return 2097152 | 1048576; - case 218: + case 219: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -18383,15 +18719,6 @@ var ts; return type; } function getPromisedType(promise) { - // - // { // promise - // then( // thenFunction - // onfulfilled: ( // onfulfilledParameterType - // value: T // valueParameterType - // ) => any - // ): any; - // } - // if (promise.flags & 1) { return undefined; } @@ -18495,22 +18822,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 211: + case 212: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 135: + case 136: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 138: + case 139: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 140: - case 142: + case 141: case 143: + case 144: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -18519,29 +18846,33 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 148) { + if (node && node.kind === 149) { var root = getFirstIdentifier(node.typeName); - var rootSymbol = resolveName(root, root.text, 107455, undefined, undefined); - if (rootSymbol && rootSymbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); + var meaning = root.parent.kind === 149 ? 793056 : 1536; + var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); + if (rootSymbol && rootSymbol.flags & 8388608) { + var aliasTarget = resolveAlias(rootSymbol); + if (aliasTarget.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } } } } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 138: + case 139: checkTypeNodeAsExpression(node.type); break; - case 135: + case 136: checkTypeNodeAsExpression(node.type); break; - case 140: - checkTypeNodeAsExpression(node.type); - break; - case 142: + case 141: checkTypeNodeAsExpression(node.type); break; case 143: + checkTypeNodeAsExpression(node.type); + break; + case 144: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -18564,24 +18895,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 211: + case 212: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 140: + case 141: checkParameterTypeAnnotationsAsExpressions(node); + case 144: case 143: - case 142: - case 138: - case 135: + case 139: + case 136: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 135) { + if (node.kind === 136) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -18604,7 +18935,7 @@ var ts; } emitAwaiter = true; } - if (node.name && node.name.kind === 133) { + if (node.name && node.name.kind === 134) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -18639,11 +18970,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 189) { + if (node.kind === 190) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 216) { + if (ts.isFunctionBlock(node) || node.kind === 217) { checkFunctionAndClassExpressionBodies(node); } } @@ -18661,19 +18992,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 138 || - node.kind === 137 || + if (node.kind === 139 || + node.kind === 138 || + node.kind === 141 || node.kind === 140 || - node.kind === 139 || - node.kind === 142 || - node.kind === 143) { + node.kind === 143 || + node.kind === 144) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 135 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 136 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -18687,7 +19018,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 66; + var isDeclaration_1 = node.kind !== 67; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -18708,7 +19039,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 66; + var isDeclaration_2 = node.kind !== 67; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -18721,22 +19052,19 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 215 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 216 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 245 && ts.isExternalModule(parent)) { + if (parent.kind === 246 && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkVarDeclaredNamesNotShadowed(node) { - // - ScriptBody : StatementList - // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList - // also occurs in the VarDeclaredNames of StatementList. if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 208 && !node.initializer) { + if (node.kind === 209 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -18746,15 +19074,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 209); - var container = varDeclList.parent.kind === 190 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210); + var container = varDeclList.parent.kind === 191 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 189 && ts.isFunctionLike(container.parent) || + (container.kind === 190 && ts.isFunctionLike(container.parent) || + container.kind === 217 || container.kind === 216 || - container.kind === 215 || - container.kind === 245); + container.kind === 246); if (!namesShareScope) { var name_14 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_14, name_14); @@ -18764,16 +19092,16 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 135) { + if (ts.getRootDeclaration(node).kind !== 136) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 66) { + if (n.kind === 67) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 135) { + if (referencedSymbol.valueDeclaration.kind === 136) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -18793,7 +19121,7 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -18802,7 +19130,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 135 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 136 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -18830,9 +19158,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 138 && node.kind !== 137) { + if (node.kind !== 139 && node.kind !== 138) { checkExportsOnMergedDeclarations(node); - if (node.kind === 208 || node.kind === 160) { + if (node.kind === 209 || node.kind === 161) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -18853,7 +19181,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 162) { + if (node.modifiers && node.parent.kind === 163) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -18886,12 +19214,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 209) { + if (node.initializer && node.initializer.kind === 210) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -18906,13 +19234,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 161 || varExpr.kind === 162) { + if (varExpr.kind === 162 || varExpr.kind === 163) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -18927,7 +19255,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -18937,7 +19265,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 161 || varExpr.kind === 162) { + if (varExpr.kind === 162 || varExpr.kind === 163) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -19099,7 +19427,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 142 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 143))); + return !!(node.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -19117,10 +19445,10 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 143) { + if (func.kind === 144) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 141) { + else if (func.kind === 142) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -19153,7 +19481,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 239 && !hasDuplicateDefaultClause) { + if (clause.kind === 240 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -19165,7 +19493,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 238) { + if (produceDiagnostics && clause.kind === 239) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -19182,7 +19510,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 204 && current.label.text === node.label.text) { + if (current.kind === 205 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -19208,7 +19536,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 66) { + if (catchClause.variableDeclaration.name.kind !== 67) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -19276,7 +19604,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 133 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 134 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -19354,6 +19682,7 @@ var ts; if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; var staticBaseType = getBaseConstructorTypeOfClass(type); + checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { @@ -19403,20 +19732,10 @@ var ts; function getTargetSymbol(s) { return s.flags & 16777216 ? getSymbolLinks(s).target : s; } + function getClassLikeDeclarationOfSymbol(symbol) { + return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); + } function checkKindsOfPropertyMemberOverrides(type, baseType) { - // TypeScript 1.0 spec (April 2014): 8.2.3 - // A derived class inherits all members from its base class it doesn't override. - // Inheritance means that a derived class implicitly contains all non - overridden members of the base class. - // Both public and private property members are inherited, but only public property members can be overridden. - // A property member in a derived class is said to override a property member in a base class - // when the derived class property member has the same name and kind(instance or static) - // as the base class property member. - // The type of an overriding property member must be assignable(section 3.8.4) - // to the type of the overridden property member, or otherwise a compile - time error occurs. - // Base class instance member functions can be overridden by derived class instance member functions, - // but not by other kinds of members. - // Base class instance member variables and accessors can be overridden by - // derived class instance member variables and accessors, but not by other kinds of members. var baseProperties = getPropertiesOfObjectType(baseType); for (var _i = 0; _i < baseProperties.length; _i++) { var baseProperty = baseProperties[_i]; @@ -19429,9 +19748,14 @@ var ts; ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { if (derived === base) { - var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 211); + var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + if (derivedClassDecl.kind === 184) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } } } else { @@ -19470,7 +19794,7 @@ var ts; } } function isAccessor(kind) { - return kind === 142 || kind === 143; + return kind === 143 || kind === 144; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -19536,7 +19860,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 212); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -19554,7 +19878,7 @@ var ts; if (symbol && symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 211 && !ts.isInAmbientContext(declaration)) { + if (declaration.kind === 212 && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -19586,28 +19910,12 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 133 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 134 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer); - if (autoValue === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (!ambient) { - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); - } - } - else if (enumIsConst) { - if (isNaN(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { autoValue = undefined; @@ -19618,22 +19926,42 @@ var ts; }); nodeLinks.flags |= 8192; } - function getConstantValueForEnumMemberInitializer(initializer) { - return evalConstant(initializer); + function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { + var reportError = true; + var value = evalConstant(initializer); + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + return value; function evalConstant(e) { switch (e.kind) { - case 176: - var value = evalConstant(e.operand); - if (value === undefined) { + case 177: + var value_1 = evalConstant(e.operand); + if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 34: return value; - case 35: return -value; - case 48: return ~value; + case 35: return value_1; + case 36: return -value_1; + case 49: return ~value_1; } return undefined; - case 178: + case 179: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -19643,39 +19971,39 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 45: return left | right; - case 44: return left & right; - case 42: return left >> right; - case 43: return left >>> right; - case 41: return left << right; - case 46: return left ^ right; - case 36: return left * right; - case 37: return left / right; - case 34: return left + right; - case 35: return left - right; - case 38: return left % right; + case 46: return left | right; + case 45: return left & right; + case 43: return left >> right; + case 44: return left >>> right; + case 42: return left << right; + case 47: return left ^ right; + case 37: return left * right; + case 38: return left / right; + case 35: return left + right; + case 36: return left - right; + case 39: return left % right; } return undefined; - case 7: + case 8: return +e.text; - case 169: + case 170: return evalConstant(e.expression); - case 66: + case 67: + case 165: case 164: - case 163: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType; + var enumType_1; var propertyName; - if (e.kind === 66) { - enumType = currentType; + if (e.kind === 67) { + enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 164) { + if (e.kind === 165) { if (e.argumentExpression === undefined || - e.argumentExpression.kind !== 8) { + e.argumentExpression.kind !== 9) { return undefined; } expression = e.expression; @@ -19687,25 +20015,25 @@ var ts; } var current = expression; while (current) { - if (current.kind === 66) { + if (current.kind === 67) { break; } - else if (current.kind === 163) { + else if (current.kind === 164) { current = current.expression; } else { return undefined; } } - enumType = checkExpression(expression); - if (!(enumType.symbol && (enumType.symbol.flags & 384))) { + enumType_1 = checkExpression(expression); + if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384))) { return undefined; } } if (propertyName === undefined) { return undefined; } - var property = getPropertyOfObjectType(enumType, propertyName); + var property = getPropertyOfObjectType(enumType_1, propertyName); if (!property || !(property.flags & 8)) { return undefined; } @@ -19714,6 +20042,8 @@ var ts; return undefined; } if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; } return getNodeLinks(propertyDecl).enumMemberValue; @@ -19747,7 +20077,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 214) { + if (declaration.kind !== 215) { return false; } var enumDeclaration = declaration; @@ -19770,8 +20100,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 211 || - (declaration.kind === 210 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 212 || + (declaration.kind === 211 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -19793,7 +20123,7 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - var isAmbientExternalModule = node.name.kind === 8; + var isAmbientExternalModule = node.name.kind === 9; var contextErrorMessage = isAmbientExternalModule ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -19801,7 +20131,7 @@ var ts; return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 8) { + if (!ts.isInAmbientContext(node) && node.name.kind === 9) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -19822,7 +20152,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 211); + var mergedClass = ts.getDeclarationOfKind(symbol, 212); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -19841,28 +20171,28 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 132) { + if (node.kind === 133) { node = node.left; } - else if (node.kind === 163) { + else if (node.kind === 164) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 66); + ts.Debug.assert(node.kind === 67); return node; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 8) { + if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9) { error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 216 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 245 && !inAmbientExternalModule) { - error(moduleName, node.kind === 225 ? + var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 246 && !inAmbientExternalModule) { + error(moduleName, node.kind === 226 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -19881,7 +20211,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 227 ? + var message = node.kind === 228 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -19907,7 +20237,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221) { + if (importClause.namedBindings.kind === 222) { checkImportBinding(importClause.namedBindings); } else { @@ -19942,7 +20272,7 @@ var ts; } } else { - if (languageVersion >= 2) { + if (languageVersion >= 2 && !ts.isInAmbientContext(node)) { grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); } } @@ -19958,8 +20288,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 216 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 245 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 246 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -19972,7 +20302,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 245 && node.parent.kind !== 216 && node.parent.kind !== 215) { + if (node.parent.kind !== 246 && node.parent.kind !== 217 && node.parent.kind !== 216) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -19986,15 +20316,15 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 245 ? node.parent : node.parent.parent; - if (container.kind === 215 && container.name.kind === 66) { + var container = node.parent.kind === 246 ? node.parent : node.parent.parent; + if (container.kind === 216 && container.name.kind === 67) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { markExportAsReferenced(node); } else { @@ -20011,10 +20341,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 245) { + if (node.kind === 246) { return node.statements; } - if (node.kind === 215 && node.body.kind === 216) { + if (node.kind === 216 && node.body.kind === 217) { return node.body.statements; } return emptyArray; @@ -20051,182 +20381,181 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 215: - case 211: + case 216: case 212: - case 210: + case 213: + case 211: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 134: - return checkTypeParameter(node); case 135: + return checkTypeParameter(node); + case 136: return checkParameter(node); + case 139: case 138: - case 137: return checkPropertyDeclaration(node); - case 149: case 150: - case 144: + case 151: case 145: - return checkSignatureDeclaration(node); case 146: return checkSignatureDeclaration(node); - case 140: - case 139: - return checkMethodDeclaration(node); - case 141: - return checkConstructorDeclaration(node); - case 142: - case 143: - return checkAccessorDeclaration(node); - case 148: - return checkTypeReferenceNode(node); case 147: + return checkSignatureDeclaration(node); + case 141: + case 140: + return checkMethodDeclaration(node); + case 142: + return checkConstructorDeclaration(node); + case 143: + case 144: + return checkAccessorDeclaration(node); + case 149: + return checkTypeReferenceNode(node); + case 148: return checkTypePredicate(node); - case 151: - return checkTypeQuery(node); case 152: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 153: - return checkArrayType(node); + return checkTypeLiteral(node); case 154: - return checkTupleType(node); + return checkArrayType(node); case 155: + return checkTupleType(node); case 156: - return checkUnionOrIntersectionType(node); case 157: + return checkUnionOrIntersectionType(node); + case 158: return checkSourceElement(node.type); - case 210: - return checkFunctionDeclaration(node); - case 189: - case 216: - return checkBlock(node); - case 190: - return checkVariableStatement(node); - case 192: - return checkExpressionStatement(node); - case 193: - return checkIfStatement(node); - case 194: - return checkDoStatement(node); - case 195: - return checkWhileStatement(node); - case 196: - return checkForStatement(node); - case 197: - return checkForInStatement(node); - case 198: - return checkForOfStatement(node); - case 199: - case 200: - return checkBreakOrContinueStatement(node); - case 201: - return checkReturnStatement(node); - case 202: - return checkWithStatement(node); - case 203: - return checkSwitchStatement(node); - case 204: - return checkLabeledStatement(node); - case 205: - return checkThrowStatement(node); - case 206: - return checkTryStatement(node); - case 208: - return checkVariableDeclaration(node); - case 160: - return checkBindingElement(node); case 211: - return checkClassDeclaration(node); - case 212: - return checkInterfaceDeclaration(node); - case 213: - return checkTypeAliasDeclaration(node); - case 214: - return checkEnumDeclaration(node); - case 215: - return checkModuleDeclaration(node); - case 219: - return checkImportDeclaration(node); - case 218: - return checkImportEqualsDeclaration(node); - case 225: - return checkExportDeclaration(node); - case 224: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 190: + case 217: + return checkBlock(node); case 191: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 193: + return checkExpressionStatement(node); + case 194: + return checkIfStatement(node); + case 195: + return checkDoStatement(node); + case 196: + return checkWhileStatement(node); + case 197: + return checkForStatement(node); + case 198: + return checkForInStatement(node); + case 199: + return checkForOfStatement(node); + case 200: + case 201: + return checkBreakOrContinueStatement(node); + case 202: + return checkReturnStatement(node); + case 203: + return checkWithStatement(node); + case 204: + return checkSwitchStatement(node); + case 205: + return checkLabeledStatement(node); + case 206: + return checkThrowStatement(node); case 207: + return checkTryStatement(node); + case 209: + return checkVariableDeclaration(node); + case 161: + return checkBindingElement(node); + case 212: + return checkClassDeclaration(node); + case 213: + return checkInterfaceDeclaration(node); + case 214: + return checkTypeAliasDeclaration(node); + case 215: + return checkEnumDeclaration(node); + case 216: + return checkModuleDeclaration(node); + case 220: + return checkImportDeclaration(node); + case 219: + return checkImportEqualsDeclaration(node); + case 226: + return checkExportDeclaration(node); + case 225: + return checkExportAssignment(node); + case 192: checkGrammarStatementInAmbientContext(node); return; - case 228: + case 208: + checkGrammarStatementInAmbientContext(node); + return; + case 229: return checkMissingDeclaration(node); } } function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 170: case 171: + case 172: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 183: + case 184: ts.forEach(node.members, checkSourceElement); break; + case 141: case 140: - case 139: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 141: case 142: case 143: - case 210: + case 144: + case 211: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 202: + case 203: checkFunctionAndClassExpressionBodies(node.expression); break; - case 136: - case 135: - case 138: case 137: - case 158: + case 136: + case 139: + case 138: case 159: case 160: case 161: case 162: - case 242: case 163: + case 243: case 164: case 165: case 166: case 167: - case 180: - case 187: case 168: - case 186: + case 181: + case 188: case 169: - case 173: + case 187: + case 170: case 174: case 175: - case 172: case 176: + case 173: case 177: case 178: case 179: + case 180: + case 183: case 182: - case 181: - case 189: - case 216: case 190: - case 192: + case 217: + case 191: case 193: case 194: case 195: @@ -20236,27 +20565,30 @@ var ts; case 199: case 200: case 201: - case 203: - case 217: - case 238: - case 239: + case 202: case 204: + case 218: + case 239: + case 240: case 205: case 206: - case 241: - case 208: + case 207: + case 242: case 209: - case 211: - case 214: - case 244: - case 224: + case 210: + case 212: + case 241: + case 186: + case 215: case 245: - case 237: - case 230: + case 225: + case 246: + case 238: case 231: - case 235: - case 236: case 232: + case 236: + case 237: + case 233: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -20334,7 +20666,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 202 && node.parent.statement === node) { + if (node.parent.kind === 203 && node.parent.statement === node) { return true; } node = node.parent; @@ -20356,34 +20688,37 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 245: + case 246: if (!ts.isExternalModule(location)) { break; } - case 215: + case 216: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 214: + case 215: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 183: + case 184: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 211: case 212: + case 213: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 170: + case 171: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); } break; } + if (ts.introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } memberFlags = location.flags; location = location.parent; } @@ -20407,42 +20742,42 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 66 && + return name.kind === 67 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 134: - case 211: + case 135: case 212: case 213: case 214: + case 215: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 132) { + while (node.parent && node.parent.kind === 133) { node = node.parent; } - return node.parent && node.parent.kind === 148; + return node.parent && node.parent.kind === 149; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 163) { + while (node.parent && node.parent.kind === 164) { node = node.parent; } - return node.parent && node.parent.kind === 185; + return node.parent && node.parent.kind === 186; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 132) { + while (nodeOnRightSide.parent.kind === 133) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 218) { + if (nodeOnRightSide.parent.kind === 219) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 224) { + if (nodeOnRightSide.parent.kind === 225) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -20454,10 +20789,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 224) { + if (entityName.parent.kind === 225) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 163) { + if (entityName.kind !== 164) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -20466,29 +20801,31 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 185 ? 793056 : 1536; + var meaning = entityName.parent.kind === 186 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 232) || (entityName.parent.kind === 231)) { + else if ((entityName.parent.kind === 233) || + (entityName.parent.kind === 232) || + (entityName.parent.kind === 235)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 66) { + if (entityName.kind === 67) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 163) { + else if (entityName.kind === 164) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 132) { + else if (entityName.kind === 133) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -20497,54 +20834,65 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 148 ? 793056 : 1536; + var meaning = entityName.parent.kind === 149 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 235) { + else if (entityName.parent.kind === 236) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 147) { + if (entityName.parent.kind === 148) { return resolveEntityName(entityName, 1); } return undefined; } - function getSymbolInfo(node) { + function getSymbolAtLocation(node) { if (isInsideWithStatementBody(node)) { return undefined; } if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 66 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 224 - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); + if (node.kind === 67) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 225 + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === 161 && + node.parent.parent.kind === 159 && + node === node.parent.propertyName) { + var typeOfPattern = getTypeOfNode(node.parent.parent); + var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } } switch (node.kind) { - case 66: - case 163: - case 132: + case 67: + case 164: + case 133: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 94: - case 92: + case 95: + case 93: var type = checkExpression(node); return type.symbol; - case 118: + case 119: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 141) { + if (constructorDeclaration && constructorDeclaration.kind === 142) { return constructorDeclaration.parent.symbol; } return undefined; - case 8: + case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 219 || node.parent.kind === 225) && + ((node.parent.kind === 220 || node.parent.kind === 226) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } - case 7: - if (node.parent.kind === 164 && node.parent.argumentExpression === node) { + case 8: + if (node.parent.kind === 165 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -20558,7 +20906,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 243) { + if (location && location.kind === 244) { return resolveEntityName(location.name, 107455); } return undefined; @@ -20581,7 +20929,7 @@ var ts; return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); } if (ts.isDeclaration(node)) { @@ -20589,14 +20937,14 @@ var ts; return getTypeOfSymbol(symbol); } if (ts.isDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getTypeOfSymbol(symbol); } if (ts.isBindingPattern(node)) { return getTypeForVariableLikeDeclaration(node.parent); } if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } @@ -20631,7 +20979,10 @@ var ts; var symbols = []; var name_15 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - symbols.push(getPropertyOfType(t, name_15)); + var symbol = getPropertyOfType(t, name_15); + if (symbol) { + symbols.push(symbol); + } }); return symbols; } @@ -20655,11 +21006,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 245) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 246) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 215 || n.kind === 214) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 216 || n.kind === 215) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -20672,11 +21023,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 189: - case 217: - case 196: + case 190: + case 218: case 197: case 198: + case 199: return true; } return false; @@ -20702,22 +21053,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 218: - case 220: + case 219: case 221: - case 223: - case 227: + case 222: + case 224: + case 228: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 225: + case 226: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 224: - return node.expression && node.expression.kind === 66 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 225: + return node.expression && node.expression.kind === 67 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 245 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 246 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -20728,7 +21079,10 @@ var ts; if (target === unknownSymbol && compilerOptions.isolatedModules) { return true; } - return target !== unknownSymbol && target && target.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(target); + return target !== unknownSymbol && + target && + target.flags & 107455 && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || s.constEnumOnlyModule; @@ -20762,7 +21116,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 244) { + if (node.kind === 245) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -20776,13 +21130,17 @@ var ts; function isFunctionType(type) { return type.flags & 80896 && getSignaturesOfType(type, 0).length > 0; } - function getTypeReferenceSerializationKind(node) { - var symbol = resolveEntityName(node.typeName, 107455, true); - var constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + function getTypeReferenceSerializationKind(typeName) { + var valueSymbol = resolveEntityName(typeName, 107455, true); + var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; if (constructorType && isConstructorType(constructorType)) { return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; } - var type = getTypeFromTypeNode(node); + var typeSymbol = resolveEntityName(typeName, 793056, true); + if (!typeSymbol) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + var type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } @@ -20804,7 +21162,7 @@ var ts; else if (allConstituentTypesHaveKind(type, 8192)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, 4194304)) { + else if (allConstituentTypesHaveKind(type, 16777216)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -20846,13 +21204,13 @@ var ts; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 160 || (n.parent.kind === 208 && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 161 || (n.parent.kind === 209 && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 | 8388608, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2) && - symbol.valueDeclaration.parent.kind !== 241; + symbol.valueDeclaration.parent.kind !== 242; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; @@ -20892,7 +21250,8 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter }; } function initializeTypeChecker() { @@ -20948,7 +21307,7 @@ var ts; } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyObjectType) { + if (promiseLikeType !== emptyGenericType) { return createTypeReference(promiseLikeType, [anyType]); } return emptyObjectType; @@ -20973,7 +21332,7 @@ var ts; else if (languageVersion < 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 142 || node.kind === 143) { + else if (node.kind === 143 || node.kind === 144) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -20983,38 +21342,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 142: case 143: - case 141: - case 138: - case 137: - case 140: + case 144: + case 142: case 139: - case 146: - case 215: + case 138: + case 141: + case 140: + case 147: + case 216: + case 220: case 219: - case 218: + case 226: case 225: - case 224: - case 135: - break; - case 210: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 115) && - node.parent.kind !== 216 && node.parent.kind !== 245) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } + case 136: break; case 211: - case 212: - case 190: - case 213: - if (node.modifiers && node.parent.kind !== 216 && node.parent.kind !== 245) { + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116) && + node.parent.kind !== 217 && node.parent.kind !== 246) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; + case 212: + case 213: + case 191: case 214: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 71) && - node.parent.kind !== 216 && node.parent.kind !== 245) { + if (node.modifiers && node.parent.kind !== 217 && node.parent.kind !== 246) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 215: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72) && + node.parent.kind !== 217 && node.parent.kind !== 246) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -21029,14 +21388,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 110: case 109: case 108: - case 107: var text = void 0; - if (modifier.kind === 109) { + if (modifier.kind === 110) { text = "public"; } - else if (modifier.kind === 108) { + else if (modifier.kind === 109) { text = "protected"; lastProtected = modifier; } @@ -21053,11 +21412,11 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 216 || node.parent.kind === 245) { + else if (node.parent.kind === 217 || node.parent.kind === 246) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256) { - if (modifier.kind === 107) { + if (modifier.kind === 108) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -21066,17 +21425,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 110: + case 111: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 216 || node.parent.kind === 245) { + else if (node.parent.kind === 217 || node.parent.kind === 246) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256) { @@ -21085,7 +21444,7 @@ var ts; flags |= 128; lastStatic = modifier; break; - case 79: + case 80: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -21098,42 +21457,42 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 119: + case 120: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 216) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 112: + case 113: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 211) { - if (node.kind !== 140) { + if (node.kind !== 212) { + if (node.kind !== 141) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 211 && node.parent.flags & 256)) { + if (!(node.parent.kind === 212 && node.parent.flags & 256)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128) { @@ -21145,14 +21504,14 @@ var ts; } flags |= 256; break; - case 115: + case 116: if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512; @@ -21160,7 +21519,7 @@ var ts; break; } } - if (node.kind === 141) { + if (node.kind === 142) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -21178,10 +21537,10 @@ var ts; } return; } - else if ((node.kind === 219 || node.kind === 218) && flags & 2) { + else if ((node.kind === 220 || node.kind === 219) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 135 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 136 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512) { @@ -21193,10 +21552,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 140: - case 210: - case 170: + case 141: + case 211: case 171: + case 172: if (!node.asteriskToken) { return false; } @@ -21244,16 +21603,14 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken || parameter.initializer) { + else if (parameter.questionToken) { seenOptionalParameter = true; - if (parameter.questionToken && parameter.initializer) { + if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } - else { - if (seenOptionalParameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); } } } @@ -21263,7 +21620,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 171) { + if (node.kind === 172) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -21298,7 +21655,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 127 && parameter.type.kind !== 125) { + if (parameter.type.kind !== 128 && parameter.type.kind !== 126) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -21330,7 +21687,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 184) { + if (arg.kind === 185) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -21357,7 +21714,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80) { + if (heritageClause.token === 81) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -21370,7 +21727,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103); + ts.Debug.assert(heritageClause.token === 104); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -21385,14 +21742,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80) { + if (heritageClause.token === 81) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103); + ts.Debug.assert(heritageClause.token === 104); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -21401,19 +21758,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 133) { + if (node.kind !== 134) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 178 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 179 && computedPropertyName.expression.operatorToken.kind === 24) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 210 || - node.kind === 170 || - node.kind === 140); + ts.Debug.assert(node.kind === 211 || + node.kind === 171 || + node.kind === 141); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -21439,26 +21796,26 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_16 = prop.name; - if (prop.kind === 184 || - name_16.kind === 133) { + if (prop.kind === 185 || + name_16.kind === 134) { checkGrammarComputedPropertyName(name_16); continue; } var currentKind = void 0; - if (prop.kind === 242 || prop.kind === 243) { + if (prop.kind === 243 || prop.kind === 244) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_16.kind === 7) { + if (name_16.kind === 8) { checkGrammarNumericLiteral(name_16); } currentKind = Property; } - else if (prop.kind === 140) { + else if (prop.kind === 141) { currentKind = Property; } - else if (prop.kind === 142) { + else if (prop.kind === 143) { currentKind = GetAccessor; } - else if (prop.kind === 143) { + else if (prop.kind === 144) { currentKind = SetAccesor; } else { @@ -21490,7 +21847,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 236) { + if (attr.kind === 237) { continue; } var jsxAttr = attr; @@ -21502,7 +21859,7 @@ var ts; return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 237 && !initializer.expression) { + if (initializer && initializer.kind === 238 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -21511,24 +21868,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 209) { + if (forInOrOfStatement.initializer.kind === 210) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -21551,10 +21908,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 142 && accessor.parameters.length) { + else if (kind === 143 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 143) { + else if (kind === 144) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -21579,7 +21936,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 133 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 134 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -21589,7 +21946,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 162) { + if (node.parent.kind === 163) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -21608,22 +21965,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 213) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 152) { + else if (node.parent.kind === 153) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 196: case 197: case 198: - case 194: + case 199: case 195: + case 196: return true; - case 204: + case 205: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -21635,9 +21992,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 204: + case 205: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 199 + var isMisplacedContinueLabel = node.kind === 200 && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -21645,8 +22002,8 @@ var ts; return false; } break; - case 203: - if (node.kind === 200 && !node.label) { + case 204: + if (node.kind === 201 && !node.label) { return false; } break; @@ -21659,13 +22016,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 200 + var message = node.kind === 201 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 200 + var message = node.kind === 201 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -21677,7 +22034,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 159 || node.name.kind === 158) { + if (node.name.kind === 160 || node.name.kind === 159) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -21686,7 +22043,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 197 && node.parent.parent.kind !== 198) { + if (node.parent.parent.kind !== 198 && node.parent.parent.kind !== 199) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -21706,7 +22063,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 66) { + if (name.kind === 67) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -21715,7 +22072,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 184) { + if (element.kind !== 185) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -21732,15 +22089,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 193: case 194: case 195: - case 202: case 196: + case 203: case 197: case 198: + case 199: return false; - case 204: + case 205: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -21756,13 +22113,13 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 176) { + if (expression.kind === 177) { var unaryExpression = expression; - if (unaryExpression.operator === 34 || unaryExpression.operator === 35) { + if (unaryExpression.operator === 35 || unaryExpression.operator === 36) { expression = unaryExpression.operand; } } - if (expression.kind === 7) { + if (expression.kind === 8) { return /^[0-9]+([eE]\+?[0-9]+)?$/.test(expression.text); } return false; @@ -21775,7 +22132,7 @@ var ts; var inAmbientContext = ts.isInAmbientContext(enumDecl); for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { var node = _a[_i]; - if (node.name.kind === 133) { + if (node.name.kind === 134) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -21818,7 +22175,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 && + return node.kind === 67 && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -21838,12 +22195,12 @@ var ts; return true; } } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 213) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 152) { + else if (node.parent.kind === 153) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -21853,11 +22210,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 212 || + if (node.kind === 213 || + node.kind === 220 || node.kind === 219 || - node.kind === 218 || + node.kind === 226 || node.kind === 225 || - node.kind === 224 || (node.flags & 2) || (node.flags & (1 | 1024))) { return false; @@ -21867,7 +22224,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 190) { + if (ts.isDeclaration(decl) || decl.kind === 191) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -21886,7 +22243,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 189 || node.parent.kind === 216 || node.parent.kind === 245) { + if (node.parent.kind === 190 || node.parent.kind === 217 || node.parent.kind === 246) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -21912,7 +22269,6 @@ var ts; } ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); -/// var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, targetSourceFile) { @@ -21959,7 +22315,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 219); + ts.Debug.assert(aliasEmitInfo.node.kind === 220); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -22032,10 +22388,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 208) { + if (declaration.kind === 209) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 222 || declaration.kind === 223 || declaration.kind === 220) { + else if (declaration.kind === 223 || declaration.kind === 224 || declaration.kind === 221) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -22046,7 +22402,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 219) { + if (moduleElementEmitInfo.node.kind === 220) { moduleElementEmitInfo.isVisible = true; } else { @@ -22054,12 +22410,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 215) { + if (nodeToCheck.kind === 216) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 215) { + if (nodeToCheck.kind === 216) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -22146,62 +22502,62 @@ var ts; } function emitType(type) { switch (type.kind) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: - case 8: + case 126: + case 118: + case 129: + case 101: + case 9: return writeTextOfNode(currentSourceFile, type); - case 185: + case 186: return emitExpressionWithTypeArguments(type); - case 148: - return emitTypeReference(type); - case 151: - return emitTypeQuery(type); - case 153: - return emitArrayType(type); - case 154: - return emitTupleType(type); - case 155: - return emitUnionType(type); - case 156: - return emitIntersectionType(type); - case 157: - return emitParenType(type); case 149: - case 150: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 152: + return emitTypeQuery(type); + case 154: + return emitArrayType(type); + case 155: + return emitTupleType(type); + case 156: + return emitUnionType(type); + case 157: + return emitIntersectionType(type); + case 158: + return emitParenType(type); + case 150: + case 151: + return emitSignatureDeclarationWithJsDocComments(type); + case 153: return emitTypeLiteral(type); - case 66: + case 67: return emitEntityName(type); - case 132: + case 133: return emitEntityName(type); - case 147: + case 148: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 66) { + if (entityName.kind === 67) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 132 ? entityName.left : entityName.expression; - var right = entityName.kind === 132 ? entityName.right : entityName.name; + var left = entityName.kind === 133 ? entityName.left : entityName.expression; + var right = entityName.kind === 133 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 218 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 219 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 66 || node.expression.kind === 163); + ts.Debug.assert(node.expression.kind === 67 || node.expression.kind === 164); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -22277,7 +22633,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -22295,7 +22651,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -22313,10 +22669,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 218 || - (node.parent.kind === 245 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 219 || + (node.parent.kind === 246 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 245) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -22325,7 +22681,7 @@ var ts; }); } else { - if (node.kind === 219) { + if (node.kind === 220) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -22343,23 +22699,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 210: - return writeFunctionDeclaration(node); - case 190: - return writeVariableStatement(node); - case 212: - return writeInterfaceDeclaration(node); case 211: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 191: + return writeVariableStatement(node); case 213: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 212: + return writeClassDeclaration(node); case 214: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 215: + return writeEnumDeclaration(node); + case 216: return writeModuleDeclaration(node); - case 218: - return writeImportEqualsDeclaration(node); case 219: + return writeImportEqualsDeclaration(node); + case 220: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -22373,7 +22729,7 @@ var ts; if (node.flags & 1024) { write("default "); } - else if (node.kind !== 212) { + else if (node.kind !== 213) { write("declare "); } } @@ -22420,7 +22776,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 221) { + if (namedBindings.kind === 222) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -22446,7 +22802,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 221) { + if (node.importClause.namedBindings.kind === 222) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -22502,7 +22858,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 216) { + while (node.body.kind !== 217) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -22519,14 +22875,18 @@ var ts; enclosingDeclaration = prevEnclosingDeclaration; } function writeTypeAliasDeclaration(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; emitJsDocComments(node); emitModuleElementDeclarationFlags(node); write("type "); writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); write(" = "); emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, @@ -22563,7 +22923,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 140 && (node.parent.flags & 32); + return node.parent.kind === 141 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -22573,15 +22933,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 149 || - node.parent.kind === 150 || - (node.parent.parent && node.parent.parent.kind === 152)) { - ts.Debug.assert(node.parent.kind === 140 || - node.parent.kind === 139 || - node.parent.kind === 149 || + if (node.parent.kind === 150 || + node.parent.kind === 151 || + (node.parent.parent && node.parent.parent.kind === 153)) { + ts.Debug.assert(node.parent.kind === 141 || + node.parent.kind === 140 || node.parent.kind === 150 || - node.parent.kind === 144 || - node.parent.kind === 145); + node.parent.kind === 151 || + node.parent.kind === 145 || + node.parent.kind === 146); emitType(node.constraint); } else { @@ -22591,31 +22951,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 211: + case 212: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 212: + case 213: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 145: + case 146: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 144: + case 145: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 141: case 140: - case 139: if (node.parent.flags & 128) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 211) { + else if (node.parent.parent.kind === 212) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 210: + case 211: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -22643,9 +23003,12 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } + else if (!isImplementsList && node.expression.kind === 91) { + write("null"); + } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 211) { + if (node.parent.parent.kind === 212) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -22725,16 +23088,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 208 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 209 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 138 || node.kind === 137) && ts.hasQuestionToken(node)) { + if ((node.kind === 139 || node.kind === 138) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 138 || node.kind === 137) && node.parent.kind === 152) { + if ((node.kind === 139 || node.kind === 138) && node.parent.kind === 153) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -22743,14 +23106,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 208) { + if (node.kind === 209) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 138 || node.kind === 137) { + else if (node.kind === 139 || node.kind === 138) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -22758,7 +23121,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -22784,7 +23147,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 184) { + if (element.kind !== 185) { elements.push(element); } } @@ -22850,7 +23213,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 142 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 143 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -22863,7 +23226,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 142 + return accessor.kind === 143 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -22872,7 +23235,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 143) { + if (accessorWithTypeAnnotation.kind === 144) { if (accessorWithTypeAnnotation.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -22918,17 +23281,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 210) { + if (node.kind === 211) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 140) { + else if (node.kind === 141) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 210) { + if (node.kind === 211) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 141) { + else if (node.kind === 142) { write("constructor"); } else { @@ -22945,11 +23308,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 145 || node.kind === 150) { + if (node.kind === 146 || node.kind === 151) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 146) { + if (node.kind === 147) { write("["); } else { @@ -22958,20 +23321,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 146) { + if (node.kind === 147) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 149 || node.kind === 150; - if (isFunctionTypeOrConstructorType || node.parent.kind === 152) { + var isFunctionTypeOrConstructorType = node.kind === 150 || node.kind === 151; + if (isFunctionTypeOrConstructorType || node.parent.kind === 153) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 141 && !(node.flags & 32)) { + else if (node.kind !== 142 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -22982,23 +23345,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 145: + case 146: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 144: + case 145: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 146: + case 147: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; + case 141: case 140: - case 139: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23006,7 +23369,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -23019,7 +23382,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 210: + case 211: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -23047,13 +23410,13 @@ var ts; else { writeTextOfNode(currentSourceFile, node.name); } - if (node.initializer || ts.hasQuestionToken(node)) { + if (resolver.isOptionalParameter(node)) { write("?"); } decreaseIndent(); - if (node.parent.kind === 149 || - node.parent.kind === 150 || - node.parent.parent.kind === 152) { + if (node.parent.kind === 150 || + node.parent.kind === 151 || + node.parent.parent.kind === 153) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -23069,22 +23432,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 141: + case 142: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 145: + case 146: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 144: + case 145: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 141: case 140: - case 139: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23092,7 +23455,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 211) { + else if (node.parent.parent.kind === 212) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23104,7 +23467,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 210: + case 211: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23115,12 +23478,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 158) { + if (bindingPattern.kind === 159) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 159) { + else if (bindingPattern.kind === 160) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -23139,21 +23502,20 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 184) { + if (bindingElement.kind === 185) { write(" "); } - else if (bindingElement.kind === 160) { + else if (bindingElement.kind === 161) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); - emitBindingPattern(bindingElement.name); } - else if (bindingElement.name) { + if (bindingElement.name) { if (ts.isBindingPattern(bindingElement.name)) { emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 66); + ts.Debug.assert(bindingElement.name.kind === 67); if (bindingElement.dotDotDotToken) { write("..."); } @@ -23165,39 +23527,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 210: - case 215: - case 218: - case 212: case 211: - case 213: - case 214: - return emitModuleElement(node, isModuleElementVisible(node)); - case 190: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 216: case 219: + case 213: + case 212: + case 214: + case 215: + return emitModuleElement(node, isModuleElementVisible(node)); + case 191: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 220: return emitModuleElement(node, !node.importClause); - case 225: + case 226: return emitExportDeclaration(node); + case 142: case 141: case 140: - case 139: return writeFunctionDeclaration(node); - case 145: - case 144: case 146: + case 145: + case 147: return emitSignatureDeclarationWithJsDocComments(node); - case 142: case 143: + case 144: return emitAccessorDeclaration(node); + case 139: case 138: - case 137: return emitPropertyDeclaration(node); - case 244: - return emitEnumMemberDeclaration(node); - case 224: - return emitExportAssignment(node); case 245: + return emitEnumMemberDeclaration(node); + case 225: + return emitExportAssignment(node); + case 246: return emitSourceFile(node); } } @@ -23206,7 +23568,7 @@ var ts; ? referencedFile.fileName : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") - : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; + : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); referencePathsOutput += "/// " + newLine; } @@ -23234,8 +23596,6 @@ var ts; } ts.writeDeclarationFile = writeDeclarationFile; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { function isExternalModuleOrDeclarationFile(sourceFile) { @@ -23262,17 +23622,17 @@ var ts; emitFile(jsFilePath, sourceFile); } }); - if (compilerOptions.out) { - emitFile(compilerOptions.out); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } else { if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ts.forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } - else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { - emitFile(compilerOptions.out); + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); @@ -23301,11 +23661,7 @@ var ts; } function emitJavaScript(jsFilePath, root) { var writer = ts.createTextWriter(newLine); - var write = writer.write; - var writeTextOfNode = writer.writeTextOfNode; - var writeLine = writer.writeLine; - var increaseIndent = writer.increaseIndent; - var decreaseIndent = writer.decreaseIndent; + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var currentSourceFile; var exportFunctionForFile; var generatedNameSet = {}; @@ -23325,13 +23681,14 @@ var ts; var writeEmittedFiles = writeJavaScriptFile; var detachedCommentsInfo; var writeComment = ts.writeCommentRange; - var emit = emitNodeWithoutSourceMap; + var emit = emitNodeWithCommentsAndWithoutSourcemap; var emitStart = function (node) { }; var emitEnd = function (node) { }; var emitToken = emitTokenText; var scopeEmitStart = function (scopeDeclaration, scopeName) { }; var scopeEmitEnd = function () { }; var sourceMapData; + var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); } @@ -23396,7 +23753,7 @@ var ts; } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 ? + var baseName = expr.kind === 9 ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; return makeUniqueName(baseName); } @@ -23408,19 +23765,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 66: + case 67: return makeUniqueName(node.text); + case 216: case 215: - case 214: return generateNameForModuleOrEnum(node); - case 219: - case 225: + case 220: + case 226: return generateNameForImportOrExportDeclaration(node); - case 210: case 211: - case 224: + case 212: + case 225: return generateNameForExportDefault(); - case 183: + case 184: return generateNameForClassExpression(); } } @@ -23474,7 +23831,7 @@ var ts; function base64VLQFormatEncode(inValue) { function base64FormatEncode(inValue) { if (inValue < 64) { - return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue); + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); } throw TypeError(inValue + ": not a 64 based value"); } @@ -23559,7 +23916,7 @@ var ts; var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { var name_21 = node.name; - if (!name_21 || name_21.kind !== 133) { + if (!name_21 || name_21.kind !== 134) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -23576,18 +23933,18 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 210 || - node.kind === 170 || + else if (node.kind === 211 || + node.kind === 171 || + node.kind === 141 || node.kind === 140 || - node.kind === 139 || - node.kind === 142 || node.kind === 143 || - node.kind === 215 || - node.kind === 211 || - node.kind === 214) { + node.kind === 144 || + node.kind === 216 || + node.kind === 212 || + node.kind === 215) { if (node.name) { var name_22 = node.name; - scopeName = name_22.kind === 133 + scopeName = name_22.kind === 134 ? ts.getTextOfNode(name_22) : node.name.text; } @@ -23686,7 +24043,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 245) { + if (node.kind !== 246) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -23697,8 +24054,11 @@ var ts; } } } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -23710,7 +24070,7 @@ var ts; ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } function createTempVariable(flags) { - var result = ts.createSynthesizedNode(66); + var result = ts.createSynthesizedNode(67); result.text = makeTempVariableName(flags); return result; } @@ -23820,7 +24180,9 @@ var ts; write(", "); } } - emitNode(nodes[start + i]); + var node = nodes[start + i]; + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); leadingComma = true; } if (trailingComma) { @@ -23846,7 +24208,7 @@ var ts; } } function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 7 && text.length > 1) { + if (node.kind === 8 && text.length > 1) { switch (text.charCodeAt(1)) { case 98: case 66: @@ -23859,7 +24221,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 8 || ts.isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { @@ -23871,23 +24233,23 @@ var ts; } function getLiteralText(node) { if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); + return getQuotedEscapedLiteralText("\"", node.text, "\""); } if (node.parent) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); } switch (node.kind) { - case 8: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 10: - return getQuotedEscapedLiteralText('`', node.text, '`'); + case 9: + return getQuotedEscapedLiteralText("\"", node.text, "\""); case 11: - return getQuotedEscapedLiteralText('`', node.text, '${'); + return getQuotedEscapedLiteralText("`", node.text, "`"); case 12: - return getQuotedEscapedLiteralText('}', node.text, '${'); + return getQuotedEscapedLiteralText("`", node.text, "${"); case 13: - return getQuotedEscapedLiteralText('}', node.text, '`'); - case 7: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -23897,15 +24259,15 @@ var ts; } function emitDownlevelRawTemplateLiteral(node) { var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 10 || node.kind === 13; + var isLast = node.kind === 11 || node.kind === 14; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); text = ts.escapeString(text); - write('"' + text + '"'); + write("\"" + text + "\""); } function emitDownlevelTaggedTemplateArray(node, literalEmitter) { write("["); - if (node.template.kind === 10) { + if (node.template.kind === 11) { literalEmitter(node.template); } else { @@ -23931,11 +24293,11 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 180) { + if (node.template.kind === 181) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 178 - && templateSpan.expression.operatorToken.kind === 23; + var needsParens = templateSpan.expression.kind === 179 + && templateSpan.expression.operatorToken.kind === 24; emitParenthesizedIf(templateSpan.expression, needsParens); }); } @@ -23958,7 +24320,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 169 + var needsParens = templateSpan.expression.kind !== 170 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -23973,29 +24335,16 @@ var ts; write(")"); } function shouldEmitTemplateHead() { - // If this expression has an empty head literal and the first template span has a non-empty - // literal, then emitting the empty head literal is not necessary. - // `${ foo } and ${ bar }` - // can be emitted as - // foo + " and " + bar - // This is because it is only required that one of the first two operands in the emit - // output must be a string literal, so that the other operand and all following operands - // are forced into strings. - // - // If the first template span has an empty literal, then the head must still be emitted. - // `${ foo }${ bar }` - // must still be emitted as - // "" + foo + bar ts.Debug.assert(node.templateSpans.length !== 0); return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 165: case 166: - return parent.expression === template; case 167: - case 169: + return parent.expression === template; + case 168: + case 170: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -24003,20 +24352,20 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 178: + case 179: switch (expression.operatorToken.kind) { - case 36: case 37: case 38: + case 39: return 1; - case 34: case 35: + case 36: return 0; default: return -1; } - case 181: - case 179: + case 182: + case 180: return -1; default: return 1; @@ -24029,10 +24378,10 @@ var ts; } function jsxEmitReact(node) { function emitTagName(name) { - if (name.kind === 66 && ts.isIntrinsicJsxName(name.text)) { - write('"'); + if (name.kind === 67 && ts.isIntrinsicJsxName(name.text)) { + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -24040,9 +24389,9 @@ var ts; } function emitAttributeName(name) { if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write('"'); + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -24059,8 +24408,12 @@ var ts; } } function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(67); + syntheticReactRef.text = 'React'; + syntheticReactRef.parent = openingNode; emitLeadingComments(openingNode); - write("React.createElement("); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); emitTagName(openingNode.tagName); write(", "); if (openingNode.attributes.length === 0) { @@ -24068,36 +24421,37 @@ var ts; } else { var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 236; })) { - write("React.__spread("); + if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) { + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); var haveOpenedObjectLiteral = false; - for (var i_2 = 0; i_2 < attrs.length; i_2++) { - if (attrs[i_2].kind === 236) { - if (i_2 === 0) { + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 237) { + if (i_1 === 0) { write("{}, "); } if (haveOpenedObjectLiteral) { write("}"); haveOpenedObjectLiteral = false; } - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } - emit(attrs[i_2].expression); + emit(attrs[i_1].expression); } else { - ts.Debug.assert(attrs[i_2].kind === 235); + ts.Debug.assert(attrs[i_1].kind === 236); if (haveOpenedObjectLiteral) { write(", "); } else { haveOpenedObjectLiteral = true; - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } write("{"); } - emitJsxAttribute(attrs[i_2]); + emitJsxAttribute(attrs[i_1]); } } if (haveOpenedObjectLiteral) @@ -24117,15 +24471,15 @@ var ts; } if (children) { for (var i = 0; i < children.length; i++) { - if (children[i].kind === 237 && !(children[i].expression)) { + if (children[i].kind === 238 && !(children[i].expression)) { continue; } - if (children[i].kind === 233) { + if (children[i].kind === 234) { var text = getTextToEmit(children[i]); if (text !== undefined) { - write(', "'); + write(", \""); write(text); - write('"'); + write("\""); } } else { @@ -24137,19 +24491,21 @@ var ts; write(")"); emitTrailingComments(openingNode); } - if (node.kind === 230) { + if (node.kind === 231) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 231); + ts.Debug.assert(node.kind === 232); emitJsxElement(node); } } function jsxEmitPreserve(node) { function emitJsxAttribute(node) { emit(node.name); - write("="); - emit(node.initializer); + if (node.initializer) { + write("="); + emit(node.initializer); + } } function emitJsxSpreadAttribute(node) { write("{..."); @@ -24161,11 +24517,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 236) { + if (attribs[i].kind === 237) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 235); + ts.Debug.assert(attribs[i].kind === 236); emitJsxAttribute(attribs[i]); } } @@ -24173,11 +24529,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 231)) { + if (node.attributes.length > 0 || (node.kind === 232)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 231) { + if (node.kind === 232) { write("/>"); } else { @@ -24196,20 +24552,20 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 230) { + if (node.kind === 231) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 231); + ts.Debug.assert(node.kind === 232); emitJsxOpeningOrSelfClosingElement(node); } } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 160); - if (node.kind === 8) { + ts.Debug.assert(node.kind !== 161); + if (node.kind === 9) { emitLiteral(node); } - else if (node.kind === 133) { + else if (node.kind === 134) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -24228,7 +24584,7 @@ var ts; } else { write("\""); - if (node.kind === 7) { + if (node.kind === 8) { write(node.text); } else { @@ -24240,58 +24596,60 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 161: - case 178: - case 165: - case 238: - case 133: + case 162: case 179: - case 136: - case 172: - case 194: - case 164: - case 224: - case 192: - case 185: - case 196: + case 166: + case 239: + case 134: + case 180: + case 137: + case 173: + case 195: + case 165: + case 225: + case 193: + case 186: case 197: case 198: - case 193: - case 231: + case 199: + case 194: case 232: - case 166: - case 169: - case 177: - case 176: - case 201: - case 243: - case 182: - case 203: + case 233: + case 237: + case 238: case 167: - case 187: - case 205: - case 168: - case 173: - case 174: - case 195: - case 202: - case 181: - return true; - case 160: - case 244: - case 135: - case 242: - case 138: - case 208: - return parent.initializer === node; - case 163: - return parent.expression === node; - case 171: case 170: + case 178: + case 177: + case 202: + case 244: + case 183: + case 204: + case 168: + case 188: + case 206: + case 169: + case 174: + case 175: + case 196: + case 203: + case 182: + return true; + case 161: + case 245: + case 136: + case 243: + case 139: + case 209: + return parent.initializer === node; + case 164: + return parent.expression === node; + case 172: + case 171: return parent.body === node; - case 218: + case 219: return parent.moduleReference === node; - case 132: + case 133: return parent.left === node; } return false; @@ -24303,7 +24661,7 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 245) { + if (container.kind === 246) { if (languageVersion < 2 && compilerOptions.module !== 4) { write("exports."); } @@ -24316,15 +24674,22 @@ var ts; else if (languageVersion < 2) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 220) { + if (declaration.kind === 221) { write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 ? '["default"]' : ".default"); + write(languageVersion === 0 ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 223) { + else if (declaration.kind === 224) { write(getGeneratedNameForNode(declaration.parent.parent.parent)); - write("."); - writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); + var name = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name); + if (languageVersion === 0 && identifier === "default") { + write("[\"default\"]"); + } + else { + write("."); + write(identifier); + } return; } } @@ -24334,17 +24699,22 @@ var ts; return; } } - writeTextOfNode(currentSourceFile, node); + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } } function isNameOfNestedRedeclaration(node) { if (languageVersion < 2) { - var parent_7 = node.parent; - switch (parent_7.kind) { - case 160: - case 211: - case 214: - case 208: - return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + var parent_6 = node.parent; + switch (parent_6.kind) { + case 161: + case 212: + case 215: + case 209: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); } } return false; @@ -24359,6 +24729,9 @@ var ts; else if (isNameOfNestedRedeclaration(node)) { write(getGeneratedNameForNode(node)); } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } else { writeTextOfNode(currentSourceFile, node); } @@ -24418,7 +24791,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(111)); + write(ts.tokenToString(112)); if (node.asteriskToken) { write("*"); } @@ -24432,7 +24805,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(111)); + write(ts.tokenToString(112)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -24440,22 +24813,22 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 178 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 179 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 179 && node.parent.condition === node) { + else if (node.parent.kind === 180 && node.parent.condition === node) { return true; } return false; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 66: - case 161: - case 163: + case 67: + case 162: case 164: case 165: - case 169: + case 166: + case 170: return false; } return true; @@ -24472,17 +24845,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 182) { + if (e.kind === 183) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 161) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 182) { + while (i < length && elements[i].kind !== 183) { i++; } write("["); @@ -24505,7 +24878,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 182; + return node.kind === 183; } function emitArrayLiteral(node) { var elements = node.elements; @@ -24566,7 +24939,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 142 || property.kind === 143) { + if (property.kind === 143 || property.kind === 144) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -24617,13 +24990,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 242) { + if (property.kind === 243) { emit(property.initializer); } - else if (property.kind === 243) { + else if (property.kind === 244) { emitExpressionIdentifier(property.name); } - else if (property.kind === 140) { + else if (property.kind === 141) { emitFunctionDeclaration(property); } else { @@ -24655,7 +25028,7 @@ var ts; var numProperties = properties.length; var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 133) { + if (properties[i].name.kind === 134) { numInitialNonComputedProperties = i; break; } @@ -24669,35 +25042,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(178, startsOnNewLine); + var result = ts.createSynthesizedNode(179, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(163); + var result = ts.createSynthesizedNode(164); result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(20); + result.dotToken = ts.createSynthesizedNode(21); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(164); + var result = ts.createSynthesizedNode(165); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 168 || expr.kind === 186) { + while (expr.kind === 169 || expr.kind === 187) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 166 && - expr.kind !== 7) { + expr.kind !== 167 && + expr.kind !== 8) { return expr; } - var node = ts.createSynthesizedNode(169); + var node = ts.createSynthesizedNode(170); node.expression = expr; return node; } @@ -24719,11 +25092,12 @@ var ts; function emitPropertyAssignment(node) { emit(node.name); write(": "); + emitTrailingCommentsOfPosition(node.initializer.pos); emit(node.initializer); } function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 245; + return container && container.kind !== 246; } function emitShorthandPropertyAssignment(node) { writeTextOfNode(currentSourceFile, node.name); @@ -24733,20 +25107,25 @@ var ts; } } function tryEmitConstantValue(node) { - if (compilerOptions.isolatedModules) { - return false; - } - var constantValue = resolver.getConstantValue(node); + var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 163 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 164 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; } return false; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 164 || node.kind === 165 + ? resolver.getConstantValue(node) + : undefined; + } function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); @@ -24769,9 +25148,15 @@ var ts; emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); var shouldEmitSpace; - if (!indentedBeforeDot && node.expression.kind === 7) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(20)) < 0; + if (!indentedBeforeDot) { + if (node.expression.kind === 8) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; + } + else { + var constantValue = tryGetConstEnumValue(node.expression); + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } } if (shouldEmitSpace) { write(" ."); @@ -24789,7 +25174,7 @@ var ts; emit(node.right); } function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 66) { + if (node.left.kind === 67) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -24805,11 +25190,11 @@ var ts; emitEntityNameAsExpression(node.left, false); } write("."); - emitNodeWithoutSourceMap(node.right); + emit(node.right); } function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 66: + case 67: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); @@ -24817,7 +25202,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 132: + case 133: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -24832,16 +25217,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 182; }); + return ts.forEach(elements, function (e) { return e.kind === 183; }); } function skipParentheses(node) { - while (node.kind === 169 || node.kind === 168 || node.kind === 186) { + while (node.kind === 170 || node.kind === 169 || node.kind === 187) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 66 || node.kind === 94 || node.kind === 92) { + if (node.kind === 67 || node.kind === 95 || node.kind === 93) { emit(node); return node; } @@ -24856,18 +25241,18 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 163) { + if (expr.kind === 164) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 164) { + else if (expr.kind === 165) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 92) { + else if (expr.kind === 93) { target = expr; write("_super"); } @@ -24876,7 +25261,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 92) { + if (target.kind === 93) { emitThis(target); } else { @@ -24896,13 +25281,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 163 && node.expression.expression.kind === 92; + superCall = node.expression.kind === 164 && node.expression.expression.kind === 93; } if (superCall && languageVersion < 2) { write(".call("); @@ -24953,20 +25338,21 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 171) { - if (node.expression.kind === 168 || node.expression.kind === 186) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172) { + if (node.expression.kind === 169 || node.expression.kind === 187) { var operand = node.expression.expression; - while (operand.kind === 168 || operand.kind === 186) { + while (operand.kind === 169 || operand.kind === 187) { operand = operand.expression; } - if (operand.kind !== 176 && + if (operand.kind !== 177 && + operand.kind !== 175 && operand.kind !== 174 && operand.kind !== 173 && - operand.kind !== 172 && - operand.kind !== 177 && - operand.kind !== 166 && - !(operand.kind === 165 && node.parent.kind === 166) && - !(operand.kind === 170 && node.parent.kind === 165)) { + operand.kind !== 178 && + operand.kind !== 167 && + !(operand.kind === 166 && node.parent.kind === 167) && + !(operand.kind === 171 && node.parent.kind === 166) && + !(operand.kind === 8 && node.parent.kind === 164)) { emit(operand); return; } @@ -24977,25 +25363,25 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(75)); + write(ts.tokenToString(76)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(100)); + write(ts.tokenToString(101)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(98)); + write(ts.tokenToString(99)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 66 || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 67 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 208 || node.parent.kind === 160); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 || node.parent.kind === 161); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -25009,12 +25395,12 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 176) { + if (node.operand.kind === 177) { var operand = node.operand; - if (node.operator === 34 && (operand.operator === 34 || operand.operator === 39)) { + if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { write(" "); } - else if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { + else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 41)) { write(" "); } } @@ -25031,7 +25417,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 39) { + if (node.operator === 40) { write(") - 1)"); } else { @@ -25052,10 +25438,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 245) { + if (current.kind === 246) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 216) { + else if (ts.isFunctionLike(current) || current.kind === 217) { return false; } else { @@ -25064,13 +25450,13 @@ var ts; } } function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 54 && - (node.left.kind === 162 || node.left.kind === 161)) { - emitDestructuring(node, node.parent.kind === 192); + if (languageVersion < 2 && node.operatorToken.kind === 55 && + (node.left.kind === 163 || node.left.kind === 162)) { + emitDestructuring(node, node.parent.kind === 193); } else { - var exportChanged = node.operatorToken.kind >= 54 && - node.operatorToken.kind <= 65 && + var exportChanged = node.operatorToken.kind >= 55 && + node.operatorToken.kind <= 66 && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -25078,7 +25464,7 @@ var ts; write("\", "); } emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 ? " " : undefined); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); write(ts.tokenToString(node.operatorToken.kind)); var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); @@ -25113,36 +25499,36 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 189) { + if (node && node.kind === 190) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } } function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - emitToken(14, node.pos); + emitToken(15, node.pos); write(" "); - emitToken(15, node.statements.end); + emitToken(16, node.statements.end); return; } - emitToken(14, node.pos); + emitToken(15, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 216) { - ts.Debug.assert(node.parent.kind === 215); + if (node.kind === 217) { + ts.Debug.assert(node.parent.kind === 216); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 216) { + if (node.kind === 217) { emitTempDeclarations(true); } decreaseIndent(); writeLine(); - emitToken(15, node.statements.end); + emitToken(16, node.statements.end); scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 189) { + if (node.kind === 190) { write(" "); emit(node); } @@ -25154,20 +25540,20 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 171); + emitParenthesizedIf(node.expression, node.expression.kind === 172); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(85, node.pos); + var endPos = emitToken(86, node.pos); write(" "); - endPos = emitToken(16, endPos); + endPos = emitToken(17, endPos); emit(node.expression); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(77, node.thenStatement.end); - if (node.elseStatement.kind === 193) { + emitToken(78, node.thenStatement.end); + if (node.elseStatement.kind === 194) { write(" "); emit(node.elseStatement); } @@ -25179,7 +25565,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 189) { + if (node.statement.kind === 190) { write(" "); } else { @@ -25199,13 +25585,13 @@ var ts; if (shouldHoistVariable(decl, true)) { return false; } - var tokenKind = 99; + var tokenKind = 100; if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { - tokenKind = 105; + tokenKind = 106; } else if (ts.isConst(decl)) { - tokenKind = 71; + tokenKind = 72; } } if (startPos !== undefined) { @@ -25214,13 +25600,13 @@ var ts; } else { switch (tokenKind) { - case 99: + case 100: write("var "); break; - case 105: + case 106: write("let "); break; - case 71: + case 72: write("const "); break; } @@ -25245,10 +25631,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 209) { + endPos = emitToken(17, endPos); + if (node.initializer && node.initializer.kind === 210) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -25269,13 +25655,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 198) { + if (languageVersion < 2 && node.kind === 199) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - if (node.initializer.kind === 209) { + endPos = emitToken(17, endPos); + if (node.initializer.kind === 210) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -25285,41 +25671,21 @@ var ts; else { emit(node.initializer); } - if (node.kind === 197) { + if (node.kind === 198) { write(" in "); } else { write(" of "); } emit(node.expression); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { - // The following ES6 code: - // - // for (let v of expr) { } - // - // should be emitted as - // - // for (let _i = 0, _a = expr; _i < _a.length; _i++) { - // let v = _a[_i]; - // } - // - // where _a and _i are temps emitted to capture the RHS and the counter, - // respectively. - // When the left hand side is an expression instead of a let declaration, - // the "let v" is not emitted. - // When the left hand side is a let/const, the v is renamed if there is - // another v in scope. - // Note that all assignments to the LHS are emitted in the body, including - // all destructuring. - // Note also that because an extra statement is needed to assign to the LHS, - // for-of bodies are always emitted as blocks. - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - var rhsIsIdentifier = node.expression.kind === 66; + endPos = emitToken(17, endPos); + var rhsIsIdentifier = node.expression.kind === 67; var counter = createTempVariable(268435456); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); emitStart(node.expression); @@ -25339,7 +25705,7 @@ var ts; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); write("; "); @@ -25347,13 +25713,13 @@ var ts; emitNodeWithoutSourceMap(counter); write("++"); emitEnd(node.initializer); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); write(" {"); writeLine(); increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -25362,7 +25728,7 @@ var ts; emitDestructuring(declaration, false, rhsIterationValue); } else { - emitNodeWithoutSourceMap(declaration); + emitNodeWithCommentsAndWithoutSourcemap(declaration); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } @@ -25374,17 +25740,17 @@ var ts; } } else { - var assignmentExpression = createBinaryExpression(node.initializer, 54, rhsIterationValue, false); - if (node.initializer.kind === 161 || node.initializer.kind === 162) { + var assignmentExpression = createBinaryExpression(node.initializer, 55, rhsIterationValue, false); + if (node.initializer.kind === 162 || node.initializer.kind === 163) { emitDestructuring(assignmentExpression, true, undefined); } else { - emitNodeWithoutSourceMap(assignmentExpression); + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); } } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 189) { + if (node.statement.kind === 190) { emitLines(node.statement.statements); } else { @@ -25396,12 +25762,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 200 ? 67 : 72, node.pos); + emitToken(node.kind === 201 ? 68 : 73, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(91, node.pos); + emitToken(92, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -25412,21 +25778,21 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(93, node.pos); + var endPos = emitToken(94, node.pos); write(" "); - emitToken(16, endPos); + emitToken(17, endPos); emit(node.expression); - endPos = emitToken(17, node.expression.end); + endPos = emitToken(18, node.expression.end); write(" "); emitCaseBlock(node.caseBlock, endPos); } function emitCaseBlock(node, startPos) { - emitToken(14, startPos); + emitToken(15, startPos); increaseIndent(); emitLines(node.clauses); decreaseIndent(); writeLine(); - emitToken(15, node.clauses.end); + emitToken(16, node.clauses.end); } function nodeStartPositionsAreOnSameLine(node1, node2) { return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === @@ -25441,7 +25807,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 238) { + if (node.kind === 239) { write("case "); emit(node.expression); write(":"); @@ -25476,16 +25842,16 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(69, node.pos); + var endPos = emitToken(70, node.pos); write(" "); - emitToken(16, endPos); + emitToken(17, endPos); emit(node.variableDeclaration); - emitToken(17, node.variableDeclaration ? node.variableDeclaration.end : endPos); + emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); write(" "); emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(73, node.pos); + emitToken(74, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -25496,7 +25862,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 215); + } while (node && node.kind !== 216); return node; } function emitContainingModuleName(node) { @@ -25515,16 +25881,33 @@ var ts; write("exports."); } } - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); emitEnd(node.name); } function createVoidZero() { - var zero = ts.createSynthesizedNode(7); + var zero = ts.createSynthesizedNode(8); zero.text = "0"; - var result = ts.createSynthesizedNode(174); + var result = ts.createSynthesizedNode(175); result.expression = zero; return result; } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 246) { + ts.Debug.assert(!!(node.flags & 1024) || node.kind === 225); + if (compilerOptions.module === 1 || compilerOptions.module === 2 || compilerOptions.module === 3) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1) { + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } function emitExportMemberAssignment(node) { if (node.flags & 1) { writeLine(); @@ -25535,7 +25918,7 @@ var ts; write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write("\", "); emitDeclarationName(node); @@ -25543,6 +25926,7 @@ var ts; } else { if (node.flags & 1024) { + emitEs6ExportDefaultCompat(node); if (languageVersion === 0) { write("exports[\"default\"]"); } @@ -25561,44 +25945,51 @@ var ts; } } function emitExportMemberAssignments(name) { + if (compilerOptions.module === 4) { + return; + } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { var specifier = _b[_a]; writeLine(); - if (compilerOptions.module === 4) { - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(specifier.name); - write("\", "); - emitExpressionIdentifier(name); - write(")"); - emitEnd(specifier.name); - } - else { - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - } + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); write(";"); } } } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(compilerOptions.module === 4); + if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { + return; + } + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 208) { + if (root.kind === 209) { var isExported = ts.getCombinedNodeFlags(root) & 1; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 135) { + else if (root.kind === 136) { canDefineTempVariablesInPlace = true; } - if (root.kind === 178) { + if (root.kind === 179) { emitAssignmentExpression(root); } else { @@ -25609,11 +26000,11 @@ var ts; if (emitCount++) { write(", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 208 || name.parent.kind === 160); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 || name.parent.kind === 161); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(name); + emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } if (isVariableDeclarationOrBindingElement) { @@ -25628,50 +26019,50 @@ var ts; write(")"); } } - function ensureIdentifier(expr) { - if (expr.kind !== 66) { - var identifier = createTempVariable(0); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expr); - expr = identifier; + function ensureIdentifier(expr, reuseIdentifierExpressions) { + if (expr.kind === 67 && reuseIdentifierExpressions) { + return expr; } - return expr; + var identifier = createTempVariable(0); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expr); + return identifier; } function createDefaultValueCheck(value, defaultValue) { - value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(178); + value = ensureIdentifier(value, true); + var equals = ts.createSynthesizedNode(179); equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(31); + equals.operatorToken = ts.createSynthesizedNode(32); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(179); + var cond = ts.createSynthesizedNode(180); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(51); + cond.questionToken = ts.createSynthesizedNode(52); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(52); + cond.colonToken = ts.createSynthesizedNode(53); cond.whenFalse = whenFalse; return cond; } function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(7); + var node = ts.createSynthesizedNode(8); node.text = "" + value; return node; } function createPropertyAccessForDestructuringProperty(object, propName) { var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 66) { + if (syntheticName.kind !== 67) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(165); - var sliceIdentifier = ts.createSynthesizedNode(66); + var call = ts.createSynthesizedNode(166); + var sliceIdentifier = ts.createSynthesizedNode(67); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -25681,11 +26072,11 @@ var ts; function emitObjectLiteralAssignment(target, value) { var properties = target.properties; if (properties.length !== 1) { - value = ensureIdentifier(value); + value = ensureIdentifier(value, true); } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 242 || p.kind === 243) { + if (p.kind === 243 || p.kind === 244) { var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -25694,12 +26085,12 @@ var ts; function emitArrayLiteralAssignment(target, value) { var elements = target.elements; if (elements.length !== 1) { - value = ensureIdentifier(value); + value = ensureIdentifier(value, true); } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184) { - if (e.kind !== 182) { + if (e.kind !== 185) { + if (e.kind !== 183) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -25709,14 +26100,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 178 && target.operatorToken.kind === 54) { + if (target.kind === 179 && target.operatorToken.kind === 55) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 162) { + if (target.kind === 163) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 161) { + else if (target.kind === 162) { emitArrayLiteralAssignment(target, value); } else { @@ -25726,18 +26117,21 @@ var ts; function emitAssignmentExpression(root) { var target = root.left; var value = root.right; - if (isAssignmentExpressionStatement) { + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 169) { + if (root.parent.kind !== 170) { write("("); } - value = ensureIdentifier(value); + value = ensureIdentifier(value, true); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 169) { + if (root.parent.kind !== 170) { write(")"); } } @@ -25752,20 +26146,21 @@ var ts; if (ts.isBindingPattern(target.name)) { var pattern = target.name; var elements = pattern.elements; - if (elements.length !== 1) { - value = ensureIdentifier(value); + var numElements = elements.length; + if (numElements !== 1) { + value = ensureIdentifier(value, numElements !== 0); } - for (var i = 0; i < elements.length; i++) { + for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (pattern.kind === 158) { + if (pattern.kind === 159) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 184) { + else if (element.kind !== 185) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } - else if (i === elements.length - 1) { + else if (i === numElements - 1) { emitBindingElement(element, createSliceCall(value, i)); } } @@ -25792,15 +26187,15 @@ var ts; var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && (getCombinedFlagsForIdentifier(node.name) & 16384); if (isUninitializedLet && - node.parent.parent.kind !== 197 && - node.parent.parent.kind !== 198) { + node.parent.parent.kind !== 198 && + node.parent.parent.kind !== 199) { initializer = createVoidZero(); } } var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); write("\", "); } emitModuleMemberName(node); @@ -25811,11 +26206,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 184) { + if (node.kind === 185) { return; } var name = node.name; - if (name.kind === 66) { + if (name.kind === 67) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -25823,7 +26218,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 208 && node.parent.kind !== 160)) { + if (!node.parent || (node.parent.kind !== 209 && node.parent.kind !== 161)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -25831,7 +26226,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1) && languageVersion >= 2 && - node.parent.kind === 245; + node.parent.kind === 246; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -25929,9 +26324,9 @@ var ts; emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -25950,7 +26345,7 @@ var ts; emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -25971,7 +26366,7 @@ var ts; increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -25980,36 +26375,39 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 142 ? "get " : "set "); + write(node.kind === 143 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 171 && languageVersion >= 2; + return node.kind === 172 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } else { write(getGeneratedNameForNode(node)); } } function shouldEmitFunctionName(node) { - if (node.kind === 170) { + if (node.kind === 171) { return !!node.name; } - if (node.kind === 210) { + if (node.kind === 211) { return !!node.name || languageVersion < 2; } } function emitFunctionDeclaration(node) { if (ts.nodeIsMissing(node.body)) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } - if (node.kind !== 140 && node.kind !== 139) { + if (node.kind !== 141 && node.kind !== 140 && + node.parent && node.parent.kind !== 243 && + node.parent.kind !== 166) { emitLeadingComments(node); } + emitStart(node); if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); @@ -26027,10 +26425,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 210 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 211 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 140 && node.kind !== 139) { + emitEnd(node); + if (node.kind !== 141 && node.kind !== 140) { emitTrailingComments(node); } } @@ -26062,7 +26461,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 171; + var isArrowFunction = node.kind === 172; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; var args; if (!isArrowFunction) { @@ -26105,7 +26504,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 189) { + if (node.body.kind === 190) { emitBlockFunctionBody(node, node.body); } else { @@ -26153,10 +26552,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 168) { + while (current.kind === 169) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 162); + emitParenthesizedIf(body, current.kind === 163); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -26222,17 +26621,17 @@ var ts; emitLeadingCommentsOfPosition(body.statements.end); decreaseIndent(); } - emitToken(15, body.statements.end); + emitToken(16, body.statements.end); scopeEmitEnd(); } function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 192) { + if (statement && statement.kind === 193) { var expr = statement.expression; - if (expr && expr.kind === 165) { + if (expr && expr.kind === 166) { var func = expr.expression; - if (func && func.kind === 92) { + if (func && func.kind === 93) { return statement; } } @@ -26256,24 +26655,24 @@ var ts; }); } function emitMemberAccessForPropertyName(memberName) { - if (memberName.kind === 8 || memberName.kind === 7) { + if (memberName.kind === 9 || memberName.kind === 8) { write("["); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 133) { + else if (memberName.kind === 134) { emitComputedPropertyName(memberName); } else { write("."); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); } } function getInitializedProperties(node, isStatic) { var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 138 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 139 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { properties.push(member); } } @@ -26313,13 +26712,13 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 188) { + if (member.kind === 189) { writeLine(); write(";"); } - else if (member.kind === 140 || node.kind === 139) { + else if (member.kind === 141 || node.kind === 140) { if (!member.body) { - return emitOnlyPinnedOrTripleSlashComments(member); + return emitCommentsOnNotEmittedNode(member); } writeLine(); emitLeadingComments(member); @@ -26329,14 +26728,12 @@ var ts; emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); - emitStart(member); emitFunctionDeclaration(member); emitEnd(member); - emitEnd(member); write(";"); emitTrailingComments(member); } - else if (member.kind === 142 || member.kind === 143) { + else if (member.kind === 143 || member.kind === 144) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -26386,22 +26783,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 140 || node.kind === 139) && !member.body) { - emitOnlyPinnedOrTripleSlashComments(member); + if ((member.kind === 141 || node.kind === 140) && !member.body) { + emitCommentsOnNotEmittedNode(member); } - else if (member.kind === 140 || - member.kind === 142 || - member.kind === 143) { + else if (member.kind === 141 || + member.kind === 143 || + member.kind === 144) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128) { write("static "); } - if (member.kind === 142) { + if (member.kind === 143) { write("get "); } - else if (member.kind === 143) { + else if (member.kind === 144) { write("set "); } if (member.asteriskToken) { @@ -26412,7 +26809,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 188) { + else if (member.kind === 189) { writeLine(); write(";"); } @@ -26433,10 +26830,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 141 && !member.body) { - emitOnlyPinnedOrTripleSlashComments(member); + if (member.kind === 142 && !member.body) { + emitCommentsOnNotEmittedNode(member); } - if (member.kind === 138 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 139 && member.initializer && (member.flags & 128) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -26467,18 +26864,21 @@ var ts; } } } + var startIndex = 0; write(" {"); scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { + startIndex = emitDirectivePrologues(ctor.body.statements, true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); + var superCall; if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - var superCall = findInitialSuperCall(ctor); + superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); emit(superCall); @@ -26505,7 +26905,7 @@ var ts; if (superCall) { statements = statements.slice(1); } - emitLines(statements); + emitLinesStartingAt(statements, startIndex); } emitTempDeclarations(true); writeLine(); @@ -26513,7 +26913,7 @@ var ts; emitLeadingCommentsOfPosition(ctor.body.statements.end); } decreaseIndent(); - emitToken(15, ctor ? ctor.body.statements.end : node.members.end); + emitToken(16, ctor ? ctor.body.statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); if (ctor) { @@ -26536,7 +26936,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 211) { + if (node.kind === 212) { if (thisNodeIsDecorated) { if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { write("export "); @@ -26553,7 +26953,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 183; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -26580,7 +26980,7 @@ var ts; emitMemberFunctionsForES6AndHigher(node); decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); if (thisNodeIsDecorated) { write(";"); @@ -26620,7 +27020,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 211) { + if (node.kind === 212) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -26658,7 +27058,7 @@ var ts; writeLine(); emitDecoratorsOfClass(node); writeLine(); - emitToken(15, node.members.end, function () { + emitToken(16, node.members.end, function () { write("return "); emitDeclarationName(node); }); @@ -26670,7 +27070,7 @@ var ts; computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); @@ -26678,11 +27078,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 211) { + if (node.kind === 212) { write(";"); } emitEnd(node); - if (node.kind === 211) { + if (node.kind === 212) { emitExportMemberAssignment(node); } if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { @@ -26756,13 +27156,13 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 140) { + if (member.kind === 141) { functionLikeMember = member; } } writeLine(); emitStart(member); - if (member.kind !== 138) { + if (member.kind !== 139) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -26792,7 +27192,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 138) { + if (member.kind !== 139) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -26831,45 +27231,45 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 140: - case 142: + case 141: case 143: - case 138: + case 144: + case 139: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 140: + case 141: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 211: - case 140: - case 143: + case 212: + case 141: + case 144: return true; } return false; } function emitSerializedTypeOfNode(node) { switch (node.kind) { - case 211: + case 212: write("Function"); return; - case 138: + case 139: emitSerializedTypeNode(node.type); return; - case 135: - emitSerializedTypeNode(node.type); - return; - case 142: + case 136: emitSerializedTypeNode(node.type); return; case 143: + emitSerializedTypeNode(node.type); + return; + case 144: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -26880,53 +27280,60 @@ var ts; write("void 0"); } function emitSerializedTypeNode(node) { - switch (node.kind) { - case 100: - write("void 0"); - return; - case 157: - emitSerializedTypeNode(node.type); - return; - case 149: - case 150: - write("Function"); - return; - case 153: - case 154: - write("Array"); - return; - case 147: - case 117: - write("Boolean"); - return; - case 127: - case 8: - write("String"); - return; - case 125: - write("Number"); - return; - case 128: - write("Symbol"); - return; - case 148: - emitSerializedTypeReferenceNode(node); - return; - case 151: - case 152: - case 155: - case 156: - case 114: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; + if (node) { + switch (node.kind) { + case 101: + write("void 0"); + return; + case 158: + emitSerializedTypeNode(node.type); + return; + case 150: + case 151: + write("Function"); + return; + case 154: + case 155: + write("Array"); + return; + case 148: + case 118: + write("Boolean"); + return; + case 128: + case 9: + write("String"); + return; + case 126: + write("Number"); + return; + case 129: + write("Symbol"); + return; + case 149: + emitSerializedTypeReferenceNode(node); + return; + case 152: + case 153: + case 156: + case 157: + case 115: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } } write("Object"); } function emitSerializedTypeReferenceNode(node) { - var typeName = node.typeName; - var result = resolver.getTypeReferenceSerializationKind(node); + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); switch (result) { case ts.TypeReferenceSerializationKind.Unknown: var temp = createAndRecordTempVariable(0); @@ -26975,7 +27382,7 @@ var ts; function emitSerializedParameterTypesOfNode(node) { if (node) { var valueDeclaration; - if (node.kind === 211) { + if (node.kind === 212) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -26991,10 +27398,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 153) { + if (parameterType.kind === 154) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 148 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 149 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -27011,7 +27418,7 @@ var ts; } } function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { + if (node && ts.isFunctionLike(node) && node.type) { emitSerializedTypeNode(node.type); return; } @@ -27054,7 +27461,7 @@ var ts; return argumentsWritten; } function emitInterfaceDeclaration(node) { - emitOnlyPinnedOrTripleSlashComments(node); + emitCommentsOnNotEmittedNode(node); } function shouldEmitEnumDeclaration(node) { var isConstEnum = ts.isConst(node); @@ -27088,7 +27495,7 @@ var ts; emitLines(node.members); decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -27147,7 +27554,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 215) { + if (moduleDeclaration.body.kind === 216) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -27161,7 +27568,7 @@ var ts; function emitModuleDeclaration(node) { var shouldEmit = shouldEmitModuleDeclaration(node); if (!shouldEmit) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); @@ -27182,7 +27589,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 216) { + if (node.body.kind === 217) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -27201,7 +27608,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(15, moduleBlock.statements.end); + emitToken(16, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -27214,7 +27621,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 66 && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 67 && node.parent === currentSourceFile) { if (compilerOptions.module === 4 && (node.flags & 1)) { writeLine(); write(exportFunctionForFile + "(\""); @@ -27226,29 +27633,41 @@ var ts; emitExportMemberAssignments(node.name); } } + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } function emitRequire(moduleName) { - if (moduleName.kind === 8) { + if (moduleName.kind === 9) { write("require("); - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - emitToken(17, moduleName.end); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18, moduleName.end); } else { write("require()"); } } function getNamespaceDeclarationNode(node) { - if (node.kind === 218) { + if (node.kind === 219) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 221) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 219 && node.importClause && !!node.importClause.name; + return node.kind === 220 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -27275,7 +27694,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 221) { + if (node.importClause.namedBindings.kind === 222) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -27301,7 +27720,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 218 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 219 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); @@ -27313,7 +27732,7 @@ var ts; write(" = "); } else { - var isNakedImport = 219 && !node.importClause; + var isNakedImport = 220 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -27359,16 +27778,29 @@ var ts; (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); + var variableDeclarationIsHoisted = shouldHoistVariable(node, true); + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1)) { + write("var "); + } } - else if (!(node.flags & 1)) { - write("var "); + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); + if (isExported) { + write(")"); + } write(";"); emitEnd(node); emitExportImportAssignments(node); @@ -27396,11 +27828,11 @@ var ts; emitStart(specifier); emitContainingModuleName(specifier); write("."); - emitNodeWithoutSourceMap(specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); write(" = "); write(generatedName); write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); write(";"); emitEnd(specifier); } @@ -27422,7 +27854,6 @@ var ts; } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { write("{ "); @@ -27434,10 +27865,9 @@ var ts; } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -27450,13 +27880,11 @@ var ts; if (needsComma) { write(", "); } - emitStart(specifier); if (specifier.propertyName) { - emitNodeWithoutSourceMap(specifier.propertyName); + emit(specifier.propertyName); write(" as "); } - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier); + emit(specifier.name); needsComma = true; } } @@ -27469,8 +27897,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 210 && - expression.kind !== 211) { + if (expression.kind !== 211 && + expression.kind !== 212) { write(";"); } emitEnd(node); @@ -27484,6 +27912,7 @@ var ts; write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0) { write("[\"default\"] = "); @@ -27506,18 +27935,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 219: + case 220: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 218: - if (node.moduleReference.kind === 229 && resolver.isReferencedAliasDeclaration(node)) { + case 219: + if (node.moduleReference.kind === 230 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 225: + case 226: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -27535,7 +27964,7 @@ var ts; } } break; - case 224: + case 225: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -27560,17 +27989,17 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 219 && node.importClause) { + if (node.kind === 220 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 225 && node.moduleSpecifier) { + if (node.kind === 226 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8) { - return getLiteralText(moduleName); + if (moduleName.kind === 9) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); } return undefined; } @@ -27582,8 +28011,8 @@ var ts; var started = false; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; - var skipNode = importNode.kind === 225 || - (importNode.kind === 219 && !importNode.importClause); + var skipNode = importNode.kind === 226 || + (importNode.kind === 220 && !importNode.importClause); if (skipNode) { continue; } @@ -27608,7 +28037,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 225 && externalImport.exportClause) { + if (externalImport.kind === 226 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -27637,7 +28066,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 225) { + if (externalImport.kind !== 226) { continue; } var exportDecl = externalImport; @@ -27659,6 +28088,8 @@ var ts; write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); + write("var exports = {};"); + writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); @@ -27666,17 +28097,19 @@ var ts; if (localNames) { write("&& !" + localNames + ".hasOwnProperty(n)"); } - write(") " + exportFunctionForFile + "(n, m[n]);"); + write(") exports[n] = m[n];"); decreaseIndent(); writeLine(); write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); decreaseIndent(); writeLine(); write("}"); return exportStarFunction; } function writeExportedName(node) { - if (node.kind !== 66 && node.flags & 1024) { + if (node.kind !== 67 && node.flags & 1024) { return; } if (started) { @@ -27687,8 +28120,8 @@ var ts; } writeLine(); write("'"); - if (node.kind === 66) { - emitNodeWithoutSourceMap(node); + if (node.kind === 67) { + emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); @@ -27707,7 +28140,7 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 66 + var name_25 = local.kind === 67 ? local : local.name; if (name_25) { @@ -27722,13 +28155,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 211 || local.kind === 215 || local.kind === 214) { + if (local.kind === 212 || local.kind === 216 || local.kind === 215) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 66 ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 67 ? local.parent : local); if (flags & 1) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -27756,21 +28189,21 @@ var ts; if (node.flags & 2) { return; } - if (node.kind === 210) { + if (node.kind === 211) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 211) { + if (node.kind === 212) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 214) { + if (node.kind === 215) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -27779,7 +28212,7 @@ var ts; } return; } - if (node.kind === 215) { + if (node.kind === 216) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -27788,10 +28221,10 @@ var ts; } return; } - if (node.kind === 208 || node.kind === 160) { + if (node.kind === 209 || node.kind === 161) { if (shouldHoistVariable(node, false)) { var name_26 = node.name; - if (name_26.kind === 66) { + if (name_26.kind === 67) { if (!hoistedVars) { hoistedVars = []; } @@ -27803,6 +28236,13 @@ var ts; } return; } + if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } if (ts.isBindingPattern(node)) { ts.forEach(node.elements, visit); return; @@ -27817,12 +28257,12 @@ var ts; return false; } return (ts.getCombinedNodeFlags(node) & 49152) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 245; + ts.getEnclosingBlockScopeContainer(node).kind === 246; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); } - function emitSystemModuleBody(node, startIndex) { + function emitSystemModuleBody(node, dependencyGroups, startIndex) { emitVariableDeclarationsForImports(); writeLine(); var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); @@ -27831,7 +28271,7 @@ var ts; write("return {"); increaseIndent(); writeLine(); - emitSetters(exportStarFunction); + emitSetters(exportStarFunction, dependencyGroups); writeLine(); emitExecute(node, startIndex); decreaseIndent(); @@ -27839,75 +28279,64 @@ var ts; write("}"); emitTempDeclarations(true); } - function emitSetters(exportStarFunction) { + function emitSetters(exportStarFunction, dependencyGroups) { write("setters:["); - for (var i = 0; i < externalImports.length; ++i) { + for (var i = 0; i < dependencyGroups.length; ++i) { if (i !== 0) { write(","); } writeLine(); increaseIndent(); - var importNode = externalImports[i]; - var importVariableName = getLocalNameForExternalImport(importNode) || ""; - var parameterName = "_" + importVariableName; + var group = dependencyGroups[i]; + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); - switch (importNode.kind) { - case 219: - if (!importNode.importClause) { - break; - } - case 218: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - writeLine(); - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - var defaultName = importNode.kind === 219 - ? importNode.importClause.name - : importNode.name; - if (defaultName) { - emitExportMemberAssignments(defaultName); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 220: + if (!entry.importClause) { + break; + } + case 219: + ts.Debug.assert(importVariableName !== ""); writeLine(); - } - if (importNode.kind === 219 && - importNode.importClause.namedBindings) { - var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 221) { - emitExportMemberAssignments(namedBindings.name); + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 226: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); } else { - for (var _a = 0, _b = namedBindings.elements; _a < _b.length; _a++) { - var element = _b[_a]; - emitExportMemberAssignments(element.name || element.propertyName); - writeLine(); - } - } - } - decreaseIndent(); - break; - case 225: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - if (importNode.exportClause) { - for (var _c = 0, _d = importNode.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; writeLine(); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(e.name); - write("\", " + parameterName + "[\""); - emitNodeWithoutSourceMap(e.propertyName || e.name); - write("\"]);"); + write(exportStarFunction + "(" + parameterName + ");"); } - } - else { writeLine(); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - decreaseIndent(); - break; + break; + } } + decreaseIndent(); write("}"); decreaseIndent(); } @@ -27920,14 +28349,25 @@ var ts; for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; switch (statement.kind) { - case 225: - case 219: - case 218: - case 210: + case 211: + case 220: continue; + case 226: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 219: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + continue; + } + default: + writeLine(); + emit(statement); } - writeLine(); - emit(statement); } decreaseIndent(); writeLine(); @@ -27943,8 +28383,19 @@ var ts; write("\"" + node.moduleName + "\", "); } write("["); + var groupIndices = {}; + var dependencyGroups = []; for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } if (i !== 0) { write(", "); } @@ -27953,24 +28404,14 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); + emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); } function emitAMDDependencies(node, includeNonAmdDependencies) { - // An AMD define function has the following shape: - // define(id?, dependencies?, factory); - // - // This has the shape of - // define(name, ["module1", "module2"], function (module1Alias) { - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // `import "module"` or `` - // we need to add modules without alias names to the end of the dependencies list var aliasedModuleNames = []; var unaliasedModuleNames = []; var importAliasNames = []; @@ -28012,6 +28453,7 @@ var ts; } } function emitAMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); write("define("); @@ -28031,6 +28473,7 @@ var ts; write("});"); } function emitCommonJSModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); @@ -28039,6 +28482,7 @@ var ts; emitExportEquals(false); } function emitUMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); emitAMDDependencies(node, false); @@ -28058,6 +28502,7 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); @@ -28083,9 +28528,9 @@ var ts; break; } } - function trimReactWhitespace(node) { + function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; - var text = ts.getTextOfNode(node); + var text = ts.getTextOfNode(node, true); var firstNonWhitespace = 0; var lastNonWhitespace = -1; for (var i = 0; i < text.length; i++) { @@ -28093,7 +28538,7 @@ var ts; if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; } firstNonWhitespace = -1; } @@ -28106,15 +28551,25 @@ var ts; } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; + } + if (result) { + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); } return result; } function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2: - var text = trimReactWhitespace(node); - if (text.length === 0) { + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { return undefined; } else { @@ -28128,13 +28583,13 @@ var ts; function emitJsxText(node) { switch (compilerOptions.jsx) { case 2: - write('"'); - write(trimReactWhitespace(node)); - write('"'); + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); break; case 1: default: - write(ts.getTextOfNode(node, true)); + writer.writeLiteral(ts.getTextOfNode(node, true)); break; } } @@ -28143,9 +28598,9 @@ var ts; switch (compilerOptions.jsx) { case 1: default: - write('{'); + write("{"); emit(node.expression); - write('}'); + write("}"); break; case 2: emit(node.expression); @@ -28177,10 +28632,7 @@ var ts; } } } - function emitSourceFileNode(node) { - writeLine(); - emitDetachedComments(node); - var startIndex = emitDirectivePrologues(node.statements, false); + function emitEmitHelpers(node) { if (!compilerOptions.noEmitHelpers) { if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { writeLines(extendsHelper); @@ -28202,6 +28654,12 @@ var ts; awaiterEmitted = true; } } + } + function emitSourceFileNode(node) { + writeLine(); + emitShebang(); + emitDetachedComments(node); + var startIndex = emitDirectivePrologues(node.statements, false); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2) { emitES6Module(node, startIndex); @@ -28224,47 +28682,63 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); } emitLeadingComments(node.endOfFileToken); } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2) { + return emitCommentsOnNotEmittedNode(node); + } + if (isSpecializedCommentHandling(node)) { + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } function emitNodeWithoutSourceMap(node) { - if (!node) { - return; + if (node) { + emitJavaScriptWorker(node); } - if (node.flags & 2) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - var emitComments = shouldEmitLeadingAndTrailingComments(node); - if (emitComments) { - emitLeadingComments(node); - } - emitJavaScriptWorker(node); - if (emitComments) { - emitTrailingComments(node); + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + case 213: + case 211: + case 220: + case 219: + case 214: + case 225: + return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 212: - case 210: - case 219: - case 218: - case 213: - case 224: - return false; - case 190: + case 191: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 215: + case 216: return shouldEmitModuleDeclaration(node); - case 214: + case 215: return shouldEmitEnumDeclaration(node); } - if (node.kind !== 189 && + ts.Debug.assert(!isSpecializedCommentHandling(node)); + if (node.kind !== 190 && node.parent && - node.parent.kind === 171 && + node.parent.kind === 172 && node.parent.body === node && compilerOptions.target <= 1) { return false; @@ -28273,170 +28747,170 @@ var ts; } function emitJavaScriptWorker(node) { switch (node.kind) { - case 66: + case 67: return emitIdentifier(node); - case 135: + case 136: return emitParameter(node); + case 141: case 140: - case 139: return emitMethod(node); - case 142: case 143: + case 144: return emitAccessor(node); - case 94: + case 95: return emitThis(node); - case 92: + case 93: return emitSuper(node); - case 90: + case 91: return write("null"); - case 96: + case 97: return write("true"); - case 81: + case 82: return write("false"); - case 7: case 8: case 9: case 10: case 11: case 12: case 13: + case 14: return emitLiteral(node); - case 180: - return emitTemplateExpression(node); - case 187: - return emitTemplateSpan(node); - case 230: - case 231: - return emitJsxElement(node); - case 233: - return emitJsxText(node); - case 237: - return emitJsxExpression(node); - case 132: - return emitQualifiedName(node); - case 158: - return emitObjectBindingPattern(node); - case 159: - return emitArrayBindingPattern(node); - case 160: - return emitBindingElement(node); - case 161: - return emitArrayLiteral(node); - case 162: - return emitObjectLiteral(node); - case 242: - return emitPropertyAssignment(node); - case 243: - return emitShorthandPropertyAssignment(node); - case 133: - return emitComputedPropertyName(node); - case 163: - return emitPropertyAccess(node); - case 164: - return emitIndexedAccess(node); - case 165: - return emitCallExpression(node); - case 166: - return emitNewExpression(node); - case 167: - return emitTaggedTemplateExpression(node); - case 168: - return emit(node.expression); - case 186: - return emit(node.expression); - case 169: - return emitParenExpression(node); - case 210: - case 170: - case 171: - return emitFunctionDeclaration(node); - case 172: - return emitDeleteExpression(node); - case 173: - return emitTypeOfExpression(node); - case 174: - return emitVoidExpression(node); - case 175: - return emitAwaitExpression(node); - case 176: - return emitPrefixUnaryExpression(node); - case 177: - return emitPostfixUnaryExpression(node); - case 178: - return emitBinaryExpression(node); - case 179: - return emitConditionalExpression(node); - case 182: - return emitSpreadElementExpression(node); case 181: - return emitYieldExpression(node); - case 184: - return; - case 189: - case 216: - return emitBlock(node); - case 190: - return emitVariableStatement(node); - case 191: - return write(";"); - case 192: - return emitExpressionStatement(node); - case 193: - return emitIfStatement(node); - case 194: - return emitDoStatement(node); - case 195: - return emitWhileStatement(node); - case 196: - return emitForStatement(node); - case 198: - case 197: - return emitForInOrForOfStatement(node); - case 199: - case 200: - return emitBreakOrContinueStatement(node); - case 201: - return emitReturnStatement(node); - case 202: - return emitWithStatement(node); - case 203: - return emitSwitchStatement(node); + return emitTemplateExpression(node); + case 188: + return emitTemplateSpan(node); + case 231: + case 232: + return emitJsxElement(node); + case 234: + return emitJsxText(node); case 238: - case 239: - return emitCaseOrDefaultClause(node); - case 204: - return emitLabelledStatement(node); - case 205: - return emitThrowStatement(node); - case 206: - return emitTryStatement(node); - case 241: - return emitCatchClause(node); - case 207: - return emitDebuggerStatement(node); - case 208: - return emitVariableDeclaration(node); - case 183: - return emitClassExpression(node); - case 211: - return emitClassDeclaration(node); - case 212: - return emitInterfaceDeclaration(node); - case 214: - return emitEnumDeclaration(node); + return emitJsxExpression(node); + case 133: + return emitQualifiedName(node); + case 159: + return emitObjectBindingPattern(node); + case 160: + return emitArrayBindingPattern(node); + case 161: + return emitBindingElement(node); + case 162: + return emitArrayLiteral(node); + case 163: + return emitObjectLiteral(node); + case 243: + return emitPropertyAssignment(node); case 244: - return emitEnumMember(node); + return emitShorthandPropertyAssignment(node); + case 134: + return emitComputedPropertyName(node); + case 164: + return emitPropertyAccess(node); + case 165: + return emitIndexedAccess(node); + case 166: + return emitCallExpression(node); + case 167: + return emitNewExpression(node); + case 168: + return emitTaggedTemplateExpression(node); + case 169: + return emit(node.expression); + case 187: + return emit(node.expression); + case 170: + return emitParenExpression(node); + case 211: + case 171: + case 172: + return emitFunctionDeclaration(node); + case 173: + return emitDeleteExpression(node); + case 174: + return emitTypeOfExpression(node); + case 175: + return emitVoidExpression(node); + case 176: + return emitAwaitExpression(node); + case 177: + return emitPrefixUnaryExpression(node); + case 178: + return emitPostfixUnaryExpression(node); + case 179: + return emitBinaryExpression(node); + case 180: + return emitConditionalExpression(node); + case 183: + return emitSpreadElementExpression(node); + case 182: + return emitYieldExpression(node); + case 185: + return; + case 190: + case 217: + return emitBlock(node); + case 191: + return emitVariableStatement(node); + case 192: + return write(";"); + case 193: + return emitExpressionStatement(node); + case 194: + return emitIfStatement(node); + case 195: + return emitDoStatement(node); + case 196: + return emitWhileStatement(node); + case 197: + return emitForStatement(node); + case 199: + case 198: + return emitForInOrForOfStatement(node); + case 200: + case 201: + return emitBreakOrContinueStatement(node); + case 202: + return emitReturnStatement(node); + case 203: + return emitWithStatement(node); + case 204: + return emitSwitchStatement(node); + case 239: + case 240: + return emitCaseOrDefaultClause(node); + case 205: + return emitLabelledStatement(node); + case 206: + return emitThrowStatement(node); + case 207: + return emitTryStatement(node); + case 242: + return emitCatchClause(node); + case 208: + return emitDebuggerStatement(node); + case 209: + return emitVariableDeclaration(node); + case 184: + return emitClassExpression(node); + case 212: + return emitClassDeclaration(node); + case 213: + return emitInterfaceDeclaration(node); case 215: - return emitModuleDeclaration(node); - case 219: - return emitImportDeclaration(node); - case 218: - return emitImportEqualsDeclaration(node); - case 225: - return emitExportDeclaration(node); - case 224: - return emitExportAssignment(node); + return emitEnumDeclaration(node); case 245: + return emitEnumMember(node); + case 216: + return emitModuleDeclaration(node); + case 220: + return emitImportDeclaration(node); + case 219: + return emitImportEqualsDeclaration(node); + case 226: + return emitExportDeclaration(node); + case 225: + return emitExportAssignment(node); + case 246: return emitSourceFileNode(node); } } @@ -28453,18 +28927,24 @@ var ts; } return leadingComments; } - function filterComments(ranges, onlyPinnedOrTripleSlashComments) { - if (ranges && onlyPinnedOrTripleSlashComments) { - ranges = ts.filter(ranges, isPinnedOrTripleSlashComment); - if (ranges.length === 0) { - return undefined; - } + function isPinnedComments(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + function isTripleSlashComment(comment) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) { + var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? + true : false; } - return ranges; + return false; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 245 || node.pos !== node.parent.pos) { + if (node.parent.kind === 246 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -28476,27 +28956,51 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 245 || node.end !== node.parent.end) { + if (node.parent.kind === 246 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } } - function emitOnlyPinnedOrTripleSlashComments(node) { - emitLeadingCommentsWorker(node, true); + function emitCommentsOnNotEmittedNode(node) { + emitLeadingCommentsWorker(node, false); } function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, compilerOptions.removeComments); + return emitLeadingCommentsWorker(node, true); } - function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) { - var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); + function emitLeadingCommentsWorker(node, isEmittedNode) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + if (node.pos === 0) { + leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); + } + } ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } function emitTrailingComments(node) { - var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); + if (compilerOptions.removeComments) { + return; + } + var trailingComments = getTrailingCommentsToEmit(node); ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); } - function emitLeadingCommentsOfPosition(pos) { + function emitTrailingCommentsOfPosition(pos) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); + ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); + } + function emitLeadingCommentsOfPositionWorker(pos) { + if (compilerOptions.removeComments) { + return; + } var leadingComments; if (hasDetachedComments(pos)) { leadingComments = getLeadingCommentsWithoutDetachedComments(); @@ -28504,12 +29008,19 @@ var ts; else { leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); } - leadingComments = filterComments(leadingComments, compilerOptions.removeComments); ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } function emitDetachedComments(node) { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + var leadingComments; + if (compilerOptions.removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } if (leadingComments) { var detachedComments = []; var lastComment; @@ -28541,15 +29052,10 @@ var ts; } } } - function isPinnedOrTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } - else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 && - currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { - return true; + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); } } } @@ -28561,16 +29067,270 @@ var ts; } } ts.emitFiles = emitFiles; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { ts.programTime = 0; ts.emitTime = 0; ts.ioReadTime = 0; ts.ioWriteTime = 0; - ts.version = "1.5.3"; + var emptyArray = []; + ts.version = "1.7.0"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -28587,6 +29347,155 @@ var ts; return undefined; } ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === 1 ? 2 : 1; + switch (moduleResolution) { + case 2: return nodeModuleNameResolver(moduleName, containingFile, host); + case 1: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + ts.resolveModuleName = resolveModuleName; + function nodeModuleNameResolver(moduleName, containingFile, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + var failedLookupLocations = []; + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolvedFileName = loadNodeModuleFromFile(candidate, false, failedLookupLocations, host); + if (resolvedFileName) { + return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; + } + resolvedFileName = loadNodeModuleFromDirectory(candidate, false, failedLookupLocations, host); + return resolvedFileName + ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { + if (loadOnlyDts) { + return tryLoad(".d.ts"); + } + else { + return ts.forEach(ts.supportedExtensions, tryLoad); + } + function tryLoad(ext) { + var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + var packageJsonPath = ts.combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + var jsonContent; + try { + var jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + jsonContent = { typings: undefined }; + } + if (jsonContent.typings) { + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + failedLookupLocation.push(packageJsonPath); + } + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + } + function loadModuleFromNodeModules(moduleName, directory, host) { + var failedLookupLocations = []; + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var result = loadNodeModuleFromFile(candidate, true, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + } + result = loadNodeModuleFromDirectory(candidate, true, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + directory = parentPath; + } + return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + function nameStartsWithDotSlashOrDotDotSlash(name) { + var i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === 46); + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + if (moduleName.indexOf('!') != -1) { + return { resolvedModule: undefined, failedLookupLocations: [] }; + } + var searchPath = ts.getDirectoryPath(containingFile); + var searchName; + var failedLookupLocations = []; + var referencedSourceFile; + while (true) { + searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); + referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + if (extension === ".tsx" && !compilerOptions.jsx) { + return undefined; + } + var candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + if (referencedSourceFile) { + break; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + ts.defaultInitCompilerOptions = { + module: 1, + target: 0, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false + }; function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; @@ -28649,7 +29558,9 @@ var ts; getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); } }; } ts.createCompilerHost = createCompilerHost; @@ -28684,10 +29595,11 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function createProgram(rootNames, options, host) { + function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; - var diagnostics = ts.createDiagnosticCollection(); + var fileProcessingDiagnostics = ts.createDiagnosticCollection(); + var programDiagnostics = ts.createDiagnosticCollection(); var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; @@ -28695,14 +29607,31 @@ var ts; var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var resolveModuleNamesWorker = host.resolveModuleNames + ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) + : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); + if (oldProgram) { + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } } verifyCompilerOptions(); + oldProgram = undefined; ts.programTime += new Date().getTime() - start; program = { + getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, @@ -28720,7 +29649,8 @@ var ts; getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, - getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); } + getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, + getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; } }; return program; function getClassifiableNames() { @@ -28734,6 +29664,71 @@ var ts; } return classifiableNames; } + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; + } + ts.Debug.assert(!oldProgram.structureIsReused); + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + var newSourceFiles = []; + var modifiedSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + return false; + } + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + return false; + } + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + return false; + } + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); + for (var i = 0; i < moduleNames.length; ++i) { + var newResolution = resolutions[i]; + var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]); + var resolutionChanged = oldResolution + ? !newResolution || + oldResolution.resolvedFileName !== newResolution.resolvedFileName || + !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport + : newResolution; + if (resolutionChanged) { + return false; + } + } + } + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + modifiedSourceFiles.push(newSourceFile); + } + else { + newSourceFile = oldSourceFile; + } + newSourceFiles.push(newSourceFile); + } + for (var _b = 0; _b < newSourceFiles.length; _b++) { + var file = newSourceFiles[_b]; + filesByName.set(file.fileName, file); + } + files = newSourceFiles; + fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); + for (var _c = 0; _c < modifiedSourceFiles.length; _c++) { + var modifiedFile = modifiedSourceFiles[_c]; + fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + } + oldProgram.structureIsReused = true; + return true; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -28760,7 +29755,7 @@ var ts; if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); var start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); ts.emitTime += new Date().getTime() - start; @@ -28812,8 +29807,9 @@ var ts; ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); - var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); + var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); + var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); + return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); }); } function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { @@ -28827,7 +29823,8 @@ var ts; } function getOptionsDiagnostics() { var allDiagnostics = []; - ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function getGlobalDiagnostics() { @@ -28841,14 +29838,51 @@ var ts; function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var start; - var length; - var diagnosticArgument; - if (refEnd !== undefined && refPos !== undefined) { - start = refPos; - length = refEnd - refPos; + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; } + var imports; + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 220: + case 219: + case 226: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9) { + break; + } + if (!moduleNameExpr.text) { + break; + } + (imports || (imports = [])).push(moduleNameExpr); + break; + case 216: + if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { + ts.forEachChild(node.body, function (node) { + if (ts.isExternalModuleImportEqualsDeclaration(node) && + ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9) { + var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); + if (moduleName) { + (imports || (imports = [])).push(moduleName); + } + } + }); + } + break; + } + } + file.imports = imports || emptyArray; + } + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { @@ -28879,15 +29913,15 @@ var ts; } } if (diagnostic) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, start, length, diagnostic].concat(diagnosticArgument))); + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); } else { - diagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); } } } - function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { + function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); if (filesByName.contains(canonicalName)) { return getSourceFileFromCache(fileName, canonicalName, false); @@ -28899,22 +29933,22 @@ var ts; return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); } var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } else { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); filesByName.set(canonicalName, file); if (file) { skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; filesByName.set(canonicalAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); - processImportedModules(file, basePath); } + processImportedModules(file, basePath); if (isDefaultLib) { file.isDefaultLib = true; files.unshift(file); @@ -28930,7 +29964,12 @@ var ts; if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } } } return file; @@ -28938,49 +29977,44 @@ var ts; } function processReferencedFiles(file, basePath) { ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = ts.isRootedDiskPath(ref.fileName) ? ref.fileName : ts.combinePaths(basePath, ref.fileName); - processSourceFile(ts.normalizePath(referencedFileName), false, file, ref.pos, ref.end); + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, false, file, ref.pos, ref.end); }); } function processImportedModules(file, basePath) { - ts.forEach(file.statements, function (node) { - if (node.kind === 219 || node.kind === 218 || node.kind === 225) { - var moduleNameExpr = ts.getExternalModuleName(node); - if (moduleNameExpr && moduleNameExpr.kind === 8) { - var moduleNameText = moduleNameExpr.text; - if (moduleNameText) { - var searchPath = basePath; - var searchName; - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleNameText)); - if (ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, moduleNameExpr); })) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); + for (var i = 0; i < file.imports.length; ++i) { + var resolution = resolutions[i]; + ts.setResolvedModule(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + var importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]); + if (importedFile && resolution.isExternalLibraryImport) { + if (!ts.isExternalModule(importedFile)) { + var start_2 = ts.getTokenPosOfNode(file.imports[i], file); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.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 (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) { + var start_3 = ts.getTokenPosOfNode(file.imports[i], file); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_3, file.imports[i].end - start_3, ts.Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition)); + } + else if (importedFile.referencedFiles.length) { + var firstRef = importedFile.referencedFiles[0]; + fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); } } } } - else if (node.kind === 215 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { - ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8) { - var nameLiteral = ts.getExternalModuleImportEqualsDeclarationExpression(node); - var moduleName = nameLiteral.text; - if (moduleName) { - var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); - ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, nameLiteral); }); - } - } - }); - } - }); + } + else { + file.resolvedModules = undefined; + } + return; function findModuleSourceFile(fileName, nameLiteral) { - return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); + return findSourceFile(fileName, false, file, ts.skipTrivia(file.text, nameLiteral.pos), nameLiteral.end); } } function computeCommonSourceDirectory(sourceFiles) { @@ -28999,7 +30033,7 @@ var ts; for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { if (commonPathComponents[i] !== sourcePathComponents[i]) { if (i === 0) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); return; } commonPathComponents.length = i; @@ -29022,7 +30056,7 @@ var ts; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); allFilesBelongToPath = false; } } @@ -29032,67 +30066,71 @@ var ts; } function verifyCompilerOptions() { if (options.isolatedModules) { - if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); - } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); } if (options.noEmitOnError) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); } if (options.out) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); } } if (options.inlineSourceMap) { if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); } if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); } } if (options.inlineSources) { if (!options.sourceMap && !options.inlineSourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); } } + if (options.out && options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); } return; } var languageVersion = options.target || 0; + var outFile = options.outFile || options.out; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (options.isolatedModules) { if (!options.module && languageVersion < 2) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); } var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); + programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } else if (firstExternalModuleSourceFile && languageVersion < 2 && !options.module) { var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); + programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } if (options.module && languageVersion >= 2) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); } if (options.outDir || options.sourceRoot || (options.mapRoot && - (!options.out || firstExternalModuleSourceFile !== undefined))) { + (!outFile || firstExternalModuleSourceFile !== undefined))) { if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); } @@ -29104,29 +30142,31 @@ var ts; } } if (options.noEmit) { - if (options.out || options.outDir) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir)); + if (options.out) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + if (options.outDir) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); } } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.experimentalAsyncFunctions && options.target !== 2) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); } } } ts.createProgram = createProgram; })(ts || (ts = {})); -/// -/// -/// -/// var ts; (function (ts) { ts.optionDeclarations = [ @@ -29154,6 +30194,11 @@ var ts; type: "boolean", description: ts.Diagnostics.Print_this_message }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + }, { name: "inlineSourceMap", type: "boolean" @@ -29244,6 +30289,12 @@ var ts; { name: "out", type: "string", + isFilePath: false, + paramType: ts.Diagnostics.FILE + }, + { + name: "outFile", + type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE @@ -29296,6 +30347,12 @@ var ts; description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, paramType: ts.Diagnostics.LOCATION }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", @@ -29342,20 +30399,39 @@ var ts; type: "boolean", experimental: true, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: { + "node": 2, + "classic": 1 + }, + description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic } ]; - function parseCommandLine(commandLine) { - var options = {}; - var fileNames = []; - var errors = []; - var shortOptionNames = {}; + var optionNameMapCache; + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } var optionNameMap = {}; + var shortOptionNames = {}; ts.forEach(ts.optionDeclarations, function (option) { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { shortOptionNames[option.shortName] = option.name; } }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function parseCommandLine(commandLine, readFile) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; parseStrings(commandLine); return { options: options, @@ -29410,7 +30486,7 @@ var ts; } } function parseResponseFile(fileName) { - var text = ts.sys.readFile(fileName); + var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); if (!text) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); return; @@ -29445,10 +30521,10 @@ var ts; } } ts.parseCommandLine = parseCommandLine; - function readConfigFile(fileName) { - var text = ''; + function readConfigFile(fileName, readFile) { + var text = ""; try { - text = ts.sys.readFile(fileName); + text = readFile(fileName); } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; @@ -29519,6 +30595,9 @@ var ts; if (json["files"] instanceof Array) { fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } } else { var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; @@ -29546,14 +30625,12 @@ var ts; } ts.parseConfigFile = parseConfigFile; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { function validateLocaleAndSetLanguage(locale, errors) { var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); if (!matchResult) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, 'en', 'ja-jp')); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp")); return false; } var language = matchResult[1]; @@ -29576,7 +30653,7 @@ var ts; if (!ts.sys.fileExists(filePath)) { return false; } - var fileContents = ''; + var fileContents = ""; try { fileContents = ts.sys.readFile(filePath); } @@ -29668,6 +30745,10 @@ var ts; reportDiagnostics(commandLine.errors); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } + if (commandLine.options.init) { + writeConfigFile(commandLine.options, commandLine.fileNames); + return ts.sys.exit(ts.ExitStatus.Success); + } if (commandLine.options.version) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Version_0, ts.version)); return ts.sys.exit(ts.ExitStatus.Success); @@ -29710,7 +30791,7 @@ var ts; function performCompilation() { if (!cachedProgram) { if (configFileName) { - var result = ts.readConfigFile(configFileName); + var result = ts.readConfigFile(configFileName, ts.sys.readFile); if (result.error) { reportDiagnostic(result.error); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); @@ -29823,16 +30904,15 @@ var ts; } return { program: program, exitStatus: exitStatus }; function compileProgram() { - var diagnostics = program.getSyntacticDiagnostics(); - reportDiagnostics(diagnostics); + var diagnostics; + diagnostics = program.getSyntacticDiagnostics(); if (diagnostics.length === 0) { - var diagnostics_1 = program.getGlobalDiagnostics(); - reportDiagnostics(diagnostics_1); - if (diagnostics_1.length === 0) { - var diagnostics_2 = program.getSemanticDiagnostics(); - reportDiagnostics(diagnostics_2); + diagnostics = program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); + if (diagnostics.length === 0) { + diagnostics = program.getSemanticDiagnostics(); } } + reportDiagnostics(diagnostics); if (compilerOptions.noEmit) { return diagnostics.length ? ts.ExitStatus.DiagnosticsPresent_OutputsSkipped @@ -29910,5 +30990,60 @@ var ts; return Array(paddingLength + 1).join(" "); } } + function writeConfigFile(options, fileNames) { + var currentDirectory = ts.sys.getCurrentDirectory(); + var file = ts.combinePaths(currentDirectory, 'tsconfig.json'); + if (ts.sys.fileExists(file)) { + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file)); + } + else { + var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); + var configurations = { + compilerOptions: serializeCompilerOptions(compilerOptions), + exclude: ["node_modules"] + }; + if (fileNames && fileNames.length) { + configurations.files = fileNames; + } + ts.sys.writeFile(file, JSON.stringify(configurations, undefined, 4)); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file)); + } + return; + function serializeCompilerOptions(options) { + var result = {}; + var optionsNameMap = ts.getOptionNameMap().optionNameMap; + for (var name_28 in options) { + if (ts.hasProperty(options, name_28)) { + var value = options[name_28]; + switch (name_28) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + var optionDefinition = optionsNameMap[name_28.toLowerCase()]; + if (optionDefinition) { + if (typeof optionDefinition.type === "string") { + result[name_28] = value; + } + else { + var typeMap = optionDefinition.type; + for (var key in typeMap) { + if (ts.hasProperty(typeMap, key)) { + if (typeMap[key] === value) + result[name_28] = key; + } + } + } + } + break; + } + } + } + return result; + } + } })(ts || (ts = {})); ts.executeCommandLine(ts.sys.args); diff --git a/lib/tsserver.js b/lib/tsserver.js index 9d582485e2f..82199e1222d 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -47,7 +47,6 @@ var ts; })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); var DiagnosticCategory = ts.DiagnosticCategory; })(ts || (ts = {})); -/// var ts; (function (ts) { function createFileMap(getCanonicalFileName) { @@ -57,6 +56,7 @@ var ts; set: set, contains: contains, remove: remove, + clear: clear, forEachValue: forEachValueInMap }; function set(fileName, value) { @@ -78,6 +78,9 @@ var ts; function normalizeKey(key) { return getCanonicalFileName(normalizeSlashes(key)); } + function clear() { + files = {}; + } } ts.createFileMap = createFileMap; function forEach(array, callback) { @@ -495,7 +498,7 @@ var ts; if (path.lastIndexOf("file:///", 0) === 0) { return "file:///".length; } - var idx = path.indexOf('://'); + var idx = path.indexOf("://"); if (idx !== -1) { return idx + "://".length; } @@ -565,9 +568,6 @@ var ts; } ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; function getNormalizedPathComponentsOfUrl(url) { - // Get root length of http://www.website.com/folder1/foler2/ - // In this example the root is: http://www.website.com/ - // normalized path components should be ["http://www.website.com/", "folder1", "folder2"] var urlLength = url.length; var rootLength = url.indexOf("://") + "://".length; while (rootLength < urlLength) { @@ -649,7 +649,7 @@ var ts; return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; } ts.fileExtensionIs = fileExtensionIs; - ts.supportedExtensions = [".tsx", ".ts", ".d.ts"]; + ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -727,7 +727,6 @@ var ts; Debug.fail = fail; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { ts.sys = (function () { @@ -864,7 +863,7 @@ var ts; function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); - var _os = require('os'); + var _os = require("os"); var platform = _os.platform(); var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; function readFile(fileName, encoding) { @@ -892,7 +891,7 @@ var ts; } function writeFile(fileName, data, writeByteOrderMark) { if (writeByteOrderMark) { - data = '\uFEFF' + data; + data = "\uFEFF" + data; } _fs.writeFileSync(fileName, data, "utf8"); } @@ -933,7 +932,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, 'utf8'); + var buffer = new Buffer(s, "utf8"); var offset = 0; var toWrite = buffer.length; var written = 0; @@ -955,7 +954,6 @@ var ts; } callback(fileName); } - ; }, resolvePath: function (path) { return _path.resolve(path); @@ -992,7 +990,7 @@ var ts; if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { return getWScriptSystem(); } - else if (typeof module !== "undefined" && module.exports) { + else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { return getNodeSystem(); } else { @@ -1000,7 +998,6 @@ var ts; } })(); })(ts || (ts = {})); -/// var ts; (function (ts) { ts.Diagnostics = { @@ -1245,7 +1242,7 @@ var ts; Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." }, @@ -1255,6 +1252,7 @@ var ts; Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, @@ -1294,7 +1292,7 @@ var ts; Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, @@ -1415,6 +1413,7 @@ var ts; The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, + Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -1425,6 +1424,12 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, + Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, + Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, + Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." }, + Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -1504,20 +1509,12 @@ var ts; Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, - Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, - Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, - Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, - Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, - Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, - Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -1566,13 +1563,17 @@ var ts; Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, + Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -1613,131 +1614,134 @@ var ts; JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." } + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } }; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { + function tokenIsIdentifierOrKeyword(token) { + return token >= 67; + } + ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = { - "abstract": 112, - "any": 114, - "as": 113, - "boolean": 117, - "break": 67, - "case": 68, - "catch": 69, - "class": 70, - "continue": 72, - "const": 71, - "constructor": 118, - "debugger": 73, - "declare": 119, - "default": 74, - "delete": 75, - "do": 76, - "else": 77, - "enum": 78, - "export": 79, - "extends": 80, - "false": 81, - "finally": 82, - "for": 83, - "from": 130, - "function": 84, - "get": 120, - "if": 85, - "implements": 103, - "import": 86, - "in": 87, - "instanceof": 88, - "interface": 104, - "is": 121, - "let": 105, - "module": 122, - "namespace": 123, - "new": 89, - "null": 90, - "number": 125, - "package": 106, - "private": 107, - "protected": 108, - "public": 109, - "require": 124, - "return": 91, - "set": 126, - "static": 110, - "string": 127, - "super": 92, - "switch": 93, - "symbol": 128, - "this": 94, - "throw": 95, - "true": 96, - "try": 97, - "type": 129, - "typeof": 98, - "var": 99, - "void": 100, - "while": 101, - "with": 102, - "yield": 111, - "async": 115, - "await": 116, - "of": 131, - "{": 14, - "}": 15, - "(": 16, - ")": 17, - "[": 18, - "]": 19, - ".": 20, - "...": 21, - ";": 22, - ",": 23, - "<": 24, - ">": 26, - "<=": 27, - ">=": 28, - "==": 29, - "!=": 30, - "===": 31, - "!==": 32, - "=>": 33, - "+": 34, - "-": 35, - "*": 36, - "/": 37, - "%": 38, - "++": 39, - "--": 40, - "<<": 41, - ">": 42, - ">>>": 43, - "&": 44, - "|": 45, - "^": 46, - "!": 47, - "~": 48, - "&&": 49, - "||": 50, - "?": 51, - ":": 52, - "=": 54, - "+=": 55, - "-=": 56, - "*=": 57, - "/=": 58, - "%=": 59, - "<<=": 60, - ">>=": 61, - ">>>=": 62, - "&=": 63, - "|=": 64, - "^=": 65, - "@": 53 + "abstract": 113, + "any": 115, + "as": 114, + "boolean": 118, + "break": 68, + "case": 69, + "catch": 70, + "class": 71, + "continue": 73, + "const": 72, + "constructor": 119, + "debugger": 74, + "declare": 120, + "default": 75, + "delete": 76, + "do": 77, + "else": 78, + "enum": 79, + "export": 80, + "extends": 81, + "false": 82, + "finally": 83, + "for": 84, + "from": 131, + "function": 85, + "get": 121, + "if": 86, + "implements": 104, + "import": 87, + "in": 88, + "instanceof": 89, + "interface": 105, + "is": 122, + "let": 106, + "module": 123, + "namespace": 124, + "new": 90, + "null": 91, + "number": 126, + "package": 107, + "private": 108, + "protected": 109, + "public": 110, + "require": 125, + "return": 92, + "set": 127, + "static": 111, + "string": 128, + "super": 93, + "switch": 94, + "symbol": 129, + "this": 95, + "throw": 96, + "true": 97, + "try": 98, + "type": 130, + "typeof": 99, + "var": 100, + "void": 101, + "while": 102, + "with": 103, + "yield": 112, + "async": 116, + "await": 117, + "of": 132, + "{": 15, + "}": 16, + "(": 17, + ")": 18, + "[": 19, + "]": 20, + ".": 21, + "...": 22, + ";": 23, + ",": 24, + "<": 25, + ">": 27, + "<=": 28, + ">=": 29, + "==": 30, + "!=": 31, + "===": 32, + "!==": 33, + "=>": 34, + "+": 35, + "-": 36, + "*": 37, + "/": 38, + "%": 39, + "++": 40, + "--": 41, + "<<": 42, + ">": 43, + ">>>": 44, + "&": 45, + "|": 46, + "^": 47, + "!": 48, + "~": 49, + "&&": 50, + "||": 51, + "?": 52, + ":": 53, + "=": 55, + "+=": 56, + "-=": 57, + "*=": 58, + "/=": 59, + "%=": 60, + "<<=": 61, + ">>=": 62, + ">>>=": 63, + "&=": 64, + "|=": 65, + "^=": 66, + "@": 54 }; var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -1838,6 +1842,7 @@ var ts; var lineNumber = ts.binarySearch(lineStarts, position); if (lineNumber < 0) { lineNumber = ~lineNumber - 1; + ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); } return { line: lineNumber, @@ -1866,16 +1871,6 @@ var ts; } ts.isWhiteSpace = isWhiteSpace; function isLineBreak(ch) { - // ES5 7.3: - // The ECMAScript line terminator characters are listed in Table 3. - // Table 3: Line Terminator Characters - // Code Unit Value Name Formal Name - // \u000A Line Feed - // \u000D Carriage Return - // \u2028 Line separator - // \u2029 Paragraph separator - // Only the characters in Table 3 are treated as line terminators. Other new line or line - // breaking characters are treated as white space but not as line terminators. return ch === 10 || ch === 13 || ch === 8232 || @@ -1903,6 +1898,8 @@ var ts; case 61: case 62: return true; + case 35: + return pos === 0; default: return ch > 127; } @@ -1959,6 +1956,12 @@ var ts; continue; } break; + case 35: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; default: if (ch > 127 && (isWhiteSpace(ch) || isLineBreak(ch))) { pos++; @@ -2010,6 +2013,16 @@ var ts; } return pos; } + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + ts.Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); + } + function scanShebangTrivia(text, pos) { + var shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; + } function getCommentRanges(text, pos, trailing) { var result; var collecting = trailing || pos === 0; @@ -2091,6 +2104,12 @@ var ts; return getCommentRanges(text, pos, true); } ts.getTrailingCommentRanges = getTrailingCommentRanges; + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch === 36 || ch === 95 || @@ -2124,8 +2143,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 66 || token > 102; }, - isReservedWord: function () { return token >= 67 && token <= 102; }, + isIdentifier: function () { return token === 67 || token > 103; }, + isReservedWord: function () { return token >= 68 && token <= 103; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -2265,20 +2284,20 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 10 : 13; + resultingToken = startedWithBacktick ? 11 : 14; break; } var currChar = text.charCodeAt(pos); if (currChar === 96) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 10 : 13; + resultingToken = startedWithBacktick ? 11 : 14; break; } if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 11 : 12; + resultingToken = startedWithBacktick ? 12 : 13; break; } if (currChar === 92) { @@ -2439,7 +2458,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 66; + return token = 67; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2471,6 +2490,15 @@ var ts; return token = 1; } var ch = text.charCodeAt(pos); + if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6; + } + } switch (ch) { case 10: case 13: @@ -2505,66 +2533,66 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 32; + return pos += 3, token = 33; } - return pos += 2, token = 30; + return pos += 2, token = 31; } - return pos++, token = 47; + return pos++, token = 48; case 34: case 39: tokenValue = scanString(); - return token = 8; + return token = 9; case 96: return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 60; } - return pos++, token = 38; + return pos++, token = 39; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 49; + return pos += 2, token = 50; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } - return pos++, token = 44; + return pos++, token = 45; case 40: - return pos++, token = 16; - case 41: return pos++, token = 17; + case 41: + return pos++, token = 18; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } - return pos++, token = 36; + return pos++, token = 37; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 39; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 55; - } - return pos++, token = 34; - case 44: - return pos++, token = 23; - case 45: - if (text.charCodeAt(pos + 1) === 45) { return pos += 2, token = 40; } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 56; } return pos++, token = 35; + case 44: + return pos++, token = 24; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 41; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 57; + } + return pos++, token = 36; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); - return token = 7; + return token = 8; } if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 21; + return pos += 3, token = 22; } - return pos++, token = 20; + return pos++, token = 21; case 47: if (text.charCodeAt(pos + 1) === 47) { pos += 2; @@ -2608,9 +2636,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; + return pos += 2, token = 59; } - return pos++, token = 37; + return pos++, token = 38; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -2620,7 +2648,7 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { pos += 2; @@ -2630,7 +2658,7 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { pos += 2; @@ -2640,11 +2668,11 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7; + return token = 8; } if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - return token = 7; + return token = 8; } case 49: case 50: @@ -2656,11 +2684,11 @@ var ts; case 56: case 57: tokenValue = "" + scanNumber(); - return token = 7; + return token = 8; case 58: - return pos++, token = 52; + return pos++, token = 53; case 59: - return pos++, token = 22; + return pos++, token = 23; case 60: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2668,22 +2696,22 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; + return pos += 3, token = 61; } - return pos += 2, token = 41; + return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 27; + return pos += 2, token = 28; } if (text.charCodeAt(pos + 1) === 47 && languageVariant === 1) { - return pos += 2, token = 25; + return pos += 2, token = 26; } - return pos++, token = 24; + return pos++, token = 25; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2691,19 +2719,19 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 31; + return pos += 3, token = 32; } - return pos += 2, token = 29; + return pos += 2, token = 30; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 33; + return pos += 2, token = 34; } - return pos++, token = 54; + return pos++, token = 55; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2711,37 +2739,37 @@ var ts; continue; } else { - return token = 6; + return token = 7; } } - return pos++, token = 26; + return pos++, token = 27; case 63: - return pos++, token = 51; + return pos++, token = 52; case 91: - return pos++, token = 18; - case 93: return pos++, token = 19; + case 93: + return pos++, token = 20; case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 66; + } + return pos++, token = 47; + case 123: + return pos++, token = 15; + case 124: + if (text.charCodeAt(pos + 1) === 124) { + return pos += 2, token = 51; + } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 65; } return pos++, token = 46; - case 123: - return pos++, token = 14; - case 124: - if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 50; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; - } - return pos++, token = 45; case 125: - return pos++, token = 15; + return pos++, token = 16; case 126: - return pos++, token = 48; + return pos++, token = 49; case 64: - return pos++, token = 53; + return pos++, token = 54; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -2777,27 +2805,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 26) { + if (token === 27) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 62; + return pos += 3, token = 63; } - return pos += 2, token = 43; + return pos += 2, token = 44; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 62; } - return pos++, token = 42; + return pos++, token = 43; } if (text.charCodeAt(pos) === 61) { - return pos++, token = 28; + return pos++, token = 29; } } return token; } function reScanSlashToken() { - if (token === 37 || token === 58) { + if (token === 38 || token === 59) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -2836,12 +2864,12 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 9; + token = 10; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 15, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 16, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -2858,14 +2886,14 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 25; + return token = 26; } pos++; - return token = 24; + return token = 25; } if (char === 123) { pos++; - return token = 14; + return token = 15; } while (pos < end) { pos++; @@ -2874,10 +2902,10 @@ var ts; break; } } - return token = 233; + return token = 234; } function scanJsxIdentifier() { - if (token === 66) { + if (tokenIsIdentifierOrKeyword(token)) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); @@ -2944,10 +2972,6 @@ var ts; } ts.createScanner = createScanner; })(ts || (ts = {})); -/// -/// -/// -/// var ts; (function (ts) { ts.optionDeclarations = [ @@ -2975,6 +2999,11 @@ var ts; type: "boolean", description: ts.Diagnostics.Print_this_message }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + }, { name: "inlineSourceMap", type: "boolean" @@ -3065,6 +3094,12 @@ var ts; { name: "out", type: "string", + isFilePath: false, + paramType: ts.Diagnostics.FILE + }, + { + name: "outFile", + type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE @@ -3117,6 +3152,12 @@ var ts; description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, paramType: ts.Diagnostics.LOCATION }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", @@ -3163,20 +3204,39 @@ var ts; type: "boolean", experimental: true, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: { + "node": 2, + "classic": 1 + }, + description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic } ]; - function parseCommandLine(commandLine) { - var options = {}; - var fileNames = []; - var errors = []; - var shortOptionNames = {}; + var optionNameMapCache; + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } var optionNameMap = {}; + var shortOptionNames = {}; ts.forEach(ts.optionDeclarations, function (option) { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { shortOptionNames[option.shortName] = option.name; } }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function parseCommandLine(commandLine, readFile) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; parseStrings(commandLine); return { options: options, @@ -3231,7 +3291,7 @@ var ts; } } function parseResponseFile(fileName) { - var text = ts.sys.readFile(fileName); + var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); if (!text) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); return; @@ -3266,10 +3326,10 @@ var ts; } } ts.parseCommandLine = parseCommandLine; - function readConfigFile(fileName) { - var text = ''; + function readConfigFile(fileName, readFile) { + var text = ""; try { - text = ts.sys.readFile(fileName); + text = readFile(fileName); } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; @@ -3340,6 +3400,9 @@ var ts; if (json["files"] instanceof Array) { fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } } else { var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; @@ -3367,7 +3430,6 @@ var ts; } ts.parseConfigFile = parseConfigFile; })(ts || (ts = {})); -/// var ts; (function (ts) { function getDeclarationOfKind(symbol, kind) { @@ -3416,6 +3478,37 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(arr1, arr2, comparer) { + if (!arr1 || !arr2) { + return arr1 === arr2; + } + if (arr1.length !== arr2.length) { + return false; + } + for (var i = 0; i < arr1.length; ++i) { + var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModule(sourceFile, moduleNameText) { + return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); + } + ts.hasResolvedModule = hasResolvedModule; + function getResolvedModule(sourceFile, moduleNameText) { + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModule = getResolvedModule; + function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + sourceFile.resolvedModules[moduleNameText] = resolvedModule; + } + ts.setResolvedModule = setResolvedModule; function containsParseError(node) { aggregateChildData(node); return (node.parserContextFlags & 64) !== 0; @@ -3432,7 +3525,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 245) { + while (node && node.kind !== 246) { node = node.parent; } return node; @@ -3508,7 +3601,7 @@ var ts; } ts.unescapeIdentifier = unescapeIdentifier; function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/\W/g, "_"); + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { @@ -3523,15 +3616,15 @@ var ts; return current; } switch (current.kind) { - case 245: - case 217: - case 241: - case 215: - case 196: + case 246: + case 218: + case 242: + case 216: case 197: case 198: + case 199: return current; - case 189: + case 190: if (!isFunctionLike(current.parent)) { return current; } @@ -3542,9 +3635,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 208 && + declaration.kind === 209 && declaration.parent && - declaration.parent.kind === 241; + declaration.parent.kind === 242; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3580,22 +3673,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 245: + case 246: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 208: - case 160: - case 211: - case 183: + case 209: + case 161: case 212: + case 184: + case 213: + case 216: case 215: - case 214: - case 244: - case 210: - case 170: + case 245: + case 211: + case 171: errorNode = node.name; break; } @@ -3617,11 +3710,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 214 && isConst(node); + return node.kind === 215 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 160 || isBindingPattern(node))) { + while (node && (node.kind === 161 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3629,14 +3722,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 208) { + if (node.kind === 209) { node = node.parent; } - if (node && node.kind === 209) { + if (node && node.kind === 210) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 190) { + if (node && node.kind === 191) { flags |= node.flags; } return flags; @@ -3651,20 +3744,18 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 192 && node.expression.kind === 8; + return node.kind === 193 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - if (node.kind === 135 || node.kind === 134) { - return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); - } - else { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); + var commentRanges = (node.kind === 136 || node.kind === 135) ? + ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return ts.filter(commentRanges, isJsDocComment); function isJsDocComment(comment) { return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 && sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 && @@ -3673,69 +3764,70 @@ var ts; } ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (148 <= node.kind && node.kind <= 157) { + if (149 <= node.kind && node.kind <= 158) { return true; } switch (node.kind) { - case 114: - case 125: - case 127: - case 117: + case 115: + case 126: case 128: + case 118: + case 129: return true; - case 100: - return node.parent.kind !== 174; - case 8: - return node.parent.kind === 135; - case 185: + case 101: + return node.parent.kind !== 175; + case 9: + return node.parent.kind === 136; + case 186: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 66: - if (node.parent.kind === 132 && node.parent.right === node) { + case 67: + if (node.parent.kind === 133 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 163 && node.parent.name === node) { + else if (node.parent.kind === 164 && node.parent.name === node) { node = node.parent; } - case 132: - case 163: - ts.Debug.assert(node.kind === 66 || node.kind === 132 || node.kind === 163, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + case 133: + case 164: + ts.Debug.assert(node.kind === 67 || node.kind === 133 || node.kind === 164, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 151) { + if (parent_1.kind === 152) { return false; } - if (148 <= parent_1.kind && parent_1.kind <= 157) { + if (149 <= parent_1.kind && parent_1.kind <= 158) { return true; } switch (parent_1.kind) { - case 185: + case 186: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 134: - return node === parent_1.constraint; - case 138: - case 137: case 135: - case 208: + return node === parent_1.constraint; + case 139: + case 138: + case 136: + case 209: return node === parent_1.type; - case 210: - case 170: + case 211: case 171: + case 172: + case 142: case 141: case 140: - case 139: - case 142: case 143: - return node === parent_1.type; case 144: + return node === parent_1.type; case 145: case 146: + case 147: return node === parent_1.type; - case 168: + case 169: return node === parent_1.type; - case 165: case 166: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 167: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 168: return false; } } @@ -3746,23 +3838,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 201: + case 202: return visitor(node); - case 217: - case 189: - case 193: + case 218: + case 190: case 194: case 195: case 196: case 197: case 198: - case 202: + case 199: case 203: - case 238: - case 239: case 204: - case 206: - case 241: + case 239: + case 240: + case 205: + case 207: + case 242: return ts.forEachChild(node, traverse); } } @@ -3772,23 +3864,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 181: + case 182: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 214: - case 212: case 215: case 213: - case 211: - case 183: + case 216: + case 214: + case 212: + case 184: return; default: if (isFunctionLike(node)) { var name_6 = node.name; - if (name_6 && name_6.kind === 133) { + if (name_6 && name_6.kind === 134) { traverse(name_6.expression); return; } @@ -3803,14 +3895,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 160: - case 244: - case 135: - case 242: - case 138: - case 137: + case 161: + case 245: + case 136: case 243: - case 208: + case 139: + case 138: + case 244: + case 209: return true; } } @@ -3818,41 +3910,55 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 142 || node.kind === 143); + return node && (node.kind === 143 || node.kind === 144); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 211 || node.kind === 183); + return node && (node.kind === 212 || node.kind === 184); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 141: - case 170: - case 210: - case 171: - case 140: - case 139: case 142: + case 171: + case 211: + case 172: + case 141: + case 140: case 143: case 144: case 145: case 146: - case 149: + case 147: case 150: + case 151: return true; } } return false; } ts.isFunctionLike = isFunctionLike; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 141: + case 140: + case 142: + case 143: + case 144: + case 211: + case 171: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 189 && isFunctionLike(node.parent); + return node && node.kind === 190 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 140 && node.parent.kind === 162; + return node && node.kind === 141 && node.parent.kind === 163; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -3880,36 +3986,36 @@ var ts; return undefined; } switch (node.kind) { - case 133: + case 134: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 136: - if (node.parent.kind === 135 && isClassElement(node.parent.parent)) { + case 137: + if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 171: + case 172: if (!includeArrowFunctions) { continue; } - case 210: - case 170: - case 215: - case 138: - case 137: - case 140: + case 211: + case 171: + case 216: case 139: + case 138: case 141: + case 140: case 142: case 143: - case 214: - case 245: + case 144: + case 215: + case 246: return node; } } @@ -3921,33 +4027,33 @@ var ts; if (!node) return node; switch (node.kind) { - case 133: + case 134: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 136: - if (node.parent.kind === 135 && isClassElement(node.parent.parent)) { + case 137: + if (node.parent.kind === 136 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 210: - case 170: + case 211: case 171: + case 172: if (!includeFunctions) { continue; } - case 138: - case 137: - case 140: case 139: + case 138: case 141: + case 140: case 142: case 143: + case 144: return node; } } @@ -3956,12 +4062,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 148: + case 149: return node.typeName; - case 185: + case 186: return node.expression; - case 66: - case 132: + case 67: + case 133: return node; } } @@ -3969,7 +4075,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 167) { + if (node.kind === 168) { return node.tag; } return node.expression; @@ -3977,40 +4083,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 211: + case 212: return true; - case 138: - return node.parent.kind === 211; - case 135: - return node.parent.body && node.parent.parent.kind === 211; - case 142: + case 139: + return node.parent.kind === 212; + case 136: + return node.parent.body && node.parent.parent.kind === 212; case 143: - case 140: - return node.body && node.parent.kind === 211; + case 144: + case 141: + return node.body && node.parent.kind === 212; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 211: + case 212: if (node.decorators) { return true; } return false; - case 138: - case 135: + case 139: + case 136: if (node.decorators) { return true; } return false; - case 142: + case 143: if (node.body && node.decorators) { return true; } return false; - case 140: - case 143: + case 141: + case 144: if (node.body && node.decorators) { return true; } @@ -4021,10 +4127,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 211: + case 212: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 140: - case 143: + case 141: + case 144: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -4036,92 +4142,93 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 94: - case 92: - case 90: - case 96: - case 81: - case 9: - case 161: + case 95: + case 93: + case 91: + case 97: + case 82: + case 10: case 162: case 163: case 164: case 165: case 166: case 167: - case 186: case 168: + case 187: case 169: case 170: - case 183: case 171: - case 174: + case 184: case 172: + case 175: case 173: - case 176: + case 174: case 177: case 178: case 179: - case 182: case 180: - case 10: - case 184: - case 230: - case 231: + case 183: case 181: + case 11: + case 185: + case 231: + case 232: + case 182: return true; - case 132: - while (node.parent.kind === 132) { + case 133: + while (node.parent.kind === 133) { node = node.parent; } - return node.parent.kind === 151; - case 66: - if (node.parent.kind === 151) { + return node.parent.kind === 152; + case 67: + if (node.parent.kind === 152) { return true; } - case 7: case 8: + case 9: var parent_2 = node.parent; switch (parent_2.kind) { - case 208: - case 135: + case 209: + case 136: + case 139: case 138: - case 137: - case 244: - case 242: - case 160: + case 245: + case 243: + case 161: return parent_2.initializer === node; - case 192: case 193: case 194: case 195: - case 201: + case 196: case 202: case 203: - case 238: - case 205: - case 203: + case 204: + case 239: + case 206: + case 204: return parent_2.expression === node; - case 196: + case 197: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 209) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 210) || forStatement.condition === node || forStatement.incrementor === node; - case 197: case 198: + case 199: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 209) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210) || forInStatement.expression === node; - case 168: - case 186: - return node === parent_2.expression; + case 169: case 187: return node === parent_2.expression; - case 133: + case 188: return node === parent_2.expression; - case 136: + case 134: + return node === parent_2.expression; + case 137: + case 238: return true; - case 185: + case 186: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4139,7 +4246,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 && node.moduleReference.kind === 229; + return node.kind === 219 && node.moduleReference.kind === 230; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4148,20 +4255,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 && node.moduleReference.kind !== 229; + return node.kind === 219 && node.moduleReference.kind !== 230; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 219) { + if (node.kind === 220) { return node.moduleSpecifier; } - if (node.kind === 218) { + if (node.kind === 219) { var reference = node.moduleReference; - if (reference.kind === 229) { + if (reference.kind === 230) { return reference.expression; } } - if (node.kind === 225) { + if (node.kind === 226) { return node.moduleSpecifier; } } @@ -4169,15 +4276,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 135: - return node.questionToken !== undefined; + case 136: + case 141: case 140: - case 139: - return node.questionToken !== undefined; + case 244: case 243: - case 242: + case 139: case 138: - case 137: return node.questionToken !== undefined; } } @@ -4185,9 +4290,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 258 && + return node.kind === 259 && node.parameters.length > 0 && - node.parameters[0].type.kind === 260; + node.parameters[0].type.kind === 261; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4201,24 +4306,24 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 266); + return getJSDocTag(node, 267); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 265); + return getJSDocTag(node, 266); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 267); + return getJSDocTag(node, 268); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 66) { + if (parameter.name && parameter.name.kind === 67) { var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 264) { + if (t.kind === 265) { var parameterTag = t; var name_7 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_7.text === parameterName) { @@ -4237,12 +4342,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32) { - if (node.type && node.type.kind === 259) { + if (node.type && node.type.kind === 260) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 259; + return paramTag.typeExpression.type.kind === 260; } } return node.dotDotDotToken !== undefined; @@ -4251,19 +4356,19 @@ var ts; } ts.isRestParameter = isRestParameter; function isLiteralKind(kind) { - return 7 <= kind && kind <= 10; + return 8 <= kind && kind <= 11; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 8 || kind === 10; + return kind === 9 || kind === 11; } ts.isTextualLiteralKind = isTextualLiteralKind; function isTemplateLiteralKind(kind) { - return 10 <= kind && kind <= 13; + return 11 <= kind && kind <= 14; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 159 || node.kind === 158); + return !!node && (node.kind === 160 || node.kind === 159); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -4278,34 +4383,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 171: - case 160: - case 211: - case 183: - case 141: - case 214: - case 244: - case 227: - case 210: - case 170: - case 142: - case 220: - case 218: - case 223: + case 172: + case 161: case 212: - case 140: - case 139: + case 184: + case 142: case 215: - case 221: - case 135: - case 242: - case 138: - case 137: + case 245: + case 228: + case 211: + case 171: case 143: - case 243: + case 221: + case 219: + case 224: case 213: - case 134: - case 208: + case 141: + case 140: + case 216: + case 222: + case 136: + case 243: + case 139: + case 138: + case 144: + case 244: + case 214: + case 135: + case 209: return true; } return false; @@ -4313,25 +4418,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 200: - case 199: - case 207: - case 194: - case 192: - case 191: - case 197: - case 198: - case 196: - case 193: - case 204: case 201: - case 203: - case 95: - case 206: - case 190: + case 200: + case 208: case 195: + case 193: + case 192: + case 198: + case 199: + case 197: + case 194: + case 205: case 202: - case 224: + case 204: + case 96: + case 207: + case 191: + case 196: + case 203: + case 225: return true; default: return false; @@ -4340,13 +4445,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 141: - case 138: - case 140: case 142: - case 143: case 139: - case 146: + case 141: + case 143: + case 144: + case 140: + case 147: return true; default: return false; @@ -4354,11 +4459,11 @@ var ts; } ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 66 && name.kind !== 8 && name.kind !== 7) { + if (name.kind !== 67 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 223 || parent.kind === 227) { + if (parent.kind === 224 || parent.kind === 228) { if (parent.propertyName) { return true; } @@ -4372,54 +4477,54 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 138: - case 137: - case 140: case 139: - case 142: + case 138: + case 141: + case 140: case 143: - case 244: - case 242: - case 163: + case 144: + case 245: + case 243: + case 164: return parent.name === node; - case 132: + case 133: if (parent.right === node) { - while (parent.kind === 132) { + while (parent.kind === 133) { parent = parent.parent; } - return parent.kind === 151; + return parent.kind === 152; } return false; - case 160: - case 223: + case 161: + case 224: return parent.propertyName === node; - case 227: + case 228: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 218 || - node.kind === 220 && !!node.name || - node.kind === 221 || - node.kind === 223 || - node.kind === 227 || - node.kind === 224 && node.expression.kind === 66; + return node.kind === 219 || + node.kind === 221 && !!node.name || + node.kind === 222 || + node.kind === 224 || + node.kind === 228 || + node.kind === 225 && node.expression.kind === 67; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80); + var heritageClause = getHeritageClause(node.heritageClauses, 81); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 103); + var heritageClause = getHeritageClause(node.heritageClauses, 104); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80); + var heritageClause = getHeritageClause(node.heritageClauses, 81); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -4488,11 +4593,11 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 67 <= token && token <= 131; + return 68 <= token && token <= 132; } ts.isKeyword = isKeyword; function isTrivia(token) { - return 2 <= token && token <= 6; + return 2 <= token && token <= 7; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { @@ -4501,19 +4606,19 @@ var ts; ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 133 && + declaration.name.kind === 134 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 163 && isESSymbolIdentifier(node.expression); + return node.kind === 164 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 66 || name.kind === 8 || name.kind === 7) { + if (name.kind === 67 || name.kind === 9 || name.kind === 8) { return name.text; } - if (name.kind === 133) { + if (name.kind === 134) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4528,21 +4633,21 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 66 && node.text === "Symbol"; + return node.kind === 67 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 112: - case 115: - case 71: - case 119: - case 74: - case 79: - case 109: - case 107: - case 108: + case 113: + case 116: + case 72: + case 120: + case 75: + case 80: case 110: + case 108: + case 109: + case 111: return true; } return false; @@ -4550,20 +4655,36 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 135; + return root.kind === 136; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 160) { + while (node.kind === 161) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 215 || n.kind === 245; + return isFunctionLike(n) || n.kind === 216 || n.kind === 246; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function cloneEntityName(node) { + if (node.kind === 67) { + var clone_1 = createSynthesizedNode(67); + clone_1.text = node.text; + return clone_1; + } + else { + var clone_2 = createSynthesizedNode(133); + clone_2.left = cloneEntityName(node.left); + clone_2.left.parent = clone_2; + clone_2.right = cloneEntityName(node.right); + clone_2.right.parent = clone_2; + return clone_2; + } + } + ts.cloneEntityName = cloneEntityName; function nodeIsSynthesized(node) { return node.pos === -1; } @@ -4590,11 +4711,21 @@ var ts; add: add, getGlobalDiagnostics: getGlobalDiagnostics, getDiagnostics: getDiagnostics, - getModificationCount: getModificationCount + getModificationCount: getModificationCount, + reattachFileDiagnostics: reattachFileDiagnostics }; function getModificationCount() { return modificationCount; } + function reattachFileDiagnostics(newFile) { + if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { + return; + } + for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { + var diagnostic = _a[_i]; + diagnostic.file = newFile; + } + } function add(diagnostic) { var diagnostics; if (diagnostic.file) { @@ -4788,7 +4919,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 141 && nodeIsPresent(member.body)) { + if (member.kind === 142 && nodeIsPresent(member.body)) { return member; } }); @@ -4800,7 +4931,7 @@ var ts; ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); } return false; @@ -4815,10 +4946,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 142) { + if (accessor.kind === 143) { getAccessor = accessor; } - else if (accessor.kind === 143) { + else if (accessor.kind === 144) { setAccessor = accessor; } else { @@ -4827,7 +4958,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 142 || member.kind === 143) + if ((member.kind === 143 || member.kind === 144) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -4838,10 +4969,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 142 && !getAccessor) { + if (member.kind === 143 && !getAccessor) { getAccessor = member; } - if (member.kind === 143 && !setAccessor) { + if (member.kind === 144 && !setAccessor) { setAccessor = member; } } @@ -4920,7 +5051,7 @@ var ts; } function writeTrimmedCurrentLine(pos, nextLineStart) { var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { writer.write(currentLineText); if (end !== comment.end) { @@ -4947,16 +5078,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 110: return 128; - case 109: return 16; - case 108: return 64; - case 107: return 32; - case 112: return 256; - case 79: return 1; - case 119: return 2; - case 71: return 32768; - case 74: return 1024; - case 115: return 512; + case 111: return 128; + case 110: return 16; + case 109: return 64; + case 108: return 32; + case 113: return 256; + case 80: return 1; + case 120: return 2; + case 72: return 32768; + case 75: return 1024; + case 116: return 512; } return 0; } @@ -4964,29 +5095,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 163: case 164: - case 166: case 165: - case 230: - case 231: case 167: - case 161: - case 169: + case 166: + case 231: + case 232: + case 168: case 162: - case 183: case 170: - case 66: - case 9: - case 7: - case 8: + case 163: + case 184: + case 171: + case 67: case 10: - case 180: - case 81: - case 90: - case 94: - case 96: - case 92: + case 8: + case 9: + case 11: + case 181: + case 82: + case 91: + case 95: + case 97: + case 93: return true; } } @@ -4994,12 +5125,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 54 && token <= 65; + return token >= 55 && token <= 66; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 185 && - node.parent.token === 80 && + return node.kind === 186 && + node.parent.token === 81 && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -5008,10 +5139,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 66) { + if (node.kind === 67) { return true; } - else if (node.kind === 163) { + else if (node.kind === 164) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -5019,10 +5150,21 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 132 && node.parent.right === node) || - (node.parent.kind === 163 && node.parent.name === node); + return (node.parent.kind === 133 && node.parent.right === node) || + (node.parent.kind === 164 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 163) { + return expression.properties.length === 0; + } + if (kind === 162) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -5226,9 +5368,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 134) { + if (d && d.kind === 135) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 212) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213) { return current; } } @@ -5236,11 +5378,9 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { - var nodeConstructors = new Array(269); + var nodeConstructors = new Array(270); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5278,20 +5418,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 132: + case 133: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 134: + case 135: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 135: + case 136: + case 139: case 138: - case 137: - case 242: case 243: - case 208: - case 160: + case 244: + case 209: + case 161: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5300,24 +5440,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 149: case 150: - case 144: + case 151: case 145: case 146: + case 147: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 140: - case 139: case 141: + case 140: case 142: case 143: - case 170: - case 210: + case 144: case 171: + case 211: + case 172: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5328,160 +5468,153 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 148: + case 149: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 147: + case 148: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 151: - return visitNode(cbNode, node.exprName); case 152: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 153: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 154: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 155: + return visitNodes(cbNodes, node.elementTypes); case 156: - return visitNodes(cbNodes, node.types); case 157: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); case 158: + return visitNode(cbNode, node.type); case 159: - return visitNodes(cbNodes, node.elements); - case 161: + case 160: return visitNodes(cbNodes, node.elements); case 162: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 163: + return visitNodes(cbNodes, node.properties); + case 164: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 164: + case 165: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 165: case 166: + case 167: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 167: + case 168: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 168: + case 169: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 169: - return visitNode(cbNode, node.expression); - case 172: + case 170: return visitNode(cbNode, node.expression); case 173: return visitNode(cbNode, node.expression); case 174: return visitNode(cbNode, node.expression); - case 176: - return visitNode(cbNode, node.operand); - case 181: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 175: return visitNode(cbNode, node.expression); case 177: return visitNode(cbNode, node.operand); + case 182: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 176: + return visitNode(cbNode, node.expression); case 178: + return visitNode(cbNode, node.operand); + case 179: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 186: + case 187: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 179: + case 180: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 182: + case 183: return visitNode(cbNode, node.expression); - case 189: - case 216: + case 190: + case 217: return visitNodes(cbNodes, node.statements); - case 245: + case 246: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 190: + case 191: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 209: + case 210: return visitNodes(cbNodes, node.declarations); - case 192: - return visitNode(cbNode, node.expression); case 193: + return visitNode(cbNode, node.expression); + case 194: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 194: + case 195: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 195: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 196: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 197: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 198: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 199: - case 200: - return visitNode(cbNode, node.label); - case 201: - return visitNode(cbNode, node.expression); - case 202: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 200: + case 201: + return visitNode(cbNode, node.label); + case 202: + return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 217: + case 218: return visitNodes(cbNodes, node.clauses); - case 238: + case 239: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 239: + case 240: return visitNodes(cbNodes, node.statements); - case 204: + case 205: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 205: - return visitNode(cbNode, node.expression); case 206: + return visitNode(cbNode, node.expression); + case 207: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 241: + case 242: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 136: + case 137: return visitNode(cbNode, node.expression); - case 211: - case 183: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); case 212: + case 184: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -5493,125 +5626,132 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 214: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 244: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 215: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 245: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 216: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 218: + case 219: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 219: + case 220: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 220: + case 221: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 221: - return visitNode(cbNode, node.name); case 222: - case 226: + return visitNode(cbNode, node.name); + case 223: + case 227: return visitNodes(cbNodes, node.elements); - case 225: + case 226: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 223: - case 227: + case 224: + case 228: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 224: + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 180: + case 181: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 187: + case 188: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 133: + case 134: return visitNode(cbNode, node.expression); - case 240: + case 241: return visitNodes(cbNodes, node.types); - case 185: + case 186: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 229: - return visitNode(cbNode, node.expression); - case 228: - return visitNodes(cbNodes, node.decorators); case 230: + return visitNode(cbNode, node.expression); + case 229: + return visitNodes(cbNodes, node.decorators); + case 231: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 231: case 232: + case 233: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 235: + case 236: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 236: - return visitNode(cbNode, node.expression); case 237: return visitNode(cbNode, node.expression); - case 234: + case 238: + return visitNode(cbNode, node.expression); + case 235: return visitNode(cbNode, node.tagName); - case 246: + case 247: return visitNode(cbNode, node.type); - case 250: - return visitNodes(cbNodes, node.types); case 251: return visitNodes(cbNodes, node.types); - case 249: + case 252: + return visitNodes(cbNodes, node.types); + case 250: return visitNode(cbNode, node.elementType); + case 254: + return visitNode(cbNode, node.type); case 253: return visitNode(cbNode, node.type); - case 252: - return visitNode(cbNode, node.type); - case 254: + case 255: return visitNodes(cbNodes, node.members); - case 256: + case 257: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 257: - return visitNode(cbNode, node.type); case 258: + return visitNode(cbNode, node.type); + case 259: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 259: - return visitNode(cbNode, node.type); case 260: return visitNode(cbNode, node.type); case 261: return visitNode(cbNode, node.type); - case 255: + case 262: + return visitNode(cbNode, node.type); + case 256: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 262: + case 263: return visitNodes(cbNodes, node.tags); - case 264: + case 265: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 265: - return visitNode(cbNode, node.typeExpression); case 266: return visitNode(cbNode, node.typeExpression); case 267: + return visitNode(cbNode, node.typeExpression); + case 268: return visitNodes(cbNodes, node.typeParameters); } } @@ -5707,9 +5847,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 190: - case 210: - case 135: + case 191: + case 211: + case 136: addJSDocComment(node); } forEachChild(node, visit); @@ -5728,10 +5868,6 @@ var ts; } } function fixupParentReferences(sourceFile) { - // normally parent references are set during binding. However, for clients that only need - // a syntax tree, and no semantic features, then the binding process is an unnecessary - // overhead. This functions allows us to set all the parents, without all the expense of - // binding. var parent = sourceFile; forEachChild(sourceFile, visitNode); return; @@ -5747,7 +5883,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(245, 0); + var sourceFile = createNode(246, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -5880,6 +6016,9 @@ var ts; function scanJsxIdentifier() { return token = scanner.scanJsxIdentifier(); } + function scanJsxText() { + return token = scanner.scanJsxToken(); + } function speculationHelper(callback, isLookAhead) { var saveToken = token; var saveParseDiagnosticsLength = parseDiagnostics.length; @@ -5903,20 +6042,23 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 66) { + if (token === 67) { return true; } - if (token === 111 && inYieldContext()) { + if (token === 112 && inYieldContext()) { return false; } - if (token === 116 && inAwaitContext()) { + if (token === 117 && inAwaitContext()) { return false; } - return token > 102; + return token > 103; } - function parseExpected(kind, diagnosticMessage) { + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } if (token === kind) { - nextToken(); + if (shouldAdvance) { + nextToken(); + } return true; } if (diagnosticMessage) { @@ -5950,20 +6092,20 @@ var ts; return finishNode(node); } function canParseSemicolon() { - if (token === 22) { + if (token === 23) { return true; } - return token === 15 || token === 1 || scanner.hasPrecedingLineBreak(); + return token === 16 || token === 1 || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token === 22) { + if (token === 23) { nextToken(); } return true; } else { - return parseExpected(22); + return parseExpected(23); } } function createNode(kind, pos) { @@ -6005,32 +6147,32 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(66); - if (token !== 66) { + var node = createNode(67); + if (token !== 67) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(66, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(67, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); } function parseIdentifierName() { - return createIdentifier(isIdentifierOrKeyword()); + return createIdentifier(ts.tokenIsIdentifierOrKeyword(token)); } function isLiteralPropertyName() { - return isIdentifierOrKeyword() || - token === 8 || - token === 7; + return ts.tokenIsIdentifierOrKeyword(token) || + token === 9 || + token === 8; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token === 8 || token === 7) { + if (token === 9 || token === 8) { return parseLiteralNode(true); } - if (allowComputedPropertyNames && token === 18) { + if (allowComputedPropertyNames && token === 19) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -6042,30 +6184,30 @@ var ts; return parsePropertyNameWorker(false); } function isSimplePropertyName() { - return token === 8 || token === 7 || isIdentifierOrKeyword(); + return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token); } function parseComputedPropertyName() { - var node = createNode(133); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(134); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); return finishNode(node); } function parseContextualModifier(t) { return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 71) { - return nextToken() === 78; + if (token === 72) { + return nextToken() === 79; } - if (token === 79) { + if (token === 80) { nextToken(); - if (token === 74) { + if (token === 75) { return lookAhead(nextTokenIsClassOrFunction); } - return token !== 36 && token !== 14 && canFollowModifier(); + return token !== 37 && token !== 15 && canFollowModifier(); } - if (token === 74) { + if (token === 75) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -6075,14 +6217,14 @@ var ts; return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token === 18 - || token === 14 - || token === 36 + return token === 19 + || token === 15 + || token === 37 || isLiteralPropertyName(); } function nextTokenIsClassOrFunction() { nextToken(); - return token === 70 || token === 84; + return token === 71 || token === 85; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -6093,21 +6235,21 @@ var ts; case 0: case 1: case 3: - return !(token === 22 && inErrorRecovery) && isStartOfStatement(); + return !(token === 23 && inErrorRecovery) && isStartOfStatement(); case 2: - return token === 68 || token === 74; + return token === 69 || token === 75; case 4: return isStartOfTypeMember(); case 5: - return lookAhead(isClassMemberStart) || (token === 22 && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token === 23 && !inErrorRecovery); case 6: - return token === 18 || isLiteralPropertyName(); + return token === 19 || isLiteralPropertyName(); case 12: - return token === 18 || token === 36 || isLiteralPropertyName(); + return token === 19 || token === 37 || isLiteralPropertyName(); case 9: return isLiteralPropertyName(); case 7: - if (token === 14) { + if (token === 15) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -6119,23 +6261,23 @@ var ts; case 8: return isIdentifierOrPattern(); case 10: - return token === 23 || token === 21 || isIdentifierOrPattern(); + return token === 24 || token === 22 || isIdentifierOrPattern(); case 17: return isIdentifier(); case 11: case 15: - return token === 23 || token === 21 || isStartOfExpression(); + return token === 24 || token === 22 || isStartOfExpression(); case 16: return isStartOfParameter(); case 18: case 19: - return token === 23 || isStartOfType(); + return token === 24 || isStartOfType(); case 20: return isHeritageClause(); case 21: - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); case 13: - return isIdentifierOrKeyword() || token === 14; + return ts.tokenIsIdentifierOrKeyword(token) || token === 15; case 14: return true; case 22: @@ -6148,10 +6290,10 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token === 14); - if (nextToken() === 15) { + ts.Debug.assert(token === 15); + if (nextToken() === 16) { var next = nextToken(); - return next === 23 || next === 14 || next === 80 || next === 103; + return next === 24 || next === 15 || next === 81 || next === 104; } return true; } @@ -6161,11 +6303,11 @@ var ts; } function nextTokenIsIdentifierOrKeyword() { nextToken(); - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 103 || - token === 80) { + if (token === 104 || + token === 81) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -6187,39 +6329,39 @@ var ts; case 12: case 9: case 21: - return token === 15; + return token === 16; case 3: - return token === 15 || token === 68 || token === 74; + return token === 16 || token === 69 || token === 75; case 7: - return token === 14 || token === 80 || token === 103; + return token === 15 || token === 81 || token === 104; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token === 26 || token === 16 || token === 14 || token === 80 || token === 103; + return token === 27 || token === 17 || token === 15 || token === 81 || token === 104; case 11: - return token === 17 || token === 22; + return token === 18 || token === 23; case 15: case 19: case 10: - return token === 19; + return token === 20; case 16: - return token === 17 || token === 19; + return token === 18 || token === 20; case 18: - return token === 26 || token === 16; + return token === 27 || token === 17; case 20: - return token === 14 || token === 15; + return token === 15 || token === 16; case 13: - return token === 26 || token === 37; + return token === 27 || token === 38; case 14: - return token === 24 && lookAhead(nextTokenIsSlash); + return token === 25 && lookAhead(nextTokenIsSlash); case 22: - return token === 17 || token === 52 || token === 15; + return token === 18 || token === 53 || token === 16; case 23: - return token === 26 || token === 15; + return token === 27 || token === 16; case 25: - return token === 19 || token === 15; + return token === 20 || token === 16; case 24: - return token === 15; + return token === 16; } } function isVariableDeclaratorListTerminator() { @@ -6229,7 +6371,7 @@ var ts; if (isInOrOfKeyword(token)) { return true; } - if (token === 33) { + if (token === 34) { return true; } return false; @@ -6334,17 +6476,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 141: - case 146: case 142: + case 147: case 143: - case 138: - case 188: + case 144: + case 139: + case 189: return true; - case 140: + case 141: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 66 && - methodDeclaration.name.originalKeywordKind === 118; + var nameIsConstructor = methodDeclaration.name.kind === 67 && + methodDeclaration.name.originalKeywordKind === 119; return !nameIsConstructor; } } @@ -6353,8 +6495,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 238: case 239: + case 240: return true; } } @@ -6363,65 +6505,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 210: + case 211: + case 191: case 190: - case 189: + case 194: case 193: - case 192: - case 205: + case 206: + case 202: + case 204: case 201: - case 203: case 200: + case 198: case 199: case 197: - case 198: case 196: - case 195: - case 202: - case 191: - case 206: - case 204: - case 194: + case 203: + case 192: case 207: + case 205: + case 195: + case 208: + case 220: case 219: - case 218: + case 226: case 225: - case 224: - case 215: - case 211: + case 216: case 212: - case 214: case 213: + case 215: + case 214: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 244; + return node.kind === 245; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 145: - case 139: case 146: - case 137: - case 144: + case 140: + case 147: + case 138: + case 145: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 208) { + if (node.kind !== 209) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 135) { + if (node.kind !== 136) { return false; } var parameter = node; @@ -6476,15 +6618,15 @@ var ts; if (isListElement(kind, false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(23)) { + if (parseOptional(24)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - parseExpected(23); - if (considerSemicolonAsDelimeter && token === 22 && !scanner.hasPrecedingLineBreak()) { + parseExpected(24); + if (considerSemicolonAsDelimeter && token === 23 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -6520,8 +6662,8 @@ var ts; } function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(20)) { - var node = createNode(132, entity.pos); + while (parseOptional(21)) { + var node = createNode(133, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6529,37 +6671,37 @@ var ts; return entity; } function parseRightSideOfDot(allowIdentifierNames) { - if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { + if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(66, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(67, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(180); + var template = createNode(181); template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 12); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 13); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(187); + var span = createNode(188); span.expression = allowInAnd(parseExpression); var literal; - if (token === 15) { + if (token === 16) { reScanTemplateToken(); literal = parseLiteralNode(); } else { - literal = parseExpectedToken(13, false, ts.Diagnostics._0_expected, ts.tokenToString(15)); + literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); } span.literal = literal; return finishNode(span); @@ -6577,7 +6719,7 @@ var ts; var tokenPos = scanner.getTokenPos(); nextToken(); finishNode(node); - if (node.kind === 7 + if (node.kind === 8 && sourceText.charCodeAt(tokenPos) === 48 && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { node.flags |= 65536; @@ -6586,30 +6728,30 @@ var ts; } function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 66 && token === 121 && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 67 && token === 122 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(147, typeName.pos); + var node_1 = createNode(148, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(148, typeName.pos); + var node = createNode(149, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token === 24) { - node.typeArguments = parseBracketedList(18, parseType, 24, 26); + if (!scanner.hasPrecedingLineBreak() && token === 25) { + node.typeArguments = parseBracketedList(18, parseType, 25, 27); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(151); - parseExpected(98); + var node = createNode(152); + parseExpected(99); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(134); + var node = createNode(135); node.name = parseIdentifier(); - if (parseOptional(80)) { + if (parseOptional(81)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -6620,20 +6762,20 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token === 24) { - return parseBracketedList(17, parseTypeParameter, 24, 26); + if (token === 25) { + return parseBracketedList(17, parseTypeParameter, 25, 27); } } function parseParameterType() { - if (parseOptional(52)) { - return token === 8 + if (parseOptional(53)) { + return token === 9 ? parseLiteralNode(true) : parseType(); } return undefined; } function isStartOfParameter() { - return token === 21 || isIdentifierOrPattern() || ts.isModifier(token) || token === 53; + return token === 22 || isIdentifierOrPattern() || ts.isModifier(token) || token === 54; } function setModifiers(node, modifiers) { if (modifiers) { @@ -6642,15 +6784,15 @@ var ts; } } function parseParameter() { - var node = createNode(135); + var node = createNode(136); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(21); + node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - node.questionToken = parseOptionalToken(51); + node.questionToken = parseOptionalToken(52); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return finishNode(node); @@ -6662,7 +6804,7 @@ var ts; return parseInitializer(true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 33; + var returnTokenRequired = returnToken === 34; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -6674,7 +6816,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(16)) { + if (parseExpected(17)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -6682,7 +6824,7 @@ var ts; var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(17) && requireCompleteParameterList) { + if (!parseExpected(18) && requireCompleteParameterList) { return undefined; } return result; @@ -6690,29 +6832,29 @@ var ts; return requireCompleteParameterList ? undefined : createMissingList(); } function parseTypeMemberSemicolon() { - if (parseOptional(23)) { + if (parseOptional(24)) { return; } parseSemicolon(); } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 145) { - parseExpected(89); + if (kind === 146) { + parseExpected(90); } - fillSignature(52, false, false, false, node); + fillSignature(53, false, false, false, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - if (token !== 18) { + if (token !== 19) { return false; } return lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { nextToken(); - if (token === 21 || token === 19) { + if (token === 22 || token === 20) { return true; } if (ts.isModifier(token)) { @@ -6727,20 +6869,20 @@ var ts; else { nextToken(); } - if (token === 52 || token === 23) { + if (token === 53 || token === 24) { return true; } - if (token !== 51) { + if (token !== 52) { return false; } nextToken(); - return token === 52 || token === 23 || token === 19; + return token === 53 || token === 24 || token === 20; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(146, fullStart); + var node = createNode(147, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(16, parseParameter, 18, 19); + node.parameters = parseBracketedList(16, parseParameter, 19, 20); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -6748,17 +6890,17 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (token === 16 || token === 24) { - var method = createNode(139, fullStart); + var questionToken = parseOptionalToken(52); + if (token === 17 || token === 25) { + var method = createNode(140, fullStart); method.name = name; method.questionToken = questionToken; - fillSignature(52, false, false, false, method); + fillSignature(53, false, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(137, fullStart); + var property = createNode(138, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -6768,9 +6910,9 @@ var ts; } function isStartOfTypeMember() { switch (token) { - case 16: - case 24: - case 18: + case 17: + case 25: + case 19: return true; default: if (ts.isModifier(token)) { @@ -6790,27 +6932,27 @@ var ts; } function isTypeMemberWithLiteralPropertyName() { nextToken(); - return token === 16 || - token === 24 || - token === 51 || + return token === 17 || + token === 25 || token === 52 || + token === 53 || canParseSemicolon(); } function parseTypeMember() { switch (token) { - case 16: - case 24: - return parseSignatureMember(144); - case 18: + case 17: + case 25: + return parseSignatureMember(145); + case 19: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 89: + case 90: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(145); + return parseSignatureMember(146); } + case 9: case 8: - case 7: return parsePropertyOrMethodSignature(); default: if (ts.isModifier(token)) { @@ -6819,7 +6961,7 @@ var ts; return result; } } - if (isIdentifierOrKeyword()) { + if (ts.tokenIsIdentifierOrKeyword(token)) { return parsePropertyOrMethodSignature(); } } @@ -6834,18 +6976,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token === 16 || token === 24; + return token === 17 || token === 25; } function parseTypeLiteral() { - var node = createNode(152); + var node = createNode(153); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(14)) { + if (parseExpected(15)) { members = parseList(4, parseTypeMember); - parseExpected(15); + parseExpected(16); } else { members = createMissingList(); @@ -6853,47 +6995,47 @@ var ts; return members; } function parseTupleType() { - var node = createNode(154); - node.elementTypes = parseBracketedList(19, parseType, 18, 19); + var node = createNode(155); + node.elementTypes = parseBracketedList(19, parseType, 19, 20); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(157); - parseExpected(16); - node.type = parseType(); + var node = createNode(158); parseExpected(17); + node.type = parseType(); + parseExpected(18); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 150) { - parseExpected(89); + if (kind === 151) { + parseExpected(90); } - fillSignature(33, false, false, false, node); + fillSignature(34, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token === 20 ? undefined : node; + return token === 21 ? undefined : node; } function parseNonArrayType() { switch (token) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: + case 126: + case 118: + case 129: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 100: + case 101: return parseTokenNode(); - case 98: + case 99: return parseTypeQuery(); - case 14: + case 15: return parseTypeLiteral(); - case 18: + case 19: return parseTupleType(); - case 16: + case 17: return parseParenthesizedType(); default: return parseTypeReferenceOrTypePredicate(); @@ -6901,19 +7043,19 @@ var ts; } function isStartOfType() { switch (token) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: - case 98: - case 14: - case 18: - case 24: - case 89: + case 126: + case 118: + case 129: + case 101: + case 99: + case 15: + case 19: + case 25: + case 90: return true; - case 16: + case 17: return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); @@ -6921,13 +7063,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token === 17 || isStartOfParameter() || isStartOfType(); + return token === 18 || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { - parseExpected(19); - var node = createNode(153, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { + parseExpected(20); + var node = createNode(154, type.pos); node.elementType = type; type = finishNode(node); } @@ -6949,32 +7091,32 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(156, parseArrayTypeOrHigher, 44); + return parseUnionOrIntersectionType(157, parseArrayTypeOrHigher, 45); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(155, parseIntersectionTypeOrHigher, 45); + return parseUnionOrIntersectionType(156, parseIntersectionTypeOrHigher, 46); } function isStartOfFunctionType() { - if (token === 24) { + if (token === 25) { return true; } - return token === 16 && lookAhead(isUnambiguouslyStartOfFunctionType); + return token === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token === 17 || token === 21) { + if (token === 18 || token === 22) { return true; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 52 || token === 23 || - token === 51 || token === 54 || + if (token === 53 || token === 24 || + token === 52 || token === 55 || isIdentifier() || ts.isModifier(token)) { return true; } - if (token === 17) { + if (token === 18) { nextToken(); - if (token === 33) { + if (token === 34) { return true; } } @@ -6986,36 +7128,36 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(149); - } - if (token === 89) { return parseFunctionOrConstructorType(150); } + if (token === 90) { + return parseFunctionOrConstructorType(151); + } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(52) ? parseType() : undefined; + return parseOptional(53) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token) { - case 94: - case 92: - case 90: - case 96: - case 81: - case 7: + case 95: + case 93: + case 91: + case 97: + case 82: case 8: - case 10: + case 9: case 11: - case 16: - case 18: - case 14: - case 84: - case 70: - case 89: - case 37: - case 58: - case 66: + case 12: + case 17: + case 19: + case 15: + case 85: + case 71: + case 90: + case 38: + case 59: + case 67: return true; default: return isIdentifier(); @@ -7026,18 +7168,18 @@ var ts; return true; } switch (token) { - case 34: case 35: + case 36: + case 49: case 48: - case 47: - case 75: - case 98: - case 100: - case 39: + case 76: + case 99: + case 101: case 40: - case 24: - case 116: - case 111: + case 41: + case 25: + case 117: + case 112: return true; default: if (isBinaryOperator()) { @@ -7047,26 +7189,23 @@ var ts; } } function isStartOfExpressionStatement() { - return token !== 14 && - token !== 84 && - token !== 70 && - token !== 53 && + return token !== 15 && + token !== 85 && + token !== 71 && + token !== 54 && isStartOfExpression(); } function allowInAndParseExpression() { return allowInAnd(parseExpression); } function parseExpression() { - // Expression[in]: - // AssignmentExpression[in] - // Expression[in] , AssignmentExpression[in] var saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { setDecoratorContext(false); } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(23))) { + while ((operatorToken = parseOptionalToken(24))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -7075,24 +7214,15 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 54) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14) || !isStartOfExpression()) { + if (token !== 55) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15) || !isStartOfExpression()) { return undefined; } } - parseExpected(54); + parseExpected(55); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { - // AssignmentExpression[in,yield]: - // 1) ConditionalExpression[?in,?yield] - // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] - // 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield] - // 4) ArrowFunctionExpression[?in,?yield] - // 5) [+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). if (isYieldExpression()) { return parseYieldExpression(); } @@ -7101,7 +7231,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 66 && token === 33) { + if (expr.kind === 67 && token === 34) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -7110,7 +7240,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 111) { + if (token === 112) { if (inYieldContext()) { return true; } @@ -7123,11 +7253,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(181); + var node = createNode(182); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token === 36 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(36); + (token === 37 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(37); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7136,15 +7266,15 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 33, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(171, identifier.pos); - var parameter = createNode(135, identifier.pos); + ts.Debug.assert(token === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(172, identifier.pos); + var parameter = createNode(136, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(33, false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(false); return finishNode(node); } @@ -7161,78 +7291,78 @@ var ts; } var isAsync = !!(arrowFunction.flags & 512); var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(33, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 33 || lastToken === 14) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 34 || lastToken === 15) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token === 16 || token === 24 || token === 115) { + if (token === 17 || token === 25 || token === 116) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 33) { + if (token === 34) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 115) { + if (token === 116) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token !== 16 && token !== 24) { + if (token !== 17 && token !== 25) { return 0; } } var first = token; var second = nextToken(); - if (first === 16) { - if (second === 17) { + if (first === 17) { + if (second === 18) { var third = nextToken(); switch (third) { - case 33: - case 52: - case 14: + case 34: + case 53: + case 15: return 1; default: return 0; } } - if (second === 18 || second === 14) { + if (second === 19 || second === 15) { return 2; } - if (second === 21) { + if (second === 22) { return 1; } if (!isIdentifier()) { return 0; } - if (nextToken() === 52) { + if (nextToken() === 53) { return 1; } return 2; } else { - ts.Debug.assert(first === 24); + ts.Debug.assert(first === 25); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 80) { + if (third === 81) { var fourth = nextToken(); switch (fourth) { - case 54: - case 26: + case 55: + case 27: return false; default: return true; } } - else if (third === 23) { + else if (third === 24) { return true; } return false; @@ -7249,25 +7379,25 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(171); + var node = createNode(172); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512); - fillSignature(52, false, isAsync, !allowAmbiguity, node); + fillSignature(53, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token !== 33 && token !== 14) { + if (!allowAmbiguity && token !== 34 && token !== 15) { return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token === 14) { + if (token === 15) { return parseFunctionBlock(false, isAsync, false); } - if (token !== 22 && - token !== 84 && - token !== 70 && + if (token !== 23 && + token !== 85 && + token !== 71 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -7277,15 +7407,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(51); + var questionToken = parseOptionalToken(52); if (!questionToken) { return leftOperand; } - var node = createNode(179, leftOperand.pos); + var node = createNode(180, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(52, false, ts.Diagnostics._0_expected, ts.tokenToString(52)); + node.colonToken = parseExpectedToken(53, false, ts.Diagnostics._0_expected, ts.tokenToString(53)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7294,7 +7424,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 87 || t === 131; + return t === 88 || t === 132; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -7303,10 +7433,10 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 87 && inDisallowInContext()) { + if (token === 88 && inDisallowInContext()) { break; } - if (token === 113) { + if (token === 114) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -7322,90 +7452,90 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 87) { + if (inDisallowInContext() && token === 88) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 50: + case 51: return 1; - case 49: + case 50: return 2; - case 45: - return 3; case 46: + return 3; + case 47: return 4; - case 44: + case 45: return 5; - case 29: case 30: case 31: case 32: + case 33: return 6; - case 24: - case 26: + case 25: case 27: case 28: + case 29: + case 89: case 88: - case 87: - case 113: + case 114: return 7; - case 41: case 42: case 43: + case 44: return 8; - case 34: case 35: - return 9; case 36: + return 9; case 37: case 38: + case 39: return 10; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(178, left.pos); + var node = createNode(179, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(186, left.pos); + var node = createNode(187, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(176); + var node = createNode(177); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(172); - nextToken(); - node.expression = parseUnaryExpressionOrHigher(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(173); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(174); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(175); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } function isAwaitExpression() { - if (token === 116) { + if (token === 117) { if (inAwaitContext()) { return true; } @@ -7414,7 +7544,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(175); + var node = createNode(176); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -7424,25 +7554,25 @@ var ts; return parseAwaitExpression(); } switch (token) { - case 34: case 35: + case 36: + case 49: case 48: - case 47: - case 39: case 40: + case 41: return parsePrefixUnaryExpression(); - case 75: + case 76: return parseDeleteExpression(); - case 98: + case 99: return parseTypeOfExpression(); - case 100: + case 101: return parseVoidExpression(); - case 24: + case 25: if (sourceFile.languageVariant !== 1) { return parseTypeAssertion(); } if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(); + return parseJsxElementOrSelfClosingElement(true); } default: return parsePostfixExpressionOrHigher(); @@ -7451,8 +7581,8 @@ var ts; function parsePostfixExpressionOrHigher() { var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 39 || token === 40) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(177, expression.pos); + if ((token === 40 || token === 41) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(178, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7461,7 +7591,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 92 + var expression = token === 93 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -7472,44 +7602,44 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token === 16 || token === 20) { + if (token === 17 || token === 21 || token === 19) { return expression; } - var node = createNode(163, expression.pos); + var node = createNode(164, expression.pos); node.expression = expression; - node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.dotToken = parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } - function parseJsxElementOrSelfClosingElement() { - var opening = parseJsxOpeningOrSelfClosingElement(); - if (opening.kind === 232) { - var node = createNode(230, opening.pos); + function parseJsxElementOrSelfClosingElement(inExpressionContext) { + var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + if (opening.kind === 233) { + var node = createNode(231, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(); + node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 231); + ts.Debug.assert(opening.kind === 232); return opening; } } function parseJsxText() { - var node = createNode(233, scanner.getStartPos()); + var node = createNode(234, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 233: + case 234: return parseJsxText(); - case 14: - return parseJsxExpression(); - case 24: - return parseJsxElementOrSelfClosingElement(); + case 15: + return parseJsxExpression(false); + case 25: + return parseJsxElementOrSelfClosingElement(false); } - ts.Debug.fail('Unknown JSX child kind ' + token); + ts.Debug.fail("Unknown JSX child kind " + token); } function parseJsxChildren(openingTagName) { var result = []; @@ -7518,7 +7648,7 @@ var ts; parsingContext |= 1 << 14; while (true) { token = scanner.reScanJsxToken(); - if (token === 25) { + if (token === 26) { break; } else if (token === 1) { @@ -7531,19 +7661,26 @@ var ts; parsingContext = saveParsingContext; return result; } - function parseJsxOpeningOrSelfClosingElement() { + function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(24); + parseExpected(25); var tagName = parseJsxElementName(); var attributes = parseList(13, parseJsxAttribute); var node; - if (parseOptional(26)) { - node = createNode(232, fullStart); + if (token === 27) { + node = createNode(233, fullStart); + scanJsxText(); } else { - parseExpected(37); - parseExpected(26); - node = createNode(231, fullStart); + parseExpected(38); + if (inExpressionContext) { + parseExpected(27); + } + else { + parseExpected(27, undefined, false); + scanJsxText(); + } + node = createNode(232, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -7552,95 +7689,107 @@ var ts; function parseJsxElementName() { scanJsxIdentifier(); var elementName = parseIdentifierName(); - while (parseOptional(20)) { + while (parseOptional(21)) { scanJsxIdentifier(); - var node = createNode(132, elementName.pos); + var node = createNode(133, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); } return elementName; } - function parseJsxExpression() { - var node = createNode(237); - parseExpected(14); - if (token !== 15) { + function parseJsxExpression(inExpressionContext) { + var node = createNode(238); + parseExpected(15); + if (token !== 16) { node.expression = parseExpression(); } - parseExpected(15); + if (inExpressionContext) { + parseExpected(16); + } + else { + parseExpected(16, undefined, false); + scanJsxText(); + } return finishNode(node); } function parseJsxAttribute() { - if (token === 14) { + if (token === 15) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(235); + var node = createNode(236); node.name = parseIdentifierName(); - if (parseOptional(54)) { + if (parseOptional(55)) { switch (token) { - case 8: + case 9: node.initializer = parseLiteralNode(); break; default: - node.initializer = parseJsxExpression(); + node.initializer = parseJsxExpression(true); break; } } return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(236); - parseExpected(14); - parseExpected(21); - node.expression = parseExpression(); + var node = createNode(237); parseExpected(15); + parseExpected(22); + node.expression = parseExpression(); + parseExpected(16); return finishNode(node); } - function parseJsxClosingElement() { - var node = createNode(234); - parseExpected(25); - node.tagName = parseJsxElementName(); + function parseJsxClosingElement(inExpressionContext) { + var node = createNode(235); parseExpected(26); + node.tagName = parseJsxElementName(); + if (inExpressionContext) { + parseExpected(27); + } + else { + parseExpected(27, undefined, false); + scanJsxText(); + } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(168); - parseExpected(24); + var node = createNode(169); + parseExpected(25); node.type = parseType(); - parseExpected(26); + parseExpected(27); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(20); + var dotToken = parseOptionalToken(21); if (dotToken) { - var propertyAccess = createNode(163, expression.pos); + var propertyAccess = createNode(164, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (!inDecoratorContext() && parseOptional(18)) { - var indexedAccess = createNode(164, expression.pos); + if (!inDecoratorContext() && parseOptional(19)) { + var indexedAccess = createNode(165, expression.pos); indexedAccess.expression = expression; - if (token !== 19) { + if (token !== 20) { indexedAccess.argumentExpression = allowInAnd(parseExpression); - if (indexedAccess.argumentExpression.kind === 8 || indexedAccess.argumentExpression.kind === 7) { + if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(19); + parseExpected(20); expression = finishNode(indexedAccess); continue; } - if (token === 10 || token === 11) { - var tagExpression = createNode(167, expression.pos); + if (token === 11 || token === 12) { + var tagExpression = createNode(168, expression.pos); tagExpression.tag = expression; - tagExpression.template = token === 10 + tagExpression.template = token === 11 ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -7652,20 +7801,20 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token === 24) { + if (token === 25) { var typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; } - var callExpr = createNode(165, expression.pos); + var callExpr = createNode(166, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token === 16) { - var callExpr = createNode(165, expression.pos); + else if (token === 17) { + var callExpr = createNode(166, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -7675,17 +7824,17 @@ var ts; } } function parseArgumentList() { - parseExpected(16); - var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(17); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(18); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(24)) { + if (!parseOptional(25)) { return undefined; } var typeArguments = parseDelimitedList(18, parseType); - if (!parseExpected(26)) { + if (!parseExpected(27)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -7694,108 +7843,108 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token) { - case 16: - case 20: case 17: - case 19: + case 21: + case 18: + case 20: + case 53: + case 23: case 52: - case 22: - case 51: - case 29: - case 31: case 30: case 32: - case 49: + case 31: + case 33: case 50: - case 46: - case 44: + case 51: + case 47: case 45: - case 15: + case 46: + case 16: case 1: return true; - case 23: - case 14: + case 24: + case 15: default: return false; } } function parsePrimaryExpression() { switch (token) { - case 7: case 8: - case 10: + case 9: + case 11: return parseLiteralNode(); - case 94: - case 92: - case 90: - case 96: - case 81: + case 95: + case 93: + case 91: + case 97: + case 82: return parseTokenNode(); - case 16: + case 17: return parseParenthesizedExpression(); - case 18: + case 19: return parseArrayLiteralExpression(); - case 14: + case 15: return parseObjectLiteralExpression(); - case 115: + case 116: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 70: + case 71: return parseClassExpression(); - case 84: + case 85: return parseFunctionExpression(); - case 89: + case 90: return parseNewExpression(); - case 37: - case 58: - if (reScanSlashToken() === 9) { + case 38: + case 59: + if (reScanSlashToken() === 10) { return parseLiteralNode(); } break; - case 11: + case 12: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(169); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(170); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); return finishNode(node); } function parseSpreadElement() { - var node = createNode(182); - parseExpected(21); + var node = createNode(183); + parseExpected(22); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(184) : + return token === 22 ? parseSpreadElement() : + token === 24 ? createNode(185) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(161); - parseExpected(18); + var node = createNode(162); + parseExpected(19); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048; node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(19); + parseExpected(20); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(120)) { - return parseAccessorDeclaration(142, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(126)) { + if (parseContextualModifier(121)) { return parseAccessorDeclaration(143, fullStart, decorators, modifiers); } + else if (parseContextualModifier(127)) { + return parseAccessorDeclaration(144, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -7806,37 +7955,37 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(36); + var asteriskToken = parseOptionalToken(37); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (asteriskToken || token === 16 || token === 24) { + var questionToken = parseOptionalToken(52); + if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(243, fullStart); + if ((token === 24 || token === 16) && tokenIsIdentifier) { + var shorthandDeclaration = createNode(244, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(242, fullStart); + var propertyAssignment = createNode(243, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(52); + parseExpected(53); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(162); - parseExpected(14); + var node = createNode(163); + parseExpected(15); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(15); + parseExpected(16); return finishNode(node); } function parseFunctionExpression() { @@ -7844,10 +7993,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(170); + var node = createNode(171); setModifiers(node, parseModifiers()); - parseExpected(84); - node.asteriskToken = parseOptionalToken(36); + parseExpected(85); + node.asteriskToken = parseOptionalToken(37); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); node.name = @@ -7855,7 +8004,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(52, isGenerator, isAsync, false, node); + fillSignature(53, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -7866,20 +8015,20 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(166); - parseExpected(89); + var node = createNode(167); + parseExpected(90); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 16) { + if (node.typeArguments || token === 17) { node.arguments = parseArgumentList(); } return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(189); - if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(190); + if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); - parseExpected(15); + parseExpected(16); } else { node.statements = createMissingList(); @@ -7904,47 +8053,47 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(191); - parseExpected(22); + var node = createNode(192); + parseExpected(23); return finishNode(node); } function parseIfStatement() { - var node = createNode(193); - parseExpected(85); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(194); + parseExpected(86); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(77) ? parseStatement() : undefined; + node.elseStatement = parseOptional(78) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(194); - parseExpected(76); + var node = createNode(195); + parseExpected(77); node.statement = parseStatement(); - parseExpected(101); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + parseExpected(102); parseExpected(17); - parseOptional(22); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + parseOptional(23); return finishNode(node); } function parseWhileStatement() { - var node = createNode(195); - parseExpected(101); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(196); + parseExpected(102); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(83); - parseExpected(16); + parseExpected(84); + parseExpected(17); var initializer = undefined; - if (token !== 22) { - if (token === 99 || token === 105 || token === 71) { + if (token !== 23) { + if (token === 100 || token === 106 || token === 72) { initializer = parseVariableDeclarationList(true); } else { @@ -7952,32 +8101,32 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(87)) { - var forInStatement = createNode(197, pos); + if (parseOptional(88)) { + var forInStatement = createNode(198, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(131)) { - var forOfStatement = createNode(198, pos); + else if (parseOptional(132)) { + var forOfStatement = createNode(199, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(196, pos); + var forStatement = createNode(197, pos); forStatement.initializer = initializer; - parseExpected(22); - if (token !== 22 && token !== 17) { + parseExpected(23); + if (token !== 23 && token !== 18) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(22); - if (token !== 17) { + parseExpected(23); + if (token !== 18) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(17); + parseExpected(18); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -7985,7 +8134,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 200 ? 67 : 72); + parseExpected(kind === 201 ? 68 : 73); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -7993,8 +8142,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(201); - parseExpected(91); + var node = createNode(202); + parseExpected(92); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -8002,151 +8151,146 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(202); - parseExpected(102); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(203); + parseExpected(103); parseExpected(17); + node.expression = allowInAnd(parseExpression); + parseExpected(18); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(238); - parseExpected(68); + var node = createNode(239); + parseExpected(69); node.expression = allowInAnd(parseExpression); - parseExpected(52); + parseExpected(53); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(239); - parseExpected(74); - parseExpected(52); + var node = createNode(240); + parseExpected(75); + parseExpected(53); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 68 ? parseCaseClause() : parseDefaultClause(); + return token === 69 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(203); - parseExpected(93); - parseExpected(16); - node.expression = allowInAnd(parseExpression); + var node = createNode(204); + parseExpected(94); parseExpected(17); - var caseBlock = createNode(217, scanner.getStartPos()); - parseExpected(14); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + node.expression = allowInAnd(parseExpression); + parseExpected(18); + var caseBlock = createNode(218, scanner.getStartPos()); parseExpected(15); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(16); node.caseBlock = finishNode(caseBlock); return finishNode(node); } function parseThrowStatement() { - // ThrowStatement[Yield] : - // throw [no LineTerminator here]Expression[In, ?Yield]; - var node = createNode(205); - parseExpected(95); + var node = createNode(206); + parseExpected(96); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(206); - parseExpected(97); + var node = createNode(207); + parseExpected(98); node.tryBlock = parseBlock(false); - node.catchClause = token === 69 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 82) { - parseExpected(82); + node.catchClause = token === 70 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 83) { + parseExpected(83); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(241); - parseExpected(69); - if (parseExpected(16)) { + var result = createNode(242); + parseExpected(70); + if (parseExpected(17)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(17); + parseExpected(18); result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(207); - parseExpected(73); + var node = createNode(208); + parseExpected(74); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 66 && parseOptional(52)) { - var labeledStatement = createNode(204, fullStart); + if (expression.kind === 67 && parseOptional(53)) { + var labeledStatement = createNode(205, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(192, fullStart); + var expressionStatement = createNode(193, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } - function isIdentifierOrKeyword() { - return token >= 66; - } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); - return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); + return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 84 && !scanner.hasPrecedingLineBreak(); + return token === 85 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); - return (isIdentifierOrKeyword() || token === 7) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token) || token === 8) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token) { - case 99: - case 105: + case 100: + case 106: + case 72: + case 85: case 71: - case 84: - case 70: - case 78: + case 79: return true; - case 104: - case 129: + case 105: + case 130: return nextTokenIsIdentifierOnSameLine(); - case 122: case 123: + case 124: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115: - case 119: + case 116: + case 120: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 86: + case 87: nextToken(); - return token === 8 || token === 36 || - token === 14 || isIdentifierOrKeyword(); - case 79: + return token === 9 || token === 37 || + token === 15 || ts.tokenIsIdentifierOrKeyword(token); + case 80: nextToken(); - if (token === 54 || token === 36 || - token === 14 || token === 74) { + if (token === 55 || token === 37 || + token === 15 || token === 75) { return true; } continue; - case 109: - case 107: - case 108: case 110: - case 112: + case 108: + case 109: + case 111: + case 113: nextToken(); continue; default: @@ -8159,44 +8303,44 @@ var ts; } function isStartOfStatement() { switch (token) { - case 53: - case 22: - case 14: - case 99: - case 105: - case 84: - case 70: - case 78: + case 54: + case 23: + case 15: + case 100: + case 106: case 85: - case 76: - case 101: - case 83: - case 72: - case 67: - case 91: - case 102: - case 93: - case 95: - case 97: - case 73: - case 69: - case 82: - return true; case 71: case 79: case 86: + case 77: + case 102: + case 84: + case 73: + case 68: + case 92: + case 103: + case 94: + case 96: + case 98: + case 74: + case 70: + case 83: + return true; + case 72: + case 80: + case 87: return isStartOfDeclaration(); - case 115: - case 119: - case 104: - case 122: + case 116: + case 120: + case 105: case 123: - case 129: + case 124: + case 130: return true; - case 109: - case 107: - case 108: case 110: + case 108: + case 109: + case 111: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -8204,71 +8348,71 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token === 14 || token === 18; + return isIdentifier() || token === 15 || token === 19; } function isLetDeclaration() { return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token) { - case 22: + case 23: return parseEmptyStatement(); - case 14: + case 15: return parseBlock(false); - case 99: + case 100: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 105: + case 106: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 84: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 70: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 85: - return parseIfStatement(); - case 76: - return parseDoStatement(); - case 101: - return parseWhileStatement(); - case 83: - return parseForOrForInOrForOfStatement(); - case 72: - return parseBreakOrContinueStatement(199); - case 67: - return parseBreakOrContinueStatement(200); - case 91: - return parseReturnStatement(); - case 102: - return parseWithStatement(); - case 93: - return parseSwitchStatement(); - case 95: - return parseThrowStatement(); - case 97: - case 69: - case 82: - return parseTryStatement(); - case 73: - return parseDebuggerStatement(); - case 53: - return parseDeclaration(); - case 115: - case 104: - case 129: - case 122: - case 123: - case 119: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 71: - case 78: - case 79: + return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 86: - case 107: + return parseIfStatement(); + case 77: + return parseDoStatement(); + case 102: + return parseWhileStatement(); + case 84: + return parseForOrForInOrForOfStatement(); + case 73: + return parseBreakOrContinueStatement(200); + case 68: + return parseBreakOrContinueStatement(201); + case 92: + return parseReturnStatement(); + case 103: + return parseWithStatement(); + case 94: + return parseSwitchStatement(); + case 96: + return parseThrowStatement(); + case 98: + case 70: + case 83: + return parseTryStatement(); + case 74: + return parseDebuggerStatement(); + case 54: + return parseDeclaration(); + case 116: + case 105: + case 130: + case 123: + case 124: + case 120: + case 72: + case 79: + case 80: + case 87: case 108: case 109: - case 112: case 110: + case 113: + case 111: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -8281,33 +8425,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 99: - case 105: - case 71: + case 100: + case 106: + case 72: return parseVariableStatement(fullStart, decorators, modifiers); - case 84: + case 85: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 70: + case 71: return parseClassDeclaration(fullStart, decorators, modifiers); - case 104: + case 105: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 129: + case 130: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 78: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 122: - case 123: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 86: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); case 79: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 123: + case 124: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 87: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 80: nextToken(); - return token === 74 || token === 54 ? + return token === 75 || token === 55 ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(228, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(229, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -8317,34 +8461,34 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token !== 14 && canParseSemicolon()) { + if (token !== 15 && canParseSemicolon()) { parseSemicolon(); return; } return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { - if (token === 23) { - return createNode(184); + if (token === 24) { + return createNode(185); } - var node = createNode(160); - node.dotDotDotToken = parseOptionalToken(21); + var node = createNode(161); + node.dotDotDotToken = parseOptionalToken(22); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(160); + var node = createNode(161); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 52) { + if (tokenIsIdentifier && token !== 53) { node.name = propertyName; } else { - parseExpected(52); + parseExpected(53); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -8352,33 +8496,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(158); - parseExpected(14); - node.elements = parseDelimitedList(9, parseObjectBindingElement); + var node = createNode(159); parseExpected(15); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(16); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(159); - parseExpected(18); - node.elements = parseDelimitedList(10, parseArrayBindingElement); + var node = createNode(160); parseExpected(19); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(20); return finishNode(node); } function isIdentifierOrPattern() { - return token === 14 || token === 18 || isIdentifier(); + return token === 15 || token === 19 || isIdentifier(); } function parseIdentifierOrPattern() { - if (token === 18) { + if (token === 19) { return parseArrayBindingPattern(); } - if (token === 14) { + if (token === 15) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(208); + var node = createNode(209); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -8387,21 +8531,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(209); + var node = createNode(210); switch (token) { - case 99: + case 100: break; - case 105: + case 106: node.flags |= 16384; break; - case 71: + case 72: node.flags |= 32768; break; default: ts.Debug.fail(); } nextToken(); - if (token === 131 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 132 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -8413,10 +8557,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 17; + return nextTokenIsIdentifier() && nextToken() === 18; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(190, fullStart); + var node = createNode(191, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -8424,29 +8568,29 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(210, fullStart); + var node = createNode(211, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(84); - node.asteriskToken = parseOptionalToken(36); + parseExpected(85); + node.asteriskToken = parseOptionalToken(37); node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512); - fillSignature(52, isGenerator, isAsync, false, node); + fillSignature(53, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(141, pos); + var node = createNode(142, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(118); - fillSignature(52, false, false, false, node); + parseExpected(119); + fillSignature(53, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(140, fullStart); + var method = createNode(141, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -8454,12 +8598,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512); - fillSignature(52, isGenerator, isAsync, false, method); + fillSignature(53, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(138, fullStart); + var property = createNode(139, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -8472,10 +8616,10 @@ var ts; return finishNode(property); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(36); + var asteriskToken = parseOptionalToken(37); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51); - if (asteriskToken || token === 16 || token === 24) { + var questionToken = parseOptionalToken(52); + if (asteriskToken || token === 17 || token === 25) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -8490,16 +8634,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(52, false, false, false, node); + fillSignature(53, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 109: - case 107: - case 108: case 110: + case 108: + case 109: + case 111: return true; default: return false; @@ -8507,7 +8651,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 53) { + if (token === 54) { return true; } while (ts.isModifier(token)) { @@ -8517,26 +8661,26 @@ var ts; } nextToken(); } - if (token === 36) { + if (token === 37) { return true; } if (isLiteralPropertyName()) { idToken = token; nextToken(); } - if (token === 18) { + if (token === 19) { return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 126 || idToken === 120) { + if (!ts.isKeyword(idToken) || idToken === 127 || idToken === 121) { return true; } switch (token) { - case 16: - case 24: + case 17: + case 25: + case 53: + case 55: case 52: - case 54: - case 51: return true; default: return canParseSemicolon(); @@ -8548,14 +8692,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(53)) { + if (!parseOptional(54)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(136, decoratorStart); + var decorator = createNode(137, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8589,7 +8733,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 115) { + if (token === 116) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -8603,8 +8747,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token === 22) { - var result = createNode(188); + if (token === 23) { + var result = createNode(189); nextToken(); return finishNode(result); } @@ -8615,42 +8759,42 @@ var ts; if (accessor) { return accessor; } - if (token === 118) { + if (token === 119) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); } - if (isIdentifierOrKeyword() || + if (ts.tokenIsIdentifierOrKeyword(token) || + token === 9 || token === 8 || - token === 7 || - token === 36 || - token === 18) { + token === 37 || + token === 19) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_8 = createMissingNode(66, true, ts.Diagnostics.Declaration_expected); + var name_8 = createMissingNode(67, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_8, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 183); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 184); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 211); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(70); + parseExpected(71); node.name = parseOptionalIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(14)) { + if (parseExpected(15)) { node.members = parseClassMembers(); - parseExpected(15); + parseExpected(16); } else { node.members = createMissingList(); @@ -8658,8 +8802,6 @@ var ts; return finishNode(node); } function parseHeritageClauses(isClassHeritageClause) { - // ClassTail[Yield,Await] : (Modified) See 14.5 - // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { return parseList(20, parseHeritageClause); } @@ -8669,8 +8811,8 @@ var ts; return parseList(20, parseHeritageClause); } function parseHeritageClause() { - if (token === 80 || token === 103) { - var node = createNode(240); + if (token === 81 || token === 104) { + var node = createNode(241); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -8679,24 +8821,24 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(185); + var node = createNode(186); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token === 24) { - node.typeArguments = parseBracketedList(18, parseType, 24, 26); + if (token === 25) { + node.typeArguments = parseBracketedList(18, parseType, 25, 27); } return finishNode(node); } function isHeritageClause() { - return token === 80 || token === 103; + return token === 81 || token === 104; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(212, fullStart); + var node = createNode(213, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(104); + parseExpected(105); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); @@ -8704,32 +8846,32 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213, fullStart); + var node = createNode(214, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(129); + parseExpected(130); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(54); + parseExpected(55); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(244, scanner.getStartPos()); + var node = createNode(245, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(78); + parseExpected(79); node.name = parseIdentifier(); - if (parseExpected(14)) { + if (parseExpected(15)) { node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(15); + parseExpected(16); } else { node.members = createMissingList(); @@ -8737,10 +8879,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(216, scanner.getStartPos()); - if (parseExpected(14)) { + var node = createNode(217, scanner.getStartPos()); + if (parseExpected(15)) { node.statements = parseList(1, parseStatement); - parseExpected(15); + parseExpected(16); } else { node.statements = createMissingList(); @@ -8748,18 +8890,19 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); + var namespaceFlag = flags & 131072; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(20) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1) + node.body = parseOptional(21) + ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215, fullStart); + var node = createNode(216, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -8768,76 +8911,70 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(123)) { + if (parseOptional(124)) { flags |= 131072; } else { - parseExpected(122); - if (token === 8) { + parseExpected(123); + if (token === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 124 && + return token === 125 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 16; + return nextToken() === 17; } function nextTokenIsSlash() { - return nextToken() === 37; + return nextToken() === 38; } function nextTokenIsCommaOrFromKeyword() { nextToken(); - return token === 23 || - token === 130; + return token === 24 || + token === 131; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(86); + parseExpected(87); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 130) { - var importEqualsDeclaration = createNode(218, fullStart); + if (token !== 24 && token !== 131) { + var importEqualsDeclaration = createNode(219, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(54); + parseExpected(55); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(219, fullStart); + var importDeclaration = createNode(220, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || - token === 36 || - token === 14) { + token === 37 || + token === 15) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(130); + parseExpected(131); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - // ImportClause: - // ImportedDefaultBinding - // NameSpaceImport - // NamedImports - // ImportedDefaultBinding, NameSpaceImport - // ImportedDefaultBinding, NamedImports - var importClause = createNode(220, fullStart); + var importClause = createNode(221, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || - parseOptional(23)) { - importClause.namedBindings = token === 36 ? parseNamespaceImport() : parseNamedImportsOrExports(222); + parseOptional(24)) { + importClause.namedBindings = token === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(223); } return finishNode(importClause); } @@ -8847,37 +8984,37 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(229); - parseExpected(124); - parseExpected(16); - node.expression = parseModuleSpecifier(); + var node = createNode(230); + parseExpected(125); parseExpected(17); + node.expression = parseModuleSpecifier(); + parseExpected(18); return finishNode(node); } function parseModuleSpecifier() { var result = parseExpression(); - if (result.kind === 8) { + if (result.kind === 9) { internIdentifier(result.text); } return result; } function parseNamespaceImport() { - var namespaceImport = createNode(221); - parseExpected(36); - parseExpected(113); + var namespaceImport = createNode(222); + parseExpected(37); + parseExpected(114); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 222 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(21, kind === 223 ? parseImportSpecifier : parseExportSpecifier, 15, 16); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(227); + return parseImportOrExportSpecifier(228); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(223); + return parseImportOrExportSpecifier(224); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -8885,9 +9022,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 113) { + if (token === 114) { node.propertyName = identifierName; - parseExpected(113); + parseExpected(114); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -8896,23 +9033,23 @@ var ts; else { node.name = identifierName; } - if (kind === 223 && checkIdentifierIsKeyword) { + if (kind === 224 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(36)) { - parseExpected(130); + if (parseOptional(37)) { + parseExpected(131); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(226); - if (token === 130 || (token === 8 && !scanner.hasPrecedingLineBreak())) { - parseExpected(130); + node.exportClause = parseNamedImportsOrExports(227); + if (token === 131 || (token === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(131); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -8920,14 +9057,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(54)) { + if (parseOptional(55)) { node.isExportEquals = true; } else { - parseExpected(74); + parseExpected(75); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -8990,10 +9127,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 218 && node.moduleReference.kind === 229 - || node.kind === 219 - || node.kind === 224 + || node.kind === 219 && node.moduleReference.kind === 230 + || node.kind === 220 || node.kind === 225 + || node.kind === 226 ? node : undefined; }); @@ -9002,19 +9139,19 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token) { - case 36: - case 51: - case 16: - case 18: - case 47: - case 14: - case 84: - case 21: - case 89: - case 94: + case 37: + case 52: + case 17: + case 19: + case 48: + case 15: + case 85: + case 22: + case 90: + case 95: return true; } - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { @@ -9028,23 +9165,23 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(246); - parseExpected(14); - result.type = parseJSDocTopLevelType(); + var result = createNode(247); parseExpected(15); + result.type = parseJSDocTopLevelType(); + parseExpected(16); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 45) { - var unionType = createNode(250, type.pos); + if (token === 46) { + var unionType = createNode(251, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 54) { - var optionalType = createNode(257, type.pos); + if (token === 55) { + var optionalType = createNode(258, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -9054,21 +9191,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token === 18) { - var arrayType = createNode(249, type.pos); + if (token === 19) { + var arrayType = createNode(250, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(19); + parseExpected(20); type = finishNode(arrayType); } - else if (token === 51) { - var nullableType = createNode(252, type.pos); + else if (token === 52) { + var nullableType = createNode(253, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 47) { - var nonNullableType = createNode(253, type.pos); + else if (token === 48) { + var nonNullableType = createNode(254, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -9081,85 +9218,85 @@ var ts; } function parseBasicTypeExpression() { switch (token) { - case 36: + case 37: return parseJSDocAllType(); - case 51: + case 52: return parseJSDocUnknownOrNullableType(); - case 16: + case 17: return parseJSDocUnionType(); - case 18: + case 19: return parseJSDocTupleType(); - case 47: + case 48: return parseJSDocNonNullableType(); - case 14: + case 15: return parseJSDocRecordType(); - case 84: + case 85: return parseJSDocFunctionType(); - case 21: + case 22: return parseJSDocVariadicType(); - case 89: + case 90: return parseJSDocConstructorType(); - case 94: + case 95: return parseJSDocThisType(); - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: + case 126: + case 118: + case 129: + case 101: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(261); + var result = createNode(262); nextToken(); - parseExpected(52); + parseExpected(53); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(260); + var result = createNode(261); nextToken(); - parseExpected(52); + parseExpected(53); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(259); + var result = createNode(260); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(258); + var result = createNode(259); nextToken(); - parseExpected(16); + parseExpected(17); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(17); - if (token === 52) { + parseExpected(18); + if (token === 53) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(135); + var parameter = createNode(136); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(257, type.pos); + var result = createNode(258, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(256); + var result = createNode(257); result.name = parseSimplePropertyName(); - while (parseOptional(20)) { - if (token === 24) { + while (parseOptional(21)) { + if (token === 25) { result.typeArguments = parseTypeArguments(); break; } @@ -9174,7 +9311,7 @@ var ts; var typeArguments = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(26); + parseExpected(27); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -9185,40 +9322,40 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(132, left.pos); + var result = createNode(133, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(254); + var result = createNode(255); nextToken(); result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); - parseExpected(15); + parseExpected(16); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(255); + var result = createNode(256); result.name = parseSimplePropertyName(); - if (token === 52) { + if (token === 53) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(253); + var result = createNode(254); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(251); + var result = createNode(252); nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(19); + parseExpected(20); return finishNode(result); } function checkForTrailingComma(list) { @@ -9228,10 +9365,10 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(250); + var result = createNode(251); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(17); + parseExpected(18); return finishNode(result); } function parseJSDocTypeList(firstType) { @@ -9239,31 +9376,31 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(45)) { + while (parseOptional(46)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(247); + var result = createNode(248); nextToken(); return finishNode(result); } function parseJSDocUnknownOrNullableType() { var pos = scanner.getStartPos(); nextToken(); - if (token === 23 || - token === 15 || - token === 17 || - token === 26 || - token === 54 || - token === 45) { - var result = createNode(248, pos); + if (token === 24 || + token === 16 || + token === 18 || + token === 27 || + token === 55 || + token === 46) { + var result = createNode(249, pos); return finishNode(result); } else { - var result = createNode(252, pos); + var result = createNode(253, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -9334,7 +9471,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(262, start); + var result = createNode(263, start); result.tags = tags; return finishNode(result, end); } @@ -9345,7 +9482,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(53, pos - 1); + var atToken = createNode(54, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -9371,7 +9508,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(263, atToken.pos); + var result = createNode(264, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -9411,7 +9548,6 @@ var ts; } if (!name) { parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); - return undefined; } var preName, postName; if (typeExpression) { @@ -9423,7 +9559,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(264, atToken.pos); + var result = createNode(265, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -9433,16 +9569,6 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 265; })) { - parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); - } - var result = createNode(265, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result, pos); - } - function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 266; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } @@ -9452,10 +9578,20 @@ var ts; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } - function handleTemplateTag(atToken, tagName) { + function handleTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 267; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } + var result = createNode(267, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result, pos); + } + function handleTemplateTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 268; })) { + parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); + } var typeParameters = []; typeParameters.pos = pos; while (true) { @@ -9466,7 +9602,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(134, name_9.pos); + var typeParameter = createNode(135, name_9.pos); typeParameter.name = name_9; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -9477,7 +9613,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(267, atToken.pos); + var result = createNode(268, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9498,7 +9634,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(66, startPos); + var result = createNode(67, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -9542,7 +9678,7 @@ var ts; } return; function visitNode(node) { - var text = ''; + var text = ""; if (aggressiveChecks && shouldCheckNode(node)) { text = oldText.substring(node.pos, node.end); } @@ -9572,9 +9708,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { + case 9: case 8: - case 7: - case 66: + case 67: return true; } return false; @@ -9788,21 +9924,20 @@ var ts; } })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 212 || node.kind === 213) { + if (node.kind === 213 || node.kind === 214) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 219 || node.kind === 218) && !(node.flags & 1)) { + else if ((node.kind === 220 || node.kind === 219) && !(node.flags & 1)) { return 0; } - else if (node.kind === 216) { + else if (node.kind === 217) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -9818,7 +9953,7 @@ var ts; }); return state; } - else if (node.kind === 215) { + else if (node.kind === 216) { return getModuleInstanceState(node.body); } else { @@ -9870,10 +10005,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 215 && node.name.kind === 8) { - return '"' + node.name.text + '"'; + if (node.kind === 216 && node.name.kind === 9) { + return "\"" + node.name.text + "\""; } - if (node.name.kind === 133) { + if (node.name.kind === 134) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -9881,22 +10016,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 141: + case 142: return "__constructor"; - case 149: - case 144: - return "__call"; case 150: case 145: - return "__new"; + return "__call"; + case 151: case 146: + return "__new"; + case 147: return "__index"; - case 225: + case 226: return "__export"; - case 224: + case 225: return node.isExportEquals ? "export=" : "default"; - case 210: case 211: + case 212: return node.flags & 1024 ? "default" : undefined; } } @@ -9938,7 +10073,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 227 || (node.kind === 218 && hasExportModifier)) { + if (node.kind === 228 || (node.kind === 219 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -9984,37 +10119,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 183: - case 211: + case 184: case 212: - case 214: - case 152: - case 162: + case 213: + case 215: + case 153: + case 163: return 1; - case 144: case 145: case 146: - case 140: - case 139: - case 210: + case 147: case 141: + case 140: + case 211: case 142: case 143: - case 149: + case 144: case 150: - case 170: + case 151: case 171: - case 215: - case 245: - case 213: + case 172: + case 216: + case 246: + case 214: return 5; - case 241: - case 196: + case 242: case 197: case 198: - case 217: + case 199: + case 218: return 2; - case 189: + case 190: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -10030,33 +10165,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 215: + case 216: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 245: + case 246: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 183: - case 211: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 214: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 152: - case 162: + case 184: case 212: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 215: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 153: + case 163: + case 213: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 149: case 150: - case 144: + case 151: case 145: case 146: - case 140: - case 139: + case 147: case 141: + case 140: case 142: case 143: - case 210: - case 170: + case 144: + case 211: case 171: - case 213: + case 172: + case 214: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -10080,11 +10215,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 245 ? node : node.body; - if (body.kind === 245 || body.kind === 216) { + var body = node.kind === 246 ? node : node.body; + if (body.kind === 246 || body.kind === 217) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 225 || stat.kind === 224) { + if (stat.kind === 226 || stat.kind === 225) { return true; } } @@ -10101,7 +10236,7 @@ var ts; } function bindModuleDeclaration(node) { setExportContextFlag(node); - if (node.name.kind === 8) { + if (node.name.kind === 9) { declareSymbolAndAddToSymbolTable(node, 512, 106639); } else { @@ -10111,12 +10246,17 @@ var ts; } else { declareSymbolAndAddToSymbolTable(node, 512, 106639); - var currentModuleIsConstEnumOnly = state === 2; - if (node.symbol.constEnumOnlyModule === undefined) { - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + if (node.symbol.flags & (16 | 32 | 256)) { + node.symbol.constEnumOnlyModule = false; } else { - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + var currentModuleIsConstEnumOnly = state === 2; + if (node.symbol.constEnumOnlyModule === undefined) { + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } } } } @@ -10134,11 +10274,11 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 66) { + if (prop.name.kind !== 67) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 242 || prop.kind === 243 || prop.kind === 140 + var currentKind = prop.kind === 243 || prop.kind === 244 || prop.kind === 141 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -10160,10 +10300,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 215: + case 216: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 245: + case 246: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -10181,8 +10321,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 103 && - node.originalKeywordKind <= 111 && + node.originalKeywordKind >= 104 && + node.originalKeywordKind <= 112 && !ts.isIdentifierName(node)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -10209,17 +10349,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 66) { + if (inStrictMode && node.expression.kind === 67) { var span = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 && + return node.kind === 67 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 66) { + if (name && name.kind === 67) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -10253,7 +10393,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 39 || node.operator === 40) { + if (node.operator === 40 || node.operator === 41) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -10282,17 +10422,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 245: - case 216: + case 246: + case 217: updateStrictModeStatementList(node.statements); return; - case 189: + case 190: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 211: - case 183: + case 212: + case 184: inStrictMode = true; return; } @@ -10311,106 +10451,106 @@ var ts; } function isUseStrictPrologueDirective(node) { var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); - return nodeText === '"use strict"' || nodeText === "'use strict'"; + return nodeText === "\"use strict\"" || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 66: + case 67: return checkStrictModeIdentifier(node); - case 178: + case 179: return checkStrictModeBinaryExpression(node); - case 241: - return checkStrictModeCatchClause(node); - case 172: - return checkStrictModeDeleteExpression(node); - case 7: - return checkStrictModeNumericLiteral(node); - case 177: - return checkStrictModePostfixUnaryExpression(node); - case 176: - return checkStrictModePrefixUnaryExpression(node); - case 202: - return checkStrictModeWithStatement(node); - case 134: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 135: - return bindParameter(node); - case 208: - case 160: - return bindVariableDeclarationOrBindingElement(node); - case 138: - case 137: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); case 242: + return checkStrictModeCatchClause(node); + case 173: + return checkStrictModeDeleteExpression(node); + case 8: + return checkStrictModeNumericLiteral(node); + case 178: + return checkStrictModePostfixUnaryExpression(node); + case 177: + return checkStrictModePrefixUnaryExpression(node); + case 203: + return checkStrictModeWithStatement(node); + case 135: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); + case 136: + return bindParameter(node); + case 209: + case 161: + return bindVariableDeclarationOrBindingElement(node); + case 139: + case 138: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); case 243: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); case 244: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 245: return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 144: case 145: case 146: + case 147: return declareSymbolAndAddToSymbolTable(node, 131072, 0); + case 141: case 140: - case 139: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 210: + case 211: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16, 106927); - case 141: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 142: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 143: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 144: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 149: case 150: + case 151: return bindFunctionOrConstructorType(node); - case 152: + case 153: return bindAnonymousDeclaration(node, 2048, "__type"); - case 162: + case 163: return bindObjectLiteralExpression(node); - case 170: case 171: + case 172: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16, bindingName); - case 183: - case 211: - return bindClassLikeDeclaration(node); + case 184: case 212: - return bindBlockScopedDeclaration(node, 64, 792960); + return bindClassLikeDeclaration(node); case 213: - return bindBlockScopedDeclaration(node, 524288, 793056); + return bindBlockScopedDeclaration(node, 64, 792960); case 214: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793056); case 215: + return bindEnumDeclaration(node); + case 216: return bindModuleDeclaration(node); - case 218: - case 221: - case 223: - case 227: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 220: - return bindImportClause(node); - case 225: - return bindExportDeclaration(node); + case 219: + case 222: case 224: + case 228: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 221: + return bindImportClause(node); + case 226: + return bindExportDeclaration(node); + case 225: return bindExportAssignment(node); - case 245: + case 246: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512, '"' + ts.removeFileExtension(file.fileName) + '"'); + bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); } } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } - else if (node.expression.kind === 66) { + else if (node.expression.kind === 67) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -10431,12 +10571,15 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 211) { + if (node.kind === 212) { bindBlockScopedDeclaration(node, 32, 899519); } else { var bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, 32, bindingName); + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } } var symbol = node.symbol; var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); @@ -10481,7 +10624,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 141 && + node.parent.kind === 142 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); @@ -10494,7 +10637,6 @@ var ts; } } })(ts || (ts = {})); -/// var ts; (function (ts) { var nextSymbolId = 1; @@ -10536,17 +10678,18 @@ var ts; isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, + getBaseTypes: getBaseTypes, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeAtLocation, + getTypeAtLocation: getTypeOfNode, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -10563,7 +10706,8 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getJsxElementAttributesType: getJsxElementAttributesType, - getJsxIntrinsicTagNames: getJsxIntrinsicTagNames + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, + isOptionalParameter: isOptionalParameter }; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); @@ -10571,16 +10715,17 @@ var ts; var stringType = createIntrinsicType(2, "string"); var numberType = createIntrinsicType(4, "number"); var booleanType = createIntrinsicType(8, "boolean"); - var esSymbolType = createIntrinsicType(4194304, "symbol"); + var esSymbolType = createIntrinsicType(16777216, "symbol"); var voidType = createIntrinsicType(16, "void"); - var undefinedType = createIntrinsicType(32 | 1048576, "undefined"); - var nullType = createIntrinsicType(64 | 1048576, "null"); + var undefinedType = createIntrinsicType(32 | 2097152, "undefined"); + var nullType = createIntrinsicType(64 | 2097152, "null"); var unknownType = createIntrinsicType(1, "unknown"); var circularType = createIntrinsicType(1, "__circular__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + anyFunctionType.flags |= 8388608; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); @@ -10624,6 +10769,7 @@ var ts; var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; + var resolutionPropertyNames = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -10645,7 +10791,7 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 4194304 + flags: 16777216 } }; var JsxNames = { @@ -10658,6 +10804,7 @@ var ts; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; + var _displayBuilder; initializeTypeChecker(); return checker; function getEmitResolver(sourceFile, cancellationToken) { @@ -10799,10 +10946,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 245); + return ts.getAncestor(node, 246); } function isGlobalSourceFile(node) { - return node.kind === 245 && !ts.isExternalModule(node); + return node.kind === 246 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -10825,7 +10972,7 @@ var ts; if (file1 === file2) { return node1.pos <= node2.pos; } - if (!compilerOptions.out) { + if (!compilerOptions.outFile && !compilerOptions.out) { return true; } var sourceFiles = host.getSourceFiles(); @@ -10850,16 +10997,16 @@ var ts; } } switch (location.kind) { - case 245: + case 246: if (!ts.isExternalModule(location)) break; - case 215: + case 216: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 245 || - (location.kind === 215 && location.name.kind === 8)) { + if (location.kind === 246 || + (location.kind === 216 && location.name.kind === 9)) { if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 227)) { + ts.getDeclarationOfKind(moduleExports[name], 228)) { break; } result = moduleExports["default"]; @@ -10873,13 +11020,13 @@ var ts; break loop; } break; - case 214: + case 215: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 139: case 138: - case 137: if (ts.isClassLike(location.parent) && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -10889,9 +11036,9 @@ var ts; } } break; - case 211: - case 183: case 212: + case 184: + case 213: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { if (lastLocation && lastLocation.flags & 128) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -10899,7 +11046,7 @@ var ts; } break loop; } - if (location.kind === 183 && meaning & 32) { + if (location.kind === 184 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -10907,28 +11054,28 @@ var ts; } } break; - case 133: + case 134: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 212) { + if (ts.isClassLike(grandparent) || grandparent.kind === 213) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 140: - case 139: case 141: + case 140: case 142: case 143: - case 210: - case 171: + case 144: + case 211: + case 172: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 170: + case 171: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -10941,8 +11088,8 @@ var ts; } } break; - case 136: - if (location.parent && location.parent.kind === 135) { + case 137: + if (location.parent && location.parent.kind === 136) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -10968,7 +11115,7 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (result.flags & 2) { + if (meaning & 2 && result.flags & 2) { checkResolvedBlockScopedVariable(result, errorLocation); } } @@ -10980,14 +11127,14 @@ var ts; ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 208); + var variableDeclaration = ts.getAncestor(declaration, 209); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 190 || - variableDeclaration.parent.parent.kind === 196) { + if (variableDeclaration.parent.parent.kind === 191 || + variableDeclaration.parent.parent.kind === 197) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 198 || - variableDeclaration.parent.parent.kind === 197) { + else if (variableDeclaration.parent.parent.kind === 199 || + variableDeclaration.parent.parent.kind === 198) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -11009,10 +11156,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 218) { + if (node.kind === 219) { return node; } - while (node && node.kind !== 219) { + while (node && node.kind !== 220) { node = node.parent; } return node; @@ -11022,7 +11169,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 229) { + if (node.moduleReference.kind === 230) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -11111,17 +11258,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 218: + case 219: return getTargetOfImportEqualsDeclaration(node); - case 220: - return getTargetOfImportClause(node); case 221: + return getTargetOfImportClause(node); + case 222: return getTargetOfNamespaceImport(node); - case 223: - return getTargetOfImportSpecifier(node); - case 227: - return getTargetOfExportSpecifier(node); case 224: + return getTargetOfImportSpecifier(node); + case 228: + return getTargetOfExportSpecifier(node); + case 225: return getTargetOfExportAssignment(node); } } @@ -11163,10 +11310,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 224) { + if (node.kind === 225) { checkExpressionCached(node.expression); } - else if (node.kind === 227) { + else if (node.kind === 228) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -11176,17 +11323,17 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 218); + importDeclaration = ts.getAncestor(entityName, 219); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 66 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 67 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 66 || entityName.parent.kind === 132) { + if (entityName.kind === 67 || entityName.parent.kind === 133) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 218); + ts.Debug.assert(entityName.parent.kind === 219); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } @@ -11198,16 +11345,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 66) { + if (name.kind === 67) { var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 132 || name.kind === 163) { - var left = name.kind === 132 ? name.left : name.expression; - var right = name.kind === 132 ? name.right : name.name; + else if (name.kind === 133 || name.kind === 164) { + var left = name.kind === 133 ? name.left : name.expression; + var right = name.kind === 133 ? name.right : name.name; var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -11230,35 +11377,24 @@ var ts; return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; } function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 8) { + if (moduleReferenceExpression.kind !== 9) { return; } var moduleReferenceLiteral = moduleReferenceExpression; var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName); var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) + if (moduleName === undefined) { return; + } var isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512); + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); if (symbol) { return symbol; } } - var fileName; - var sourceFile; - while (true) { - fileName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - sourceFile = ts.forEach(ts.supportedExtensions, function (extension) { return host.getSourceFile(fileName + extension); }); - if (sourceFile || isRelative) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } + var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); + var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { return sourceFile.symbol; @@ -11354,7 +11490,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 141 && ts.nodeIsPresent(member.body)) { + if (member.kind === 142 && ts.nodeIsPresent(member.body)) { return member; } } @@ -11419,17 +11555,17 @@ var ts; } } switch (location_1.kind) { - case 245: + case 246: if (!ts.isExternalModule(location_1)) { break; } - case 215: + case 216: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 211: case 212: + case 213: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -11462,7 +11598,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -11491,7 +11627,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -11546,8 +11682,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 215 && declaration.name.kind === 8) || - (declaration.kind === 245 && ts.isExternalModule(declaration)); + return (declaration.kind === 216 && declaration.name.kind === 9) || + (declaration.kind === 246 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -11579,11 +11715,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 151) { + if (entityName.parent.kind === 152) { meaning = 107455 | 1048576; } - else if (entityName.kind === 132 || entityName.kind === 163 || - entityName.parent.kind === 218) { + else if (entityName.kind === 133 || entityName.kind === 164 || + entityName.parent.kind === 219) { meaning = 1536; } else { @@ -11634,16 +11770,15 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 157) { + while (node.kind === 158) { node = node.parent; } - if (node.kind === 213) { + if (node.kind === 214) { return getSymbolOfNode(node); } } return undefined; } - var _displayBuilder; function getSymbolDisplayBuilder() { function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { @@ -11652,10 +11787,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 183: + case 184: return "(Anonymous class)"; - case 170: case 171: + case 172: return "(Anonymous function)"; } } @@ -11676,7 +11811,7 @@ var ts; buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -11718,7 +11853,7 @@ var ts; var globalFlagsToPass = globalFlags & 16; return writeType(type, globalFlags); function writeType(type, flags) { - if (type.flags & 4194431) { + if (type.flags & 16777343) { writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) ? "any" : type.intrinsicName); @@ -11742,23 +11877,23 @@ var ts; writer.writeStringLiteral(type.text); } else { - writePunctuation(writer, 14); - writeSpace(writer); - writePunctuation(writer, 21); - writeSpace(writer); writePunctuation(writer, 15); + writeSpace(writer); + writePunctuation(writer, 22); + writeSpace(writer); + writePunctuation(writer, 16); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 23) { + if (delimiter !== 24) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 23 ? 0 : 64); + writeType(types[i], delimiter === 24 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end) { @@ -11766,22 +11901,22 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056); } if (pos < end) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeType(typeArguments[pos++], 0); while (pos < end) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); writeType(typeArguments[pos++], 0); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); - writePunctuation(writer, 18); writePunctuation(writer, 19); + writePunctuation(writer, 20); } else { var outerTypeParameters = type.target.outerTypeParameters; @@ -11796,7 +11931,7 @@ var ts; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_3); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_3, typeArguments, start, i); - writePunctuation(writer, 20); + writePunctuation(writer, 21); } } } @@ -11804,18 +11939,18 @@ var ts; } } function writeTupleType(type) { - writePunctuation(writer, 18); - writeTypeList(type.elementTypes, 23); writePunctuation(writer, 19); + writeTypeList(type.elementTypes, 24); + writePunctuation(writer, 20); } function writeUnionOrIntersectionType(type, flags) { - if (flags & 64) { - writePunctuation(writer, 16); - } - writeTypeList(type.types, type.flags & 16384 ? 45 : 44); if (flags & 64) { writePunctuation(writer, 17); } + writeTypeList(type.types, type.flags & 16384 ? 46 : 45); + if (flags & 64) { + writePunctuation(writer, 18); + } } function writeAnonymousType(type, flags) { var symbol = type.symbol; @@ -11832,7 +11967,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 114); + writeKeyword(writer, 115); } } else { @@ -11853,7 +11988,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 245 || declaration.parent.kind === 216; + return declaration.parent.kind === 246 || declaration.parent.kind === 217; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -11862,7 +11997,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 98); + writeKeyword(writer, 99); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -11878,74 +12013,74 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 14); writePunctuation(writer, 15); + writePunctuation(writer, 16); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { if (flags & 64) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); } - writeKeyword(writer, 89); + writeKeyword(writer, 90); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } return; } } - writePunctuation(writer, 14); + writePunctuation(writer, 15); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 89); + writeKeyword(writer, 90); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } if (resolved.stringIndexType) { - writePunctuation(writer, 18); - writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 52); - writeSpace(writer); - writeKeyword(writer, 127); writePunctuation(writer, 19); - writePunctuation(writer, 52); + writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); + writePunctuation(writer, 53); + writeSpace(writer); + writeKeyword(writer, 128); + writePunctuation(writer, 20); + writePunctuation(writer, 53); writeSpace(writer); writeType(resolved.stringIndexType, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } if (resolved.numberIndexType) { - writePunctuation(writer, 18); - writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 52); - writeSpace(writer); - writeKeyword(writer, 125); writePunctuation(writer, 19); - writePunctuation(writer, 52); + writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); + writePunctuation(writer, 53); + writeSpace(writer); + writeKeyword(writer, 126); + writePunctuation(writer, 20); + writePunctuation(writer, 53); writeSpace(writer); writeType(resolved.numberIndexType, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { @@ -11957,32 +12092,32 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } } else { buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } - writePunctuation(writer, 52); + writePunctuation(writer, 53); writeSpace(writer); writeType(t, 0); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 15); + writePunctuation(writer, 16); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 || targetSymbol.flags & 64) { + if (targetSymbol.flags & 32 || targetSymbol.flags & 64 || targetSymbol.flags & 524288) { buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } @@ -11991,7 +12126,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 80); + writeKeyword(writer, 81); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -11999,67 +12134,67 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 21); + writePunctuation(writer, 22); } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } - writePunctuation(writer, 52); + writePunctuation(writer, 53); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0); } - writePunctuation(writer, 26); + writePunctuation(writer, 27); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); for (var i = 0; i < parameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 17); + writePunctuation(writer, 18); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 33); + writePunctuation(writer, 34); } else { - writePunctuation(writer, 52); + writePunctuation(writer, 53); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 121); + writeKeyword(writer, 122); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -12079,15 +12214,12 @@ var ts; buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { - symbolToString: symbolToString, - typeToString: typeToString, buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildDisplayForTypeArgumentsAndDelimiters: buildDisplayForTypeArgumentsAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay @@ -12096,12 +12228,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 215) { - if (node.name.kind === 8) { + if (node.kind === 216) { + if (node.name.kind === 9) { return node; } } - else if (node.kind === 245) { + else if (node.kind === 246) { return ts.isExternalModule(node) ? node : undefined; } } @@ -12144,60 +12276,60 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 160: + case 161: return isDeclarationVisible(node.parent.parent); - case 208: + case 209: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 215: - case 211: + case 216: case 212: case 213: - case 210: case 214: - case 218: + case 211: + case 215: + case 219: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 218 && parent_4.kind !== 245 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 219 && parent_4.kind !== 246 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 138: - case 137: - case 142: - case 143: - case 140: case 139: + case 138: + case 143: + case 144: + case 141: + case 140: if (node.flags & (32 | 64)) { return false; } - case 141: - case 145: - case 144: + case 142: case 146: - case 135: - case 216: - case 149: + case 145: + case 147: + case 136: + case 217: case 150: - case 152: - case 148: + case 151: case 153: + case 149: case 154: case 155: case 156: case 157: + case 158: return isDeclarationVisible(node.parent); - case 220: case 221: - case 223: - return false; - case 134: - case 245: - return true; + case 222: case 224: return false; + case 135: + case 246: + return true; + case 225: + return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); } @@ -12212,11 +12344,14 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 224) { - exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); + if (node.parent && node.parent.kind === 225) { + exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 227) { - exportSymbol = getTargetOfExportSpecifier(node.parent); + else if (node.parent.kind === 228) { + var exportSpecifier = node.parent; + exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 | 793056 | 1536 | 8388608); } var result = []; if (exportSymbol) { @@ -12239,29 +12374,55 @@ var ts; }); } } - function pushTypeResolution(target) { - var i = 0; - var count = resolutionTargets.length; - while (i < count && resolutionTargets[i] !== target) { - i++; - } - if (i < count) { - do { - resolutionResults[i++] = false; - } while (i < count); + function pushTypeResolution(target, propertyName) { + var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + var length_2 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_2; i++) { + resolutionResults[i] = false; + } return false; } resolutionTargets.push(target); resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); return true; } + function findResolutionCycleStartIndex(target, propertyName) { + for (var i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + return -1; + } + function hasType(target, propertyName) { + if (propertyName === 0) { + return getSymbolLinks(target).type; + } + if (propertyName === 2) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === 1) { + ts.Debug.assert(!!(target.flags & 1024)); + return target.resolvedBaseConstructorType; + } + if (propertyName === 3) { + return target.resolvedReturnType; + } + ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } function popTypeResolution() { resolutionTargets.pop(); + resolutionPropertyNames.pop(); return resolutionResults.pop(); } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 208 ? node.parent.parent.parent : node.parent; + return node.kind === 209 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -12287,7 +12448,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 158) { + if (pattern.kind === 159) { var name_11 = declaration.propertyName || declaration.name; type = getTypeOfPropertyOfType(parentType, name_11.text) || isNumericLiteralName(name_11.text) && getIndexTypeOfType(parentType, 1) || @@ -12300,9 +12461,6 @@ var ts; else { var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); if (!declaration.dotDotDotToken) { - if (isTypeAny(elementType)) { - return elementType; - } var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) ? getTypeOfPropertyOfType(parentType, propName) @@ -12324,10 +12482,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 197) { + if (declaration.parent.parent.kind === 198) { return anyType; } - if (declaration.parent.parent.kind === 198) { + if (declaration.parent.parent.kind === 199) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -12336,10 +12494,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135) { + if (declaration.kind === 136) { var func = declaration.parent; - if (func.kind === 143 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 142); + if (func.kind === 144 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -12352,53 +12510,56 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 243) { + if (declaration.kind === 244) { return checkIdentifier(declaration.name); } + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name, false); + } return undefined; } - function getTypeFromBindingElement(element) { + function getTypeFromBindingElement(element, includePatternInType) { if (element.initializer) { return getWidenedType(checkExpressionCached(element.initializer)); } if (ts.isBindingPattern(element.name)) { - return getTypeFromBindingPattern(element.name); + return getTypeFromBindingPattern(element.name, includePatternInType); } return anyType; } - function getTypeFromObjectBindingPattern(pattern) { + function getTypeFromObjectBindingPattern(pattern, includePatternInType) { var members = {}; ts.forEach(pattern.elements, function (e) { var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); var name = e.propertyName || e.name; var symbol = createSymbol(flags, name.text); - symbol.type = getTypeFromBindingElement(e); + symbol.type = getTypeFromBindingElement(e, includePatternInType); + symbol.bindingElement = e; members[symbol.name] = symbol; }); - return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + if (includePatternInType) { + result.pattern = pattern; + } + return result; } - function getTypeFromArrayBindingPattern(pattern) { - var hasSpreadElement = false; - var elementTypes = []; - ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 184 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); - if (e.dotDotDotToken) { - hasSpreadElement = true; - } - }); - if (!elementTypes.length) { + function getTypeFromArrayBindingPattern(pattern, includePatternInType) { + var elements = pattern.elements; + if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } - else if (hasSpreadElement) { - var unionOfElements = getUnionType(elementTypes); - return languageVersion >= 2 ? createIterableType(unionOfElements) : createArrayType(unionOfElements); + var elementTypes = ts.map(elements, function (e) { return e.kind === 185 ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + if (includePatternInType) { + var result = createNewTupleType(elementTypes); + result.pattern = pattern; + return result; } return createTupleType(elementTypes); } - function getTypeFromBindingPattern(pattern) { - return pattern.kind === 158 - ? getTypeFromObjectBindingPattern(pattern) - : getTypeFromArrayBindingPattern(pattern); + function getTypeFromBindingPattern(pattern, includePatternInType) { + return pattern.kind === 159 + ? getTypeFromObjectBindingPattern(pattern, includePatternInType) + : getTypeFromArrayBindingPattern(pattern, includePatternInType); } function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { var type = getTypeForVariableLikeDeclaration(declaration); @@ -12406,15 +12567,12 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 242 ? getWidenedType(type) : type; - } - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return declaration.kind !== 243 ? getWidenedType(type) : type; } type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 135 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 136 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -12427,13 +12585,13 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 241) { + if (declaration.parent.kind === 242) { return links.type = anyType; } - if (declaration.kind === 224) { + if (declaration.kind === 225) { return links.type = checkExpression(declaration.expression); } - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -12455,7 +12613,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 142) { + if (accessor.kind === 143) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -12468,11 +12626,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 142); - var setter = ts.getDeclarationOfKind(symbol, 143); + var getter = ts.getDeclarationOfKind(symbol, 143); + var setter = ts.getDeclarationOfKind(symbol, 144); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -12498,7 +12656,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 142); + var getter_1 = ts.getDeclarationOfKind(symbol, 143); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -12587,9 +12745,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 211 || node.kind === 183 || - node.kind === 210 || node.kind === 170 || - node.kind === 140 || node.kind === 171) { + if (node.kind === 212 || node.kind === 184 || + node.kind === 211 || node.kind === 171 || + node.kind === 141 || node.kind === 172) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -12598,15 +12756,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 212); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 212 || node.kind === 211 || - node.kind === 183 || node.kind === 213) { + if (node.kind === 213 || node.kind === 212 || + node.kind === 184 || node.kind === 214) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -12642,7 +12800,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type)) { + if (!pushTypeResolution(type, 1)) { return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -12711,7 +12869,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 212 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 213 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -12755,10 +12913,10 @@ var ts; function getDeclaredTypeOfTypeAlias(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - if (!pushTypeResolution(links)) { + if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 213); + var declaration = ts.getDeclarationOfKind(symbol, 214); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -12789,7 +12947,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 134).constraint) { + if (!ts.getDeclarationOfKind(symbol, 135).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -12951,43 +13109,64 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); + var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, true))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } - function signatureListsIdentical(s, t) { - if (s.length !== t.length) { - return false; - } - for (var i = 0; i < s.length; i++) { - if (!compareSignatures(s[i], t[i], false, compareTypes)) { - return false; + function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { + for (var _i = 0; _i < signatureList.length; _i++) { + var s = signatureList[_i]; + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { + return s; } } - return true; + } + function findMatchingSignatures(signatureLists, signature, listIndex) { + if (signature.typeParameters) { + if (listIndex > 0) { + return undefined; + } + for (var i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, false, false)) { + return undefined; + } + } + return [signature]; + } + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, true); + if (!match) { + return undefined; + } + if (!ts.contains(result, match)) { + (result || (result = [])).push(match); + } + } + return result; } function getUnionSignatures(types, kind) { var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var signatures = signatureLists[0]; - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; - if (signature.typeParameters) { - return emptyArray; + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { + var signature = _a[_i]; + if (!result || !findMatchingSignature(result, signature, false, true)) { + var unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + var s = signature; + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } + } } } - for (var i_1 = 1; i_1 < signatureLists.length; i_1++) { - if (!signatureListsIdentical(signatures, signatureLists[i_1])) { - return emptyArray; - } - } - var result = ts.map(signatures, cloneSignature); - for (var i = 0; i < result.length; i++) { - var s = result[i]; - s.resolvedReturnType = undefined; - s.unionSignatures = ts.map(signatureLists, function (signatures) { return signatures[i]; }); - } - return result; + return result || emptyArray; } function getUnionIndexType(types, kind) { var indexTypes = []; @@ -13124,9 +13303,6 @@ var ts; return type.flags & 49152 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function getApparentType(type) { - if (type.flags & 16384) { - type = getReducedTypeOfUnionType(type); - } if (type.flags & 512) { do { type = getConstraintOfTypeParameter(type); @@ -13144,7 +13320,7 @@ var ts; else if (type.flags & 8) { type = globalBooleanType; } - else if (type.flags & 4194304) { + else if (type.flags & 16777216) { type = globalESSymbolType; } return type; @@ -13280,12 +13456,22 @@ var ts; return result; } function isOptionalParameter(node) { - return ts.hasQuestionToken(node) || !!node.initializer; + if (ts.hasQuestionToken(node)) { + return true; + } + if (node.initializer) { + var signatureDeclaration = node.parent; + var signature = getSignatureFromDeclaration(signatureDeclaration); + var parameterIndex = signatureDeclaration.parameters.indexOf(node); + ts.Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + return false; } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 141 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 142 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -13294,14 +13480,17 @@ var ts; for (var i = 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; parameters.push(param.symbol); - if (param.type && param.type.kind === 8) { + if (param.type && param.type.kind === 9) { hasStringLiterals = true; } - if (minArgumentCount < 0) { - if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { minArgumentCount = i; } } + else { + minArgumentCount = -1; + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length; @@ -13313,7 +13502,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 147) { + if (declaration.type.kind === 148) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -13323,8 +13512,8 @@ var ts; } } else { - if (declaration.kind === 142 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 143); + if (declaration.kind === 143 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 144); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -13342,19 +13531,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 149: case 150: - case 210: - case 140: - case 139: + case 151: + case 211: case 141: - case 144: + case 140: + case 142: case 145: case 146: - case 142: + case 147: case 143: - case 170: + case 144: case 171: + case 172: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -13368,7 +13557,7 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, 3)) { return unknownType; } var type; @@ -13424,7 +13613,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 141 || signature.declaration.kind === 145; + var isConstructor = signature.declaration.kind === 142 || signature.declaration.kind === 146; var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; @@ -13438,7 +13627,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 125 : 127; + var syntaxKind = kind === 1 ? 126 : 128; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -13467,13 +13656,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 134).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 134).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135).parent); } function getTypeListId(types) { switch (types.length) { @@ -13492,19 +13681,19 @@ var ts; return result; } } - function getWideningFlagsOfTypes(types) { + function getPropagatingFlagsOfTypes(types) { var result = 0; for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; result |= type.flags; } - return result & 3145728; + return result & 14680064; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 | getWideningFlagsOfTypes(typeArguments); + var flags = 4096 | getPropagatingFlagsOfTypes(typeArguments); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -13520,13 +13709,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 134; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 148 && n.typeName.kind === 66) { + if (n.kind === 149 && n.typeName.kind === 67) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -13593,7 +13782,7 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 148 ? node.typeName : + var typeNameOrExpression = node.kind === 149 ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; @@ -13619,9 +13808,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 211: case 212: - case 214: + case 213: + case 215: return declaration; } } @@ -13667,7 +13856,7 @@ var ts; } function createTypedPropertyDescriptorType(propertyType) { var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyObjectType + return globalTypedPropertyDescriptorType !== emptyGenericType ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } @@ -13692,11 +13881,11 @@ var ts; } function createTupleType(elementTypes) { var id = getTypeListId(elementTypes); - var type = tupleTypes[id]; - if (!type) { - type = tupleTypes[id] = createObjectType(8192 | getWideningFlagsOfTypes(elementTypes)); - type.elementTypes = elementTypes; - } + return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); + } + function createNewTupleType(elementTypes) { + var type = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes)); + type.elementTypes = elementTypes; return type; } function getTypeFromTupleTypeNode(node) { @@ -13721,9 +13910,8 @@ var ts; } } function isSubtypeOfAny(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - if (candidate !== type && isTypeSubtypeOf(candidate, type)) { + for (var i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { return true; } } @@ -13756,20 +13944,16 @@ var ts; } } } - function compareTypeIds(type1, type2) { - return type1.id - type2.id; - } function getUnionType(types, noSubtypeReduction) { if (types.length === 0) { return emptyObjectType; } var typeSet = []; addTypesToSet(typeSet, types, 16384); - typeSet.sort(compareTypeIds); + if (containsTypeAny(typeSet)) { + return anyType; + } if (noSubtypeReduction) { - if (containsTypeAny(typeSet)) { - return anyType; - } removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } @@ -13782,25 +13966,11 @@ var ts; var id = getTypeListId(typeSet); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 | getWideningFlagsOfTypes(typeSet)); + type = unionTypes[id] = createObjectType(16384 | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; - type.reducedType = noSubtypeReduction ? undefined : type; } return type; } - function getReducedTypeOfUnionType(type) { - if (!type.reducedType) { - type.reducedType = circularType; - var reducedType = getUnionType(type.types, false); - if (type.reducedType === circularType) { - type.reducedType = reducedType; - } - } - else if (type.reducedType === circularType) { - type.reducedType = type; - } - return type.reducedType; - } function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { @@ -13823,7 +13993,7 @@ var ts; var id = getTypeListId(typeSet); var type = intersectionTypes[id]; if (!type) { - type = intersectionTypes[id] = createObjectType(32768 | getWideningFlagsOfTypes(typeSet)); + type = intersectionTypes[id] = createObjectType(32768 | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; } return type; @@ -13859,45 +14029,45 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 114: + case 115: return anyType; - case 127: - return stringType; - case 125: - return numberType; - case 117: - return booleanType; case 128: - return esSymbolType; - case 100: - return voidType; - case 8: - return getTypeFromStringLiteral(node); - case 148: - return getTypeFromTypeReference(node); - case 147: + return stringType; + case 126: + return numberType; + case 118: return booleanType; - case 185: - return getTypeFromTypeReference(node); - case 151: - return getTypeFromTypeQueryNode(node); - case 153: - return getTypeFromArrayTypeNode(node); - case 154: - return getTypeFromTupleTypeNode(node); - case 155: - return getTypeFromUnionTypeNode(node); - case 156: - return getTypeFromIntersectionTypeNode(node); - case 157: - return getTypeFromTypeNode(node.type); + case 129: + return esSymbolType; + case 101: + return voidType; + case 9: + return getTypeFromStringLiteral(node); case 149: - case 150: + return getTypeFromTypeReference(node); + case 148: + return booleanType; + case 186: + return getTypeFromTypeReference(node); case 152: + return getTypeFromTypeQueryNode(node); + case 154: + return getTypeFromArrayTypeNode(node); + case 155: + return getTypeFromTupleTypeNode(node); + case 156: + return getTypeFromUnionTypeNode(node); + case 157: + return getTypeFromIntersectionTypeNode(node); + case 158: + return getTypeFromTypeNode(node.type); + case 150: + case 151: + case 153: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 66: - case 132: - var symbol = getSymbolInfo(node); + case 67: + case 133: + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: return unknownType; @@ -13956,7 +14126,7 @@ var ts; }; } function createInferenceMapper(context) { - return function (t) { + var mapper = function (t) { for (var i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { context.inferences[i].isFixed = true; @@ -13965,6 +14135,8 @@ var ts; } return t; }; + mapper.context = context; + return mapper; } function identityMapper(type) { return type; @@ -14020,6 +14192,15 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { + if (mapper.instantiations) { + var cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } var result = createObjectType(65536 | 131072, type.symbol); result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); result.members = createSymbolTable(result.properties); @@ -14031,6 +14212,7 @@ var ts; result.stringIndexType = instantiateType(stringIndexType, mapper); if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper); + mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { @@ -14058,27 +14240,27 @@ var ts; return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 170: case 171: + case 172: return isContextSensitiveFunctionLikeDeclaration(node); - case 162: + case 163: return ts.forEach(node.properties, isContextSensitive); - case 161: + case 162: return ts.forEach(node.elements, isContextSensitive); - case 179: + case 180: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 178: - return node.operatorToken.kind === 50 && + case 179: + return node.operatorToken.kind === 51 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 242: + case 243: return isContextSensitive(node.initializer); + case 141: case 140: - case 139: return isContextSensitiveFunctionLikeDeclaration(node); - case 169: + case 170: return isContextSensitive(node.expression); } return false; @@ -14152,99 +14334,158 @@ var ts; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } + function reportRelationError(message, source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, undefined, 128); + targetType = typeToString(target, undefined, 128); + } + reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } function isRelatedTo(source, target, reportErrors, headMessage) { var result; if (source === target) return -1; - if (relation !== identityRelation) { - if (isTypeAny(target)) + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + if (isTypeAny(target)) + return -1; + if (source === undefinedType) + return -1; + if (source === nullType && target !== undefinedType) + return -1; + if (source.flags & 128 && target === numberType) + return -1; + if (source.flags & 256 && target === stringType) + return -1; + if (relation === assignableRelation) { + if (isTypeAny(source)) return -1; - if (source === undefinedType) + if (source === numberType && target.flags & 128) return -1; - if (source === nullType && target !== undefinedType) - return -1; - if (source.flags & 128 && target === numberType) - return -1; - if (source.flags & 256 && target === stringType) - return -1; - if (relation === assignableRelation) { - if (isTypeAny(source)) - return -1; - if (source === numberType && target.flags & 128) - return -1; + } + if (source.flags & 1048576) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0; + } + if (target.flags & 49152) { + source = getRegularTypeOfObjectLiteral(source); } } var saveErrorInfo = errorInfo; - if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + if (source.flags & 16384) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { return result; } } - else if (source.flags & 512 && target.flags & 512) { - if (result = typeParameterRelatedTo(source, target, reportErrors)) { + else if (target.flags & 32768) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { return result; } } - else if (relation !== identityRelation) { - if (source.flags & 16384) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 32768) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - if (source.flags & 32768) { - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { - return result; - } - } - if (target.flags & 16384) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - } else { - if (source.flags & 16384 && target.flags & 16384 || - source.flags & 32768 && target.flags & 32768) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } + if (source.flags & 32768) { + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { + return result; + } + } + if (target.flags & 16384) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; } } } - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & (80896 | 32768) && target.flags & 80896) { - if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + if (source.flags & 512) { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 512 && sourceOrApparentType.flags & 49152) { - errorInfo = saveErrorInfo; - if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { - return result; + else { + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; + } + } + var apparentType = getApparentType(source); + if (apparentType.flags & (80896 | 32768) && target.flags & 80896) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } if (reportErrors) { - headMessage = headMessage || ts.Diagnostics.Type_0_is_not_assignable_to_type_1; - var sourceType = typeToString(source); - var targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, undefined, 128); - targetType = typeToString(target, undefined, 128); - } - reportError(headMessage, sourceType, targetType); + reportRelationError(headMessage, source, target); } return 0; } + function isIdenticalTo(source, target) { + var result; + if (source.flags & 80896 && target.flags & 80896) { + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, false)) { + return result; + } + } + return objectTypeRelatedTo(source, target, false); + } + if (source.flags & 512 && target.flags & 512) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & 16384 && target.flags & 16384 || + source.flags & 32768 && target.flags & 32768) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return 0; + } + function isKnownProperty(type, name) { + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); + if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || + resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + return true; + } + return false; + } + if (type.flags & 49152) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } + function hasExcessProperties(source, target, reportErrors) { + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + errorNode = prop.valueDeclaration; + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; @@ -14315,30 +14556,17 @@ var ts; } return result; } - function typeParameterRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - if (source.symbol.name !== target.symbol.name) { - return 0; - } - if (source.constraint === target.constraint) { - return -1; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0; - } - return isRelatedTo(source.constraint, target.constraint, reportErrors); - } - else { - while (true) { - var constraint = getConstraintOfTypeParameter(source); - if (constraint === target) - return -1; - if (!(constraint && constraint.flags & 512)) - break; - source = constraint; - } + function typeParameterIdenticalTo(source, target) { + if (source.symbol.name !== target.symbol.name) { return 0; } + if (source.constraint === target.constraint) { + return -1; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return 0; + } + return isIdenticalTo(source.constraint, target.constraint); } function objectTypeRelatedTo(source, target, reportErrors) { if (overflow) { @@ -14515,22 +14743,12 @@ var ts; var targetSignatures = getSignaturesOfType(target, kind); var result = -1; var saveErrorInfo = errorInfo; - var sourceSig = sourceSignatures[0]; - var targetSig = targetSignatures[0]; - if (sourceSig && targetSig) { - var sourceErasedSignature = getErasedSignature(sourceSig); - var targetErasedSignature = getErasedSignature(targetSig); - var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 211); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 211); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; - if (sourceIsAbstract && !targetIsAbstract) { - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return 0; + if (kind === 1) { + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== -1) { + return result; } } outer: for (var _i = 0; _i < targetSignatures.length; _i++) { @@ -14554,6 +14772,30 @@ var ts; } } return result; + function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { + if (sourceSig && targetSig) { + var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); + var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); + if (!sourceDecl) { + return -1; + } + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0; + } + } + return -1; + } } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { @@ -14642,7 +14884,7 @@ var ts; } var result = -1; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], false, false, isRelatedTo); if (!related) { return 0; } @@ -14655,7 +14897,7 @@ var ts; return indexTypesIdenticalTo(0, source, target); } var targetType = getIndexTypeOfType(target, 0); - if (targetType) { + if (targetType && !(targetType.flags & 1)) { var sourceType = getIndexTypeOfType(source, 0); if (!sourceType) { if (reportErrors) { @@ -14679,7 +14921,7 @@ var ts; return indexTypesIdenticalTo(1, source, target); } var targetType = getIndexTypeOfType(target, 1); - if (targetType) { + if (targetType && !(targetType.flags & 1)) { var sourceStringType = getIndexTypeOfType(source, 0); var sourceNumberType = getIndexTypeOfType(source, 1); if (!(sourceStringType || sourceNumberType)) { @@ -14756,14 +14998,18 @@ var ts; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } - function compareSignatures(source, target, compareReturnTypes, compareTypes) { + function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { if (source === target) { return -1; } if (source.parameters.length !== target.parameters.length || source.minArgumentCount !== target.minArgumentCount || source.hasRestParameter !== target.hasRestParameter) { - return 0; + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return 0; + } } var result = -1; if (source.typeParameters && target.typeParameters) { @@ -14783,16 +15029,18 @@ var ts; } source = getErasedSignature(source); target = getErasedSignature(target); - for (var i = 0, len = source.parameters.length; i < len; i++) { - var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var sourceLen = source.parameters.length; + var targetLen = target.parameters.length; + for (var i = 0; i < targetLen; i++) { + var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); var related = compareTypes(s, t); if (!related) { return 0; } result &= related; } - if (compareReturnTypes) { + if (!ignoreReturnTypes) { result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; @@ -14847,6 +15095,24 @@ var ts; function isTupleType(type) { return !!(type.flags & 8192); } + function getRegularTypeOfObjectLiteral(type) { + if (type.flags & 1048576) { + var regularType = type.regularType; + if (!regularType) { + regularType = createType(type.flags & ~1048576); + regularType.symbol = type.symbol; + regularType.members = type.members; + regularType.properties = type.properties; + regularType.callSignatures = type.callSignatures; + regularType.constructSignatures = type.constructSignatures; + regularType.stringIndexType = type.stringIndexType; + regularType.numberIndexType = type.numberIndexType; + type.regularType = regularType; + } + return regularType; + } + return type; + } function getWidenedTypeOfObjectLiteral(type) { var properties = getPropertiesOfObjectType(type); var members = {}; @@ -14874,7 +15140,7 @@ var ts; return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); } function getWidenedType(type) { - if (type.flags & 3145728) { + if (type.flags & 6291456) { if (type.flags & (32 | 64)) { return anyType; } @@ -14882,7 +15148,7 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 16384) { - return getUnionType(ts.map(type.types, getWidenedType)); + return getUnionType(ts.map(type.types, getWidenedType), true); } if (isArrayType(type)) { return createArrayType(getWidenedType(type.typeArguments[0])); @@ -14918,7 +15184,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 1048576) { + if (t.flags & 2097152) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -14932,22 +15198,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 139: case 138: - case 137: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 135: + case 136: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 210: + case 211: + case 141: case 140: - case 139: - case 142: case 143: - case 170: + case 144: case 171: + case 172: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -14960,7 +15226,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 1048576) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -14996,7 +15262,9 @@ var ts; var inferences = []; for (var _i = 0; _i < typeParameters.length; _i++) { var unused = typeParameters[_i]; - inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); + inferences.push({ + primary: undefined, secondary: undefined, isFixed: false + }); } return { typeParameters: typeParameters, @@ -15020,10 +15288,10 @@ var ts; return false; } function inferFromTypes(source, target) { - if (source === anyFunctionType) { - return; - } if (target.flags & 512) { + if (source.flags & 8388608) { + return; + } var typeParameters = context.typeParameters; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { @@ -15047,6 +15315,13 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 8192 && target.flags & 8192 && source.elementTypes.length === target.elementTypes.length) { + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } else if (target.flags & 49152) { var targetTypes = target.types; var typeParameterCount = 0; @@ -15190,10 +15465,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 151: + case 152: return true; - case 66: - case 132: + case 67: + case 133: node = node.parent; continue; default: @@ -15233,12 +15508,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 54 && node.operatorToken.kind <= 65) { + if (node.operatorToken.kind >= 55 && node.operatorToken.kind <= 66) { var n = node.left; - while (n.kind === 169) { + while (n.kind === 170) { n = n.expression; } - if (n.kind === 66 && getResolvedSymbol(n) === symbol) { + if (n.kind === 67 && getResolvedSymbol(n) === symbol) { return true; } } @@ -15252,82 +15527,60 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 178: + case 179: return isAssignedInBinaryExpression(node); - case 208: - case 160: - return isAssignedInVariableDeclaration(node); - case 158: - case 159: + case 209: case 161: + return isAssignedInVariableDeclaration(node); + case 159: + case 160: case 162: case 163: case 164: case 165: case 166: - case 168: - case 186: + case 167: case 169: - case 176: - case 172: - case 175: - case 173: - case 174: + case 187: + case 170: case 177: - case 181: - case 179: + case 173: + case 176: + case 174: + case 175: + case 178: case 182: - case 189: + case 180: + case 183: case 190: - case 192: + case 191: case 193: case 194: case 195: case 196: case 197: case 198: - case 201: + case 199: case 202: case 203: - case 238: - case 239: case 204: + case 239: + case 240: case 205: case 206: - case 241: - case 230: + case 207: + case 242: case 231: - case 235: - case 236: case 232: + case 236: case 237: + case 233: + case 238: return ts.forEachChild(node, isAssignedIn); } return false; } } - function resolveLocation(node) { - var containerNodes = []; - for (var parent_5 = node.parent; parent_5; parent_5 = parent_5.parent) { - if ((ts.isExpression(parent_5) || ts.isObjectLiteralMethod(node)) && - isContextSensitive(parent_5)) { - containerNodes.unshift(parent_5); - } - } - ts.forEach(containerNodes, function (node) { getTypeOfNode(node); }); - } - function getSymbolAtLocation(node) { - resolveLocation(node); - return getSymbolInfo(node); - } - function getTypeAtLocation(node) { - resolveLocation(node); - return getTypeOfNode(node); - } - function getTypeOfSymbolAtLocation(symbol, node) { - resolveLocation(node); - return getNarrowedTypeOfSymbol(symbol, node); - } function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); if (node && symbol.flags & 3) { @@ -15337,34 +15590,34 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 193: + case 194: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 179: + case 180: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 178: + case 179: if (child === node.right) { - if (node.operatorToken.kind === 49) { + if (node.operatorToken.kind === 50) { narrowedType = narrowType(type, node.left, true); } - else if (node.operatorToken.kind === 50) { + else if (node.operatorToken.kind === 51) { narrowedType = narrowType(type, node.left, false); } } break; - case 245: - case 215: - case 210: - case 140: - case 139: - case 142: - case 143: + case 246: + case 216: + case 211: case 141: + case 140: + case 143: + case 144: + case 142: break loop; } if (narrowedType !== type) { @@ -15378,21 +15631,21 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 173 || expr.right.kind !== 8) { + if (expr.left.kind !== 174 || expr.right.kind !== 9) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 66 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 67 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 32) { + if (expr.operatorToken.kind === 33) { assumeTrue = !assumeTrue; } if (assumeTrue) { if (!typeInfo) { - return removeTypesFromUnionType(type, 258 | 132 | 8 | 4194304, true, false); + return removeTypesFromUnionType(type, 258 | 132 | 8 | 16777216, true, false); } if (isTypeSubtypeOf(typeInfo.type, type)) { return typeInfo.type; @@ -15429,7 +15682,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 66 || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -15462,11 +15715,14 @@ var ts; return type; } function getNarrowedType(originalType, narrowedTypeCandidate) { - if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { - return narrowedTypeCandidate; - } if (originalType.flags & 16384) { - return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + return narrowedTypeCandidate; } return originalType; } @@ -15490,27 +15746,27 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 165: + case 166: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 169: + case 170: return narrowType(type, expr.expression, assumeTrue); - case 178: + case 179: var operator = expr.operatorToken.kind; - if (operator === 31 || operator === 32) { + if (operator === 32 || operator === 33) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 49) { + else if (operator === 50) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 50) { + else if (operator === 51) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 88) { + else if (operator === 89) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 176: - if (expr.operator === 47) { + case 177: + if (expr.operator === 48) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -15522,7 +15778,7 @@ var ts; var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 171) { + if (container.kind === 172) { if (languageVersion < 2) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -15553,15 +15809,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 241) { + symbol.valueDeclaration.parent.kind === 242) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 209) { + while (container.kind !== 210) { container = container.parent; } container = container.parent; - if (container.kind === 190) { + if (container.kind === 191) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -15579,7 +15835,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 138 || container.kind === 141) { + if (container.kind === 139 || container.kind === 142) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -15590,29 +15846,29 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 171) { + if (container.kind === 172) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 215: + case 216: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 214: + case 215: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 141: + case 142: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 139: case 138: - case 137: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 133: + case 134: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -15627,90 +15883,96 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 135) { + if (n.kind === 136) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 165 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 166 && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; + var container = ts.getSuperContainer(node, true); + var needToCaptureLexicalThis = false; + if (!isCallExpression) { + while (container && container.kind === 172) { + container = ts.getSuperContainer(container, true); + needToCaptureLexicalThis = languageVersion < 2; + } + } + var canUseSuperExpression = isLegalUsageOfSuperExpression(container); + var nodeCheckFlag = 0; + if (canUseSuperExpression) { + if ((container.flags & 128) || isCallExpression) { + nodeCheckFlag = 512; + } + else { + nodeCheckFlag = 256; + } + getNodeLinks(node).flags |= nodeCheckFlag; + if (needToCaptureLexicalThis) { + captureLexicalThis(node.parent, container); + } + } if (!baseClassType) { if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); } return unknownType; } - var container = ts.getSuperContainer(node, true); - if (container) { - var canUseSuperExpression = false; - var needToCaptureLexicalThis; + if (!canUseSuperExpression) { + if (container && container.kind === 134) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); + } + else if (isCallExpression) { + error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); + } + else { + error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; + } + if (container.kind === 142 && isInConstructorArgumentInitializer(node, container)) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + return nodeCheckFlag === 512 + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + function isLegalUsageOfSuperExpression(container) { + if (!container) { + return false; + } if (isCallExpression) { - canUseSuperExpression = container.kind === 141; + return container.kind === 142; } else { - needToCaptureLexicalThis = false; - while (container && container.kind === 171) { - container = ts.getSuperContainer(container, true); - needToCaptureLexicalThis = languageVersion < 2; - } if (container && ts.isClassLike(container.parent)) { if (container.flags & 128) { - canUseSuperExpression = + return container.kind === 141 || container.kind === 140 || - container.kind === 139 || - container.kind === 142 || - container.kind === 143; + container.kind === 143 || + container.kind === 144; } else { - canUseSuperExpression = + return container.kind === 141 || container.kind === 140 || - container.kind === 139 || - container.kind === 142 || - container.kind === 143 || - container.kind === 138 || - container.kind === 137 || - container.kind === 141; + container.kind === 143 || + container.kind === 144 || + container.kind === 139 || + container.kind === 138 || + container.kind === 142; } } } - if (canUseSuperExpression) { - var returnType; - if ((container.flags & 128) || isCallExpression) { - getNodeLinks(node).flags |= 512; - returnType = getBaseConstructorTypeOfClass(classType); - } - else { - getNodeLinks(node).flags |= 256; - returnType = baseClassType; - } - if (container.kind === 141 && isInConstructorArgumentInitializer(node, container)) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - returnType = unknownType; - } - if (!isCallExpression && needToCaptureLexicalThis) { - captureLexicalThis(node.parent, container); - } - return returnType; - } + return false; } - if (container && container.kind === 133) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); - } - else if (isCallExpression) { - error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); - } - else { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; } function getContextuallyTypedParameterType(parameter) { - if (isFunctionExpressionOrArrowFunction(parameter.parent)) { - var func = parameter.parent; + var func = parameter.parent; + if (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) { if (isContextSensitive(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -15735,14 +15997,14 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135) { + if (declaration.kind === 136) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; } } if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return getTypeFromBindingPattern(declaration.name, true); } } return undefined; @@ -15768,7 +16030,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 135 && node.parent.initializer === node) { + if (node.parent.kind === 136 && node.parent.initializer === node) { return true; } node = node.parent; @@ -15777,8 +16039,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 141 || - functionDecl.kind === 142 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 143))) { + functionDecl.kind === 142 || + functionDecl.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -15797,7 +16059,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 167) { + if (template.parent.kind === 168) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -15805,12 +16067,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 54 && operator <= 65) { + if (operator >= 55 && operator <= 66) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 50) { + else if (operator === 51) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -15897,7 +16159,7 @@ var ts; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } function getContextualTypeForJsxExpression(expr) { - if (expr.parent.kind === 235) { + if (expr.parent.kind === 236) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -15907,7 +16169,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 236) { + if (expr.kind === 237) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -15925,38 +16187,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 208: - case 135: + case 209: + case 136: + case 139: case 138: - case 137: - case 160: - return getContextualTypeForInitializerExpression(node); - case 171: - case 201: - return getContextualTypeForReturnExpression(node); - case 181: - return getContextualTypeForYieldOperand(parent); - case 165: - case 166: - return getContextualTypeForArgument(parent, node); - case 168: - case 186: - return getTypeFromTypeNode(parent.type); - case 178: - return getContextualTypeForBinaryOperand(node); - case 242: - return getContextualTypeForObjectLiteralElement(parent); case 161: - return getContextualTypeForElementExpression(node); - case 179: - return getContextualTypeForConditionalOperand(node); - case 187: - ts.Debug.assert(parent.parent.kind === 180); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 172: + case 202: + return getContextualTypeForReturnExpression(node); + case 182: + return getContextualTypeForYieldOperand(parent); + case 166: + case 167: + return getContextualTypeForArgument(parent, node); case 169: + case 187: + return getTypeFromTypeNode(parent.type); + case 179: + return getContextualTypeForBinaryOperand(node); + case 243: + return getContextualTypeForObjectLiteralElement(parent); + case 162: + return getContextualTypeForElementExpression(node); + case 180: + return getContextualTypeForConditionalOperand(node); + case 188: + ts.Debug.assert(parent.parent.kind === 181); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 170: return getContextualType(parent); + case 238: case 237: - case 236: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -15971,7 +16233,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 170 || node.kind === 171; + return node.kind === 171 || node.kind === 172; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -15979,7 +16241,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -15993,16 +16255,12 @@ var ts; var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; - if (signatureList && - getSignaturesOfStructuredType(current, 0).length > 1) { - return undefined; - } var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { signatureList = [signature]; } - else if (!compareSignatures(signatureList[0], signature, false, compareTypes)) { + else if (!compareSignatures(signatureList[0], signature, false, true, compareTypes)) { return undefined; } else { @@ -16019,17 +16277,17 @@ var ts; return result; } function isInferentialContext(mapper) { - return mapper && mapper !== identityMapper; + return mapper && mapper.context; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 178 && parent.operatorToken.kind === 54 && parent.left === node) { + if (parent.kind === 179 && parent.operatorToken.kind === 55 && parent.left === node) { return true; } - if (parent.kind === 242) { + if (parent.kind === 243) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 161) { + if (parent.kind === 162) { return isAssignmentTarget(parent); } return false; @@ -16038,17 +16296,18 @@ var ts; var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } + function hasDefaultValue(node) { + return (node.kind === 161 && !!node.initializer) || + (node.kind === 179 && node.operatorToken.kind === 55); + } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; - if (!elements.length) { - return createArrayType(undefinedType); - } var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 182) { + if (inDestructuringPattern && e.kind === 183) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -16060,18 +16319,41 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 182; + hasSpreadElement = hasSpreadElement || e.kind === 183; } if (!hasSpreadElement) { + if (inDestructuringPattern && elementTypes.length) { + var type = createNewTupleType(elementTypes); + type.pattern = node; + return type; + } var contextualType = getContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) { - return createTupleType(elementTypes); + if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { + var pattern = contextualType.pattern; + if (pattern && (pattern.kind === 160 || pattern.kind === 162)) { + var patternElements = pattern.elements; + for (var i = elementTypes.length; i < patternElements.length; i++) { + var patternElement = patternElements[i]; + if (hasDefaultValue(patternElement)) { + elementTypes.push(contextualType.elementTypes[i]); + } + else { + if (patternElement.kind !== 185) { + error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + elementTypes.push(unknownType); + } + } + } + if (elementTypes.length) { + return createTupleType(elementTypes); + } } } - return createArrayType(getUnionType(elementTypes)); + return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 133 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 134 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -16086,7 +16368,7 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 4194304)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 16777216)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -16100,26 +16382,43 @@ var ts; var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); - var typeFlags; + var contextualTypeHasPattern = contextualType && contextualType.pattern && + (contextualType.pattern.kind === 159 || contextualType.pattern.kind === 163); + var inDestructuringPattern = isAssignmentTarget(node); + var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 242 || - memberDecl.kind === 243 || + if (memberDecl.kind === 243 || + memberDecl.kind === 244 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 242) { + if (memberDecl.kind === 243) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 140) { + else if (memberDecl.kind === 141) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 243); + ts.Debug.assert(memberDecl.kind === 244); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); + if (inDestructuringPattern) { + if (memberDecl.kind === 243 && hasDefaultValue(memberDecl.initializer)) { + prop.flags |= 536870912; + } + } + else if (contextualTypeHasPattern) { + var impliedProp = getPropertyOfType(contextualType, member.name); + if (impliedProp) { + prop.flags |= impliedProp.flags & 536870912; + } + else if (!compilerOptions.suppressExcessPropertyErrors) { + error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); + } + } prop.declarations = member.declarations; prop.parent = member.parent; if (member.valueDeclaration) { @@ -16130,7 +16429,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 142 || memberDecl.kind === 143); + ts.Debug.assert(memberDecl.kind === 143 || memberDecl.kind === 144); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -16138,10 +16437,26 @@ var ts; } propertiesArray.push(member); } + if (contextualTypeHasPattern) { + for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) { + var prop = _c[_b]; + if (!ts.hasProperty(propertiesTable, prop.name)) { + if (!(prop.flags & 536870912)) { + error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + propertiesTable[prop.name] = prop; + propertiesArray.push(prop); + } + } + } var stringIndexType = getIndexType(0); var numberIndexType = getIndexType(1); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 524288 | 2097152 | (typeFlags & 1048576); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; + result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); + if (inDestructuringPattern) { + result.pattern = node; + } return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -16170,31 +16485,34 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 66) { + if (lhs.kind === 67) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && tagNamesAreEquivalent(lhs.left, rhs.left); } function checkJsxElement(node) { + checkJsxOpeningLikeElement(node.openingElement); if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); } - checkJsxOpeningLikeElement(node.openingElement); + else { + getJsxElementTagSymbol(node.closingElement); + } for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 237: + case 238: checkJsxExpression(child); break; - case 230: + case 231: checkJsxElement(child); break; - case 231: + case 232: checkJsxSelfClosingElement(child); break; default: - ts.Debug.assert(child.kind === 233); + ts.Debug.assert(child.kind === 234); } } return jsxElementType || anyType; @@ -16203,7 +16521,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 132) { + if (tagName.kind === 133) { return false; } else { @@ -16218,9 +16536,17 @@ var ts; else if (elementAttributesType && !isTypeAny(elementAttributesType)) { var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; + if (isUnhyphenatedJsxName(node.name.text)) { + var indexerType = getIndexTypeOfType(elementAttributesType, 0); + if (indexerType) { + correspondingPropType = indexerType; + } + else { + if (!correspondingPropType) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } } } var exprType; @@ -16283,7 +16609,7 @@ var ts; links.jsxFlags |= 2; return intrinsicElementsType.symbol; } - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, 'JSX.' + JsxNames.IntrinsicElements); + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); return unknownSymbol; } else { @@ -16293,26 +16619,26 @@ var ts; } } function lookupClassTag(node) { - var valueSymbol; - if (node.tagName.kind === 66) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - valueSymbol = sym.exportSymbol || sym; - } - else { - valueSymbol = checkQualifiedName(node.tagName).symbol; - } + var valueSymbol = resolveJsxTagName(node); if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4; getSymbolLinks(valueSymbol).referenced = true; } return valueSymbol || unknownSymbol; } + function resolveJsxTagName(node) { + if (node.tagName.kind === 67) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } } function getJsxElementInstanceType(node) { - if (!(getNodeLinks(node).jsxFlags & 4)) { - return undefined; - } + ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4), "Should not call getJsxElementInstanceType on non-class Element"); var classSymbol = getJsxElementTagSymbol(node); if (classSymbol === unknownSymbol) { return anyType; @@ -16326,14 +16652,10 @@ var ts; signatures = getSignaturesOfType(valueType, 0); if (signatures.length === 0) { error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); - return undefined; + return unknownType; } } - var returnType = getUnionType(signatures.map(function (s) { return getReturnTypeOfSignature(s); })); - if (!isTypeAny(returnType) && !(returnType.flags & 80896)) { - error(node.tagName, ts.Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); - return undefined; - } + var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); var elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); @@ -16368,7 +16690,7 @@ var ts; if (links.jsxFlags & 4) { var elemInstanceType = getJsxElementInstanceType(node); if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = anyType; + return links.resolvedJsxType = elemInstanceType; } var propsName = getJsxElementPropertiesName(); if (propsName === undefined) { @@ -16436,7 +16758,7 @@ var ts; checkGrammarJsxElement(node); checkJsxPreconditions(node); if (compilerOptions.jsx === 2) { - var reactSym = resolveName(node.tagName, 'React', 107455, ts.Diagnostics.Cannot_find_name_0, 'React'); + var reactSym = resolveName(node.tagName, "React", 107455, ts.Diagnostics.Cannot_find_name_0, "React"); if (reactSym) { getSymbolLinks(reactSym).referenced = true; } @@ -16445,11 +16767,11 @@ var ts; var nameTable = {}; var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 235) { + if (node.attributes[i].kind === 236) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 236); + ts.Debug.assert(node.attributes[i].kind === 237); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -16475,7 +16797,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 138; + return s.valueDeclaration ? s.valueDeclaration.kind : 139; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; @@ -16483,11 +16805,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 92) { - var errorNode = node.kind === 163 ? + if (left.kind === 93) { + var errorNode = node.kind === 164 ? node.name : node.right; - if (getDeclarationKindFromSymbol(prop) !== 140) { + if (getDeclarationKindFromSymbol(prop) !== 141) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -16508,7 +16830,7 @@ var ts; } return true; } - if (left.kind === 92) { + if (left.kind === 93) { return true; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -16553,7 +16875,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 163 + var left = node.kind === 164 ? node.expression : node.left; var type = checkExpression(left); @@ -16568,7 +16890,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 166 && node.parent.expression === node) { + if (node.parent.kind === 167 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -16586,7 +16908,7 @@ var ts; } var isConstEnum = isConstEnumObjectType(objectType); if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 8)) { + (!node.argumentExpression || node.argumentExpression.kind !== 9)) { error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } @@ -16604,7 +16926,7 @@ var ts; } } } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 4194304)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 16777216)) { if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132)) { var numberIndexType = getIndexTypeOfType(objectType, 1); if (numberIndexType) { @@ -16624,7 +16946,7 @@ var ts; return unknownType; } function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 8 || indexArgumentExpression.kind === 7) { + if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { @@ -16640,7 +16962,7 @@ var ts; if (!ts.isWellKnownSymbolSyntactically(expression)) { return false; } - if ((expressionType.flags & 4194304) === 0) { + if ((expressionType.flags & 16777216) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -16664,10 +16986,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 167) { + if (node.kind === 168) { checkExpression(node.template); } - else if (node.kind !== 136) { + else if (node.kind !== 137) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -16689,19 +17011,19 @@ var ts; for (var _i = 0; _i < signatures.length; _i++) { var signature = signatures[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_6 = signature.declaration && signature.declaration.parent; + var parent_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_6 === lastParent) { + if (lastParent && parent_5 === lastParent) { index++; } else { - lastParent = parent_6; + lastParent = parent_5; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_6; + lastParent = parent_5; } lastSymbol = symbol; if (signature.hasStringLiterals) { @@ -16718,7 +17040,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 182) { + if (arg && arg.kind === 183) { return i; } } @@ -16730,11 +17052,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 167) { + if (node.kind === 168) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 180) { + if (tagExpression.template.kind === 181) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -16742,11 +17064,11 @@ var ts; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 10); + ts.Debug.assert(templateLiteral.kind === 11); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 136) { + else if (node.kind === 137) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -16754,7 +17076,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 166); + ts.Debug.assert(callExpression.kind === 167); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -16807,7 +17129,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 184) { + if (arg === undefined || arg.kind !== 185) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -16854,11 +17176,11 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 184) { + if (arg === undefined || arg.kind !== 185) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { - argType = arg.kind === 8 && !reportErrors + argType = arg.kind === 9 && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -16873,16 +17195,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 167) { + if (node.kind === 168) { var template = node.template; args = [undefined]; - if (template.kind === 180) { + if (template.kind === 181) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 136) { + else if (node.kind === 137) { return undefined; } else { @@ -16891,18 +17213,18 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 136) { + if (node.kind === 137) { switch (node.parent.kind) { - case 211: - case 183: + case 212: + case 184: return 1; - case 138: + case 139: return 2; - case 140: - case 142: + case 141: case 143: + case 144: return signature.parameters.length >= 3 ? 3 : 2; - case 135: + case 136: return 3; } } @@ -16912,20 +17234,20 @@ var ts; } function getEffectiveDecoratorFirstArgumentType(node) { switch (node.kind) { - case 211: - case 183: + case 212: + case 184: var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 135: + case 136: node = node.parent; - if (node.kind === 141) { + if (node.kind === 142) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } - case 138: - case 140: - case 142: + case 139: + case 141: case 143: + case 144: return getParentTypeOfClassElement(node); default: ts.Debug.fail("Unsupported decorator target."); @@ -16934,27 +17256,27 @@ var ts; } function getEffectiveDecoratorSecondArgumentType(node) { switch (node.kind) { - case 211: + case 212: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 135: + case 136: node = node.parent; - if (node.kind === 141) { + if (node.kind === 142) { return anyType; } - case 138: - case 140: - case 142: + case 139: + case 141: case 143: + case 144: var element = node; switch (element.name.kind) { - case 66: - case 7: + case 67: case 8: + case 9: return getStringLiteralType(element.name); - case 133: + case 134: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 4194304)) { + if (allConstituentTypesHaveKind(nameType, 16777216)) { return nameType; } else { @@ -16971,17 +17293,17 @@ var ts; } function getEffectiveDecoratorThirdArgumentType(node) { switch (node.kind) { - case 211: + case 212: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 135: + case 136: return numberType; - case 138: + case 139: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 140: - case 142: + case 141: case 143: + case 144: var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); default: @@ -17003,26 +17325,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 136) { + if (node.kind === 137) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 167) { + else if (argIndex === 0 && node.kind === 168) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 136 || - (argIndex === 0 && node.kind === 167)) { + if (node.kind === 137 || + (argIndex === 0 && node.kind === 168)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 136) { + if (node.kind === 137) { return node.expression; } - else if (argIndex === 0 && node.kind === 167) { + else if (argIndex === 0 && node.kind === 168) { return node.template; } else { @@ -17030,12 +17352,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 167; - var isDecorator = node.kind === 136; + var isTaggedTemplate = node.kind === 168; + var isDecorator = node.kind === 137; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 92) { + if (node.expression.kind !== 93) { ts.forEach(typeArguments, checkSourceElement); } } @@ -17098,6 +17420,9 @@ var ts; for (var _i = 0; _i < candidates.length; _i++) { var candidate = candidates[_i]; if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); + } return candidate; } } @@ -17170,7 +17495,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -17215,7 +17540,7 @@ var ts; if (expressionType === unknownType) { return resolveErrorCall(node); } - var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 211); + var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); if (valueDecl && valueDecl.flags & 256) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); @@ -17259,16 +17584,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 211: - case 183: + case 212: + case 184: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 135: + case 136: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 138: + case 139: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 140: - case 142: + case 141: case 143: + case 144: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -17296,16 +17621,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 165) { + if (node.kind === 166) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 166) { + else if (node.kind === 167) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 167) { + else if (node.kind === 168) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 136) { + else if (node.kind === 137) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -17317,15 +17642,15 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { return voidType; } - if (node.kind === 166) { + if (node.kind === 167) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 141 && - declaration.kind !== 145 && - declaration.kind !== 150) { + declaration.kind !== 142 && + declaration.kind !== 146 && + declaration.kind !== 151) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -17338,7 +17663,7 @@ var ts; return getReturnTypeOfSignature(getResolvedSignature(node)); } function checkAssertion(node) { - var exprType = checkExpression(node.expression); + var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { var widenedType = getWidenedType(exprType); @@ -17357,18 +17682,27 @@ var ts; var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeAtPosition(context, i), mapper); + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { var parameter = ts.lastOrUndefined(signature.parameters); - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } + } + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + var links = getSymbolLinks(parameter); + if (!links.type) { + links.type = instantiateType(contextualType, mapper); + } + else if (isInferentialContext(mapper)) { + inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); } } function createPromiseType(promisedType) { var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyObjectType) { + if (globalPromiseType !== emptyGenericType) { promisedType = getAwaitedType(promisedType); return createTypeReference(globalPromiseType, [promisedType]); } @@ -17381,7 +17715,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 189) { + if (func.body.kind !== 190) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -17485,7 +17819,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 205); + return (body.statements.length === 1) && (body.statements[0].kind === 206); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -17494,7 +17828,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 189) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 190) { return; } var bodyBlock = func.body; @@ -17507,9 +17841,9 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 170) { + if (!hasGrammarError && node.kind === 171) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -17521,33 +17855,38 @@ var ts; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); - if (!(links.flags & 1024)) { + var contextSensitive = isContextSensitive(node); + var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + if (mightFixTypeParameters || !(links.flags & 1024)) { var contextualSignature = getContextualSignature(node); - if (!(links.flags & 1024)) { + var contextChecked = !!(links.flags & 1024); + if (mightFixTypeParameters || !contextChecked) { links.flags |= 1024; if (contextualSignature) { var signature = getSignaturesOfType(type, 0)[0]; - if (isContextSensitive(node)) { + if (contextSensitive) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type && !signature.resolvedReturnType) { + if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { var returnType = getReturnTypeFromBody(node, contextualMapper); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } } - checkSignatureDeclaration(node); + if (!contextChecked) { + checkSignatureDeclaration(node); + } } } - if (produceDiagnostics && node.kind !== 140 && node.kind !== 139) { + if (produceDiagnostics && node.kind !== 141 && node.kind !== 140) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -17564,7 +17903,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 189) { + if (node.body.kind === 190) { checkSourceElement(node.body); } else { @@ -17596,17 +17935,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 66: { + case 67: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 163: { + case 164: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 164: + case 165: return true; - case 169: + case 170: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -17614,22 +17953,22 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 66: - case 163: { + case 67: + case 164: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; } - case 164: { + case 165: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 8) { + if (symbol && index && index.kind === 9) { var name_13 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_13); return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768) !== 0; } return false; } - case 169: + case 170: return isConstVariableReference(n.expression); default: return false; @@ -17672,17 +18011,17 @@ var ts; function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 34: case 35: - case 48: - if (someConstituentTypeHasKind(operandType, 4194304)) { + case 36: + case 49: + if (someConstituentTypeHasKind(operandType, 16777216)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 47: + case 48: return booleanType; - case 39: case 40: + case 41: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); @@ -17738,7 +18077,7 @@ var ts; return (symbol.flags & 128) !== 0; } function checkInstanceOfExpression(node, leftType, rightType) { - if (allConstituentTypesHaveKind(leftType, 4194814)) { + if (allConstituentTypesHaveKind(leftType, 16777726)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { @@ -17747,7 +18086,7 @@ var ts; return booleanType; } function checkInExpression(node, leftType, rightType) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 4194304)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 16777216)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { @@ -17759,7 +18098,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 242 || p.kind === 243) { + if (p.kind === 243 || p.kind === 244) { var name_14 = p.name; var type = isTypeAny(sourceType) ? sourceType @@ -17784,8 +18123,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184) { - if (e.kind !== 182) { + if (e.kind !== 185) { + if (e.kind !== 183) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -17810,7 +18149,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 178 && restExpression.operatorToken.kind === 54) { + if (restExpression.kind === 179 && restExpression.operatorToken.kind === 55) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -17823,14 +18162,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 178 && target.operatorToken.kind === 54) { + if (target.kind === 179 && target.operatorToken.kind === 55) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 162) { + if (target.kind === 163) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 161) { + if (target.kind === 162) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -17844,32 +18183,32 @@ var ts; } function checkBinaryExpression(node, contextualMapper) { var operator = node.operatorToken.kind; - if (operator === 54 && (node.left.kind === 162 || node.left.kind === 161)) { + if (operator === 55 && (node.left.kind === 163 || node.left.kind === 162)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 36: - case 57: case 37: case 58: case 38: case 59: - case 35: - case 56: - case 41: + case 39: case 60: + case 36: + case 57: case 42: case 61: case 43: case 62: - case 45: - case 64: - case 46: - case 65: case 44: case 63: + case 46: + case 65: + case 47: + case 66: + case 45: + case 64: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17888,8 +18227,8 @@ var ts; } } return numberType; - case 34: - case 55: + case 35: + case 56: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -17913,42 +18252,42 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 55) { + if (operator === 56) { checkAssignmentOperator(resultType); } return resultType; - case 24: - case 26: + case 25: case 27: case 28: + case 29: if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - case 29: case 30: case 31: case 32: + case 33: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 88: + case 89: return checkInstanceOfExpression(node, leftType, rightType); - case 87: + case 88: return checkInExpression(node, leftType, rightType); - case 49: - return rightType; case 50: - return getUnionType([leftType, rightType]); - case 54: - checkAssignmentOperator(rightType); return rightType; - case 23: + case 51: + return getUnionType([leftType, rightType]); + case 55: + checkAssignmentOperator(rightType); + return getRegularTypeOfObjectLiteral(rightType); + case 24: return rightType; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 4194304) ? node.left : - someConstituentTypeHasKind(rightType, 4194304) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216) ? node.left : + someConstituentTypeHasKind(rightType, 16777216) ? node.right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -17958,21 +18297,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 46: + case 65: + return 51; + case 47: + case 66: + return 33; case 45: case 64: return 50; - case 46: - case 65: - return 32; - case 44: - case 63: - return 49; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 54 && operator <= 65) { + if (produceDiagnostics && operator >= 55 && operator <= 66) { var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { checkTypeAssignableTo(valueType, leftType, node.left, undefined); @@ -18056,21 +18395,21 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (contextualMapper && contextualMapper !== identityMapper) { + if (isInferentialContext(contextualMapper)) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getContextualType(node); @@ -18086,7 +18425,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 132) { + if (node.kind === 133) { type = checkQualifiedName(node); } else { @@ -18094,9 +18433,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 163 && node.parent.expression === node) || - (node.parent.kind === 164 && node.parent.expression === node) || - ((node.kind === 66 || node.kind === 132) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 164 && node.parent.expression === node) || + (node.parent.kind === 165 && node.parent.expression === node) || + ((node.kind === 67 || node.kind === 133) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -18109,78 +18448,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 66: + case 67: return checkIdentifier(node); - case 94: + case 95: return checkThisExpression(node); - case 92: + case 93: return checkSuperExpression(node); - case 90: + case 91: return nullType; - case 96: - case 81: + case 97: + case 82: return booleanType; - case 7: - return checkNumericLiteral(node); - case 180: - return checkTemplateExpression(node); case 8: - case 10: - return stringType; - case 9: - return globalRegExpType; - case 161: - return checkArrayLiteral(node, contextualMapper); - case 162: - return checkObjectLiteral(node, contextualMapper); - case 163: - return checkPropertyAccessExpression(node); - case 164: - return checkIndexedAccess(node); - case 165: - case 166: - return checkCallExpression(node); - case 167: - return checkTaggedTemplateExpression(node); - case 169: - return checkExpression(node.expression, contextualMapper); - case 183: - return checkClassExpression(node); - case 170: - case 171: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 173: - return checkTypeOfExpression(node); - case 168: - case 186: - return checkAssertion(node); - case 172: - return checkDeleteExpression(node); - case 174: - return checkVoidExpression(node); - case 175: - return checkAwaitExpression(node); - case 176: - return checkPrefixUnaryExpression(node); - case 177: - return checkPostfixUnaryExpression(node); - case 178: - return checkBinaryExpression(node, contextualMapper); - case 179: - return checkConditionalExpression(node, contextualMapper); - case 182: - return checkSpreadElementExpression(node, contextualMapper); - case 184: - return undefinedType; + return checkNumericLiteral(node); case 181: + return checkTemplateExpression(node); + case 9: + case 11: + return stringType; + case 10: + return globalRegExpType; + case 162: + return checkArrayLiteral(node, contextualMapper); + case 163: + return checkObjectLiteral(node, contextualMapper); + case 164: + return checkPropertyAccessExpression(node); + case 165: + return checkIndexedAccess(node); + case 166: + case 167: + return checkCallExpression(node); + case 168: + return checkTaggedTemplateExpression(node); + case 170: + return checkExpression(node.expression, contextualMapper); + case 184: + return checkClassExpression(node); + case 171: + case 172: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 174: + return checkTypeOfExpression(node); + case 169: + case 187: + return checkAssertion(node); + case 173: + return checkDeleteExpression(node); + case 175: + return checkVoidExpression(node); + case 176: + return checkAwaitExpression(node); + case 177: + return checkPrefixUnaryExpression(node); + case 178: + return checkPostfixUnaryExpression(node); + case 179: + return checkBinaryExpression(node, contextualMapper); + case 180: + return checkConditionalExpression(node, contextualMapper); + case 183: + return checkSpreadElementExpression(node, contextualMapper); + case 185: + return undefinedType; + case 182: return checkYieldExpression(node); - case 237: + case 238: return checkJsxExpression(node); - case 230: - return checkJsxElement(node); case 231: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 232: + return checkJsxSelfClosingElement(node); + case 233: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -18196,16 +18535,12 @@ var ts; } } function checkParameter(node) { - // Grammar checking - // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the - // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code - // or if its FunctionBody is strict code(11.1.5). checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 141 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 142 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -18220,15 +18555,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 140 || - node.kind === 210 || - node.kind === 170; + return node.kind === 141 || + node.kind === 211 || + node.kind === 171; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 66 && + if (param.name.kind === 67 && param.name.text === parameter.text) { return i; } @@ -18238,30 +18573,30 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { + case 172: + case 145: + case 211: case 171: - case 144: - case 210: - case 170: - case 149: + case 150: + case 141: case 140: - case 139: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { - if (node.kind === 146) { + if (node.kind === 147) { checkGrammarIndexSignature(node); } - else if (node.kind === 149 || node.kind === 210 || node.kind === 150 || - node.kind === 144 || node.kind === 141 || - node.kind === 145) { + else if (node.kind === 150 || node.kind === 211 || node.kind === 151 || + node.kind === 145 || node.kind === 142 || + node.kind === 146) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 147) { + if (node.type.kind === 148) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -18270,7 +18605,7 @@ var ts; error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); } } else if (typePredicateNode.parameterName) { @@ -18280,19 +18615,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 158 || - param.name.kind === 159) { + if (param.name.kind === 159 || + param.name.kind === 160) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 66 && + if (element.name.kind === 67 && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 159 || - element.name.kind === 158) { + else if (element.name.kind === 160 || + element.name.kind === 159) { checkBindingPattern(element.name); } } @@ -18316,10 +18651,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 145: + case 146: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 144: + case 145: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -18341,7 +18676,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 212) { + if (node.kind === 213) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -18356,7 +18691,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 127: + case 128: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -18364,7 +18699,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 125: + case 126: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -18404,48 +18739,69 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 165 && n.expression.kind === 92; + return n.kind === 166 && n.expression.kind === 93; + } + function containsSuperCallAsComputedPropertyName(n) { + return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } - switch (n.kind) { - case 170: - case 210: - case 171: - case 162: return false; - default: return ts.forEachChild(n, containsSuperCall); + else if (ts.isFunctionLike(n)) { + return false; } + else if (ts.isClassLike(n)) { + return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); + } + return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 94) { + if (n.kind === 95) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 170 && n.kind !== 210) { + else if (n.kind !== 171 && n.kind !== 211) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 138 && + return n.kind === 139 && !(n.flags & 128) && !!n.initializer; } - if (ts.getClassExtendsHeritageClauseElement(node.parent)) { + var containingClassDecl = node.parent; + if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + var containingClassSymbol = getSymbolOfNode(containingClassDecl); + var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); if (containsSuperCall(node.body)) { + if (baseConstructorType === nullType) { + error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 192 || !isSuperCallExpression(statements[0].expression)) { + var superCallStatement; + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (statement.kind === 193 && isSuperCallExpression(statement.expression)) { + superCallStatement = statement; + break; + } + if (!ts.isPrologueDirective(statement)) { + break; + } + } + if (!superCallStatement) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { - markThisReferencesAsErrors(statements[0].expression); + markThisReferencesAsErrors(superCallStatement.expression); } } } - else { + else if (baseConstructorType !== nullType) { error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -18453,13 +18809,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 142) { + if (node.kind === 143) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 142 ? 143 : 142; + var otherKind = node.kind === 143 ? 144 : 143; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -18544,9 +18900,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 212) { - ts.Debug.assert(signatureDeclarationNode.kind === 144 || signatureDeclarationNode.kind === 145); - var signatureKind = signatureDeclarationNode.kind === 144 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213) { + ts.Debug.assert(signatureDeclarationNode.kind === 145 || signatureDeclarationNode.kind === 146); + var signatureKind = signatureDeclarationNode.kind === 145 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -18564,7 +18920,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 212 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 213 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -18640,7 +18996,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 140 || node.kind === 139); + ts.Debug.assert(node.kind === 141 || node.kind === 140); ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -18672,11 +19028,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 212 || node.parent.kind === 152 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 213 || node.parent.kind === 153 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 210 || node.kind === 140 || node.kind === 139 || node.kind === 141) { + if (node.kind === 211 || node.kind === 141 || node.kind === 140 || node.kind === 142) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -18755,35 +19111,50 @@ var ts; } var exportedDeclarationSpaces = 0; var nonExportedDeclarationSpaces = 0; - ts.forEach(symbol.declarations, function (d) { + var defaultExportedDeclarationSpaces = 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - if (getEffectiveDeclarationFlags(d, 1)) { - exportedDeclarationSpaces |= declarationSpaces; + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 1024); + if (effectiveDeclarationFlags & 1) { + if (effectiveDeclarationFlags & 1024) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } } else { nonExportedDeclarationSpaces |= declarationSpaces; } - }); - var commonDeclarationSpace = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - if (commonDeclarationSpace) { - ts.forEach(symbol.declarations, function (d) { - if (getDeclarationSpaces(d) & commonDeclarationSpace) { + } + var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declarationSpaces = getDeclarationSpaces(d); + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); } - }); + } } function getDeclarationSpaces(d) { switch (d.kind) { - case 212: + case 213: return 2097152; - case 215: - return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 + case 216: + return d.name.kind === 9 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 211: - case 214: + case 212: + case 215: return 2097152 | 1048576; - case 218: + case 219: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -18806,15 +19177,6 @@ var ts; return type; } function getPromisedType(promise) { - // - // { // promise - // then( // thenFunction - // onfulfilled: ( // onfulfilledParameterType - // value: T // valueParameterType - // ) => any - // ): any; - // } - // if (promise.flags & 1) { return undefined; } @@ -18918,22 +19280,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 211: + case 212: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 135: + case 136: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 138: + case 139: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 140: - case 142: + case 141: case 143: + case 144: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -18942,29 +19304,33 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 148) { + if (node && node.kind === 149) { var root = getFirstIdentifier(node.typeName); - var rootSymbol = resolveName(root, root.text, 107455, undefined, undefined); - if (rootSymbol && rootSymbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); + var meaning = root.parent.kind === 149 ? 793056 : 1536; + var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); + if (rootSymbol && rootSymbol.flags & 8388608) { + var aliasTarget = resolveAlias(rootSymbol); + if (aliasTarget.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } } } } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 138: + case 139: checkTypeNodeAsExpression(node.type); break; - case 135: + case 136: checkTypeNodeAsExpression(node.type); break; - case 140: - checkTypeNodeAsExpression(node.type); - break; - case 142: + case 141: checkTypeNodeAsExpression(node.type); break; case 143: + checkTypeNodeAsExpression(node.type); + break; + case 144: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -18987,24 +19353,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 211: + case 212: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 140: + case 141: checkParameterTypeAnnotationsAsExpressions(node); + case 144: case 143: - case 142: - case 138: - case 135: + case 139: + case 136: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 135) { + if (node.kind === 136) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -19027,7 +19393,7 @@ var ts; } emitAwaiter = true; } - if (node.name && node.name.kind === 133) { + if (node.name && node.name.kind === 134) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -19062,11 +19428,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 189) { + if (node.kind === 190) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 216) { + if (ts.isFunctionBlock(node) || node.kind === 217) { checkFunctionAndClassExpressionBodies(node); } } @@ -19084,19 +19450,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 138 || - node.kind === 137 || + if (node.kind === 139 || + node.kind === 138 || + node.kind === 141 || node.kind === 140 || - node.kind === 139 || - node.kind === 142 || - node.kind === 143) { + node.kind === 143 || + node.kind === 144) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 135 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 136 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -19110,7 +19476,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 66; + var isDeclaration_1 = node.kind !== 67; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -19131,7 +19497,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 66; + var isDeclaration_2 = node.kind !== 67; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -19144,22 +19510,19 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 215 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 216 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 245 && ts.isExternalModule(parent)) { + if (parent.kind === 246 && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkVarDeclaredNamesNotShadowed(node) { - // - ScriptBody : StatementList - // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList - // also occurs in the VarDeclaredNames of StatementList. if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 208 && !node.initializer) { + if (node.kind === 209 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -19169,15 +19532,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 209); - var container = varDeclList.parent.kind === 190 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210); + var container = varDeclList.parent.kind === 191 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 189 && ts.isFunctionLike(container.parent) || + (container.kind === 190 && ts.isFunctionLike(container.parent) || + container.kind === 217 || container.kind === 216 || - container.kind === 215 || - container.kind === 245); + container.kind === 246); if (!namesShareScope) { var name_15 = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_15, name_15); @@ -19187,16 +19550,16 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 135) { + if (ts.getRootDeclaration(node).kind !== 136) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 66) { + if (n.kind === 67) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 135) { + if (referencedSymbol.valueDeclaration.kind === 136) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -19216,7 +19579,7 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 133) { + if (node.name.kind === 134) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -19225,7 +19588,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 135 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 136 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -19253,9 +19616,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 138 && node.kind !== 137) { + if (node.kind !== 139 && node.kind !== 138) { checkExportsOnMergedDeclarations(node); - if (node.kind === 208 || node.kind === 160) { + if (node.kind === 209 || node.kind === 161) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -19276,7 +19639,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 162) { + if (node.modifiers && node.parent.kind === 163) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -19309,12 +19672,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 209) { + if (node.initializer && node.initializer.kind === 210) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -19329,13 +19692,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 161 || varExpr.kind === 162) { + if (varExpr.kind === 162 || varExpr.kind === 163) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -19350,7 +19713,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -19360,7 +19723,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 161 || varExpr.kind === 162) { + if (varExpr.kind === 162 || varExpr.kind === 163) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -19522,7 +19885,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 142 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 143))); + return !!(node.kind === 143 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -19540,10 +19903,10 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 143) { + if (func.kind === 144) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 141) { + else if (func.kind === 142) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -19576,7 +19939,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 239 && !hasDuplicateDefaultClause) { + if (clause.kind === 240 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -19588,7 +19951,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 238) { + if (produceDiagnostics && clause.kind === 239) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -19605,7 +19968,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 204 && current.label.text === node.label.text) { + if (current.kind === 205 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -19631,7 +19994,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 66) { + if (catchClause.variableDeclaration.name.kind !== 67) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -19699,7 +20062,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 133 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 134 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -19777,6 +20140,7 @@ var ts; if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; var staticBaseType = getBaseConstructorTypeOfClass(type); + checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { @@ -19826,20 +20190,10 @@ var ts; function getTargetSymbol(s) { return s.flags & 16777216 ? getSymbolLinks(s).target : s; } + function getClassLikeDeclarationOfSymbol(symbol) { + return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); + } function checkKindsOfPropertyMemberOverrides(type, baseType) { - // TypeScript 1.0 spec (April 2014): 8.2.3 - // A derived class inherits all members from its base class it doesn't override. - // Inheritance means that a derived class implicitly contains all non - overridden members of the base class. - // Both public and private property members are inherited, but only public property members can be overridden. - // A property member in a derived class is said to override a property member in a base class - // when the derived class property member has the same name and kind(instance or static) - // as the base class property member. - // The type of an overriding property member must be assignable(section 3.8.4) - // to the type of the overridden property member, or otherwise a compile - time error occurs. - // Base class instance member functions can be overridden by derived class instance member functions, - // but not by other kinds of members. - // Base class instance member variables and accessors can be overridden by - // derived class instance member variables and accessors, but not by other kinds of members. var baseProperties = getPropertiesOfObjectType(baseType); for (var _i = 0; _i < baseProperties.length; _i++) { var baseProperty = baseProperties[_i]; @@ -19852,9 +20206,14 @@ var ts; ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { if (derived === base) { - var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 211); + var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + if (derivedClassDecl.kind === 184) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } } } else { @@ -19893,7 +20252,7 @@ var ts; } } function isAccessor(kind) { - return kind === 142 || kind === 143; + return kind === 143 || kind === 144; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -19959,7 +20318,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 212); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -19977,7 +20336,7 @@ var ts; if (symbol && symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 211 && !ts.isInAmbientContext(declaration)) { + if (declaration.kind === 212 && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -20009,28 +20368,12 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 133 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 134 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer); - if (autoValue === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (!ambient) { - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); - } - } - else if (enumIsConst) { - if (isNaN(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { autoValue = undefined; @@ -20041,22 +20384,42 @@ var ts; }); nodeLinks.flags |= 8192; } - function getConstantValueForEnumMemberInitializer(initializer) { - return evalConstant(initializer); + function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { + var reportError = true; + var value = evalConstant(initializer); + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + return value; function evalConstant(e) { switch (e.kind) { - case 176: - var value = evalConstant(e.operand); - if (value === undefined) { + case 177: + var value_1 = evalConstant(e.operand); + if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 34: return value; - case 35: return -value; - case 48: return ~value; + case 35: return value_1; + case 36: return -value_1; + case 49: return ~value_1; } return undefined; - case 178: + case 179: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -20066,39 +20429,39 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 45: return left | right; - case 44: return left & right; - case 42: return left >> right; - case 43: return left >>> right; - case 41: return left << right; - case 46: return left ^ right; - case 36: return left * right; - case 37: return left / right; - case 34: return left + right; - case 35: return left - right; - case 38: return left % right; + case 46: return left | right; + case 45: return left & right; + case 43: return left >> right; + case 44: return left >>> right; + case 42: return left << right; + case 47: return left ^ right; + case 37: return left * right; + case 38: return left / right; + case 35: return left + right; + case 36: return left - right; + case 39: return left % right; } return undefined; - case 7: + case 8: return +e.text; - case 169: + case 170: return evalConstant(e.expression); - case 66: + case 67: + case 165: case 164: - case 163: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType; + var enumType_1; var propertyName; - if (e.kind === 66) { - enumType = currentType; + if (e.kind === 67) { + enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 164) { + if (e.kind === 165) { if (e.argumentExpression === undefined || - e.argumentExpression.kind !== 8) { + e.argumentExpression.kind !== 9) { return undefined; } expression = e.expression; @@ -20110,25 +20473,25 @@ var ts; } var current = expression; while (current) { - if (current.kind === 66) { + if (current.kind === 67) { break; } - else if (current.kind === 163) { + else if (current.kind === 164) { current = current.expression; } else { return undefined; } } - enumType = checkExpression(expression); - if (!(enumType.symbol && (enumType.symbol.flags & 384))) { + enumType_1 = checkExpression(expression); + if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384))) { return undefined; } } if (propertyName === undefined) { return undefined; } - var property = getPropertyOfObjectType(enumType, propertyName); + var property = getPropertyOfObjectType(enumType_1, propertyName); if (!property || !(property.flags & 8)) { return undefined; } @@ -20137,6 +20500,8 @@ var ts; return undefined; } if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; } return getNodeLinks(propertyDecl).enumMemberValue; @@ -20170,7 +20535,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 214) { + if (declaration.kind !== 215) { return false; } var enumDeclaration = declaration; @@ -20193,8 +20558,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 211 || - (declaration.kind === 210 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 212 || + (declaration.kind === 211 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -20216,7 +20581,7 @@ var ts; } function checkModuleDeclaration(node) { if (produceDiagnostics) { - var isAmbientExternalModule = node.name.kind === 8; + var isAmbientExternalModule = node.name.kind === 9; var contextErrorMessage = isAmbientExternalModule ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -20224,7 +20589,7 @@ var ts; return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 8) { + if (!ts.isInAmbientContext(node) && node.name.kind === 9) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -20245,7 +20610,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 211); + var mergedClass = ts.getDeclarationOfKind(symbol, 212); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -20264,28 +20629,28 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 132) { + if (node.kind === 133) { node = node.left; } - else if (node.kind === 163) { + else if (node.kind === 164) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 66); + ts.Debug.assert(node.kind === 67); return node; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 8) { + if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9) { error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 216 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 245 && !inAmbientExternalModule) { - error(moduleName, node.kind === 225 ? + var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 246 && !inAmbientExternalModule) { + error(moduleName, node.kind === 226 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -20304,7 +20669,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 227 ? + var message = node.kind === 228 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -20330,7 +20695,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221) { + if (importClause.namedBindings.kind === 222) { checkImportBinding(importClause.namedBindings); } else { @@ -20365,7 +20730,7 @@ var ts; } } else { - if (languageVersion >= 2) { + if (languageVersion >= 2 && !ts.isInAmbientContext(node)) { grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); } } @@ -20381,8 +20746,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 216 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 245 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 217 && node.parent.parent.name.kind === 9; + if (node.parent.kind !== 246 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -20395,7 +20760,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 245 && node.parent.kind !== 216 && node.parent.kind !== 215) { + if (node.parent.kind !== 246 && node.parent.kind !== 217 && node.parent.kind !== 216) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -20409,15 +20774,15 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 245 ? node.parent : node.parent.parent; - if (container.kind === 215 && container.name.kind === 66) { + var container = node.parent.kind === 246 ? node.parent : node.parent.parent; + if (container.kind === 216 && container.name.kind === 67) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { markExportAsReferenced(node); } else { @@ -20434,10 +20799,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 245) { + if (node.kind === 246) { return node.statements; } - if (node.kind === 215 && node.body.kind === 216) { + if (node.kind === 216 && node.body.kind === 217) { return node.body.statements; } return emptyArray; @@ -20474,182 +20839,181 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 215: - case 211: + case 216: case 212: - case 210: + case 213: + case 211: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 134: - return checkTypeParameter(node); case 135: + return checkTypeParameter(node); + case 136: return checkParameter(node); + case 139: case 138: - case 137: return checkPropertyDeclaration(node); - case 149: case 150: - case 144: + case 151: case 145: - return checkSignatureDeclaration(node); case 146: return checkSignatureDeclaration(node); - case 140: - case 139: - return checkMethodDeclaration(node); - case 141: - return checkConstructorDeclaration(node); - case 142: - case 143: - return checkAccessorDeclaration(node); - case 148: - return checkTypeReferenceNode(node); case 147: + return checkSignatureDeclaration(node); + case 141: + case 140: + return checkMethodDeclaration(node); + case 142: + return checkConstructorDeclaration(node); + case 143: + case 144: + return checkAccessorDeclaration(node); + case 149: + return checkTypeReferenceNode(node); + case 148: return checkTypePredicate(node); - case 151: - return checkTypeQuery(node); case 152: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 153: - return checkArrayType(node); + return checkTypeLiteral(node); case 154: - return checkTupleType(node); + return checkArrayType(node); case 155: + return checkTupleType(node); case 156: - return checkUnionOrIntersectionType(node); case 157: + return checkUnionOrIntersectionType(node); + case 158: return checkSourceElement(node.type); - case 210: - return checkFunctionDeclaration(node); - case 189: - case 216: - return checkBlock(node); - case 190: - return checkVariableStatement(node); - case 192: - return checkExpressionStatement(node); - case 193: - return checkIfStatement(node); - case 194: - return checkDoStatement(node); - case 195: - return checkWhileStatement(node); - case 196: - return checkForStatement(node); - case 197: - return checkForInStatement(node); - case 198: - return checkForOfStatement(node); - case 199: - case 200: - return checkBreakOrContinueStatement(node); - case 201: - return checkReturnStatement(node); - case 202: - return checkWithStatement(node); - case 203: - return checkSwitchStatement(node); - case 204: - return checkLabeledStatement(node); - case 205: - return checkThrowStatement(node); - case 206: - return checkTryStatement(node); - case 208: - return checkVariableDeclaration(node); - case 160: - return checkBindingElement(node); case 211: - return checkClassDeclaration(node); - case 212: - return checkInterfaceDeclaration(node); - case 213: - return checkTypeAliasDeclaration(node); - case 214: - return checkEnumDeclaration(node); - case 215: - return checkModuleDeclaration(node); - case 219: - return checkImportDeclaration(node); - case 218: - return checkImportEqualsDeclaration(node); - case 225: - return checkExportDeclaration(node); - case 224: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 190: + case 217: + return checkBlock(node); case 191: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 193: + return checkExpressionStatement(node); + case 194: + return checkIfStatement(node); + case 195: + return checkDoStatement(node); + case 196: + return checkWhileStatement(node); + case 197: + return checkForStatement(node); + case 198: + return checkForInStatement(node); + case 199: + return checkForOfStatement(node); + case 200: + case 201: + return checkBreakOrContinueStatement(node); + case 202: + return checkReturnStatement(node); + case 203: + return checkWithStatement(node); + case 204: + return checkSwitchStatement(node); + case 205: + return checkLabeledStatement(node); + case 206: + return checkThrowStatement(node); case 207: + return checkTryStatement(node); + case 209: + return checkVariableDeclaration(node); + case 161: + return checkBindingElement(node); + case 212: + return checkClassDeclaration(node); + case 213: + return checkInterfaceDeclaration(node); + case 214: + return checkTypeAliasDeclaration(node); + case 215: + return checkEnumDeclaration(node); + case 216: + return checkModuleDeclaration(node); + case 220: + return checkImportDeclaration(node); + case 219: + return checkImportEqualsDeclaration(node); + case 226: + return checkExportDeclaration(node); + case 225: + return checkExportAssignment(node); + case 192: checkGrammarStatementInAmbientContext(node); return; - case 228: + case 208: + checkGrammarStatementInAmbientContext(node); + return; + case 229: return checkMissingDeclaration(node); } } function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 170: case 171: + case 172: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 183: + case 184: ts.forEach(node.members, checkSourceElement); break; + case 141: case 140: - case 139: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 141: case 142: case 143: - case 210: + case 144: + case 211: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 202: + case 203: checkFunctionAndClassExpressionBodies(node.expression); break; - case 136: - case 135: - case 138: case 137: - case 158: + case 136: + case 139: + case 138: case 159: case 160: case 161: case 162: - case 242: case 163: + case 243: case 164: case 165: case 166: case 167: - case 180: - case 187: case 168: - case 186: + case 181: + case 188: case 169: - case 173: + case 187: + case 170: case 174: case 175: - case 172: case 176: + case 173: case 177: case 178: case 179: + case 180: + case 183: case 182: - case 181: - case 189: - case 216: case 190: - case 192: + case 217: + case 191: case 193: case 194: case 195: @@ -20659,27 +21023,30 @@ var ts; case 199: case 200: case 201: - case 203: - case 217: - case 238: - case 239: + case 202: case 204: + case 218: + case 239: + case 240: case 205: case 206: - case 241: - case 208: + case 207: + case 242: case 209: - case 211: - case 214: - case 244: - case 224: + case 210: + case 212: + case 241: + case 186: + case 215: case 245: - case 237: - case 230: + case 225: + case 246: + case 238: case 231: - case 235: - case 236: case 232: + case 236: + case 237: + case 233: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -20757,7 +21124,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 202 && node.parent.statement === node) { + if (node.parent.kind === 203 && node.parent.statement === node) { return true; } node = node.parent; @@ -20779,34 +21146,37 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 245: + case 246: if (!ts.isExternalModule(location)) { break; } - case 215: + case 216: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 214: + case 215: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 183: + case 184: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 211: case 212: + case 213: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 170: + case 171: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); } break; } + if (ts.introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } memberFlags = location.flags; location = location.parent; } @@ -20830,42 +21200,42 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 66 && + return name.kind === 67 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 134: - case 211: + case 135: case 212: case 213: case 214: + case 215: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 132) { + while (node.parent && node.parent.kind === 133) { node = node.parent; } - return node.parent && node.parent.kind === 148; + return node.parent && node.parent.kind === 149; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 163) { + while (node.parent && node.parent.kind === 164) { node = node.parent; } - return node.parent && node.parent.kind === 185; + return node.parent && node.parent.kind === 186; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 132) { + while (nodeOnRightSide.parent.kind === 133) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 218) { + if (nodeOnRightSide.parent.kind === 219) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 224) { + if (nodeOnRightSide.parent.kind === 225) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -20877,10 +21247,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 224) { + if (entityName.parent.kind === 225) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 163) { + if (entityName.kind !== 164) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -20889,29 +21259,31 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 185 ? 793056 : 1536; + var meaning = entityName.parent.kind === 186 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 232) || (entityName.parent.kind === 231)) { + else if ((entityName.parent.kind === 233) || + (entityName.parent.kind === 232) || + (entityName.parent.kind === 235)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 66) { + if (entityName.kind === 67) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 163) { + else if (entityName.kind === 164) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 132) { + else if (entityName.kind === 133) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -20920,54 +21292,65 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 148 ? 793056 : 1536; + var meaning = entityName.parent.kind === 149 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 235) { + else if (entityName.parent.kind === 236) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 147) { + if (entityName.parent.kind === 148) { return resolveEntityName(entityName, 1); } return undefined; } - function getSymbolInfo(node) { + function getSymbolAtLocation(node) { if (isInsideWithStatementBody(node)) { return undefined; } if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 66 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 224 - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); + if (node.kind === 67) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 225 + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === 161 && + node.parent.parent.kind === 159 && + node === node.parent.propertyName) { + var typeOfPattern = getTypeOfNode(node.parent.parent); + var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } } switch (node.kind) { - case 66: - case 163: - case 132: + case 67: + case 164: + case 133: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 94: - case 92: + case 95: + case 93: var type = checkExpression(node); return type.symbol; - case 118: + case 119: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 141) { + if (constructorDeclaration && constructorDeclaration.kind === 142) { return constructorDeclaration.parent.symbol; } return undefined; - case 8: + case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 219 || node.parent.kind === 225) && + ((node.parent.kind === 220 || node.parent.kind === 226) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } - case 7: - if (node.parent.kind === 164 && node.parent.argumentExpression === node) { + case 8: + if (node.parent.kind === 165 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -20981,7 +21364,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 243) { + if (location && location.kind === 244) { return resolveEntityName(location.name, 107455); } return undefined; @@ -21004,7 +21387,7 @@ var ts; return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); } if (ts.isDeclaration(node)) { @@ -21012,14 +21395,14 @@ var ts; return getTypeOfSymbol(symbol); } if (ts.isDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getTypeOfSymbol(symbol); } if (ts.isBindingPattern(node)) { return getTypeForVariableLikeDeclaration(node.parent); } if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } @@ -21054,7 +21437,10 @@ var ts; var symbols = []; var name_16 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - symbols.push(getPropertyOfType(t, name_16)); + var symbol = getPropertyOfType(t, name_16); + if (symbol) { + symbols.push(symbol); + } }); return symbols; } @@ -21078,11 +21464,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 245) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 246) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 215 || n.kind === 214) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 216 || n.kind === 215) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -21095,11 +21481,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 189: - case 217: - case 196: + case 190: + case 218: case 197: case 198: + case 199: return true; } return false; @@ -21125,22 +21511,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 218: - case 220: + case 219: case 221: - case 223: - case 227: + case 222: + case 224: + case 228: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 225: + case 226: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 224: - return node.expression && node.expression.kind === 66 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 225: + return node.expression && node.expression.kind === 67 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 245 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 246 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -21151,7 +21537,10 @@ var ts; if (target === unknownSymbol && compilerOptions.isolatedModules) { return true; } - return target !== unknownSymbol && target && target.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(target); + return target !== unknownSymbol && + target && + target.flags & 107455 && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || s.constEnumOnlyModule; @@ -21185,7 +21574,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 244) { + if (node.kind === 245) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -21199,13 +21588,17 @@ var ts; function isFunctionType(type) { return type.flags & 80896 && getSignaturesOfType(type, 0).length > 0; } - function getTypeReferenceSerializationKind(node) { - var symbol = resolveEntityName(node.typeName, 107455, true); - var constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + function getTypeReferenceSerializationKind(typeName) { + var valueSymbol = resolveEntityName(typeName, 107455, true); + var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; if (constructorType && isConstructorType(constructorType)) { return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; } - var type = getTypeFromTypeNode(node); + var typeSymbol = resolveEntityName(typeName, 793056, true); + if (!typeSymbol) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + var type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } @@ -21227,7 +21620,7 @@ var ts; else if (allConstituentTypesHaveKind(type, 8192)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, 4194304)) { + else if (allConstituentTypesHaveKind(type, 16777216)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -21269,13 +21662,13 @@ var ts; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 160 || (n.parent.kind === 208 && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 161 || (n.parent.kind === 209 && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 | 8388608, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2) && - symbol.valueDeclaration.parent.kind !== 241; + symbol.valueDeclaration.parent.kind !== 242; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; @@ -21315,7 +21708,8 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter }; } function initializeTypeChecker() { @@ -21371,7 +21765,7 @@ var ts; } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyObjectType) { + if (promiseLikeType !== emptyGenericType) { return createTypeReference(promiseLikeType, [anyType]); } return emptyObjectType; @@ -21396,7 +21790,7 @@ var ts; else if (languageVersion < 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 142 || node.kind === 143) { + else if (node.kind === 143 || node.kind === 144) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -21406,38 +21800,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 142: case 143: - case 141: - case 138: - case 137: - case 140: + case 144: + case 142: case 139: - case 146: - case 215: + case 138: + case 141: + case 140: + case 147: + case 216: + case 220: case 219: - case 218: + case 226: case 225: - case 224: - case 135: - break; - case 210: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 115) && - node.parent.kind !== 216 && node.parent.kind !== 245) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); - } + case 136: break; case 211: - case 212: - case 190: - case 213: - if (node.modifiers && node.parent.kind !== 216 && node.parent.kind !== 245) { + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116) && + node.parent.kind !== 217 && node.parent.kind !== 246) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; + case 212: + case 213: + case 191: case 214: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 71) && - node.parent.kind !== 216 && node.parent.kind !== 245) { + if (node.modifiers && node.parent.kind !== 217 && node.parent.kind !== 246) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 215: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72) && + node.parent.kind !== 217 && node.parent.kind !== 246) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -21452,14 +21846,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 110: case 109: case 108: - case 107: var text = void 0; - if (modifier.kind === 109) { + if (modifier.kind === 110) { text = "public"; } - else if (modifier.kind === 108) { + else if (modifier.kind === 109) { text = "protected"; lastProtected = modifier; } @@ -21476,11 +21870,11 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 216 || node.parent.kind === 245) { + else if (node.parent.kind === 217 || node.parent.kind === 246) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256) { - if (modifier.kind === 107) { + if (modifier.kind === 108) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -21489,17 +21883,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 110: + case 111: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 216 || node.parent.kind === 245) { + else if (node.parent.kind === 217 || node.parent.kind === 246) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256) { @@ -21508,7 +21902,7 @@ var ts; flags |= 128; lastStatic = modifier; break; - case 79: + case 80: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -21521,42 +21915,42 @@ var ts; else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 119: + case 120: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 216) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 112: + case 113: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 211) { - if (node.kind !== 140) { + if (node.kind !== 212) { + if (node.kind !== 141) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 211 && node.parent.flags & 256)) { + if (!(node.parent.kind === 212 && node.parent.flags & 256)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128) { @@ -21568,14 +21962,14 @@ var ts; } flags |= 256; break; - case 115: + case 116: if (flags & 512) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 135) { + else if (node.kind === 136) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512; @@ -21583,7 +21977,7 @@ var ts; break; } } - if (node.kind === 141) { + if (node.kind === 142) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -21601,10 +21995,10 @@ var ts; } return; } - else if ((node.kind === 219 || node.kind === 218) && flags & 2) { + else if ((node.kind === 220 || node.kind === 219) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 135 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 136 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512) { @@ -21616,10 +22010,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 140: - case 210: - case 170: + case 141: + case 211: case 171: + case 172: if (!node.asteriskToken) { return false; } @@ -21667,16 +22061,14 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken || parameter.initializer) { + else if (parameter.questionToken) { seenOptionalParameter = true; - if (parameter.questionToken && parameter.initializer) { + if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } - else { - if (seenOptionalParameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); } } } @@ -21686,7 +22078,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 171) { + if (node.kind === 172) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -21721,7 +22113,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 127 && parameter.type.kind !== 125) { + if (parameter.type.kind !== 128 && parameter.type.kind !== 126) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -21753,7 +22145,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 184) { + if (arg.kind === 185) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -21780,7 +22172,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80) { + if (heritageClause.token === 81) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -21793,7 +22185,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103); + ts.Debug.assert(heritageClause.token === 104); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -21808,14 +22200,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80) { + if (heritageClause.token === 81) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103); + ts.Debug.assert(heritageClause.token === 104); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -21824,19 +22216,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 133) { + if (node.kind !== 134) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 178 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 179 && computedPropertyName.expression.operatorToken.kind === 24) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 210 || - node.kind === 170 || - node.kind === 140); + ts.Debug.assert(node.kind === 211 || + node.kind === 171 || + node.kind === 141); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -21862,26 +22254,26 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_17 = prop.name; - if (prop.kind === 184 || - name_17.kind === 133) { + if (prop.kind === 185 || + name_17.kind === 134) { checkGrammarComputedPropertyName(name_17); continue; } var currentKind = void 0; - if (prop.kind === 242 || prop.kind === 243) { + if (prop.kind === 243 || prop.kind === 244) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_17.kind === 7) { + if (name_17.kind === 8) { checkGrammarNumericLiteral(name_17); } currentKind = Property; } - else if (prop.kind === 140) { + else if (prop.kind === 141) { currentKind = Property; } - else if (prop.kind === 142) { + else if (prop.kind === 143) { currentKind = GetAccessor; } - else if (prop.kind === 143) { + else if (prop.kind === 144) { currentKind = SetAccesor; } else { @@ -21913,7 +22305,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 236) { + if (attr.kind === 237) { continue; } var jsxAttr = attr; @@ -21925,7 +22317,7 @@ var ts; return grammarErrorOnNode(name_18, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 237 && !initializer.expression) { + if (initializer && initializer.kind === 238 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -21934,24 +22326,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 209) { + if (forInOrOfStatement.initializer.kind === 210) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 197 + var diagnostic = forInOrOfStatement.kind === 198 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -21974,10 +22366,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 142 && accessor.parameters.length) { + else if (kind === 143 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 143) { + else if (kind === 144) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -22002,7 +22394,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 133 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 134 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -22012,7 +22404,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 162) { + if (node.parent.kind === 163) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -22031,22 +22423,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 213) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 152) { + else if (node.parent.kind === 153) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 196: case 197: case 198: - case 194: + case 199: case 195: + case 196: return true; - case 204: + case 205: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -22058,9 +22450,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 204: + case 205: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 199 + var isMisplacedContinueLabel = node.kind === 200 && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -22068,8 +22460,8 @@ var ts; return false; } break; - case 203: - if (node.kind === 200 && !node.label) { + case 204: + if (node.kind === 201 && !node.label) { return false; } break; @@ -22082,13 +22474,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 200 + var message = node.kind === 201 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 200 + var message = node.kind === 201 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -22100,7 +22492,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 159 || node.name.kind === 158) { + if (node.name.kind === 160 || node.name.kind === 159) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -22109,7 +22501,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 197 && node.parent.parent.kind !== 198) { + if (node.parent.parent.kind !== 198 && node.parent.parent.kind !== 199) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -22129,7 +22521,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 66) { + if (name.kind === 67) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -22138,7 +22530,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 184) { + if (element.kind !== 185) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -22155,15 +22547,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 193: case 194: case 195: - case 202: case 196: + case 203: case 197: case 198: + case 199: return false; - case 204: + case 205: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -22179,13 +22571,13 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 176) { + if (expression.kind === 177) { var unaryExpression = expression; - if (unaryExpression.operator === 34 || unaryExpression.operator === 35) { + if (unaryExpression.operator === 35 || unaryExpression.operator === 36) { expression = unaryExpression.operand; } } - if (expression.kind === 7) { + if (expression.kind === 8) { return /^[0-9]+([eE]\+?[0-9]+)?$/.test(expression.text); } return false; @@ -22198,7 +22590,7 @@ var ts; var inAmbientContext = ts.isInAmbientContext(enumDecl); for (var _i = 0, _a = enumDecl.members; _i < _a.length; _i++) { var node = _a[_i]; - if (node.name.kind === 133) { + if (node.name.kind === 134) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -22241,7 +22633,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 && + return node.kind === 67 && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -22261,12 +22653,12 @@ var ts; return true; } } - else if (node.parent.kind === 212) { + else if (node.parent.kind === 213) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 152) { + else if (node.parent.kind === 153) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -22276,11 +22668,11 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 212 || + if (node.kind === 213 || + node.kind === 220 || node.kind === 219 || - node.kind === 218 || + node.kind === 226 || node.kind === 225 || - node.kind === 224 || (node.flags & 2) || (node.flags & (1 | 1024))) { return false; @@ -22290,7 +22682,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 190) { + if (ts.isDeclaration(decl) || decl.kind === 191) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -22309,7 +22701,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 189 || node.parent.kind === 216 || node.parent.kind === 245) { + if (node.parent.kind === 190 || node.parent.kind === 217 || node.parent.kind === 246) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -22335,7 +22727,6 @@ var ts; } ts.createTypeChecker = createTypeChecker; })(ts || (ts = {})); -/// var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, targetSourceFile) { @@ -22382,7 +22773,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 219); + ts.Debug.assert(aliasEmitInfo.node.kind === 220); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -22455,10 +22846,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 208) { + if (declaration.kind === 209) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 222 || declaration.kind === 223 || declaration.kind === 220) { + else if (declaration.kind === 223 || declaration.kind === 224 || declaration.kind === 221) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -22469,7 +22860,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 219) { + if (moduleElementEmitInfo.node.kind === 220) { moduleElementEmitInfo.isVisible = true; } else { @@ -22477,12 +22868,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 215) { + if (nodeToCheck.kind === 216) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 215) { + if (nodeToCheck.kind === 216) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -22569,62 +22960,62 @@ var ts; } function emitType(type) { switch (type.kind) { - case 114: - case 127: - case 125: - case 117: + case 115: case 128: - case 100: - case 8: + case 126: + case 118: + case 129: + case 101: + case 9: return writeTextOfNode(currentSourceFile, type); - case 185: + case 186: return emitExpressionWithTypeArguments(type); - case 148: - return emitTypeReference(type); - case 151: - return emitTypeQuery(type); - case 153: - return emitArrayType(type); - case 154: - return emitTupleType(type); - case 155: - return emitUnionType(type); - case 156: - return emitIntersectionType(type); - case 157: - return emitParenType(type); case 149: - case 150: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 152: + return emitTypeQuery(type); + case 154: + return emitArrayType(type); + case 155: + return emitTupleType(type); + case 156: + return emitUnionType(type); + case 157: + return emitIntersectionType(type); + case 158: + return emitParenType(type); + case 150: + case 151: + return emitSignatureDeclarationWithJsDocComments(type); + case 153: return emitTypeLiteral(type); - case 66: + case 67: return emitEntityName(type); - case 132: + case 133: return emitEntityName(type); - case 147: + case 148: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 66) { + if (entityName.kind === 67) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 132 ? entityName.left : entityName.expression; - var right = entityName.kind === 132 ? entityName.right : entityName.name; + var left = entityName.kind === 133 ? entityName.left : entityName.expression; + var right = entityName.kind === 133 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 218 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 219 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 66 || node.expression.kind === 163); + ts.Debug.assert(node.expression.kind === 67 || node.expression.kind === 164); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -22700,7 +23091,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -22718,7 +23109,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 66) { + if (node.expression.kind === 67) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -22736,10 +23127,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 218 || - (node.parent.kind === 245 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 219 || + (node.parent.kind === 246 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 245) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -22748,7 +23139,7 @@ var ts; }); } else { - if (node.kind === 219) { + if (node.kind === 220) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -22766,23 +23157,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 210: - return writeFunctionDeclaration(node); - case 190: - return writeVariableStatement(node); - case 212: - return writeInterfaceDeclaration(node); case 211: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 191: + return writeVariableStatement(node); case 213: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 212: + return writeClassDeclaration(node); case 214: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 215: + return writeEnumDeclaration(node); + case 216: return writeModuleDeclaration(node); - case 218: - return writeImportEqualsDeclaration(node); case 219: + return writeImportEqualsDeclaration(node); + case 220: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -22796,7 +23187,7 @@ var ts; if (node.flags & 1024) { write("default "); } - else if (node.kind !== 212) { + else if (node.kind !== 213) { write("declare "); } } @@ -22843,7 +23234,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 221) { + if (namedBindings.kind === 222) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -22869,7 +23260,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 221) { + if (node.importClause.namedBindings.kind === 222) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -22925,7 +23316,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 216) { + while (node.body.kind !== 217) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -22942,14 +23333,18 @@ var ts; enclosingDeclaration = prevEnclosingDeclaration; } function writeTypeAliasDeclaration(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; emitJsDocComments(node); emitModuleElementDeclarationFlags(node); write("type "); writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); write(" = "); emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, @@ -22986,7 +23381,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 140 && (node.parent.flags & 32); + return node.parent.kind === 141 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -22996,15 +23391,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 149 || - node.parent.kind === 150 || - (node.parent.parent && node.parent.parent.kind === 152)) { - ts.Debug.assert(node.parent.kind === 140 || - node.parent.kind === 139 || - node.parent.kind === 149 || + if (node.parent.kind === 150 || + node.parent.kind === 151 || + (node.parent.parent && node.parent.parent.kind === 153)) { + ts.Debug.assert(node.parent.kind === 141 || + node.parent.kind === 140 || node.parent.kind === 150 || - node.parent.kind === 144 || - node.parent.kind === 145); + node.parent.kind === 151 || + node.parent.kind === 145 || + node.parent.kind === 146); emitType(node.constraint); } else { @@ -23014,31 +23409,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 211: + case 212: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 212: + case 213: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 145: + case 146: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 144: + case 145: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 141: case 140: - case 139: if (node.parent.flags & 128) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 211) { + else if (node.parent.parent.kind === 212) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 210: + case 211: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -23066,9 +23461,12 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } + else if (!isImplementsList && node.expression.kind === 91) { + write("null"); + } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 211) { + if (node.parent.parent.kind === 212) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -23148,16 +23546,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 208 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 209 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 138 || node.kind === 137) && ts.hasQuestionToken(node)) { + if ((node.kind === 139 || node.kind === 138) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 138 || node.kind === 137) && node.parent.kind === 152) { + if ((node.kind === 139 || node.kind === 138) && node.parent.kind === 153) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -23166,14 +23564,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 208) { + if (node.kind === 209) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 138 || node.kind === 137) { + else if (node.kind === 139 || node.kind === 138) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23181,7 +23579,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23207,7 +23605,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 184) { + if (element.kind !== 185) { elements.push(element); } } @@ -23273,7 +23671,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 142 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 143 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -23286,7 +23684,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 142 + return accessor.kind === 143 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -23295,7 +23693,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 143) { + if (accessorWithTypeAnnotation.kind === 144) { if (accessorWithTypeAnnotation.parent.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -23341,17 +23739,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 210) { + if (node.kind === 211) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 140) { + else if (node.kind === 141) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 210) { + if (node.kind === 211) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 141) { + else if (node.kind === 142) { write("constructor"); } else { @@ -23368,11 +23766,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 145 || node.kind === 150) { + if (node.kind === 146 || node.kind === 151) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 146) { + if (node.kind === 147) { write("["); } else { @@ -23381,20 +23779,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 146) { + if (node.kind === 147) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 149 || node.kind === 150; - if (isFunctionTypeOrConstructorType || node.parent.kind === 152) { + var isFunctionTypeOrConstructorType = node.kind === 150 || node.kind === 151; + if (isFunctionTypeOrConstructorType || node.parent.kind === 153) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 141 && !(node.flags & 32)) { + else if (node.kind !== 142 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -23405,23 +23803,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 145: + case 146: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 144: + case 145: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 146: + case 147: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; + case 141: case 140: - case 139: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23429,7 +23827,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 211) { + else if (node.parent.kind === 212) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -23442,7 +23840,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 210: + case 211: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -23470,13 +23868,13 @@ var ts; else { writeTextOfNode(currentSourceFile, node.name); } - if (node.initializer || ts.hasQuestionToken(node)) { + if (resolver.isOptionalParameter(node)) { write("?"); } decreaseIndent(); - if (node.parent.kind === 149 || - node.parent.kind === 150 || - node.parent.parent.kind === 152) { + if (node.parent.kind === 150 || + node.parent.kind === 151 || + node.parent.parent.kind === 153) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -23492,22 +23890,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 141: + case 142: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 145: + case 146: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 144: + case 145: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 141: case 140: - case 139: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -23515,7 +23913,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 211) { + else if (node.parent.parent.kind === 212) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23527,7 +23925,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 210: + case 211: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23538,12 +23936,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 158) { + if (bindingPattern.kind === 159) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 159) { + else if (bindingPattern.kind === 160) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -23562,21 +23960,20 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 184) { + if (bindingElement.kind === 185) { write(" "); } - else if (bindingElement.kind === 160) { + else if (bindingElement.kind === 161) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); - emitBindingPattern(bindingElement.name); } - else if (bindingElement.name) { + if (bindingElement.name) { if (ts.isBindingPattern(bindingElement.name)) { emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 66); + ts.Debug.assert(bindingElement.name.kind === 67); if (bindingElement.dotDotDotToken) { write("..."); } @@ -23588,39 +23985,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 210: - case 215: - case 218: - case 212: case 211: - case 213: - case 214: - return emitModuleElement(node, isModuleElementVisible(node)); - case 190: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 216: case 219: + case 213: + case 212: + case 214: + case 215: + return emitModuleElement(node, isModuleElementVisible(node)); + case 191: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 220: return emitModuleElement(node, !node.importClause); - case 225: + case 226: return emitExportDeclaration(node); + case 142: case 141: case 140: - case 139: return writeFunctionDeclaration(node); - case 145: - case 144: case 146: + case 145: + case 147: return emitSignatureDeclarationWithJsDocComments(node); - case 142: case 143: + case 144: return emitAccessorDeclaration(node); + case 139: case 138: - case 137: return emitPropertyDeclaration(node); - case 244: - return emitEnumMemberDeclaration(node); - case 224: - return emitExportAssignment(node); case 245: + return emitEnumMemberDeclaration(node); + case 225: + return emitExportAssignment(node); + case 246: return emitSourceFile(node); } } @@ -23629,7 +24026,7 @@ var ts; ? referencedFile.fileName : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") - : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; + : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); referencePathsOutput += "/// " + newLine; } @@ -23657,8 +24054,6 @@ var ts; } ts.writeDeclarationFile = writeDeclarationFile; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { function isExternalModuleOrDeclarationFile(sourceFile) { @@ -23685,17 +24080,17 @@ var ts; emitFile(jsFilePath, sourceFile); } }); - if (compilerOptions.out) { - emitFile(compilerOptions.out); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } else { if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ts.forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } - else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { - emitFile(compilerOptions.out); + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } diagnostics = ts.sortAndDeduplicateDiagnostics(diagnostics); @@ -23724,11 +24119,7 @@ var ts; } function emitJavaScript(jsFilePath, root) { var writer = ts.createTextWriter(newLine); - var write = writer.write; - var writeTextOfNode = writer.writeTextOfNode; - var writeLine = writer.writeLine; - var increaseIndent = writer.increaseIndent; - var decreaseIndent = writer.decreaseIndent; + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var currentSourceFile; var exportFunctionForFile; var generatedNameSet = {}; @@ -23748,13 +24139,14 @@ var ts; var writeEmittedFiles = writeJavaScriptFile; var detachedCommentsInfo; var writeComment = ts.writeCommentRange; - var emit = emitNodeWithoutSourceMap; + var emit = emitNodeWithCommentsAndWithoutSourcemap; var emitStart = function (node) { }; var emitEnd = function (node) { }; var emitToken = emitTokenText; var scopeEmitStart = function (scopeDeclaration, scopeName) { }; var scopeEmitEnd = function () { }; var sourceMapData; + var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); } @@ -23819,7 +24211,7 @@ var ts; } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 ? + var baseName = expr.kind === 9 ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; return makeUniqueName(baseName); } @@ -23831,19 +24223,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 66: + case 67: return makeUniqueName(node.text); + case 216: case 215: - case 214: return generateNameForModuleOrEnum(node); - case 219: - case 225: + case 220: + case 226: return generateNameForImportOrExportDeclaration(node); - case 210: case 211: - case 224: + case 212: + case 225: return generateNameForExportDefault(); - case 183: + case 184: return generateNameForClassExpression(); } } @@ -23897,7 +24289,7 @@ var ts; function base64VLQFormatEncode(inValue) { function base64FormatEncode(inValue) { if (inValue < 64) { - return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue); + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); } throw TypeError(inValue + ": not a 64 based value"); } @@ -23982,7 +24374,7 @@ var ts; var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { var name_22 = node.name; - if (!name_22 || name_22.kind !== 133) { + if (!name_22 || name_22.kind !== 134) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -23999,18 +24391,18 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 210 || - node.kind === 170 || + else if (node.kind === 211 || + node.kind === 171 || + node.kind === 141 || node.kind === 140 || - node.kind === 139 || - node.kind === 142 || node.kind === 143 || - node.kind === 215 || - node.kind === 211 || - node.kind === 214) { + node.kind === 144 || + node.kind === 216 || + node.kind === 212 || + node.kind === 215) { if (node.name) { var name_23 = node.name; - scopeName = name_23.kind === 133 + scopeName = name_23.kind === 134 ? ts.getTextOfNode(name_23) : node.name.text; } @@ -24109,7 +24501,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 245) { + if (node.kind !== 246) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -24120,8 +24512,11 @@ var ts; } } } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -24133,7 +24528,7 @@ var ts; ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } function createTempVariable(flags) { - var result = ts.createSynthesizedNode(66); + var result = ts.createSynthesizedNode(67); result.text = makeTempVariableName(flags); return result; } @@ -24243,7 +24638,9 @@ var ts; write(", "); } } - emitNode(nodes[start + i]); + var node = nodes[start + i]; + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); leadingComma = true; } if (trailingComma) { @@ -24269,7 +24666,7 @@ var ts; } } function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 7 && text.length > 1) { + if (node.kind === 8 && text.length > 1) { switch (text.charCodeAt(1)) { case 98: case 66: @@ -24282,7 +24679,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 8 || ts.isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { @@ -24294,23 +24691,23 @@ var ts; } function getLiteralText(node) { if (languageVersion < 2 && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); + return getQuotedEscapedLiteralText("\"", node.text, "\""); } if (node.parent) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); } switch (node.kind) { - case 8: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 10: - return getQuotedEscapedLiteralText('`', node.text, '`'); + case 9: + return getQuotedEscapedLiteralText("\"", node.text, "\""); case 11: - return getQuotedEscapedLiteralText('`', node.text, '${'); + return getQuotedEscapedLiteralText("`", node.text, "`"); case 12: - return getQuotedEscapedLiteralText('}', node.text, '${'); + return getQuotedEscapedLiteralText("`", node.text, "${"); case 13: - return getQuotedEscapedLiteralText('}', node.text, '`'); - case 7: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -24320,15 +24717,15 @@ var ts; } function emitDownlevelRawTemplateLiteral(node) { var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 10 || node.kind === 13; + var isLast = node.kind === 11 || node.kind === 14; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); text = ts.escapeString(text); - write('"' + text + '"'); + write("\"" + text + "\""); } function emitDownlevelTaggedTemplateArray(node, literalEmitter) { write("["); - if (node.template.kind === 10) { + if (node.template.kind === 11) { literalEmitter(node.template); } else { @@ -24354,11 +24751,11 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 180) { + if (node.template.kind === 181) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 178 - && templateSpan.expression.operatorToken.kind === 23; + var needsParens = templateSpan.expression.kind === 179 + && templateSpan.expression.operatorToken.kind === 24; emitParenthesizedIf(templateSpan.expression, needsParens); }); } @@ -24381,7 +24778,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 169 + var needsParens = templateSpan.expression.kind !== 170 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -24396,29 +24793,16 @@ var ts; write(")"); } function shouldEmitTemplateHead() { - // If this expression has an empty head literal and the first template span has a non-empty - // literal, then emitting the empty head literal is not necessary. - // `${ foo } and ${ bar }` - // can be emitted as - // foo + " and " + bar - // This is because it is only required that one of the first two operands in the emit - // output must be a string literal, so that the other operand and all following operands - // are forced into strings. - // - // If the first template span has an empty literal, then the head must still be emitted. - // `${ foo }${ bar }` - // must still be emitted as - // "" + foo + bar ts.Debug.assert(node.templateSpans.length !== 0); return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 165: case 166: - return parent.expression === template; case 167: - case 169: + return parent.expression === template; + case 168: + case 170: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -24426,20 +24810,20 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 178: + case 179: switch (expression.operatorToken.kind) { - case 36: case 37: case 38: + case 39: return 1; - case 34: case 35: + case 36: return 0; default: return -1; } - case 181: - case 179: + case 182: + case 180: return -1; default: return 1; @@ -24452,10 +24836,10 @@ var ts; } function jsxEmitReact(node) { function emitTagName(name) { - if (name.kind === 66 && ts.isIntrinsicJsxName(name.text)) { - write('"'); + if (name.kind === 67 && ts.isIntrinsicJsxName(name.text)) { + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -24463,9 +24847,9 @@ var ts; } function emitAttributeName(name) { if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write('"'); + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -24482,8 +24866,12 @@ var ts; } } function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(67); + syntheticReactRef.text = 'React'; + syntheticReactRef.parent = openingNode; emitLeadingComments(openingNode); - write("React.createElement("); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); emitTagName(openingNode.tagName); write(", "); if (openingNode.attributes.length === 0) { @@ -24491,36 +24879,37 @@ var ts; } else { var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 236; })) { - write("React.__spread("); + if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) { + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); var haveOpenedObjectLiteral = false; - for (var i_2 = 0; i_2 < attrs.length; i_2++) { - if (attrs[i_2].kind === 236) { - if (i_2 === 0) { + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 237) { + if (i_1 === 0) { write("{}, "); } if (haveOpenedObjectLiteral) { write("}"); haveOpenedObjectLiteral = false; } - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } - emit(attrs[i_2].expression); + emit(attrs[i_1].expression); } else { - ts.Debug.assert(attrs[i_2].kind === 235); + ts.Debug.assert(attrs[i_1].kind === 236); if (haveOpenedObjectLiteral) { write(", "); } else { haveOpenedObjectLiteral = true; - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } write("{"); } - emitJsxAttribute(attrs[i_2]); + emitJsxAttribute(attrs[i_1]); } } if (haveOpenedObjectLiteral) @@ -24540,15 +24929,15 @@ var ts; } if (children) { for (var i = 0; i < children.length; i++) { - if (children[i].kind === 237 && !(children[i].expression)) { + if (children[i].kind === 238 && !(children[i].expression)) { continue; } - if (children[i].kind === 233) { + if (children[i].kind === 234) { var text = getTextToEmit(children[i]); if (text !== undefined) { - write(', "'); + write(", \""); write(text); - write('"'); + write("\""); } } else { @@ -24560,19 +24949,21 @@ var ts; write(")"); emitTrailingComments(openingNode); } - if (node.kind === 230) { + if (node.kind === 231) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 231); + ts.Debug.assert(node.kind === 232); emitJsxElement(node); } } function jsxEmitPreserve(node) { function emitJsxAttribute(node) { emit(node.name); - write("="); - emit(node.initializer); + if (node.initializer) { + write("="); + emit(node.initializer); + } } function emitJsxSpreadAttribute(node) { write("{..."); @@ -24584,11 +24975,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 236) { + if (attribs[i].kind === 237) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 235); + ts.Debug.assert(attribs[i].kind === 236); emitJsxAttribute(attribs[i]); } } @@ -24596,11 +24987,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 231)) { + if (node.attributes.length > 0 || (node.kind === 232)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 231) { + if (node.kind === 232) { write("/>"); } else { @@ -24619,20 +25010,20 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 230) { + if (node.kind === 231) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 231); + ts.Debug.assert(node.kind === 232); emitJsxOpeningOrSelfClosingElement(node); } } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 160); - if (node.kind === 8) { + ts.Debug.assert(node.kind !== 161); + if (node.kind === 9) { emitLiteral(node); } - else if (node.kind === 133) { + else if (node.kind === 134) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -24651,7 +25042,7 @@ var ts; } else { write("\""); - if (node.kind === 7) { + if (node.kind === 8) { write(node.text); } else { @@ -24663,58 +25054,60 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 161: - case 178: - case 165: - case 238: - case 133: + case 162: case 179: - case 136: - case 172: - case 194: - case 164: - case 224: - case 192: - case 185: - case 196: + case 166: + case 239: + case 134: + case 180: + case 137: + case 173: + case 195: + case 165: + case 225: + case 193: + case 186: case 197: case 198: - case 193: - case 231: + case 199: + case 194: case 232: - case 166: - case 169: - case 177: - case 176: - case 201: - case 243: - case 182: - case 203: + case 233: + case 237: + case 238: case 167: - case 187: - case 205: - case 168: - case 173: - case 174: - case 195: - case 202: - case 181: - return true; - case 160: - case 244: - case 135: - case 242: - case 138: - case 208: - return parent.initializer === node; - case 163: - return parent.expression === node; - case 171: case 170: + case 178: + case 177: + case 202: + case 244: + case 183: + case 204: + case 168: + case 188: + case 206: + case 169: + case 174: + case 175: + case 196: + case 203: + case 182: + return true; + case 161: + case 245: + case 136: + case 243: + case 139: + case 209: + return parent.initializer === node; + case 164: + return parent.expression === node; + case 172: + case 171: return parent.body === node; - case 218: + case 219: return parent.moduleReference === node; - case 132: + case 133: return parent.left === node; } return false; @@ -24726,7 +25119,7 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 245) { + if (container.kind === 246) { if (languageVersion < 2 && compilerOptions.module !== 4) { write("exports."); } @@ -24739,15 +25132,22 @@ var ts; else if (languageVersion < 2) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 220) { + if (declaration.kind === 221) { write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 ? '["default"]' : ".default"); + write(languageVersion === 0 ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 223) { + else if (declaration.kind === 224) { write(getGeneratedNameForNode(declaration.parent.parent.parent)); - write("."); - writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); + var name = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name); + if (languageVersion === 0 && identifier === "default") { + write("[\"default\"]"); + } + else { + write("."); + write(identifier); + } return; } } @@ -24757,17 +25157,22 @@ var ts; return; } } - writeTextOfNode(currentSourceFile, node); + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } } function isNameOfNestedRedeclaration(node) { if (languageVersion < 2) { - var parent_7 = node.parent; - switch (parent_7.kind) { - case 160: - case 211: - case 214: - case 208: - return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + var parent_6 = node.parent; + switch (parent_6.kind) { + case 161: + case 212: + case 215: + case 209: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); } } return false; @@ -24782,6 +25187,9 @@ var ts; else if (isNameOfNestedRedeclaration(node)) { write(getGeneratedNameForNode(node)); } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } else { writeTextOfNode(currentSourceFile, node); } @@ -24841,7 +25249,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(111)); + write(ts.tokenToString(112)); if (node.asteriskToken) { write("*"); } @@ -24855,7 +25263,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(111)); + write(ts.tokenToString(112)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -24863,22 +25271,22 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 178 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 179 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 179 && node.parent.condition === node) { + else if (node.parent.kind === 180 && node.parent.condition === node) { return true; } return false; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 66: - case 161: - case 163: + case 67: + case 162: case 164: case 165: - case 169: + case 166: + case 170: return false; } return true; @@ -24895,17 +25303,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 182) { + if (e.kind === 183) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 161) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 182) { + while (i < length && elements[i].kind !== 183) { i++; } write("["); @@ -24928,7 +25336,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 182; + return node.kind === 183; } function emitArrayLiteral(node) { var elements = node.elements; @@ -24989,7 +25397,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 142 || property.kind === 143) { + if (property.kind === 143 || property.kind === 144) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -25040,13 +25448,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 242) { + if (property.kind === 243) { emit(property.initializer); } - else if (property.kind === 243) { + else if (property.kind === 244) { emitExpressionIdentifier(property.name); } - else if (property.kind === 140) { + else if (property.kind === 141) { emitFunctionDeclaration(property); } else { @@ -25078,7 +25486,7 @@ var ts; var numProperties = properties.length; var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 133) { + if (properties[i].name.kind === 134) { numInitialNonComputedProperties = i; break; } @@ -25092,35 +25500,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(178, startsOnNewLine); + var result = ts.createSynthesizedNode(179, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(163); + var result = ts.createSynthesizedNode(164); result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(20); + result.dotToken = ts.createSynthesizedNode(21); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(164); + var result = ts.createSynthesizedNode(165); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 168 || expr.kind === 186) { + while (expr.kind === 169 || expr.kind === 187) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 166 && - expr.kind !== 7) { + expr.kind !== 167 && + expr.kind !== 8) { return expr; } - var node = ts.createSynthesizedNode(169); + var node = ts.createSynthesizedNode(170); node.expression = expr; return node; } @@ -25142,11 +25550,12 @@ var ts; function emitPropertyAssignment(node) { emit(node.name); write(": "); + emitTrailingCommentsOfPosition(node.initializer.pos); emit(node.initializer); } function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 245; + return container && container.kind !== 246; } function emitShorthandPropertyAssignment(node) { writeTextOfNode(currentSourceFile, node.name); @@ -25156,20 +25565,25 @@ var ts; } } function tryEmitConstantValue(node) { - if (compilerOptions.isolatedModules) { - return false; - } - var constantValue = resolver.getConstantValue(node); + var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 163 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 164 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; } return false; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 164 || node.kind === 165 + ? resolver.getConstantValue(node) + : undefined; + } function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2); @@ -25192,9 +25606,15 @@ var ts; emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); var shouldEmitSpace; - if (!indentedBeforeDot && node.expression.kind === 7) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(20)) < 0; + if (!indentedBeforeDot) { + if (node.expression.kind === 8) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21)) < 0; + } + else { + var constantValue = tryGetConstEnumValue(node.expression); + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } } if (shouldEmitSpace) { write(" ."); @@ -25212,7 +25632,7 @@ var ts; emit(node.right); } function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 66) { + if (node.left.kind === 67) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -25228,11 +25648,11 @@ var ts; emitEntityNameAsExpression(node.left, false); } write("."); - emitNodeWithoutSourceMap(node.right); + emit(node.right); } function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 66: + case 67: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); @@ -25240,7 +25660,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 132: + case 133: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -25255,16 +25675,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 182; }); + return ts.forEach(elements, function (e) { return e.kind === 183; }); } function skipParentheses(node) { - while (node.kind === 169 || node.kind === 168 || node.kind === 186) { + while (node.kind === 170 || node.kind === 169 || node.kind === 187) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 66 || node.kind === 94 || node.kind === 92) { + if (node.kind === 67 || node.kind === 95 || node.kind === 93) { emit(node); return node; } @@ -25279,18 +25699,18 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 163) { + if (expr.kind === 164) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 164) { + else if (expr.kind === 165) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 92) { + else if (expr.kind === 93) { target = expr; write("_super"); } @@ -25299,7 +25719,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 92) { + if (target.kind === 93) { emitThis(target); } else { @@ -25319,13 +25739,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 92) { + if (node.expression.kind === 93) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 163 && node.expression.expression.kind === 92; + superCall = node.expression.kind === 164 && node.expression.expression.kind === 93; } if (superCall && languageVersion < 2) { write(".call("); @@ -25376,20 +25796,21 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 171) { - if (node.expression.kind === 168 || node.expression.kind === 186) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172) { + if (node.expression.kind === 169 || node.expression.kind === 187) { var operand = node.expression.expression; - while (operand.kind === 168 || operand.kind === 186) { + while (operand.kind === 169 || operand.kind === 187) { operand = operand.expression; } - if (operand.kind !== 176 && + if (operand.kind !== 177 && + operand.kind !== 175 && operand.kind !== 174 && operand.kind !== 173 && - operand.kind !== 172 && - operand.kind !== 177 && - operand.kind !== 166 && - !(operand.kind === 165 && node.parent.kind === 166) && - !(operand.kind === 170 && node.parent.kind === 165)) { + operand.kind !== 178 && + operand.kind !== 167 && + !(operand.kind === 166 && node.parent.kind === 167) && + !(operand.kind === 171 && node.parent.kind === 166) && + !(operand.kind === 8 && node.parent.kind === 164)) { emit(operand); return; } @@ -25400,25 +25821,25 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(75)); + write(ts.tokenToString(76)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(100)); + write(ts.tokenToString(101)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(98)); + write(ts.tokenToString(99)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 66 || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 67 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 208 || node.parent.kind === 160); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 || node.parent.kind === 161); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -25432,12 +25853,12 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 176) { + if (node.operand.kind === 177) { var operand = node.operand; - if (node.operator === 34 && (operand.operator === 34 || operand.operator === 39)) { + if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { write(" "); } - else if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { + else if (node.operator === 36 && (operand.operator === 36 || operand.operator === 41)) { write(" "); } } @@ -25454,7 +25875,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 39) { + if (node.operator === 40) { write(") - 1)"); } else { @@ -25475,10 +25896,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 245) { + if (current.kind === 246) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 216) { + else if (ts.isFunctionLike(current) || current.kind === 217) { return false; } else { @@ -25487,13 +25908,13 @@ var ts; } } function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 54 && - (node.left.kind === 162 || node.left.kind === 161)) { - emitDestructuring(node, node.parent.kind === 192); + if (languageVersion < 2 && node.operatorToken.kind === 55 && + (node.left.kind === 163 || node.left.kind === 162)) { + emitDestructuring(node, node.parent.kind === 193); } else { - var exportChanged = node.operatorToken.kind >= 54 && - node.operatorToken.kind <= 65 && + var exportChanged = node.operatorToken.kind >= 55 && + node.operatorToken.kind <= 66 && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -25501,7 +25922,7 @@ var ts; write("\", "); } emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 ? " " : undefined); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 ? " " : undefined); write(ts.tokenToString(node.operatorToken.kind)); var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); @@ -25536,36 +25957,36 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 189) { + if (node && node.kind === 190) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } } function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - emitToken(14, node.pos); + emitToken(15, node.pos); write(" "); - emitToken(15, node.statements.end); + emitToken(16, node.statements.end); return; } - emitToken(14, node.pos); + emitToken(15, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 216) { - ts.Debug.assert(node.parent.kind === 215); + if (node.kind === 217) { + ts.Debug.assert(node.parent.kind === 216); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 216) { + if (node.kind === 217) { emitTempDeclarations(true); } decreaseIndent(); writeLine(); - emitToken(15, node.statements.end); + emitToken(16, node.statements.end); scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 189) { + if (node.kind === 190) { write(" "); emit(node); } @@ -25577,20 +25998,20 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 171); + emitParenthesizedIf(node.expression, node.expression.kind === 172); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(85, node.pos); + var endPos = emitToken(86, node.pos); write(" "); - endPos = emitToken(16, endPos); + endPos = emitToken(17, endPos); emit(node.expression); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(77, node.thenStatement.end); - if (node.elseStatement.kind === 193) { + emitToken(78, node.thenStatement.end); + if (node.elseStatement.kind === 194) { write(" "); emit(node.elseStatement); } @@ -25602,7 +26023,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 189) { + if (node.statement.kind === 190) { write(" "); } else { @@ -25622,13 +26043,13 @@ var ts; if (shouldHoistVariable(decl, true)) { return false; } - var tokenKind = 99; + var tokenKind = 100; if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { - tokenKind = 105; + tokenKind = 106; } else if (ts.isConst(decl)) { - tokenKind = 71; + tokenKind = 72; } } if (startPos !== undefined) { @@ -25637,13 +26058,13 @@ var ts; } else { switch (tokenKind) { - case 99: + case 100: write("var "); break; - case 105: + case 106: write("let "); break; - case 71: + case 72: write("const "); break; } @@ -25668,10 +26089,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 209) { + endPos = emitToken(17, endPos); + if (node.initializer && node.initializer.kind === 210) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -25692,13 +26113,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 198) { + if (languageVersion < 2 && node.kind === 199) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - if (node.initializer.kind === 209) { + endPos = emitToken(17, endPos); + if (node.initializer.kind === 210) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -25708,41 +26129,21 @@ var ts; else { emit(node.initializer); } - if (node.kind === 197) { + if (node.kind === 198) { write(" in "); } else { write(" of "); } emit(node.expression); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { - // The following ES6 code: - // - // for (let v of expr) { } - // - // should be emitted as - // - // for (let _i = 0, _a = expr; _i < _a.length; _i++) { - // let v = _a[_i]; - // } - // - // where _a and _i are temps emitted to capture the RHS and the counter, - // respectively. - // When the left hand side is an expression instead of a let declaration, - // the "let v" is not emitted. - // When the left hand side is a let/const, the v is renamed if there is - // another v in scope. - // Note that all assignments to the LHS are emitted in the body, including - // all destructuring. - // Note also that because an extra statement is needed to assign to the LHS, - // for-of bodies are always emitted as blocks. - var endPos = emitToken(83, node.pos); + var endPos = emitToken(84, node.pos); write(" "); - endPos = emitToken(16, endPos); - var rhsIsIdentifier = node.expression.kind === 66; + endPos = emitToken(17, endPos); + var rhsIsIdentifier = node.expression.kind === 67; var counter = createTempVariable(268435456); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); emitStart(node.expression); @@ -25762,7 +26163,7 @@ var ts; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); write("; "); @@ -25770,13 +26171,13 @@ var ts; emitNodeWithoutSourceMap(counter); write("++"); emitEnd(node.initializer); - emitToken(17, node.expression.end); + emitToken(18, node.expression.end); write(" {"); writeLine(); increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 209) { + if (node.initializer.kind === 210) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -25785,7 +26186,7 @@ var ts; emitDestructuring(declaration, false, rhsIterationValue); } else { - emitNodeWithoutSourceMap(declaration); + emitNodeWithCommentsAndWithoutSourcemap(declaration); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } @@ -25797,17 +26198,17 @@ var ts; } } else { - var assignmentExpression = createBinaryExpression(node.initializer, 54, rhsIterationValue, false); - if (node.initializer.kind === 161 || node.initializer.kind === 162) { + var assignmentExpression = createBinaryExpression(node.initializer, 55, rhsIterationValue, false); + if (node.initializer.kind === 162 || node.initializer.kind === 163) { emitDestructuring(assignmentExpression, true, undefined); } else { - emitNodeWithoutSourceMap(assignmentExpression); + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); } } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 189) { + if (node.statement.kind === 190) { emitLines(node.statement.statements); } else { @@ -25819,12 +26220,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 200 ? 67 : 72, node.pos); + emitToken(node.kind === 201 ? 68 : 73, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(91, node.pos); + emitToken(92, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -25835,21 +26236,21 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(93, node.pos); + var endPos = emitToken(94, node.pos); write(" "); - emitToken(16, endPos); + emitToken(17, endPos); emit(node.expression); - endPos = emitToken(17, node.expression.end); + endPos = emitToken(18, node.expression.end); write(" "); emitCaseBlock(node.caseBlock, endPos); } function emitCaseBlock(node, startPos) { - emitToken(14, startPos); + emitToken(15, startPos); increaseIndent(); emitLines(node.clauses); decreaseIndent(); writeLine(); - emitToken(15, node.clauses.end); + emitToken(16, node.clauses.end); } function nodeStartPositionsAreOnSameLine(node1, node2) { return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === @@ -25864,7 +26265,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 238) { + if (node.kind === 239) { write("case "); emit(node.expression); write(":"); @@ -25899,16 +26300,16 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(69, node.pos); + var endPos = emitToken(70, node.pos); write(" "); - emitToken(16, endPos); + emitToken(17, endPos); emit(node.variableDeclaration); - emitToken(17, node.variableDeclaration ? node.variableDeclaration.end : endPos); + emitToken(18, node.variableDeclaration ? node.variableDeclaration.end : endPos); write(" "); emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(73, node.pos); + emitToken(74, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -25919,7 +26320,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 215); + } while (node && node.kind !== 216); return node; } function emitContainingModuleName(node) { @@ -25938,16 +26339,33 @@ var ts; write("exports."); } } - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); emitEnd(node.name); } function createVoidZero() { - var zero = ts.createSynthesizedNode(7); + var zero = ts.createSynthesizedNode(8); zero.text = "0"; - var result = ts.createSynthesizedNode(174); + var result = ts.createSynthesizedNode(175); result.expression = zero; return result; } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 246) { + ts.Debug.assert(!!(node.flags & 1024) || node.kind === 225); + if (compilerOptions.module === 1 || compilerOptions.module === 2 || compilerOptions.module === 3) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1) { + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } function emitExportMemberAssignment(node) { if (node.flags & 1) { writeLine(); @@ -25958,7 +26376,7 @@ var ts; write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write("\", "); emitDeclarationName(node); @@ -25966,6 +26384,7 @@ var ts; } else { if (node.flags & 1024) { + emitEs6ExportDefaultCompat(node); if (languageVersion === 0) { write("exports[\"default\"]"); } @@ -25984,44 +26403,51 @@ var ts; } } function emitExportMemberAssignments(name) { + if (compilerOptions.module === 4) { + return; + } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { var specifier = _b[_a]; writeLine(); - if (compilerOptions.module === 4) { - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(specifier.name); - write("\", "); - emitExpressionIdentifier(name); - write(")"); - emitEnd(specifier.name); - } - else { - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - } + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); write(";"); } } } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(compilerOptions.module === 4); + if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { + return; + } + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 208) { + if (root.kind === 209) { var isExported = ts.getCombinedNodeFlags(root) & 1; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 135) { + else if (root.kind === 136) { canDefineTempVariablesInPlace = true; } - if (root.kind === 178) { + if (root.kind === 179) { emitAssignmentExpression(root); } else { @@ -26032,11 +26458,11 @@ var ts; if (emitCount++) { write(", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 208 || name.parent.kind === 160); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 || name.parent.kind === 161); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(name); + emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } if (isVariableDeclarationOrBindingElement) { @@ -26051,50 +26477,50 @@ var ts; write(")"); } } - function ensureIdentifier(expr) { - if (expr.kind !== 66) { - var identifier = createTempVariable(0); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expr); - expr = identifier; + function ensureIdentifier(expr, reuseIdentifierExpressions) { + if (expr.kind === 67 && reuseIdentifierExpressions) { + return expr; } - return expr; + var identifier = createTempVariable(0); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expr); + return identifier; } function createDefaultValueCheck(value, defaultValue) { - value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(178); + value = ensureIdentifier(value, true); + var equals = ts.createSynthesizedNode(179); equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(31); + equals.operatorToken = ts.createSynthesizedNode(32); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(179); + var cond = ts.createSynthesizedNode(180); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(51); + cond.questionToken = ts.createSynthesizedNode(52); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(52); + cond.colonToken = ts.createSynthesizedNode(53); cond.whenFalse = whenFalse; return cond; } function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(7); + var node = ts.createSynthesizedNode(8); node.text = "" + value; return node; } function createPropertyAccessForDestructuringProperty(object, propName) { var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 66) { + if (syntheticName.kind !== 67) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(165); - var sliceIdentifier = ts.createSynthesizedNode(66); + var call = ts.createSynthesizedNode(166); + var sliceIdentifier = ts.createSynthesizedNode(67); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -26104,11 +26530,11 @@ var ts; function emitObjectLiteralAssignment(target, value) { var properties = target.properties; if (properties.length !== 1) { - value = ensureIdentifier(value); + value = ensureIdentifier(value, true); } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 242 || p.kind === 243) { + if (p.kind === 243 || p.kind === 244) { var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -26117,12 +26543,12 @@ var ts; function emitArrayLiteralAssignment(target, value) { var elements = target.elements; if (elements.length !== 1) { - value = ensureIdentifier(value); + value = ensureIdentifier(value, true); } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184) { - if (e.kind !== 182) { + if (e.kind !== 185) { + if (e.kind !== 183) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -26132,14 +26558,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 178 && target.operatorToken.kind === 54) { + if (target.kind === 179 && target.operatorToken.kind === 55) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 162) { + if (target.kind === 163) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 161) { + else if (target.kind === 162) { emitArrayLiteralAssignment(target, value); } else { @@ -26149,18 +26575,21 @@ var ts; function emitAssignmentExpression(root) { var target = root.left; var value = root.right; - if (isAssignmentExpressionStatement) { + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 169) { + if (root.parent.kind !== 170) { write("("); } - value = ensureIdentifier(value); + value = ensureIdentifier(value, true); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 169) { + if (root.parent.kind !== 170) { write(")"); } } @@ -26175,20 +26604,21 @@ var ts; if (ts.isBindingPattern(target.name)) { var pattern = target.name; var elements = pattern.elements; - if (elements.length !== 1) { - value = ensureIdentifier(value); + var numElements = elements.length; + if (numElements !== 1) { + value = ensureIdentifier(value, numElements !== 0); } - for (var i = 0; i < elements.length; i++) { + for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (pattern.kind === 158) { + if (pattern.kind === 159) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 184) { + else if (element.kind !== 185) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } - else if (i === elements.length - 1) { + else if (i === numElements - 1) { emitBindingElement(element, createSliceCall(value, i)); } } @@ -26215,15 +26645,15 @@ var ts; var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && (getCombinedFlagsForIdentifier(node.name) & 16384); if (isUninitializedLet && - node.parent.parent.kind !== 197 && - node.parent.parent.kind !== 198) { + node.parent.parent.kind !== 198 && + node.parent.parent.kind !== 199) { initializer = createVoidZero(); } } var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); write("\", "); } emitModuleMemberName(node); @@ -26234,11 +26664,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 184) { + if (node.kind === 185) { return; } var name = node.name; - if (name.kind === 66) { + if (name.kind === 67) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -26246,7 +26676,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 208 && node.parent.kind !== 160)) { + if (!node.parent || (node.parent.kind !== 209 && node.parent.kind !== 161)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -26254,7 +26684,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1) && languageVersion >= 2 && - node.parent.kind === 245; + node.parent.kind === 246; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -26352,9 +26782,9 @@ var ts; emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -26373,7 +26803,7 @@ var ts; emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -26394,7 +26824,7 @@ var ts; increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -26403,36 +26833,39 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 142 ? "get " : "set "); + write(node.kind === 143 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 171 && languageVersion >= 2; + return node.kind === 172 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } else { write(getGeneratedNameForNode(node)); } } function shouldEmitFunctionName(node) { - if (node.kind === 170) { + if (node.kind === 171) { return !!node.name; } - if (node.kind === 210) { + if (node.kind === 211) { return !!node.name || languageVersion < 2; } } function emitFunctionDeclaration(node) { if (ts.nodeIsMissing(node.body)) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } - if (node.kind !== 140 && node.kind !== 139) { + if (node.kind !== 141 && node.kind !== 140 && + node.parent && node.parent.kind !== 243 && + node.parent.kind !== 166) { emitLeadingComments(node); } + emitStart(node); if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); @@ -26450,10 +26883,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 210 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 211 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 140 && node.kind !== 139) { + emitEnd(node); + if (node.kind !== 141 && node.kind !== 140) { emitTrailingComments(node); } } @@ -26485,7 +26919,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 171; + var isArrowFunction = node.kind === 172; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096) !== 0; var args; if (!isArrowFunction) { @@ -26528,7 +26962,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 189) { + if (node.body.kind === 190) { emitBlockFunctionBody(node, node.body); } else { @@ -26576,10 +27010,10 @@ var ts; } write(" "); var current = body; - while (current.kind === 168) { + while (current.kind === 169) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 162); + emitParenthesizedIf(body, current.kind === 163); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -26645,17 +27079,17 @@ var ts; emitLeadingCommentsOfPosition(body.statements.end); decreaseIndent(); } - emitToken(15, body.statements.end); + emitToken(16, body.statements.end); scopeEmitEnd(); } function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 192) { + if (statement && statement.kind === 193) { var expr = statement.expression; - if (expr && expr.kind === 165) { + if (expr && expr.kind === 166) { var func = expr.expression; - if (func && func.kind === 92) { + if (func && func.kind === 93) { return statement; } } @@ -26679,24 +27113,24 @@ var ts; }); } function emitMemberAccessForPropertyName(memberName) { - if (memberName.kind === 8 || memberName.kind === 7) { + if (memberName.kind === 9 || memberName.kind === 8) { write("["); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 133) { + else if (memberName.kind === 134) { emitComputedPropertyName(memberName); } else { write("."); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); } } function getInitializedProperties(node, isStatic) { var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 138 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 139 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { properties.push(member); } } @@ -26736,13 +27170,13 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 188) { + if (member.kind === 189) { writeLine(); write(";"); } - else if (member.kind === 140 || node.kind === 139) { + else if (member.kind === 141 || node.kind === 140) { if (!member.body) { - return emitOnlyPinnedOrTripleSlashComments(member); + return emitCommentsOnNotEmittedNode(member); } writeLine(); emitLeadingComments(member); @@ -26752,14 +27186,12 @@ var ts; emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); - emitStart(member); emitFunctionDeclaration(member); emitEnd(member); - emitEnd(member); write(";"); emitTrailingComments(member); } - else if (member.kind === 142 || member.kind === 143) { + else if (member.kind === 143 || member.kind === 144) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -26809,22 +27241,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 140 || node.kind === 139) && !member.body) { - emitOnlyPinnedOrTripleSlashComments(member); + if ((member.kind === 141 || node.kind === 140) && !member.body) { + emitCommentsOnNotEmittedNode(member); } - else if (member.kind === 140 || - member.kind === 142 || - member.kind === 143) { + else if (member.kind === 141 || + member.kind === 143 || + member.kind === 144) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128) { write("static "); } - if (member.kind === 142) { + if (member.kind === 143) { write("get "); } - else if (member.kind === 143) { + else if (member.kind === 144) { write("set "); } if (member.asteriskToken) { @@ -26835,7 +27267,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 188) { + else if (member.kind === 189) { writeLine(); write(";"); } @@ -26856,10 +27288,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 141 && !member.body) { - emitOnlyPinnedOrTripleSlashComments(member); + if (member.kind === 142 && !member.body) { + emitCommentsOnNotEmittedNode(member); } - if (member.kind === 138 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 139 && member.initializer && (member.flags & 128) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -26890,18 +27322,21 @@ var ts; } } } + var startIndex = 0; write(" {"); scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { + startIndex = emitDirectivePrologues(ctor.body.statements, true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); + var superCall; if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - var superCall = findInitialSuperCall(ctor); + superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); emit(superCall); @@ -26928,7 +27363,7 @@ var ts; if (superCall) { statements = statements.slice(1); } - emitLines(statements); + emitLinesStartingAt(statements, startIndex); } emitTempDeclarations(true); writeLine(); @@ -26936,7 +27371,7 @@ var ts; emitLeadingCommentsOfPosition(ctor.body.statements.end); } decreaseIndent(); - emitToken(15, ctor ? ctor.body.statements.end : node.members.end); + emitToken(16, ctor ? ctor.body.statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); if (ctor) { @@ -26959,7 +27394,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 211) { + if (node.kind === 212) { if (thisNodeIsDecorated) { if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { write("export "); @@ -26976,7 +27411,7 @@ var ts; } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 183; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -27003,7 +27438,7 @@ var ts; emitMemberFunctionsForES6AndHigher(node); decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); if (thisNodeIsDecorated) { write(";"); @@ -27043,7 +27478,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 211) { + if (node.kind === 212) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -27081,7 +27516,7 @@ var ts; writeLine(); emitDecoratorsOfClass(node); writeLine(); - emitToken(15, node.members.end, function () { + emitToken(16, node.members.end, function () { write("return "); emitDeclarationName(node); }); @@ -27093,7 +27528,7 @@ var ts; computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); @@ -27101,11 +27536,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 211) { + if (node.kind === 212) { write(";"); } emitEnd(node); - if (node.kind === 211) { + if (node.kind === 212) { emitExportMemberAssignment(node); } if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { @@ -27179,13 +27614,13 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 140) { + if (member.kind === 141) { functionLikeMember = member; } } writeLine(); emitStart(member); - if (member.kind !== 138) { + if (member.kind !== 139) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -27215,7 +27650,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 138) { + if (member.kind !== 139) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -27254,45 +27689,45 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 140: - case 142: + case 141: case 143: - case 138: + case 144: + case 139: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 140: + case 141: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 211: - case 140: - case 143: + case 212: + case 141: + case 144: return true; } return false; } function emitSerializedTypeOfNode(node) { switch (node.kind) { - case 211: + case 212: write("Function"); return; - case 138: + case 139: emitSerializedTypeNode(node.type); return; - case 135: - emitSerializedTypeNode(node.type); - return; - case 142: + case 136: emitSerializedTypeNode(node.type); return; case 143: + emitSerializedTypeNode(node.type); + return; + case 144: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -27303,53 +27738,60 @@ var ts; write("void 0"); } function emitSerializedTypeNode(node) { - switch (node.kind) { - case 100: - write("void 0"); - return; - case 157: - emitSerializedTypeNode(node.type); - return; - case 149: - case 150: - write("Function"); - return; - case 153: - case 154: - write("Array"); - return; - case 147: - case 117: - write("Boolean"); - return; - case 127: - case 8: - write("String"); - return; - case 125: - write("Number"); - return; - case 128: - write("Symbol"); - return; - case 148: - emitSerializedTypeReferenceNode(node); - return; - case 151: - case 152: - case 155: - case 156: - case 114: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; + if (node) { + switch (node.kind) { + case 101: + write("void 0"); + return; + case 158: + emitSerializedTypeNode(node.type); + return; + case 150: + case 151: + write("Function"); + return; + case 154: + case 155: + write("Array"); + return; + case 148: + case 118: + write("Boolean"); + return; + case 128: + case 9: + write("String"); + return; + case 126: + write("Number"); + return; + case 129: + write("Symbol"); + return; + case 149: + emitSerializedTypeReferenceNode(node); + return; + case 152: + case 153: + case 156: + case 157: + case 115: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } } write("Object"); } function emitSerializedTypeReferenceNode(node) { - var typeName = node.typeName; - var result = resolver.getTypeReferenceSerializationKind(node); + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); switch (result) { case ts.TypeReferenceSerializationKind.Unknown: var temp = createAndRecordTempVariable(0); @@ -27398,7 +27840,7 @@ var ts; function emitSerializedParameterTypesOfNode(node) { if (node) { var valueDeclaration; - if (node.kind === 211) { + if (node.kind === 212) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -27414,10 +27856,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 153) { + if (parameterType.kind === 154) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 148 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 149 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -27434,7 +27876,7 @@ var ts; } } function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { + if (node && ts.isFunctionLike(node) && node.type) { emitSerializedTypeNode(node.type); return; } @@ -27477,7 +27919,7 @@ var ts; return argumentsWritten; } function emitInterfaceDeclaration(node) { - emitOnlyPinnedOrTripleSlashComments(node); + emitCommentsOnNotEmittedNode(node); } function shouldEmitEnumDeclaration(node) { var isConstEnum = ts.isConst(node); @@ -27511,7 +27953,7 @@ var ts; emitLines(node.members); decreaseIndent(); writeLine(); - emitToken(15, node.members.end); + emitToken(16, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -27570,7 +28012,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 215) { + if (moduleDeclaration.body.kind === 216) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -27584,7 +28026,7 @@ var ts; function emitModuleDeclaration(node) { var shouldEmit = shouldEmitModuleDeclaration(node); if (!shouldEmit) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); @@ -27605,7 +28047,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 216) { + if (node.body.kind === 217) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -27624,7 +28066,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(15, moduleBlock.statements.end); + emitToken(16, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -27637,7 +28079,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 66 && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 67 && node.parent === currentSourceFile) { if (compilerOptions.module === 4 && (node.flags & 1)) { writeLine(); write(exportFunctionForFile + "(\""); @@ -27649,29 +28091,41 @@ var ts; emitExportMemberAssignments(node.name); } } + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } function emitRequire(moduleName) { - if (moduleName.kind === 8) { + if (moduleName.kind === 9) { write("require("); - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - emitToken(17, moduleName.end); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18, moduleName.end); } else { write("require()"); } } function getNamespaceDeclarationNode(node) { - if (node.kind === 218) { + if (node.kind === 219) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 221) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 219 && node.importClause && !!node.importClause.name; + return node.kind === 220 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -27698,7 +28152,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 221) { + if (node.importClause.namedBindings.kind === 222) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -27724,7 +28178,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 218 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 219 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); @@ -27736,7 +28190,7 @@ var ts; write(" = "); } else { - var isNakedImport = 219 && !node.importClause; + var isNakedImport = 220 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -27782,16 +28236,29 @@ var ts; (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); + var variableDeclarationIsHoisted = shouldHoistVariable(node, true); + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1)) { + write("var "); + } } - else if (!(node.flags & 1)) { - write("var "); + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); + if (isExported) { + write(")"); + } write(";"); emitEnd(node); emitExportImportAssignments(node); @@ -27819,11 +28286,11 @@ var ts; emitStart(specifier); emitContainingModuleName(specifier); write("."); - emitNodeWithoutSourceMap(specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); write(" = "); write(generatedName); write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); write(";"); emitEnd(specifier); } @@ -27845,7 +28312,6 @@ var ts; } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { write("{ "); @@ -27857,10 +28323,9 @@ var ts; } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -27873,13 +28338,11 @@ var ts; if (needsComma) { write(", "); } - emitStart(specifier); if (specifier.propertyName) { - emitNodeWithoutSourceMap(specifier.propertyName); + emit(specifier.propertyName); write(" as "); } - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier); + emit(specifier.name); needsComma = true; } } @@ -27892,8 +28355,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 210 && - expression.kind !== 211) { + if (expression.kind !== 211 && + expression.kind !== 212) { write(";"); } emitEnd(node); @@ -27907,6 +28370,7 @@ var ts; write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0) { write("[\"default\"] = "); @@ -27929,18 +28393,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 219: + case 220: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 218: - if (node.moduleReference.kind === 229 && resolver.isReferencedAliasDeclaration(node)) { + case 219: + if (node.moduleReference.kind === 230 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 225: + case 226: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -27958,7 +28422,7 @@ var ts; } } break; - case 224: + case 225: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -27983,17 +28447,17 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 219 && node.importClause) { + if (node.kind === 220 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 225 && node.moduleSpecifier) { + if (node.kind === 226 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8) { - return getLiteralText(moduleName); + if (moduleName.kind === 9) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); } return undefined; } @@ -28005,8 +28469,8 @@ var ts; var started = false; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; - var skipNode = importNode.kind === 225 || - (importNode.kind === 219 && !importNode.importClause); + var skipNode = importNode.kind === 226 || + (importNode.kind === 220 && !importNode.importClause); if (skipNode) { continue; } @@ -28031,7 +28495,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 225 && externalImport.exportClause) { + if (externalImport.kind === 226 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -28060,7 +28524,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 225) { + if (externalImport.kind !== 226) { continue; } var exportDecl = externalImport; @@ -28082,6 +28546,8 @@ var ts; write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); + write("var exports = {};"); + writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); @@ -28089,17 +28555,19 @@ var ts; if (localNames) { write("&& !" + localNames + ".hasOwnProperty(n)"); } - write(") " + exportFunctionForFile + "(n, m[n]);"); + write(") exports[n] = m[n];"); decreaseIndent(); writeLine(); write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); decreaseIndent(); writeLine(); write("}"); return exportStarFunction; } function writeExportedName(node) { - if (node.kind !== 66 && node.flags & 1024) { + if (node.kind !== 67 && node.flags & 1024) { return; } if (started) { @@ -28110,8 +28578,8 @@ var ts; } writeLine(); write("'"); - if (node.kind === 66) { - emitNodeWithoutSourceMap(node); + if (node.kind === 67) { + emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); @@ -28130,7 +28598,7 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_26 = local.kind === 66 + var name_26 = local.kind === 67 ? local : local.name; if (name_26) { @@ -28145,13 +28613,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 211 || local.kind === 215 || local.kind === 214) { + if (local.kind === 212 || local.kind === 216 || local.kind === 215) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 66 ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 67 ? local.parent : local); if (flags & 1) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -28179,21 +28647,21 @@ var ts; if (node.flags & 2) { return; } - if (node.kind === 210) { + if (node.kind === 211) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 211) { + if (node.kind === 212) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 214) { + if (node.kind === 215) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -28202,7 +28670,7 @@ var ts; } return; } - if (node.kind === 215) { + if (node.kind === 216) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -28211,10 +28679,10 @@ var ts; } return; } - if (node.kind === 208 || node.kind === 160) { + if (node.kind === 209 || node.kind === 161) { if (shouldHoistVariable(node, false)) { var name_27 = node.name; - if (name_27.kind === 66) { + if (name_27.kind === 67) { if (!hoistedVars) { hoistedVars = []; } @@ -28226,6 +28694,13 @@ var ts; } return; } + if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } if (ts.isBindingPattern(node)) { ts.forEach(node.elements, visit); return; @@ -28240,12 +28715,12 @@ var ts; return false; } return (ts.getCombinedNodeFlags(node) & 49152) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 245; + ts.getEnclosingBlockScopeContainer(node).kind === 246; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); } - function emitSystemModuleBody(node, startIndex) { + function emitSystemModuleBody(node, dependencyGroups, startIndex) { emitVariableDeclarationsForImports(); writeLine(); var exportedDeclarations = processTopLevelVariableAndFunctionDeclarations(node); @@ -28254,7 +28729,7 @@ var ts; write("return {"); increaseIndent(); writeLine(); - emitSetters(exportStarFunction); + emitSetters(exportStarFunction, dependencyGroups); writeLine(); emitExecute(node, startIndex); decreaseIndent(); @@ -28262,75 +28737,64 @@ var ts; write("}"); emitTempDeclarations(true); } - function emitSetters(exportStarFunction) { + function emitSetters(exportStarFunction, dependencyGroups) { write("setters:["); - for (var i = 0; i < externalImports.length; ++i) { + for (var i = 0; i < dependencyGroups.length; ++i) { if (i !== 0) { write(","); } writeLine(); increaseIndent(); - var importNode = externalImports[i]; - var importVariableName = getLocalNameForExternalImport(importNode) || ""; - var parameterName = "_" + importVariableName; + var group = dependencyGroups[i]; + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); - switch (importNode.kind) { - case 219: - if (!importNode.importClause) { - break; - } - case 218: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - writeLine(); - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - var defaultName = importNode.kind === 219 - ? importNode.importClause.name - : importNode.name; - if (defaultName) { - emitExportMemberAssignments(defaultName); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 220: + if (!entry.importClause) { + break; + } + case 219: + ts.Debug.assert(importVariableName !== ""); writeLine(); - } - if (importNode.kind === 219 && - importNode.importClause.namedBindings) { - var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 221) { - emitExportMemberAssignments(namedBindings.name); + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 226: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); } else { - for (var _a = 0, _b = namedBindings.elements; _a < _b.length; _a++) { - var element = _b[_a]; - emitExportMemberAssignments(element.name || element.propertyName); - writeLine(); - } - } - } - decreaseIndent(); - break; - case 225: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - if (importNode.exportClause) { - for (var _c = 0, _d = importNode.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; writeLine(); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(e.name); - write("\", " + parameterName + "[\""); - emitNodeWithoutSourceMap(e.propertyName || e.name); - write("\"]);"); + write(exportStarFunction + "(" + parameterName + ");"); } - } - else { writeLine(); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - decreaseIndent(); - break; + break; + } } + decreaseIndent(); write("}"); decreaseIndent(); } @@ -28343,14 +28807,25 @@ var ts; for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; switch (statement.kind) { - case 225: - case 219: - case 218: - case 210: + case 211: + case 220: continue; + case 226: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 219: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + continue; + } + default: + writeLine(); + emit(statement); } - writeLine(); - emit(statement); } decreaseIndent(); writeLine(); @@ -28366,8 +28841,19 @@ var ts; write("\"" + node.moduleName + "\", "); } write("["); + var groupIndices = {}; + var dependencyGroups = []; for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } if (i !== 0) { write(", "); } @@ -28376,24 +28862,14 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); + emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); } function emitAMDDependencies(node, includeNonAmdDependencies) { - // An AMD define function has the following shape: - // define(id?, dependencies?, factory); - // - // This has the shape of - // define(name, ["module1", "module2"], function (module1Alias) { - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // `import "module"` or `` - // we need to add modules without alias names to the end of the dependencies list var aliasedModuleNames = []; var unaliasedModuleNames = []; var importAliasNames = []; @@ -28435,6 +28911,7 @@ var ts; } } function emitAMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); write("define("); @@ -28454,6 +28931,7 @@ var ts; write("});"); } function emitCommonJSModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); @@ -28462,6 +28940,7 @@ var ts; emitExportEquals(false); } function emitUMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); emitAMDDependencies(node, false); @@ -28481,6 +28960,7 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); @@ -28506,9 +28986,9 @@ var ts; break; } } - function trimReactWhitespace(node) { + function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; - var text = ts.getTextOfNode(node); + var text = ts.getTextOfNode(node, true); var firstNonWhitespace = 0; var lastNonWhitespace = -1; for (var i = 0; i < text.length; i++) { @@ -28516,7 +28996,7 @@ var ts; if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; } firstNonWhitespace = -1; } @@ -28529,15 +29009,25 @@ var ts; } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; + } + if (result) { + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); } return result; } function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2: - var text = trimReactWhitespace(node); - if (text.length === 0) { + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { return undefined; } else { @@ -28551,13 +29041,13 @@ var ts; function emitJsxText(node) { switch (compilerOptions.jsx) { case 2: - write('"'); - write(trimReactWhitespace(node)); - write('"'); + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); break; case 1: default: - write(ts.getTextOfNode(node, true)); + writer.writeLiteral(ts.getTextOfNode(node, true)); break; } } @@ -28566,9 +29056,9 @@ var ts; switch (compilerOptions.jsx) { case 1: default: - write('{'); + write("{"); emit(node.expression); - write('}'); + write("}"); break; case 2: emit(node.expression); @@ -28600,10 +29090,7 @@ var ts; } } } - function emitSourceFileNode(node) { - writeLine(); - emitDetachedComments(node); - var startIndex = emitDirectivePrologues(node.statements, false); + function emitEmitHelpers(node) { if (!compilerOptions.noEmitHelpers) { if ((languageVersion < 2) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8)) { writeLines(extendsHelper); @@ -28625,6 +29112,12 @@ var ts; awaiterEmitted = true; } } + } + function emitSourceFileNode(node) { + writeLine(); + emitShebang(); + emitDetachedComments(node); + var startIndex = emitDirectivePrologues(node.statements, false); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2) { emitES6Module(node, startIndex); @@ -28647,47 +29140,63 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); } emitLeadingComments(node.endOfFileToken); } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2) { + return emitCommentsOnNotEmittedNode(node); + } + if (isSpecializedCommentHandling(node)) { + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } function emitNodeWithoutSourceMap(node) { - if (!node) { - return; + if (node) { + emitJavaScriptWorker(node); } - if (node.flags & 2) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - var emitComments = shouldEmitLeadingAndTrailingComments(node); - if (emitComments) { - emitLeadingComments(node); - } - emitJavaScriptWorker(node); - if (emitComments) { - emitTrailingComments(node); + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + case 213: + case 211: + case 220: + case 219: + case 214: + case 225: + return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 212: - case 210: - case 219: - case 218: - case 213: - case 224: - return false; - case 190: + case 191: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 215: + case 216: return shouldEmitModuleDeclaration(node); - case 214: + case 215: return shouldEmitEnumDeclaration(node); } - if (node.kind !== 189 && + ts.Debug.assert(!isSpecializedCommentHandling(node)); + if (node.kind !== 190 && node.parent && - node.parent.kind === 171 && + node.parent.kind === 172 && node.parent.body === node && compilerOptions.target <= 1) { return false; @@ -28696,170 +29205,170 @@ var ts; } function emitJavaScriptWorker(node) { switch (node.kind) { - case 66: + case 67: return emitIdentifier(node); - case 135: + case 136: return emitParameter(node); + case 141: case 140: - case 139: return emitMethod(node); - case 142: case 143: + case 144: return emitAccessor(node); - case 94: + case 95: return emitThis(node); - case 92: + case 93: return emitSuper(node); - case 90: + case 91: return write("null"); - case 96: + case 97: return write("true"); - case 81: + case 82: return write("false"); - case 7: case 8: case 9: case 10: case 11: case 12: case 13: + case 14: return emitLiteral(node); - case 180: - return emitTemplateExpression(node); - case 187: - return emitTemplateSpan(node); - case 230: - case 231: - return emitJsxElement(node); - case 233: - return emitJsxText(node); - case 237: - return emitJsxExpression(node); - case 132: - return emitQualifiedName(node); - case 158: - return emitObjectBindingPattern(node); - case 159: - return emitArrayBindingPattern(node); - case 160: - return emitBindingElement(node); - case 161: - return emitArrayLiteral(node); - case 162: - return emitObjectLiteral(node); - case 242: - return emitPropertyAssignment(node); - case 243: - return emitShorthandPropertyAssignment(node); - case 133: - return emitComputedPropertyName(node); - case 163: - return emitPropertyAccess(node); - case 164: - return emitIndexedAccess(node); - case 165: - return emitCallExpression(node); - case 166: - return emitNewExpression(node); - case 167: - return emitTaggedTemplateExpression(node); - case 168: - return emit(node.expression); - case 186: - return emit(node.expression); - case 169: - return emitParenExpression(node); - case 210: - case 170: - case 171: - return emitFunctionDeclaration(node); - case 172: - return emitDeleteExpression(node); - case 173: - return emitTypeOfExpression(node); - case 174: - return emitVoidExpression(node); - case 175: - return emitAwaitExpression(node); - case 176: - return emitPrefixUnaryExpression(node); - case 177: - return emitPostfixUnaryExpression(node); - case 178: - return emitBinaryExpression(node); - case 179: - return emitConditionalExpression(node); - case 182: - return emitSpreadElementExpression(node); case 181: - return emitYieldExpression(node); - case 184: - return; - case 189: - case 216: - return emitBlock(node); - case 190: - return emitVariableStatement(node); - case 191: - return write(";"); - case 192: - return emitExpressionStatement(node); - case 193: - return emitIfStatement(node); - case 194: - return emitDoStatement(node); - case 195: - return emitWhileStatement(node); - case 196: - return emitForStatement(node); - case 198: - case 197: - return emitForInOrForOfStatement(node); - case 199: - case 200: - return emitBreakOrContinueStatement(node); - case 201: - return emitReturnStatement(node); - case 202: - return emitWithStatement(node); - case 203: - return emitSwitchStatement(node); + return emitTemplateExpression(node); + case 188: + return emitTemplateSpan(node); + case 231: + case 232: + return emitJsxElement(node); + case 234: + return emitJsxText(node); case 238: - case 239: - return emitCaseOrDefaultClause(node); - case 204: - return emitLabelledStatement(node); - case 205: - return emitThrowStatement(node); - case 206: - return emitTryStatement(node); - case 241: - return emitCatchClause(node); - case 207: - return emitDebuggerStatement(node); - case 208: - return emitVariableDeclaration(node); - case 183: - return emitClassExpression(node); - case 211: - return emitClassDeclaration(node); - case 212: - return emitInterfaceDeclaration(node); - case 214: - return emitEnumDeclaration(node); + return emitJsxExpression(node); + case 133: + return emitQualifiedName(node); + case 159: + return emitObjectBindingPattern(node); + case 160: + return emitArrayBindingPattern(node); + case 161: + return emitBindingElement(node); + case 162: + return emitArrayLiteral(node); + case 163: + return emitObjectLiteral(node); + case 243: + return emitPropertyAssignment(node); case 244: - return emitEnumMember(node); + return emitShorthandPropertyAssignment(node); + case 134: + return emitComputedPropertyName(node); + case 164: + return emitPropertyAccess(node); + case 165: + return emitIndexedAccess(node); + case 166: + return emitCallExpression(node); + case 167: + return emitNewExpression(node); + case 168: + return emitTaggedTemplateExpression(node); + case 169: + return emit(node.expression); + case 187: + return emit(node.expression); + case 170: + return emitParenExpression(node); + case 211: + case 171: + case 172: + return emitFunctionDeclaration(node); + case 173: + return emitDeleteExpression(node); + case 174: + return emitTypeOfExpression(node); + case 175: + return emitVoidExpression(node); + case 176: + return emitAwaitExpression(node); + case 177: + return emitPrefixUnaryExpression(node); + case 178: + return emitPostfixUnaryExpression(node); + case 179: + return emitBinaryExpression(node); + case 180: + return emitConditionalExpression(node); + case 183: + return emitSpreadElementExpression(node); + case 182: + return emitYieldExpression(node); + case 185: + return; + case 190: + case 217: + return emitBlock(node); + case 191: + return emitVariableStatement(node); + case 192: + return write(";"); + case 193: + return emitExpressionStatement(node); + case 194: + return emitIfStatement(node); + case 195: + return emitDoStatement(node); + case 196: + return emitWhileStatement(node); + case 197: + return emitForStatement(node); + case 199: + case 198: + return emitForInOrForOfStatement(node); + case 200: + case 201: + return emitBreakOrContinueStatement(node); + case 202: + return emitReturnStatement(node); + case 203: + return emitWithStatement(node); + case 204: + return emitSwitchStatement(node); + case 239: + case 240: + return emitCaseOrDefaultClause(node); + case 205: + return emitLabelledStatement(node); + case 206: + return emitThrowStatement(node); + case 207: + return emitTryStatement(node); + case 242: + return emitCatchClause(node); + case 208: + return emitDebuggerStatement(node); + case 209: + return emitVariableDeclaration(node); + case 184: + return emitClassExpression(node); + case 212: + return emitClassDeclaration(node); + case 213: + return emitInterfaceDeclaration(node); case 215: - return emitModuleDeclaration(node); - case 219: - return emitImportDeclaration(node); - case 218: - return emitImportEqualsDeclaration(node); - case 225: - return emitExportDeclaration(node); - case 224: - return emitExportAssignment(node); + return emitEnumDeclaration(node); case 245: + return emitEnumMember(node); + case 216: + return emitModuleDeclaration(node); + case 220: + return emitImportDeclaration(node); + case 219: + return emitImportEqualsDeclaration(node); + case 226: + return emitExportDeclaration(node); + case 225: + return emitExportAssignment(node); + case 246: return emitSourceFileNode(node); } } @@ -28876,18 +29385,24 @@ var ts; } return leadingComments; } - function filterComments(ranges, onlyPinnedOrTripleSlashComments) { - if (ranges && onlyPinnedOrTripleSlashComments) { - ranges = ts.filter(ranges, isPinnedOrTripleSlashComment); - if (ranges.length === 0) { - return undefined; - } + function isPinnedComments(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + function isTripleSlashComment(comment) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) { + var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? + true : false; } - return ranges; + return false; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 245 || node.pos !== node.parent.pos) { + if (node.parent.kind === 246 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -28899,27 +29414,51 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 245 || node.end !== node.parent.end) { + if (node.parent.kind === 246 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } } - function emitOnlyPinnedOrTripleSlashComments(node) { - emitLeadingCommentsWorker(node, true); + function emitCommentsOnNotEmittedNode(node) { + emitLeadingCommentsWorker(node, false); } function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, compilerOptions.removeComments); + return emitLeadingCommentsWorker(node, true); } - function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) { - var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); + function emitLeadingCommentsWorker(node, isEmittedNode) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + if (node.pos === 0) { + leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); + } + } ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } function emitTrailingComments(node) { - var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); + if (compilerOptions.removeComments) { + return; + } + var trailingComments = getTrailingCommentsToEmit(node); ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); } - function emitLeadingCommentsOfPosition(pos) { + function emitTrailingCommentsOfPosition(pos) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); + ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment); + } + function emitLeadingCommentsOfPositionWorker(pos) { + if (compilerOptions.removeComments) { + return; + } var leadingComments; if (hasDetachedComments(pos)) { leadingComments = getLeadingCommentsWithoutDetachedComments(); @@ -28927,12 +29466,19 @@ var ts; else { leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); } - leadingComments = filterComments(leadingComments, compilerOptions.removeComments); ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } function emitDetachedComments(node) { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + var leadingComments; + if (compilerOptions.removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } if (leadingComments) { var detachedComments = []; var lastComment; @@ -28964,15 +29510,10 @@ var ts; } } } - function isPinnedOrTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } - else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 && - currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { - return true; + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); } } } @@ -28984,16 +29525,270 @@ var ts; } } ts.emitFiles = emitFiles; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { ts.programTime = 0; ts.emitTime = 0; ts.ioReadTime = 0; ts.ioWriteTime = 0; - ts.version = "1.5.3"; + var emptyArray = []; + ts.version = "1.7.0"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -29010,6 +29805,155 @@ var ts; return undefined; } ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === 1 ? 2 : 1; + switch (moduleResolution) { + case 2: return nodeModuleNameResolver(moduleName, containingFile, host); + case 1: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + ts.resolveModuleName = resolveModuleName; + function nodeModuleNameResolver(moduleName, containingFile, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + var failedLookupLocations = []; + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolvedFileName = loadNodeModuleFromFile(candidate, false, failedLookupLocations, host); + if (resolvedFileName) { + return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; + } + resolvedFileName = loadNodeModuleFromDirectory(candidate, false, failedLookupLocations, host); + return resolvedFileName + ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { + if (loadOnlyDts) { + return tryLoad(".d.ts"); + } + else { + return ts.forEach(ts.supportedExtensions, tryLoad); + } + function tryLoad(ext) { + var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + var packageJsonPath = ts.combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + var jsonContent; + try { + var jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + jsonContent = { typings: undefined }; + } + if (jsonContent.typings) { + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + failedLookupLocation.push(packageJsonPath); + } + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + } + function loadModuleFromNodeModules(moduleName, directory, host) { + var failedLookupLocations = []; + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var result = loadNodeModuleFromFile(candidate, true, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + } + result = loadNodeModuleFromDirectory(candidate, true, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + directory = parentPath; + } + return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + function nameStartsWithDotSlashOrDotDotSlash(name) { + var i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === 46); + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + if (moduleName.indexOf('!') != -1) { + return { resolvedModule: undefined, failedLookupLocations: [] }; + } + var searchPath = ts.getDirectoryPath(containingFile); + var searchName; + var failedLookupLocations = []; + var referencedSourceFile; + while (true) { + searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); + referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + if (extension === ".tsx" && !compilerOptions.jsx) { + return undefined; + } + var candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + if (referencedSourceFile) { + break; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + ts.defaultInitCompilerOptions = { + module: 1, + target: 0, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false + }; function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; @@ -29072,7 +30016,9 @@ var ts; getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); } }; } ts.createCompilerHost = createCompilerHost; @@ -29107,10 +30053,11 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function createProgram(rootNames, options, host) { + function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; - var diagnostics = ts.createDiagnosticCollection(); + var fileProcessingDiagnostics = ts.createDiagnosticCollection(); + var programDiagnostics = ts.createDiagnosticCollection(); var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; @@ -29118,14 +30065,31 @@ var ts; var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var resolveModuleNamesWorker = host.resolveModuleNames + ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) + : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); + if (oldProgram) { + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } } verifyCompilerOptions(); + oldProgram = undefined; ts.programTime += new Date().getTime() - start; program = { + getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, @@ -29143,7 +30107,8 @@ var ts; getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, - getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); } + getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, + getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; } }; return program; function getClassifiableNames() { @@ -29157,6 +30122,71 @@ var ts; } return classifiableNames; } + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; + } + ts.Debug.assert(!oldProgram.structureIsReused); + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + var newSourceFiles = []; + var modifiedSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + return false; + } + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + return false; + } + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + return false; + } + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); + for (var i = 0; i < moduleNames.length; ++i) { + var newResolution = resolutions[i]; + var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]); + var resolutionChanged = oldResolution + ? !newResolution || + oldResolution.resolvedFileName !== newResolution.resolvedFileName || + !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport + : newResolution; + if (resolutionChanged) { + return false; + } + } + } + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + modifiedSourceFiles.push(newSourceFile); + } + else { + newSourceFile = oldSourceFile; + } + newSourceFiles.push(newSourceFile); + } + for (var _b = 0; _b < newSourceFiles.length; _b++) { + var file = newSourceFiles[_b]; + filesByName.set(file.fileName, file); + } + files = newSourceFiles; + fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); + for (var _c = 0; _c < modifiedSourceFiles.length; _c++) { + var modifiedFile = modifiedSourceFiles[_c]; + fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + } + oldProgram.structureIsReused = true; + return true; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -29183,7 +30213,7 @@ var ts; if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); var start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); ts.emitTime += new Date().getTime() - start; @@ -29235,8 +30265,9 @@ var ts; ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); - var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); + var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); + var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); + return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); }); } function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { @@ -29250,7 +30281,8 @@ var ts; } function getOptionsDiagnostics() { var allDiagnostics = []; - ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function getGlobalDiagnostics() { @@ -29264,14 +30296,51 @@ var ts; function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var start; - var length; - var diagnosticArgument; - if (refEnd !== undefined && refPos !== undefined) { - start = refPos; - length = refEnd - refPos; + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; } + var imports; + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 220: + case 219: + case 226: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9) { + break; + } + if (!moduleNameExpr.text) { + break; + } + (imports || (imports = [])).push(moduleNameExpr); + break; + case 216: + if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { + ts.forEachChild(node.body, function (node) { + if (ts.isExternalModuleImportEqualsDeclaration(node) && + ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9) { + var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); + if (moduleName) { + (imports || (imports = [])).push(moduleName); + } + } + }); + } + break; + } + } + file.imports = imports || emptyArray; + } + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { @@ -29302,15 +30371,15 @@ var ts; } } if (diagnostic) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, start, length, diagnostic].concat(diagnosticArgument))); + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); } else { - diagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); } } } - function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { + function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); if (filesByName.contains(canonicalName)) { return getSourceFileFromCache(fileName, canonicalName, false); @@ -29322,22 +30391,22 @@ var ts; return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); } var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } else { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); filesByName.set(canonicalName, file); if (file) { skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; filesByName.set(canonicalAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); - processImportedModules(file, basePath); } + processImportedModules(file, basePath); if (isDefaultLib) { file.isDefaultLib = true; files.unshift(file); @@ -29353,7 +30422,12 @@ var ts; if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } } } return file; @@ -29361,49 +30435,44 @@ var ts; } function processReferencedFiles(file, basePath) { ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = ts.isRootedDiskPath(ref.fileName) ? ref.fileName : ts.combinePaths(basePath, ref.fileName); - processSourceFile(ts.normalizePath(referencedFileName), false, file, ref.pos, ref.end); + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, false, file, ref.pos, ref.end); }); } function processImportedModules(file, basePath) { - ts.forEach(file.statements, function (node) { - if (node.kind === 219 || node.kind === 218 || node.kind === 225) { - var moduleNameExpr = ts.getExternalModuleName(node); - if (moduleNameExpr && moduleNameExpr.kind === 8) { - var moduleNameText = moduleNameExpr.text; - if (moduleNameText) { - var searchPath = basePath; - var searchName; - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleNameText)); - if (ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, moduleNameExpr); })) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); + for (var i = 0; i < file.imports.length; ++i) { + var resolution = resolutions[i]; + ts.setResolvedModule(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + var importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]); + if (importedFile && resolution.isExternalLibraryImport) { + if (!ts.isExternalModule(importedFile)) { + var start_2 = ts.getTokenPosOfNode(file.imports[i], file); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.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 (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) { + var start_3 = ts.getTokenPosOfNode(file.imports[i], file); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_3, file.imports[i].end - start_3, ts.Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition)); + } + else if (importedFile.referencedFiles.length) { + var firstRef = importedFile.referencedFiles[0]; + fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); } } } } - else if (node.kind === 215 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { - ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8) { - var nameLiteral = ts.getExternalModuleImportEqualsDeclarationExpression(node); - var moduleName = nameLiteral.text; - if (moduleName) { - var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); - ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, nameLiteral); }); - } - } - }); - } - }); + } + else { + file.resolvedModules = undefined; + } + return; function findModuleSourceFile(fileName, nameLiteral) { - return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); + return findSourceFile(fileName, false, file, ts.skipTrivia(file.text, nameLiteral.pos), nameLiteral.end); } } function computeCommonSourceDirectory(sourceFiles) { @@ -29422,7 +30491,7 @@ var ts; for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { if (commonPathComponents[i] !== sourcePathComponents[i]) { if (i === 0) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); return; } commonPathComponents.length = i; @@ -29445,7 +30514,7 @@ var ts; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); allFilesBelongToPath = false; } } @@ -29455,67 +30524,71 @@ var ts; } function verifyCompilerOptions() { if (options.isolatedModules) { - if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); - } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); } if (options.noEmitOnError) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); } if (options.out) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); } } if (options.inlineSourceMap) { if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); } if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); } } if (options.inlineSources) { if (!options.sourceMap && !options.inlineSourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); } } + if (options.out && options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); } return; } var languageVersion = options.target || 0; + var outFile = options.outFile || options.out; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (options.isolatedModules) { if (!options.module && languageVersion < 2) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); } var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); + programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } else if (firstExternalModuleSourceFile && languageVersion < 2 && !options.module) { var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); + programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } if (options.module && languageVersion >= 2) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); } if (options.outDir || options.sourceRoot || (options.mapRoot && - (!options.out || firstExternalModuleSourceFile !== undefined))) { + (!outFile || firstExternalModuleSourceFile !== undefined))) { if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); } @@ -29527,28 +30600,31 @@ var ts; } } if (options.noEmit) { - if (options.out || options.outDir) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir)); + if (options.out) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + if (options.outDir) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); } } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.experimentalAsyncFunctions && options.target !== 2) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); } } } ts.createProgram = createProgram; })(ts || (ts = {})); -// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. -// See LICENSE.txt in the project root for complete license information. -/// var ts; (function (ts) { var BreakpointResolver; @@ -29587,128 +30663,128 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 194) { + if (node.parent.kind === 195) { return spanInPreviousNode(node); } - if (node.parent.kind === 196) { + if (node.parent.kind === 197) { return textSpan(node); } - if (node.parent.kind === 178 && node.parent.operatorToken.kind === 23) { + if (node.parent.kind === 179 && node.parent.operatorToken.kind === 24) { return textSpan(node); } - if (node.parent.kind === 171 && node.parent.body === node) { + if (node.parent.kind === 172 && node.parent.body === node) { return textSpan(node); } } switch (node.kind) { - case 190: + case 191: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 208: - case 138: - case 137: - return spanInVariableDeclaration(node); - case 135: - return spanInParameterDeclaration(node); - case 210: - case 140: + case 209: case 139: - case 142: - case 143: + case 138: + return spanInVariableDeclaration(node); + case 136: + return spanInParameterDeclaration(node); + case 211: case 141: - case 170: + case 140: + case 143: + case 144: + case 142: case 171: + case 172: return spanInFunctionDeclaration(node); - case 189: + case 190: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 216: + case 217: return spanInBlock(node); - case 241: + case 242: return spanInBlock(node.block); - case 192: - return textSpan(node.expression); - case 201: - return textSpan(node.getChildAt(0), node.expression); - case 195: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 194: - return spanInNode(node.statement); - case 207: - return textSpan(node.getChildAt(0)); case 193: + return textSpan(node.expression); + case 202: + return textSpan(node.getChildAt(0), node.expression); + case 196: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 195: + return spanInNode(node.statement); + case 208: + return textSpan(node.getChildAt(0)); + case 194: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 205: + return spanInNode(node.statement); + case 201: + case 200: + return textSpan(node.getChildAt(0), node.label); + case 197: + return spanInForStatement(node); + case 198: + case 199: return textSpan(node, ts.findNextToken(node.expression, node)); case 204: - return spanInNode(node.statement); - case 200: - case 199: - return textSpan(node.getChildAt(0), node.label); - case 196: - return spanInForStatement(node); - case 197: - case 198: return textSpan(node, ts.findNextToken(node.expression, node)); - case 203: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 238: case 239: + case 240: return spanInNode(node.statements[0]); - case 206: + case 207: return spanInBlock(node.tryBlock); - case 205: + case 206: return textSpan(node, node.expression); - case 224: - return textSpan(node, node.expression); - case 218: - return textSpan(node, node.moduleReference); - case 219: - return textSpan(node, node.moduleSpecifier); case 225: + return textSpan(node, node.expression); + case 219: + return textSpan(node, node.moduleReference); + case 220: return textSpan(node, node.moduleSpecifier); - case 215: + case 226: + return textSpan(node, node.moduleSpecifier); + case 216: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 211: - case 214: - case 244: - case 165: - case 166: - return textSpan(node); - case 202: - return spanInNode(node.statement); case 212: + case 215: + case 245: + case 166: + case 167: + return textSpan(node); + case 203: + return spanInNode(node.statement); case 213: + case 214: return undefined; - case 22: + case 23: case 1: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 23: - return spanInPreviousNode(node); - case 14: - return spanInOpenBraceToken(node); - case 15: - return spanInCloseBraceToken(node); - case 16: - return spanInOpenParenToken(node); - case 17: - return spanInCloseParenToken(node); - case 52: - return spanInColonToken(node); - case 26: case 24: + return spanInPreviousNode(node); + case 15: + return spanInOpenBraceToken(node); + case 16: + return spanInCloseBraceToken(node); + case 17: + return spanInOpenParenToken(node); + case 18: + return spanInCloseParenToken(node); + case 53: + return spanInColonToken(node); + case 27: + case 25: return spanInGreaterThanOrLessThanToken(node); - case 101: + case 102: return spanInWhileKeyword(node); - case 77: - case 69: - case 82: + case 78: + case 70: + case 83: return spanInNextNode(node); default: - if (node.parent.kind === 242 && node.parent.name === node) { + if (node.parent.kind === 243 && node.parent.name === node) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 168 && node.parent.type === node) { + if (node.parent.kind === 169 && node.parent.type === node) { return spanInNode(node.parent.expression); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { @@ -29718,12 +30794,12 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 197 || - variableDeclaration.parent.parent.kind === 198) { + if (variableDeclaration.parent.parent.kind === 198 || + variableDeclaration.parent.parent.kind === 199) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 190; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 196 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -29769,7 +30845,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1) || - (functionDeclaration.parent.kind === 211 && functionDeclaration.kind !== 141); + (functionDeclaration.parent.kind === 212 && functionDeclaration.kind !== 142); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -29789,23 +30865,23 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 215: + case 216: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 195: - case 193: - case 197: - case 198: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 196: + case 194: + case 198: + case 199: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 197: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 209) { + if (forStatement.initializer.kind === 210) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -29824,34 +30900,34 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 214: + case 215: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 211: + case 212: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 217: + case 218: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 216: + case 217: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 214: - case 211: + case 215: + case 212: return textSpan(node); - case 189: + case 190: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 241: + case 242: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 217: + case 218: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { @@ -29863,24 +30939,24 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 194) { + if (node.parent.kind === 195) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 170: - case 210: case 171: - case 140: - case 139: - case 142: - case 143: + case 211: + case 172: case 141: - case 195: - case 194: + case 140: + case 143: + case 144: + case 142: case 196: + case 195: + case 197: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -29888,19 +30964,19 @@ var ts; return spanInNode(node.parent); } function spanInColonToken(node) { - if (ts.isFunctionLike(node.parent) || node.parent.kind === 242) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 243) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 168) { + if (node.parent.kind === 169) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 194) { + if (node.parent.kind === 195) { return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } return spanInNode(node.parent); @@ -29978,7 +31054,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 171; + return ts.isFunctionBlock(node) && node.parent.kind !== 172; } var depth = 0; var maxDepth = 20; @@ -29990,30 +31066,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 189: + case 190: if (!ts.isFunctionBlock(n)) { - var parent_8 = n.parent; - var openBrace = ts.findChildOfKind(n, 14, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15, sourceFile); - if (parent_8.kind === 194 || - parent_8.kind === 197 || - parent_8.kind === 198 || - parent_8.kind === 196 || - parent_8.kind === 193 || - parent_8.kind === 195 || - parent_8.kind === 202 || - parent_8.kind === 241) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + var parent_7 = n.parent; + var openBrace = ts.findChildOfKind(n, 15, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16, sourceFile); + if (parent_7.kind === 195 || + parent_7.kind === 198 || + parent_7.kind === 199 || + parent_7.kind === 197 || + parent_7.kind === 194 || + parent_7.kind === 196 || + parent_7.kind === 203 || + parent_7.kind === 242) { + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_8.kind === 206) { - var tryStatement = parent_8; + if (parent_7.kind === 207) { + var tryStatement = parent_7; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -30029,25 +31105,25 @@ var ts; }); break; } - case 216: { - var openBrace = ts.findChildOfKind(n, 14, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15, sourceFile); + case 217: { + var openBrace = ts.findChildOfKind(n, 15, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 211: case 212: - case 214: - case 162: - case 217: { - var openBrace = ts.findChildOfKind(n, 14, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15, sourceFile); + case 213: + case 215: + case 163: + case 218: { + var openBrace = ts.findChildOfKind(n, 15, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 161: - var openBracket = ts.findChildOfKind(n, 18, sourceFile); - var closeBracket = ts.findChildOfKind(n, 19, sourceFile); + case 162: + var openBracket = ts.findChildOfKind(n, 19, sourceFile); + var closeBracket = ts.findChildOfKind(n, 20, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -30115,9 +31191,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 || - node.kind === 8 || - node.kind === 7) { + if (node.kind === 67 || + node.kind === 9 || + node.kind === 8) { return node.text; } } @@ -30129,7 +31205,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 133) { + else if (declaration.name.kind === 134) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -30146,7 +31222,7 @@ var ts; } return true; } - if (expression.kind === 163) { + if (expression.kind === 164) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -30157,7 +31233,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 133) { + if (declaration.name.kind === 134) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -30208,7 +31284,6 @@ var ts; NavigateTo.getNavigateToItems = getNavigateToItems; })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var NavigationBar; @@ -30221,14 +31296,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 215: + case 216: do { current = current.parent; - } while (current.kind === 215); - case 211: - case 214: + } while (current.kind === 216); case 212: - case 210: + case 215: + case 213: + case 211: indent++; } current = current.parent; @@ -30239,26 +31314,26 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 190: + case 191: ts.forEach(node.declarationList.declarations, visit); break; - case 158: case 159: + case 160: ts.forEach(node.elements, visit); break; - case 225: + case 226: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 219: + case 220: var importClause = node.importClause; if (importClause) { if (importClause.name) { childNodes.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221) { + if (importClause.namedBindings.kind === 222) { childNodes.push(importClause.namedBindings); } else { @@ -30267,20 +31342,20 @@ var ts; } } break; - case 160: - case 208: + case 161: + case 209: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } - case 211: - case 214: case 212: case 215: - case 210: - case 218: - case 223: - case 227: + case 213: + case 216: + case 211: + case 219: + case 224: + case 228: childNodes.push(node); break; } @@ -30315,17 +31390,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 211: - case 214: case 212: + case 215: + case 213: topLevelNodes.push(node); break; - case 215: + case 216: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 210: + case 211: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -30336,9 +31411,9 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 210) { - if (functionDeclaration.body && functionDeclaration.body.kind === 189) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 210 && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 211) { + if (functionDeclaration.body && functionDeclaration.body.kind === 190) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 && !isEmpty(s.name.text); })) { return true; } if (!ts.isFunctionBlock(functionDeclaration.parent)) { @@ -30391,7 +31466,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 135: + case 136: if (ts.isBindingPattern(node.name)) { break; } @@ -30399,34 +31474,34 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 141: case 140: - case 139: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 142: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); case 143: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 146: - return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 244: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); case 144: - return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 145: - return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 138: - case 137: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 147: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 245: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 210: + case 145: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 146: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); + case 139: + case 138: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 211: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 208: - case 160: + case 209: + case 161: var variableDeclarationNode; var name_29; - if (node.kind === 160) { + if (node.kind === 161) { name_29 = node.name; variableDeclarationNode = node; - while (variableDeclarationNode && variableDeclarationNode.kind !== 208) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 209) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -30445,13 +31520,13 @@ var ts; else { return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); } - case 141: + case 142: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 227: - case 223: - case 218: - case 220: + case 228: + case 224: + case 219: case 221: + case 222: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -30481,27 +31556,27 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 245: + case 246: return createSourceFileItem(node); - case 211: - return createClassItem(node); - case 214: - return createEnumItem(node); case 212: - return createIterfaceItem(node); + return createClassItem(node); case 215: + return createEnumItem(node); + case 213: + return createIterfaceItem(node); + case 216: return createModuleItem(node); - case 210: + case 211: return createFunctionItem(node); } return undefined; function getModuleName(moduleDeclaration) { - if (moduleDeclaration.name.kind === 8) { + if (moduleDeclaration.name.kind === 9) { return getTextOfNode(moduleDeclaration.name); } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 215) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 216) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -30513,7 +31588,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 189) { + if (node.body && node.body.kind === 190) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -30534,7 +31609,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 141 && member; + return member.kind === 142 && member; }); var nodes = removeDynamicallyNamedProperties(node); if (constructor) { @@ -30555,19 +31630,19 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 133; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134; }); } function removeDynamicallyNamedProperties(node) { return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 215) { + while (node.body.kind === 216) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 245 + return node.kind === 246 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -31029,7 +32104,6 @@ var ts; return transition; } })(ts || (ts = {})); -/// var ts; (function (ts) { var SignatureHelp; @@ -31058,14 +32132,14 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 165) { + if (argumentInfo.invocation.kind !== 166) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 66 + var name = expression.kind === 67 ? expression - : expression.kind === 163 + : expression.kind === 164 ? expression.name : undefined; if (!name || !name.text) { @@ -31094,10 +32168,10 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 165 || node.parent.kind === 166) { + if (node.parent.kind === 166 || node.parent.kind === 167) { var callExpression = node.parent; - if (node.kind === 24 || - node.kind === 16) { + if (node.kind === 25 || + node.kind === 17) { var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; ts.Debug.assert(list !== undefined); @@ -31125,24 +32199,24 @@ var ts; }; } } - else if (node.kind === 10 && node.parent.kind === 167) { + else if (node.kind === 11 && node.parent.kind === 168) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 11 && node.parent.parent.kind === 167) { + else if (node.kind === 12 && node.parent.parent.kind === 168) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180); + ts.Debug.assert(templateExpression.kind === 181); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 187 && node.parent.parent.parent.kind === 167) { + else if (node.parent.kind === 188 && node.parent.parent.parent.kind === 168) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180); - if (node.kind === 13 && !ts.isInsideTemplateLiteral(node, position)) { + ts.Debug.assert(templateExpression.kind === 181); + if (node.kind === 14 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -31159,7 +32233,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 23) { + if (child.kind !== 24) { argumentIndex++; } } @@ -31167,8 +32241,8 @@ var ts; } function getArgumentCount(argumentsList) { var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 23; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 23) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24) { argumentCount++; } return argumentCount; @@ -31184,7 +32258,7 @@ var ts; return spanIndex + 1; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex) { - var argumentCount = tagExpression.template.kind === 10 + var argumentCount = tagExpression.template.kind === 11 ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -31205,7 +32279,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 180) { + if (template.kind === 181) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -31214,7 +32288,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 245; n = n.parent) { + for (var n = node; n.kind !== 246; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -31264,10 +32338,10 @@ var ts; ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(24)); + prefixDisplayParts.push(ts.punctuationPart(25)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(26)); + suffixDisplayParts.push(ts.punctuationPart(27)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); }); @@ -31278,10 +32352,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(16)); + prefixDisplayParts.push(ts.punctuationPart(17)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(17)); + suffixDisplayParts.push(ts.punctuationPart(18)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -31291,7 +32365,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(23), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(24), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -31314,12 +32388,11 @@ var ts; var displayParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); }); - var isOptional = ts.hasQuestionToken(parameter.valueDeclaration); return { name: parameter.name, documentation: parameter.getDocumentationComment(), displayParts: displayParts, - isOptional: isOptional + isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) }; } function createSignatureHelpParameterForTypeParameter(typeParameter) { @@ -31395,101 +32468,101 @@ var ts; return false; } switch (n.kind) { - case 211: case 212: - case 214: - case 162: - case 158: - case 152: - case 189: - case 216: + case 213: + case 215: + case 163: + case 159: + case 153: + case 190: case 217: - return nodeEndsWith(n, 15, sourceFile); - case 241: + case 218: + return nodeEndsWith(n, 16, sourceFile); + case 242: return isCompletedNode(n.block, sourceFile); - case 166: + case 167: if (!n.arguments) { return true; } - case 165: - case 169: - case 157: - return nodeEndsWith(n, 17, sourceFile); - case 149: + case 166: + case 170: + case 158: + return nodeEndsWith(n, 18, sourceFile); case 150: + case 151: return isCompletedNode(n.type, sourceFile); - case 141: case 142: case 143: - case 210: - case 170: - case 140: - case 139: - case 145: case 144: + case 211: case 171: + case 141: + case 140: + case 146: + case 145: + case 172: if (n.body) { return isCompletedNode(n.body, sourceFile); } if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 17, sourceFile); - case 215: + return hasChildOfKind(n, 18, sourceFile); + case 216: return n.body && isCompletedNode(n.body, sourceFile); - case 193: + case 194: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 192: + case 193: return isCompletedNode(n.expression, sourceFile); - case 161: - case 159: - case 164: - case 133: - case 154: - return nodeEndsWith(n, 19, sourceFile); - case 146: + case 162: + case 160: + case 165: + case 134: + case 155: + return nodeEndsWith(n, 20, sourceFile); + case 147: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 19, sourceFile); - case 238: + return hasChildOfKind(n, 20, sourceFile); case 239: + case 240: return false; - case 196: case 197: case 198: - case 195: + case 199: + case 196: return isCompletedNode(n.statement, sourceFile); - case 194: - var hasWhileKeyword = findChildOfKind(n, 101, sourceFile); + case 195: + var hasWhileKeyword = findChildOfKind(n, 102, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 17, sourceFile); + return nodeEndsWith(n, 18, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 151: + case 152: return isCompletedNode(n.exprName, sourceFile); - case 173: - case 172: case 174: - case 181: + case 173: + case 175: case 182: + case 183: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 167: + case 168: return isCompletedNode(n.template, sourceFile); - case 180: + case 181: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 187: + case 188: return ts.nodeIsPresent(n.literal); - case 176: + case 177: return isCompletedNode(n.operand, sourceFile); - case 178: - return isCompletedNode(n.right, sourceFile); case 179: + return isCompletedNode(n.right, sourceFile); + case 180: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -31503,7 +32576,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 22 && children.length !== 1) { + else if (last.kind === 23 && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -31532,7 +32605,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 268 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 269 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -31612,7 +32685,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n)) { + if (isToken(n) || n.kind === 234) { return n; } var children = n.getChildren(); @@ -31620,25 +32693,26 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n)) { + if (isToken(n) || n.kind === 234) { return n; } var children = n.getChildren(); for (var i = 0, len = children.length; i < len; i++) { var child = children[i]; - if (nodeHasTokens(child)) { - if (position <= child.end) { - if (child.getStart(sourceFile) >= position) { - var candidate = findRightmostChildNodeWithTokens(children, i); - return candidate && findRightmostToken(candidate); - } - else { - return find(child); - } + if (position < child.end && (nodeHasTokens(child) || child.kind === 234)) { + var start = child.getStart(sourceFile); + var lookInPreviousChild = (start >= position) || + (child.kind === 234 && start === child.end); + if (lookInPreviousChild) { + var candidate = findRightmostChildNodeWithTokens(children, i); + return candidate && findRightmostToken(candidate); + } + else { + return find(child); } } } - ts.Debug.assert(startNode !== undefined || n.kind === 245); + ts.Debug.assert(startNode !== undefined || n.kind === 246); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -31653,6 +32727,67 @@ var ts; } } ts.findPrecedingToken = findPrecedingToken; + function isInString(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + return token && token.kind === 9 && position > token.getStart(); + } + ts.isInString = isInString; + function isInComment(sourceFile, position) { + return isInCommentHelper(sourceFile, position, undefined); + } + ts.isInComment = isInComment; + function isInCommentHelper(sourceFile, position, predicate) { + var token = getTokenAtPosition(sourceFile, position); + if (token && position <= token.getStart()) { + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return predicate ? + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 ? position <= c.end : position < c.end) && + predicate(c); }) : + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 ? position <= c.end : position < c.end); }); + } + return false; + } + ts.isInCommentHelper = isInCommentHelper; + function hasDocComment(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return ts.forEach(commentRanges, jsDocPrefix); + function jsDocPrefix(c) { + var text = sourceFile.text; + return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*'; + } + } + ts.hasDocComment = hasDocComment; + function getJsDocTagAtPosition(sourceFile, position) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (isToken(node)) { + switch (node.kind) { + case 100: + case 106: + case 72: + node = node.parent === undefined ? undefined : node.parent.parent; + break; + default: + node = node.parent; + break; + } + } + if (node) { + var jsDocComment = node.jsDocComment; + if (jsDocComment) { + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.pos <= position && position <= tag.end) { + return tag; + } + } + } + } + return undefined; + } + ts.getJsDocTagAtPosition = getJsDocTagAtPosition; function nodeHasTokens(n) { return n.getWidth() !== 0; } @@ -31677,32 +32812,32 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 148 || node.kind === 165) { + if (node.kind === 149 || node.kind === 166) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 211 || node.kind === 212) { + if (ts.isFunctionLike(node) || node.kind === 212 || node.kind === 213) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 131; + return n.kind >= 0 && n.kind <= 132; } ts.isToken = isToken; function isWord(kind) { - return kind === 66 || ts.isKeyword(kind); + return kind === 67 || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { - return kind === 8 || kind === 7 || isWord(kind); + return kind === 9 || kind === 8 || isWord(kind); } function isComment(kind) { return kind === 2 || kind === 3; } ts.isComment = isComment; function isPunctuation(kind) { - return 14 <= kind && kind <= 65; + return 15 <= kind && kind <= 66; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -31712,9 +32847,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 109: - case 107: + case 110: case 108: + case 109: return true; } return false; @@ -31740,7 +32875,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 135; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -31875,6 +33010,11 @@ var ts; return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; + var carriageReturnLineFeed = "\r\n"; + function getNewLineOrDefaultFromHost(host) { + return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + } + ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; function lineBreakPart() { return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); } @@ -31915,7 +33055,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 223 || location.parent.kind === 227) && + (location.parent.kind === 224 || location.parent.kind === 228) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -31931,8 +33071,6 @@ var ts; } ts.stripQuotes = stripQuotes; })(ts || (ts = {})); -/// -/// var ts; (function (ts) { var formatting; @@ -31998,25 +33136,37 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 28: - case 61: + case 29: case 62: + case 63: + case 44: case 43: - case 42: return true; } } return false; } + function shouldRescanJsxIdentifier(node) { + if (node.parent) { + switch (node.parent.kind) { + case 236: + case 233: + case 235: + case 232: + return node.kind === 67; + } + } + return false; + } function shouldRescanSlashToken(container) { - return container.kind === 9; + return container.kind === 10; } function shouldRescanTemplateToken(container) { - return container.kind === 12 || - container.kind === 13; + return container.kind === 13 || + container.kind === 14; } function startsWithSlashToken(t) { - return t === 37 || t === 58; + return t === 38 || t === 59; } function readTokenInfo(n) { if (!isOnToken()) { @@ -32032,7 +33182,9 @@ var ts; ? 2 : shouldRescanTemplateToken(n) ? 3 - : 0; + : shouldRescanJsxIdentifier(n) + ? 4 + : 0; if (lastTokenInfo && expectedScanAction === lastScanAction) { return fixTokenKind(lastTokenInfo, n); } @@ -32042,7 +33194,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 && currentToken === 26) { + if (expectedScanAction === 1 && currentToken === 27) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1; @@ -32052,10 +33204,14 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2; } - else if (expectedScanAction === 3 && currentToken === 15) { + else if (expectedScanAction === 3 && currentToken === 16) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3; } + else if (expectedScanAction === 4 && currentToken === 67) { + currentToken = scanner.scanJsxIdentifier(); + lastScanAction = 4; + } else { lastScanAction = 0; } @@ -32108,7 +33264,6 @@ var ts; formatting.getFormattingScanner = getFormattingScanner; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var formatting; @@ -32173,8 +33328,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 14, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 15, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 15, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 16, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -32187,8 +33342,6 @@ var ts; formatting.FormattingContext = FormattingContext; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// -/// var ts; (function (ts) { var formatting; @@ -32210,8 +33363,6 @@ var ts; formatting.Rule = Rule; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// -/// var ts; (function (ts) { var formatting; @@ -32242,8 +33393,6 @@ var ts; formatting.RuleDescriptor = RuleDescriptor; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// -/// var ts; (function (ts) { var formatting; @@ -32271,7 +33420,6 @@ var ts; formatting.RuleOperation = RuleOperation; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var formatting; @@ -32305,91 +33453,88 @@ var ts; formatting.RuleOperationContext = RuleOperationContext; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var formatting; (function (formatting) { var Rules = (function () { function Rules() { - /// - /// Common Rules - /// this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1)); - this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(51, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(51, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15, 77), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15, 101), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.FromTokens([17, 19, 23, 22])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(18, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16, 78), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 102), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.FromTokens([18, 20, 24, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; - this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([66, 3]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17, 3, 76, 97, 82, 77]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8)); - this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(14, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); - this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67, 3, 71]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18, 3, 77, 98, 83, 78]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); + this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(39, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(39, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(34, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(34, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(40, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([99, 95, 89, 75, 91, 98]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105, 71]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); - this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(84, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(100, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(91, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17, 76, 77, 68]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([97, 82]), 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([120, 126]), 66), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100, 96, 90, 76, 92, 99, 117]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18, 77, 78, 69]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([98, 83]), 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121, 127]), 67), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(118, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([122, 124]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112, 70, 119, 74, 78, 79, 80, 120, 103, 86, 104, 122, 123, 107, 109, 108, 126, 110]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([80, 103])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(33, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21, 66), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(51, formatting.Shared.TokenRange.FromTokens([17, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(17, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.TypeNames), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26, formatting.Shared.TokenRange.FromTokens([16, 18, 26, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8)); - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([112, 66, 79, 74, 70, 110, 109, 107, 108, 120, 126, 18, 36])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(84, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(36, formatting.Shared.TokenRange.FromTokens([66, 16])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(111, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([111, 36]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 125]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113, 71, 120, 75, 79, 80, 81, 121, 104, 87, 105, 123, 124, 108, 110, 109, 127, 111, 130]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81, 104])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22, 67), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.FromTokens([18, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.FromTokens([17, 19, 27, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([113, 67, 80, 75, 71, 111, 110, 108, 109, 121, 127, 19, 37])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37, formatting.Shared.TokenRange.FromTokens([67, 17])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -32415,6 +33560,8 @@ var ts; this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, + this.SpaceBetweenAsyncAndFunctionKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, this.SpaceAfterModuleName, @@ -32427,6 +33574,7 @@ var ts; this.NoSpaceAfterOpenAngularBracket, this.NoSpaceBeforeCloseAngularBracket, this.NoSpaceAfterCloseAngularBracket, + this.NoSpaceAfterTypeAssertion, this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, @@ -32436,32 +33584,37 @@ var ts; this.NoSpaceBeforeSemicolon, this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, this.NoSpaceBeforeComma, - this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterOpenBracket, - this.NoSpaceBeforeCloseBracket, this.NoSpaceAfterCloseBracket, + this.NoSpaceBeforeOpenBracket, + this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8)); - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8)); - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -32473,31 +33626,33 @@ var ts; throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 196; + return context.contextNode.kind === 197; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 178: case 179: - case 186: - case 147: + case 180: + case 187: + case 148: + case 156: + case 157: return true; - case 160: - case 213: - case 218: - case 208: - case 135: - case 244: + case 161: + case 214: + case 219: + case 209: + case 136: + case 245: + case 139: case 138: - case 137: - return context.currentTokenSpan.kind === 54 || context.nextTokenSpan.kind === 54; - case 197: - return context.currentTokenSpan.kind === 87 || context.nextTokenSpan.kind === 87; + return context.currentTokenSpan.kind === 55 || context.nextTokenSpan.kind === 55; case 198: - return context.currentTokenSpan.kind === 131 || context.nextTokenSpan.kind === 131; + return context.currentTokenSpan.kind === 88 || context.nextTokenSpan.kind === 88; + case 199: + return context.currentTokenSpan.kind === 132 || context.nextTokenSpan.kind === 132; } return false; }; @@ -32505,25 +33660,9 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 179; + return context.contextNode.kind === 180; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { - //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. - //// - //// Ex: - //// if (1) { .... - //// * ) and { are on the same line so apply the rule. Here we don't care whether it's same or multi block context - //// - //// Ex: - //// if (1) - //// { ... } - //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we don't format. - //// - //// Ex: - //// if (1) - //// { ... - //// } - //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we format. return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; Rules.IsBeforeMultilineBlockContext = function (context) { @@ -32546,91 +33685,92 @@ var ts; return true; } switch (node.kind) { - case 189: + case 190: + case 218: + case 163: case 217: - case 162: - case 216: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 210: + case 211: + case 141: case 140: - case 139: - case 142: case 143: case 144: - case 170: - case 141: + case 145: case 171: - case 212: + case 142: + case 172: + case 213: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 210 || context.contextNode.kind === 170; + return context.contextNode.kind === 211 || context.contextNode.kind === 171; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 211: case 212: - case 214: - case 152: + case 184: + case 213: case 215: + case 153: + case 216: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 211: - case 215: - case 214: - case 189: - case 241: + case 212: case 216: - case 203: + case 215: + case 190: + case 242: + case 217: + case 204: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 193: - case 203: - case 196: + case 194: + case 204: case 197: case 198: + case 199: + case 196: + case 207: case 195: - case 206: - case 194: - case 202: - case 241: + case 203: + case 242: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 162; + return context.contextNode.kind === 163; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 165; + return context.contextNode.kind === 166; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 166; + return context.contextNode.kind === 167; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 23; + return context.currentTokenSpan.kind !== 24; }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); @@ -32648,59 +33788,64 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 136; + return node.kind === 137; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 209 && + return context.currentTokenParent.kind === 210 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 215; + return context.contextNode.kind === 216; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 152; + return context.contextNode.kind === 153; }; - Rules.IsTypeArgumentOrParameter = function (token, parent) { - if (token.kind !== 24 && token.kind !== 26) { + Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { + if (token.kind !== 25 && token.kind !== 27) { return false; } switch (parent.kind) { - case 148: - case 211: + case 149: + case 169: case 212: - case 210: - case 170: + case 184: + case 213: + case 211: case 171: + case 172: + case 141: case 140: - case 139: - case 144: case 145: - case 165: + case 146: case 166: + case 167: + case 186: return true; default: return false; } }; - Rules.IsTypeArgumentOrParameterContext = function (context) { - return Rules.IsTypeArgumentOrParameter(context.currentTokenSpan, context.currentTokenParent) || - Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); + Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { + return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || + Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); + }; + Rules.IsTypeAssertionContext = function (context) { + return context.contextNode.kind === 169; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 100 && context.currentTokenParent.kind === 174; + return context.currentTokenSpan.kind === 101 && context.currentTokenParent.kind === 175; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 181 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 182 && context.contextNode.expression !== undefined; }; return Rules; })(); formatting.Rules = Rules; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var formatting; @@ -32716,7 +33861,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 131 + 1; + this.mapRowLength = 132 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -32837,7 +33982,6 @@ var ts; formatting.RulesBucket = RulesBucket; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var formatting; @@ -32893,7 +34037,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 131; token++) { + for (var token = 0; token <= 132; token++) { result.push(token); } return result; @@ -32935,36 +34079,23 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(67, 131); - TokenRange.BinaryOperators = TokenRange.FromRange(24, 65); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([87, 88, 131, 113, 121]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([39, 40, 48, 47]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7, 66, 16, 18, 14, 94, 89]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([66, 16, 94, 89]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([66, 17, 19, 89]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([66, 16, 94, 89]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([66, 17, 19, 89]); + TokenRange.Keywords = TokenRange.FromRange(68, 132); + TokenRange.BinaryOperators = TokenRange.FromRange(25, 66); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88, 89, 132, 114, 122]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40, 41, 49, 48]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 67, 17, 19, 15, 95, 90]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67, 17, 95, 90]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67, 18, 20, 90]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67, 17, 95, 90]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67, 18, 20, 90]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([66, 125, 127, 117, 128, 100, 114]); + TokenRange.TypeNames = TokenRange.FromTokens([67, 126, 128, 118, 129, 101, 115]); return TokenRange; })(); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// var ts; (function (ts) { var formatting; @@ -33021,6 +34152,16 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeCloseParen); rules.push(this.globalRules.NoSpaceBetweenParens); } + if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { + rules.push(this.globalRules.SpaceAfterOpenBracket); + rules.push(this.globalRules.SpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBracket); + rules.push(this.globalRules.NoSpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } if (options.InsertSpaceAfterSemicolonInForStatements) { rules.push(this.globalRules.SpaceAfterSemicolonInFor); } @@ -33050,10 +34191,6 @@ var ts; formatting.RulesProvider = RulesProvider; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// -/// -/// -/// var ts; (function (ts) { var formatting; @@ -33071,11 +34208,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 22, sourceFile, options, rulesProvider, 3); + return formatOutermostParent(position, 23, sourceFile, options, rulesProvider, 3); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 15, sourceFile, options, rulesProvider, 4); + return formatOutermostParent(position, 16, sourceFile, options, rulesProvider, 4); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -33123,17 +34260,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 211: case 212: + case 213: return ts.rangeContainsRange(parent.members, node); - case 215: - var body = parent.body; - return body && body.kind === 189 && ts.rangeContainsRange(body.statements, node); - case 245: - case 189: case 216: + var body = parent.body; + return body && body.kind === 190 && ts.rangeContainsRange(body.statements, node); + case 246: + case 190: + case 217: return ts.rangeContainsRange(parent.statements, node); - case 241: + case 242: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -33258,9 +34395,9 @@ var ts; if (indentation === -1) { if (isSomeBlock(node.kind)) { if (isSomeBlock(parent.kind) || - parent.kind === 245 || - parent.kind === 238 || - parent.kind === 239) { + parent.kind === 246 || + parent.kind === 239 || + parent.kind === 240) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -33293,30 +34430,31 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 211: return 70; - case 212: return 104; - case 210: return 84; - case 214: return 214; - case 142: return 120; - case 143: return 126; - case 140: + case 212: return 71; + case 213: return 105; + case 211: return 85; + case 215: return 215; + case 143: return 121; + case 144: return 127; + case 141: if (node.asteriskToken) { - return 36; + return 37; } - case 138: - case 135: + case 139: + case 136: return node.name.kind; } } function getDynamicIndentation(node, nodeStartLine, indentation, delta) { return { - getIndentationForComment: function (kind) { + getIndentationForComment: function (kind, tokenIndentation) { switch (kind) { - case 15: - case 19: + case 16: + case 20: + case 18: return indentation + delta; } - return indentation; + return tokenIndentation !== -1 ? tokenIndentation : indentation; }, getIndentationForToken: function (line, kind) { if (nodeStartLine !== line && node.decorators) { @@ -33325,15 +34463,15 @@ var ts; } } switch (kind) { - case 14: case 15: - case 18: - case 19: case 16: + case 19: + case 20: case 17: - case 77: - case 101: - case 53: + case 18: + case 78: + case 102: + case 54: return indentation; default: return nodeStartLine !== line ? indentation + delta : indentation; @@ -33413,7 +34551,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 136 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 137 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -33485,8 +34623,12 @@ var ts; processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation); } if (indentToken) { - var indentNextTokenOrTrivia = true; + var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) : + -1; if (currentTokenInfo.leadingTrivia) { + var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation); + var indentNextTokenOrTrivia = true; for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) { var triviaItem = _a[_i]; if (!ts.rangeContainsRange(originalRange, triviaItem)) { @@ -33494,14 +34636,12 @@ var ts; } switch (triviaItem.kind) { case 3: - var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); indentMultilineComment(triviaItem, commentIndentation, !indentNextTokenOrTrivia); indentNextTokenOrTrivia = false; break; case 2: if (indentNextTokenOrTrivia) { - var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - insertIndentation(triviaItem.pos, commentIndentation_1, false); + insertIndentation(triviaItem.pos, commentIndentation, false); indentNextTokenOrTrivia = false; } break; @@ -33511,8 +34651,7 @@ var ts; } } } - if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) { - var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind); + if (tokenIndentation !== -1) { insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); lastIndentedLine = tokenStart.line; indentationOnLastIndentedLine = tokenIndentation; @@ -33703,49 +34842,49 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 189: - case 216: + case 190: + case 217: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 141: - case 210: - case 170: - case 140: - case 139: + case 142: + case 211: case 171: + case 141: + case 140: + case 172: if (node.typeParameters === list) { - return 24; + return 25; } else if (node.parameters === list) { - return 16; + return 17; } break; - case 165: case 166: + case 167: if (node.typeArguments === list) { - return 24; + return 25; } else if (node.arguments === list) { - return 16; + return 17; } break; - case 148: + case 149: if (node.typeArguments === list) { - return 24; + return 25; } } return 0; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 16: - return 17; - case 24: - return 26; + case 17: + return 18; + case 25: + return 27; } return 0; } @@ -33800,7 +34939,6 @@ var ts; formatting.getIndentationString = getIndentationString; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// var ts; (function (ts) { var formatting; @@ -33815,17 +34953,17 @@ var ts; if (!precedingToken) { return 0; } - var precedingTokenIsLiteral = precedingToken.kind === 8 || - precedingToken.kind === 9 || + var precedingTokenIsLiteral = precedingToken.kind === 9 || precedingToken.kind === 10 || precedingToken.kind === 11 || precedingToken.kind === 12 || - precedingToken.kind === 13; + precedingToken.kind === 13 || + precedingToken.kind === 14; if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 && precedingToken.parent.kind !== 178) { + if (precedingToken.kind === 24 && precedingToken.parent.kind !== 179) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -33923,7 +35061,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 245 || !parentAndChildShareLine); + (parent.kind === 246 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -33934,10 +35072,10 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 14) { + if (nextToken.kind === 15) { return true; } - else if (nextToken.kind === 15) { + else if (nextToken.kind === 16) { var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; return lineAtPosition === nextTokenStartLine; } @@ -33947,8 +35085,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 193 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 77, sourceFile); + if (parent.kind === 194 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 78, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -33959,23 +35097,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 148: + case 149: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 162: + case 163: return node.parent.properties; - case 161: + case 162: return node.parent.elements; - case 210: - case 170: + case 211: case 171: + case 172: + case 141: case 140: - case 139: - case 144: - case 145: { + case 145: + case 146: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -33986,8 +35124,8 @@ var ts; } break; } - case 166: - case 165: { + case 167: + case 166: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -34012,11 +35150,11 @@ var ts; } } function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { - if (node.kind === 17) { + if (node.kind === 18) { return -1; } - if (node.parent && (node.parent.kind === 165 || - node.parent.kind === 166) && + if (node.parent && (node.parent.kind === 166 || + node.parent.kind === 167) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -34034,10 +35172,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 165: case 166: - case 163: + case 167: case 164: + case 165: node = node.expression; break; default: @@ -34052,7 +35190,7 @@ var ts; var node = list[index]; var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; --i) { - if (list[i].kind === 23) { + if (list[i].kind === 24) { continue; } var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line; @@ -34092,28 +35230,42 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 211: case 212: + case 184: + case 213: + case 215: case 214: - case 161: - case 189: - case 216: case 162: - case 152: - case 154: - case 217: - case 239: - case 238: - case 169: - case 165: - case 166: case 190: - case 208: - case 224: - case 201: - case 179: + case 217: + case 163: + case 153: + case 155: + case 218: + case 240: + case 239: + case 170: + case 164: + case 166: + case 167: + case 191: + case 209: + case 225: + case 202: + case 180: + case 160: case 159: + case 231: + case 232: + case 140: + case 145: + case 146: + case 136: + case 150: + case 151: case 158: + case 168: + case 176: return true; } return false; @@ -34123,22 +35275,20 @@ var ts; return true; } switch (parent) { - case 194: case 195: - case 197: - case 198: case 196: - case 193: - case 210: - case 170: - case 140: - case 139: - case 144: + case 198: + case 199: + case 197: + case 194: + case 211: case 171: case 141: + case 172: case 142: case 143: - return child !== 189; + case 144: + return child !== 190; default: return false; } @@ -34147,21 +35297,11 @@ var ts; })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); -/// var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -/// -/// -/// -/// -/// -/// -/// -/// -/// var ts; (function (ts) { ts.servicesVersion = "0.4"; @@ -34189,6 +35329,45 @@ var ts; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); var scanner = ts.createScanner(2, true); var emptyArray = []; + var jsDocTagNames = [ + "augments", + "author", + "argument", + "borrows", + "class", + "constant", + "constructor", + "constructs", + "default", + "deprecated", + "description", + "event", + "example", + "extends", + "field", + "fileOverview", + "function", + "ignore", + "inner", + "lends", + "link", + "memberOf", + "name", + "namespace", + "param", + "private", + "property", + "public", + "requires", + "returns", + "see", + "since", + "static", + "throws", + "type", + "version" + ]; + var jsDocCompletionEntries; function createNode(kind, pos, end, flags, parent) { var node = new (ts.getNodeConstructor(kind))(); node.pos = pos; @@ -34238,7 +35417,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(268, nodes.pos, nodes.end, 4096, this); + var list = createNode(269, nodes.pos, nodes.end, 4096, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -34257,7 +35436,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 132) { + if (this.kind >= 133) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -34299,24 +35478,20 @@ var ts; return this._children; }; NodeObject.prototype.getFirstToken = function (sourceFile) { - var children = this.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; - if (child.kind < 132) { - return child; - } - return child.getFirstToken(sourceFile); + var children = this.getChildren(sourceFile); + if (!children.length) { + return undefined; } + var child = children[0]; + return child.kind < 133 ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); - for (var i = children.length - 1; i >= 0; i--) { - var child = children[i]; - if (child.kind < 132) { - return child; - } - return child.getLastToken(sourceFile); + var child = ts.lastOrUndefined(children); + if (!child) { + return undefined; } + return child.kind < 133 ? child : child.getLastToken(sourceFile); }; return NodeObject; })(); @@ -34358,7 +35533,7 @@ var ts; ts.forEach(declarations, function (declaration, indexOfDeclaration) { if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 135) { + if (canUseParsedParamTagComments && declaration.kind === 136) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -34366,13 +35541,13 @@ var ts; } }); } - if (declaration.kind === 215 && declaration.body.kind === 215) { + if (declaration.kind === 216 && declaration.body.kind === 216) { return; } - while (declaration.kind === 215 && declaration.parent.kind === 215) { + while (declaration.kind === 216 && declaration.parent.kind === 216) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 208 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -34608,6 +35783,11 @@ var ts; TypeObject.prototype.getNumberIndexType = function () { return this.checker.getIndexTypeOfType(this, 1); }; + TypeObject.prototype.getBaseTypes = function () { + return this.flags & (1024 | 2048) + ? this.checker.getBaseTypes(this) + : undefined; + }; return TypeObject; })(); var SignatureObject = (function () { @@ -34677,9 +35857,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 133) { + if (declaration.name.kind === 134) { var expr = declaration.name.expression; - if (expr.kind === 163) { + if (expr.kind === 164) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -34689,9 +35869,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 || - node.kind === 8 || - node.kind === 7) { + if (node.kind === 67 || + node.kind === 9 || + node.kind === 8) { return node.text; } } @@ -34699,9 +35879,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 210: + case 211: + case 141: case 140: - case 139: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -34718,62 +35898,62 @@ var ts; ts.forEachChild(node, visit); } break; - case 211: case 212: case 213: case 214: case 215: - case 218: - case 227: - case 223: - case 218: - case 220: - case 221: - case 142: - case 143: - case 152: - addDeclaration(node); - case 141: - case 190: - case 209: - case 158: - case 159: case 216: + case 219: + case 228: + case 224: + case 219: + case 221: + case 222: + case 143: + case 144: + case 153: + addDeclaration(node); + case 142: + case 191: + case 210: + case 159: + case 160: + case 217: ts.forEachChild(node, visit); break; - case 189: + case 190: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 135: + case 136: if (!(node.flags & 112)) { break; } - case 208: - case 160: + case 209: + case 161: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 244: + case 245: + case 139: case 138: - case 137: addDeclaration(node); break; - case 225: + case 226: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 219: + case 220: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221) { + if (importClause.namedBindings.kind === 222) { addDeclaration(importClause.namedBindings); } else { @@ -34915,14 +36095,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 170) { + if (declaration.kind === 171) { return true; } - if (declaration.kind !== 208 && declaration.kind !== 210) { + if (declaration.kind !== 209 && declaration.kind !== 211) { return false; } - for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { - if (parent_9.kind === 245 || parent_9.kind === 216) { + for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { + if (parent_8.kind === 246 || parent_8.kind === 217) { return false; } } @@ -35027,37 +36207,57 @@ var ts; sourceFile.version = version; sourceFile.scriptSnapshot = scriptSnapshot; } - function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { - var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); + function transpileModule(input, transpileOptions) { + var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; options.allowNonTsExtensions = true; options.noLib = true; options.noResolve = true; - var inputFileName = fileName || "module.ts"; + var inputFileName = transpileOptions.fileName || "module.ts"; var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - if (moduleName) { - sourceFile.moduleName = moduleName; + if (transpileOptions.moduleName) { + sourceFile.moduleName = transpileOptions.moduleName; } + sourceFile.renamedDependencies = transpileOptions.renamedDependencies; var newLine = ts.getNewLineCharacter(options); var outputText; + var sourceMapText; var compilerHost = { - getSourceFile: function (fileName, target) { return fileName === inputFileName ? sourceFile : undefined; }, + getSourceFile: function (fileName, target) { return fileName === ts.normalizeSlashes(inputFileName) ? sourceFile : undefined; }, writeFile: function (name, text, writeByteOrderMark) { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); - outputText = text; + if (ts.fileExtensionIs(name, ".map")) { + ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + sourceMapText = text; + } + else { + ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); + outputText = text; + } }, getDefaultLibFileName: function () { return "lib.d.ts"; }, useCaseSensitiveFileNames: function () { return false; }, getCanonicalFileName: function (fileName) { return fileName; }, getCurrentDirectory: function () { return ""; }, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return fileName === inputFileName; }, + readFile: function (fileName) { return ""; } }; var program = ts.createProgram([inputFileName], options, compilerHost); - ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); - ts.addRange(diagnostics, program.getOptionsDiagnostics()); + var diagnostics; + if (transpileOptions.reportDiagnostics) { + diagnostics = []; + ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(diagnostics, program.getOptionsDiagnostics()); + } program.emit(); ts.Debug.assert(outputText !== undefined, "Output generation failed"); - return outputText; + return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; + } + ts.transpileModule = transpileModule; + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { + var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); + ts.addRange(diagnostics, output.diagnostics); + return output.outputText; } ts.transpile = transpile; function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { @@ -35112,11 +36312,12 @@ var ts; ? (function (fileName) { return fileName; }) : (function (fileName) { return fileName.toLowerCase(); }); } + ts.createGetCanonicalFileName = createGetCanonicalFileName; function createDocumentRegistry(useCaseSensitiveFileNames) { var buckets = {}; var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { - return "_" + settings.target; + return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx; } function getBucketForCompilationSettings(settings, createIfMissing) { var key = getKeyFromCompilationSettings(settings); @@ -35197,6 +36398,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } var referencedFiles = []; var importedFiles = []; + var ambientExternalModules; var isNoDefaultLib = false; function processTripleSlashDirectives() { var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); @@ -35212,6 +36414,12 @@ var ts; } }); } + function recordAmbientExternalModule() { + if (!ambientExternalModules) { + ambientExternalModules = []; + } + ambientExternalModules.push(scanner.getTokenValue()); + } function recordModuleName() { var importPath = scanner.getTokenValue(); var pos = scanner.getTokenPos(); @@ -35225,66 +36433,76 @@ var ts; scanner.setText(sourceText); var token = scanner.scan(); while (token !== 1) { - if (token === 86) { + if (token === 120) { token = scanner.scan(); - if (token === 8) { + if (token === 123) { + token = scanner.scan(); + if (token === 9) { + recordAmbientExternalModule(); + continue; + } + } + } + else if (token === 87) { + token = scanner.scan(); + if (token === 9) { recordModuleName(); continue; } else { - if (token === 66) { + if (token === 67 || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130) { + if (token === 131) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); continue; } } - else if (token === 54) { + else if (token === 55) { token = scanner.scan(); - if (token === 124) { + if (token === 125) { token = scanner.scan(); - if (token === 16) { + if (token === 17) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); continue; } } } } - else if (token === 23) { + else if (token === 24) { token = scanner.scan(); } else { continue; } } - if (token === 14) { + if (token === 15) { token = scanner.scan(); - while (token !== 15) { + while (token !== 16) { token = scanner.scan(); } - if (token === 15) { + if (token === 16) { token = scanner.scan(); - if (token === 130) { + if (token === 131) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); } } } } - else if (token === 36) { + else if (token === 37) { token = scanner.scan(); - if (token === 113) { + if (token === 114) { token = scanner.scan(); - if (token === 66) { + if (token === 67 || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130) { + if (token === 131) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); } } @@ -35293,32 +36511,50 @@ var ts; } } } - else if (token === 79) { + else if (token === 80) { token = scanner.scan(); - if (token === 14) { + if (token === 15) { token = scanner.scan(); - while (token !== 15) { + while (token !== 16) { token = scanner.scan(); } - if (token === 15) { + if (token === 16) { token = scanner.scan(); - if (token === 130) { + if (token === 131) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); } } } } - else if (token === 36) { + else if (token === 37) { token = scanner.scan(); - if (token === 130) { + if (token === 131) { token = scanner.scan(); - if (token === 8) { + if (token === 9) { recordModuleName(); } } } + else if (token === 87) { + token = scanner.scan(); + if (token === 67 || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 55) { + token = scanner.scan(); + if (token === 125) { + token = scanner.scan(); + if (token === 17) { + token = scanner.scan(); + if (token === 9) { + recordModuleName(); + } + } + } + } + } + } } token = scanner.scan(); } @@ -35328,12 +36564,12 @@ var ts; processImport(); } processTripleSlashDirectives(); - return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib }; + return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; } ts.preProcessFile = preProcessFile; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 204 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 205 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -35341,17 +36577,17 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 66 && - (node.parent.kind === 200 || node.parent.kind === 199) && + return node.kind === 67 && + (node.parent.kind === 201 || node.parent.kind === 200) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 66 && - node.parent.kind === 204 && + return node.kind === 67 && + node.parent.kind === 205 && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 204; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 205; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -35362,55 +36598,55 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 132 && node.parent.right === node; + return node.parent.kind === 133 && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 163 && node.parent.name === node; + return node && node.parent && node.parent.kind === 164 && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 165 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 166 && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 166 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 167 && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 215 && node.parent.name === node; + return node.parent.kind === 216 && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 66 && + return node.kind === 67 && ts.isFunctionLike(node.parent) && node.parent.name === node; } function isNameOfPropertyAssignment(node) { - return (node.kind === 66 || node.kind === 8 || node.kind === 7) && - (node.parent.kind === 242 || node.parent.kind === 243) && node.parent.name === node; + return (node.kind === 67 || node.kind === 9 || node.kind === 8) && + (node.parent.kind === 243 || node.parent.kind === 244) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 8 || node.kind === 7) { + if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { - case 138: - case 137: - case 242: - case 244: - case 140: case 139: - case 142: + case 138: + case 243: + case 245: + case 141: + case 140: case 143: - case 215: + case 144: + case 216: return node.parent.name === node; - case 164: + case 165: return node.parent.argumentExpression === node; } } return false; } function isNameOfExternalModuleImportOrDeclaration(node) { - if (node.kind === 8) { + if (node.kind === 9) { return isNameOfModuleDeclaration(node) || (ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node); } @@ -35441,7 +36677,7 @@ var ts; } } var keywordCompletions = []; - for (var i = 67; i <= 131; i++) { + for (var i = 68; i <= 132; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -35456,17 +36692,17 @@ var ts; return undefined; } switch (node.kind) { - case 245: + case 246: + case 141: case 140: - case 139: - case 210: - case 170: - case 142: - case 143: case 211: + case 171: + case 143: + case 144: case 212: - case 214: + case 213: case 215: + case 216: return node; } } @@ -35474,38 +36710,38 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 215: return ScriptElementKind.moduleElement; - case 211: return ScriptElementKind.classElement; - case 212: return ScriptElementKind.interfaceElement; - case 213: return ScriptElementKind.typeElement; - case 214: return ScriptElementKind.enumElement; - case 208: + case 216: return ScriptElementKind.moduleElement; + case 212: return ScriptElementKind.classElement; + case 213: return ScriptElementKind.interfaceElement; + case 214: return ScriptElementKind.typeElement; + case 215: return ScriptElementKind.enumElement; + case 209: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 210: return ScriptElementKind.functionElement; - case 142: return ScriptElementKind.memberGetAccessorElement; - case 143: return ScriptElementKind.memberSetAccessorElement; + case 211: return ScriptElementKind.functionElement; + case 143: return ScriptElementKind.memberGetAccessorElement; + case 144: return ScriptElementKind.memberSetAccessorElement; + case 141: case 140: - case 139: return ScriptElementKind.memberFunctionElement; + case 139: case 138: - case 137: return ScriptElementKind.memberVariableElement; - case 146: return ScriptElementKind.indexSignatureElement; - case 145: return ScriptElementKind.constructSignatureElement; - case 144: return ScriptElementKind.callSignatureElement; - case 141: return ScriptElementKind.constructorImplementationElement; - case 134: return ScriptElementKind.typeParameterElement; - case 244: return ScriptElementKind.variableElement; - case 135: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 218: - case 223: - case 220: - case 227: + case 147: return ScriptElementKind.indexSignatureElement; + case 146: return ScriptElementKind.constructSignatureElement; + case 145: return ScriptElementKind.callSignatureElement; + case 142: return ScriptElementKind.constructorImplementationElement; + case 135: return ScriptElementKind.typeParameterElement; + case 245: return ScriptElementKind.variableElement; + case 136: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 219: + case 224: case 221: + case 228: + case 222: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -35573,17 +36809,33 @@ var ts; } var oldSettings = program && program.getCompilerOptions(); var newSettings = hostCache.compilationSettings(); - var changesInCompilationSettingsAffectSyntax = oldSettings && oldSettings.target !== newSettings.target; - var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, { + var changesInCompilationSettingsAffectSyntax = oldSettings && + (oldSettings.target !== newSettings.target || + oldSettings.module !== newSettings.module || + oldSettings.noResolve !== newSettings.noResolve || + oldSettings.jsx !== newSettings.jsx); + var compilerHost = { getSourceFile: getOrCreateSourceFile, getCancellationToken: function () { return cancellationToken; }, getCanonicalFileName: getCanonicalFileName, useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, - getNewLine: function () { return host.getNewLine ? host.getNewLine() : "\r\n"; }, + getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); } - }); + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + fileExists: function (fileName) { + ts.Debug.assert(!host.resolveModuleNames); + return hostCache.getOrCreateEntry(fileName) !== undefined; + }, + readFile: function (fileName) { + var entry = hostCache.getOrCreateEntry(fileName); + return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); + } + }; + if (host.resolveModuleNames) { + compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + } + var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); if (program) { var oldSourceFiles = program.getSourceFiles(); for (var _i = 0; _i < oldSourceFiles.length; _i++) { @@ -35671,44 +36923,44 @@ var ts; return false; } switch (node.kind) { - case 218: + case 219: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 224: + case 225: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 211: + case 212: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 240: + case 241: var heritageClause = node; - if (heritageClause.token === 103) { + if (heritageClause.token === 104) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 212: + case 213: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 215: + case 216: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 213: + case 214: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 140: - case 139: case 141: + case 140: case 142: case 143: - case 170: - case 210: + case 144: case 171: - case 210: + case 211: + case 172: + case 211: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -35716,20 +36968,20 @@ var ts; return true; } break; - case 190: + case 191: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 208: + case 209: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 165: case 166: + case 167: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -35737,7 +36989,7 @@ var ts; return true; } break; - case 135: + case 136: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -35753,17 +37005,17 @@ var ts; return true; } break; - case 138: + case 139: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 214: + case 215: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 168: + case 169: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 136: + case 137: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -35789,17 +37041,17 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { - case 109: - case 107: + case 110: case 108: - case 119: + case 109: + case 120: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; - case 110: - case 79: - case 71: - case 74: - case 112: + case 111: + case 80: + case 72: + case 75: + case 113: } } } @@ -35845,6 +37097,7 @@ var ts; var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); var isJavaScriptFile = ts.isJavaScript(fileName); + var isJsDocTagName = false; var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); log("getCompletionData: Get current token: " + (new Date().getTime() - start)); @@ -35852,17 +37105,42 @@ var ts; var insideComment = isInsideComment(sourceFile, currentToken, position); log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); if (insideComment) { - log("Returning an empty list because completion was inside a comment."); - return undefined; + if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64) { + isJsDocTagName = true; + } + var insideJsDocTagExpression = false; + var tag = ts.getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (tag.tagName.pos <= position && position <= tag.tagName.end) { + isJsDocTagName = true; + } + switch (tag.kind) { + case 267: + case 265: + case 266: + var tagWithExpression = tag; + if (tagWithExpression.typeExpression) { + insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; + } + break; + } + } + if (isJsDocTagName) { + return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + } + if (!insideJsDocTagExpression) { + log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); + return undefined; + } } start = new Date().getTime(); var previousToken = ts.findPrecedingToken(position, sourceFile); log("getCompletionData: Get previous token 1: " + (new Date().getTime() - start)); var contextToken = previousToken; if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) { - var start_2 = new Date().getTime(); + var start_4 = new Date().getTime(); contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); - log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_2)); + log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_4)); } var node = currentToken; var isRightOfDot = false; @@ -35873,13 +37151,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_10 = contextToken.parent, kind = contextToken.kind; - if (kind === 20) { - if (parent_10.kind === 163) { + var parent_9 = contextToken.parent, kind = contextToken.kind; + if (kind === 21) { + if (parent_9.kind === 164) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_10.kind === 132) { + else if (parent_9.kind === 133) { node = contextToken.parent.left; isRightOfDot = true; } @@ -35887,7 +37165,7 @@ var ts; return undefined; } } - else if (kind === 24 && sourceFile.languageVariant === 1) { + else if (kind === 25 && sourceFile.languageVariant === 1) { isRightOfOpenTag = true; location = contextToken; } @@ -35916,11 +37194,11 @@ var ts; } } log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; function getTypeScriptMemberSymbols() { isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 66 || node.kind === 132 || node.kind === 163) { + if (node.kind === 67 || node.kind === 133 || node.kind === 164) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -35966,7 +37244,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 231) || (jsxContainer.kind === 232)) { + if ((jsxContainer.kind === 232) || (jsxContainer.kind === 233)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); @@ -36008,41 +37286,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 23: - return containingNodeKind === 165 - || containingNodeKind === 141 - || containingNodeKind === 166 - || containingNodeKind === 161 - || containingNodeKind === 178 - || containingNodeKind === 149; - case 16: - return containingNodeKind === 165 - || containingNodeKind === 141 - || containingNodeKind === 166 - || containingNodeKind === 169 - || containingNodeKind === 157; - case 18: - return containingNodeKind === 161 - || containingNodeKind === 146 - || containingNodeKind === 133; - case 122: + case 24: + return containingNodeKind === 166 + || containingNodeKind === 142 + || containingNodeKind === 167 + || containingNodeKind === 162 + || containingNodeKind === 179 + || containingNodeKind === 150; + case 17: + return containingNodeKind === 166 + || containingNodeKind === 142 + || containingNodeKind === 167 + || containingNodeKind === 170 + || containingNodeKind === 158; + case 19: + return containingNodeKind === 162 + || containingNodeKind === 147 + || containingNodeKind === 134; case 123: + case 124: return true; - case 20: - return containingNodeKind === 215; - case 14: - return containingNodeKind === 211; - case 54: - return containingNodeKind === 208 - || containingNodeKind === 178; - case 11: - return containingNodeKind === 180; + case 21: + return containingNodeKind === 216; + case 15: + return containingNodeKind === 212; + case 55: + return containingNodeKind === 209 + || containingNodeKind === 179; case 12: - return containingNodeKind === 187; - case 109: - case 107: + return containingNodeKind === 181; + case 13: + return containingNodeKind === 188; + case 110: case 108: - return containingNodeKind === 138; + case 109: + return containingNodeKind === 139; } switch (previousToken.getText()) { case "public": @@ -36054,17 +37332,17 @@ var ts; return false; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 8 - || contextToken.kind === 9 + if (contextToken.kind === 9 + || contextToken.kind === 10 || ts.isTemplateLiteralKind(contextToken.kind)) { - var start_3 = contextToken.getStart(); + var start_5 = contextToken.getStart(); var end = contextToken.getEnd(); - if (start_3 < position && position < end) { + if (start_5 < position && position < end) { return true; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 9; + || contextToken.kind === 10; } } return false; @@ -36073,15 +37351,23 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 162) { + if (objectLikeContainer.kind === 163) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 158) { + else if (objectLikeContainer.kind === 159) { isNewIdentifierLocation = false; - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = objectLikeContainer.elements; + var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); + if (ts.isVariableLike(rootDeclaration)) { + if (rootDeclaration.initializer || rootDeclaration.type) { + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = objectLikeContainer.elements; + } + } + else { + ts.Debug.fail("Root declaration is not variable-like."); + } } else { ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); @@ -36096,9 +37382,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 222 ? - 219 : - 225; + var declarationKind = namedImportsOrExports.kind === 223 ? + 220 : + 226; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -36117,11 +37403,11 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14: - case 23: - var parent_11 = contextToken.parent; - if (parent_11 && (parent_11.kind === 162 || parent_11.kind === 158)) { - return parent_11; + case 15: + case 24: + var parent_10 = contextToken.parent; + if (parent_10 && (parent_10.kind === 163 || parent_10.kind === 159)) { + return parent_10; } break; } @@ -36131,11 +37417,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14: - case 23: + case 15: + case 24: switch (contextToken.parent.kind) { - case 222: - case 226: + case 223: + case 227: return contextToken.parent; } } @@ -36144,21 +37430,31 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_12 = contextToken.parent; + var parent_11 = contextToken.parent; switch (contextToken.kind) { - case 25: - case 37: - case 66: - if (parent_12 && (parent_12.kind === 231 || parent_12.kind === 232)) { - return parent_12; + case 26: + case 38: + case 67: + case 236: + case 237: + if (parent_11 && (parent_11.kind === 232 || parent_11.kind === 233)) { + return parent_11; } break; - case 15: - if (parent_12 && - parent_12.kind === 237 && - parent_12.parent && - parent_12.parent.kind === 235) { - return parent_12.parent.parent; + case 9: + if (parent_11 && ((parent_11.kind === 236) || (parent_11.kind === 237))) { + return parent_11.parent; + } + break; + case 16: + if (parent_11 && + parent_11.kind === 238 && + parent_11.parent && + (parent_11.parent.kind === 236)) { + return parent_11.parent.parent; + } + if (parent_11 && parent_11.kind === 237) { + return parent_11.parent; } break; } @@ -36167,16 +37463,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 170: case 171: - case 210: + case 172: + case 211: + case 141: case 140: - case 139: - case 142: case 143: case 144: case 145: case 146: + case 147: return true; } return false; @@ -36184,65 +37480,67 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 23: - return containingNodeKind === 208 || - containingNodeKind === 209 || - containingNodeKind === 190 || - containingNodeKind === 214 || - isFunction(containingNodeKind) || - containingNodeKind === 211 || - containingNodeKind === 210 || - containingNodeKind === 212 || - containingNodeKind === 159; - case 20: - return containingNodeKind === 159; - case 52: - return containingNodeKind === 160; - case 18: - return containingNodeKind === 159; - case 16: - return containingNodeKind === 241 || - isFunction(containingNodeKind); - case 14: - return containingNodeKind === 214 || - containingNodeKind === 212 || - containingNodeKind === 152; - case 22: - return containingNodeKind === 137 && - contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 212 || - contextToken.parent.parent.kind === 152); case 24: - return containingNodeKind === 211 || + return containingNodeKind === 209 || containingNodeKind === 210 || + containingNodeKind === 191 || + containingNodeKind === 215 || + isFunction(containingNodeKind) || containingNodeKind === 212 || - isFunction(containingNodeKind); - case 110: - return containingNodeKind === 138; + containingNodeKind === 184 || + containingNodeKind === 213 || + containingNodeKind === 160 || + containingNodeKind === 214; case 21: - return containingNodeKind === 135 || - (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 159); - case 109: - case 107: - case 108: - return containingNodeKind === 135; - case 113: - containingNodeKind === 223 || - containingNodeKind === 227 || - containingNodeKind === 221; - case 70: - case 78: - case 104: - case 84: - case 99: - case 120: - case 126: - case 86: - case 105: - case 71: + return containingNodeKind === 160; + case 53: + return containingNodeKind === 161; + case 19: + return containingNodeKind === 160; + case 17: + return containingNodeKind === 242 || + isFunction(containingNodeKind); + case 15: + return containingNodeKind === 215 || + containingNodeKind === 213 || + containingNodeKind === 153; + case 23: + return containingNodeKind === 138 && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 213 || + contextToken.parent.parent.kind === 153); + case 25: + return containingNodeKind === 212 || + containingNodeKind === 184 || + containingNodeKind === 213 || + containingNodeKind === 214 || + isFunction(containingNodeKind); case 111: - case 129: + return containingNodeKind === 139; + case 22: + return containingNodeKind === 136 || + (contextToken.parent && contextToken.parent.parent && + contextToken.parent.parent.kind === 160); + case 110: + case 108: + case 109: + return containingNodeKind === 136; + case 114: + containingNodeKind === 224 || + containingNodeKind === 228 || + containingNodeKind === 222; + case 71: + case 79: + case 105: + case 85: + case 100: + case 121: + case 127: + case 87: + case 106: + case 72: + case 112: + case 130: return true; } switch (contextToken.getText()) { @@ -36260,7 +37558,7 @@ var ts; return false; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 7) { + if (contextToken.kind === 8) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } @@ -36288,16 +37586,16 @@ var ts; var existingMemberNames = {}; for (var _i = 0; _i < existingMembers.length; _i++) { var m = existingMembers[_i]; - if (m.kind !== 242 && - m.kind !== 243 && - m.kind !== 160) { + if (m.kind !== 243 && + m.kind !== 244 && + m.kind !== 161) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 160 && m.propertyName) { + if (m.kind === 161 && m.propertyName) { existingName = m.propertyName.text; } else { @@ -36314,7 +37612,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 235) { + if (attr.kind === 236) { seenNames[attr.name.text] = true; } } @@ -36327,8 +37625,11 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot; + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; var entries; + if (isJsDocTagName) { + return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; + } if (isRightOfDot && ts.isJavaScript(fileName)) { entries = getCompletionEntriesFromSymbols(symbols); ts.addRange(entries, getJavaScriptCompletionEntries()); @@ -36339,7 +37640,7 @@ var ts; } entries = getCompletionEntriesFromSymbols(symbols); } - if (!isMemberCompletion) { + if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; @@ -36368,6 +37669,16 @@ var ts; } return entries; } + function getAllJsDocCompletionEntries() { + return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } function createCompletionEntry(symbol, location) { var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true, location); if (!displayName) { @@ -36434,7 +37745,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 183) ? + return ts.getDeclarationOfKind(symbol, 184) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384) return ScriptElementKind.enumElement; @@ -36530,14 +37841,14 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 163) { + if (location.parent && location.parent.kind === 164) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression; - if (location.kind === 165 || location.kind === 166) { + if (location.kind === 166 || location.kind === 167) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -36549,7 +37860,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 166 || callExpression.expression.kind === 92; + var useConstructSignatures = callExpression.kind === 167 || callExpression.expression.kind === 93; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -36564,7 +37875,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89)); + displayParts.push(ts.keywordPart(90)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -36579,10 +37890,10 @@ var ts; case ScriptElementKind.letElement: case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: - displayParts.push(ts.punctuationPart(52)); + displayParts.push(ts.punctuationPart(53)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89)); + displayParts.push(ts.keywordPart(90)); displayParts.push(ts.spacePart()); } if (!(type.flags & 65536)) { @@ -36597,21 +37908,21 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 118 && location.parent.kind === 141)) { + (location.kind === 119 && location.parent.kind === 142)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 141 ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 142 ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 141) { + if (functionDeclaration.kind === 142) { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 144 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -36620,11 +37931,11 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 183)) { + if (ts.getDeclarationOfKind(symbol, 184)) { pushTypePart(ScriptElementKind.localClassElement); } else { - displayParts.push(ts.keywordPart(70)); + displayParts.push(ts.keywordPart(71)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -36632,74 +37943,85 @@ var ts; } if ((symbolFlags & 64) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(104)); + displayParts.push(ts.keywordPart(105)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(129)); + displayParts.push(ts.keywordPart(130)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54)); + displayParts.push(ts.operatorPart(55)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(71)); + displayParts.push(ts.keywordPart(72)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(78)); + displayParts.push(ts.keywordPart(79)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 215); - var isNamespace = declaration && declaration.name && declaration.name.kind === 66; - displayParts.push(ts.keywordPart(isNamespace ? 123 : 122)); + var declaration = ts.getDeclarationOfKind(symbol, 216); + var isNamespace = declaration && declaration.name && declaration.name.kind === 67; + displayParts.push(ts.keywordPart(isNamespace ? 124 : 123)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.textPart("type parameter")); displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.textPart("type parameter")); + displayParts.push(ts.punctuationPart(18)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(87)); + displayParts.push(ts.keywordPart(88)); displayParts.push(ts.spacePart()); if (symbol.parent) { addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 134).parent; - var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 145) { - displayParts.push(ts.keywordPart(89)); + var container = ts.getContainingFunction(location); + if (container) { + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135).parent; + var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === 146) { + displayParts.push(ts.keywordPart(90)); + displayParts.push(ts.spacePart()); + } + else if (signatureDeclaration.kind !== 145 && signatureDeclaration.name) { + addFullSymbolName(signatureDeclaration.symbol); + } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); + } + else { + var declaration = ts.getDeclarationOfKind(symbol, 135).parent; + displayParts.push(ts.keywordPart(130)); displayParts.push(ts.spacePart()); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); } - else if (signatureDeclaration.kind !== 144 && signatureDeclaration.name) { - addFullSymbolName(signatureDeclaration.symbol); - } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } } if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 244) { + if (declaration.kind === 245) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54)); + displayParts.push(ts.operatorPart(55)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -36707,26 +38029,26 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(86)); + displayParts.push(ts.keywordPart(87)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 218) { + if (declaration.kind === 219) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54)); + displayParts.push(ts.operatorPart(55)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(124)); - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.keywordPart(125)); displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.punctuationPart(18)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54)); + displayParts.push(ts.operatorPart(55)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -36742,7 +38064,7 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(52)); + displayParts.push(ts.punctuationPart(53)); displayParts.push(ts.spacePart()); if (type.symbol && type.symbol.flags & 262144) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -36800,9 +38122,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.textOrKeywordPart(symbolKind)); displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.textOrKeywordPart(symbolKind)); + displayParts.push(ts.punctuationPart(18)); return; } } @@ -36810,12 +38132,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.operatorPart(34)); + displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.operatorPart(35)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(17)); + displayParts.push(ts.punctuationPart(18)); } documentation = signature.getDocumentationComment(); } @@ -36840,11 +38162,11 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) { switch (node.kind) { - case 66: - case 163: - case 132: - case 94: - case 92: + case 67: + case 164: + case 133: + case 95: + case 93: var type = typeChecker.getTypeAtLocation(node); if (type) { return { @@ -36893,11 +38215,15 @@ var ts; } return result; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isNewExpressionTarget(location) || location.kind === 118) { + if (isNewExpressionTarget(location) || location.kind === 119) { if (symbol.flags & 32) { - var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 211); - return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); + for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isClassLike(declaration)) { + return tryAddSignature(declaration.members, true, symbolKind, symbolName, containerName, result); + } + } + ts.Debug.fail("Expected declaration to have at least one class-like declaration"); } } return false; @@ -36912,8 +38238,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 141) || - (!selectConstructors && (d.kind === 210 || d.kind === 140 || d.kind === 139))) { + if ((selectConstructors && d.kind === 142) || + (!selectConstructors && (d.kind === 211 || d.kind === 141 || d.kind === 140))) { declarations.push(d); if (d.body) definition = d; @@ -36964,11 +38290,11 @@ var ts; } if (symbol.flags & 8388608) { var declaration = symbol.declarations[0]; - if (node.kind === 66 && node.parent === declaration) { + if (node.kind === 67 && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 243) { + if (node.parent.kind === 244) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -37039,9 +38365,9 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 66 || - node.kind === 94 || - node.kind === 92 || + if (node.kind === 67 || + node.kind === 95 || + node.kind === 93 || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); @@ -37090,77 +38416,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 85: - case 77: - if (hasKind(node.parent, 193)) { + case 86: + case 78: + if (hasKind(node.parent, 194)) { return getIfElseOccurrences(node.parent); } break; - case 91: - if (hasKind(node.parent, 201)) { + case 92: + if (hasKind(node.parent, 202)) { return getReturnOccurrences(node.parent); } break; - case 95: - if (hasKind(node.parent, 205)) { + case 96: + if (hasKind(node.parent, 206)) { return getThrowOccurrences(node.parent); } break; - case 69: - if (hasKind(parent(parent(node)), 206)) { + case 70: + if (hasKind(parent(parent(node)), 207)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 97: - case 82: - if (hasKind(parent(node), 206)) { + case 98: + case 83: + if (hasKind(parent(node), 207)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 93: - if (hasKind(node.parent, 203)) { + case 94: + if (hasKind(node.parent, 204)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 68: - case 74: - if (hasKind(parent(parent(parent(node))), 203)) { + case 69: + case 75: + if (hasKind(parent(parent(parent(node))), 204)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 67: - case 72: - if (hasKind(node.parent, 200) || hasKind(node.parent, 199)) { - return getBreakOrContinueStatementOccurences(node.parent); + case 68: + case 73: + if (hasKind(node.parent, 201) || hasKind(node.parent, 200)) { + return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 83: - if (hasKind(node.parent, 196) || - hasKind(node.parent, 197) || - hasKind(node.parent, 198)) { + case 84: + if (hasKind(node.parent, 197) || + hasKind(node.parent, 198) || + hasKind(node.parent, 199)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 101: - case 76: - if (hasKind(node.parent, 195) || hasKind(node.parent, 194)) { + case 102: + case 77: + if (hasKind(node.parent, 196) || hasKind(node.parent, 195)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 118: - if (hasKind(node.parent, 141)) { + case 119: + if (hasKind(node.parent, 142)) { return getConstructorOccurrences(node.parent); } break; - case 120: - case 126: - if (hasKind(node.parent, 142) || hasKind(node.parent, 143)) { + case 121: + case 127: + if (hasKind(node.parent, 143) || hasKind(node.parent, 144)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 190)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 191)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -37172,10 +38498,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 205) { + if (node.kind === 206) { statementAccumulator.push(node); } - else if (node.kind === 206) { + else if (node.kind === 207) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -37196,17 +38522,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_13 = child.parent; - if (ts.isFunctionBlock(parent_13) || parent_13.kind === 245) { - return parent_13; + var parent_12 = child.parent; + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246) { + return parent_12; } - if (parent_13.kind === 206) { - var tryStatement = parent_13; + if (parent_12.kind === 207) { + var tryStatement = parent_12; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_13; + child = parent_12; } return undefined; } @@ -37215,7 +38541,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 200 || node.kind === 199) { + if (node.kind === 201 || node.kind === 200) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -37231,15 +38557,15 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 203: - if (statement.kind === 199) { + case 204: + if (statement.kind === 200) { continue; } - case 196: case 197: case 198: + case 199: + case 196: case 195: - case 194: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -37256,24 +38582,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 211 || - container.kind === 183 || - (declaration.kind === 135 && hasKind(container, 141)))) { + if (!(container.kind === 212 || + container.kind === 184 || + (declaration.kind === 136 && hasKind(container, 142)))) { return undefined; } } - else if (modifier === 110) { - if (!(container.kind === 211 || container.kind === 183)) { + else if (modifier === 111) { + if (!(container.kind === 212 || container.kind === 184)) { return undefined; } } - else if (modifier === 79 || modifier === 119) { - if (!(container.kind === 216 || container.kind === 245)) { + else if (modifier === 80 || modifier === 120) { + if (!(container.kind === 217 || container.kind === 246)) { return undefined; } } - else if (modifier === 112) { - if (!(container.kind === 211 || declaration.kind === 211)) { + else if (modifier === 113) { + if (!(container.kind === 212 || declaration.kind === 212)) { return undefined; } } @@ -37284,8 +38610,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 216: - case 245: + case 217: + case 246: if (modifierFlag & 256) { nodes = declaration.members.concat(declaration); } @@ -37293,15 +38619,15 @@ var ts; nodes = container.statements; } break; - case 141: + case 142: nodes = container.parameters.concat(container.parent.members); break; - case 211: - case 183: + case 212: + case 184: nodes = container.members; if (modifierFlag & 112) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 141 && member; + return member.kind === 142 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -37322,19 +38648,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 109: - return 16; - case 107: - return 32; - case 108: - return 64; case 110: + return 16; + case 108: + return 32; + case 109: + return 64; + case 111: return 128; - case 79: + case 80: return 1; - case 119: + case 120: return 2; - case 112: + case 113: return 256; default: ts.Debug.fail(); @@ -37354,13 +38680,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 142); tryPushAccessorKeyword(accessorDeclaration.symbol, 143); + tryPushAccessorKeyword(accessorDeclaration.symbol, 144); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 120, 126); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 121, 127); }); } } } @@ -37369,18 +38695,18 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 118); + return pushKeywordIf(keywords, token, 119); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 83, 101, 76)) { - if (loopNode.kind === 194) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84, 102, 77)) { + if (loopNode.kind === 195) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 101)) { + if (pushKeywordIf(keywords, loopTokens[i], 102)) { break; } } @@ -37389,22 +38715,22 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67, 72); + pushKeywordIf(keywords, statement.getFirstToken(), 68, 73); } }); return ts.map(keywords, getHighlightSpanForNode); } - function getBreakOrContinueStatementOccurences(breakOrContinueStatement) { + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 196: case 197: case 198: - case 194: + case 199: case 195: + case 196: return getLoopBreakContinueOccurrences(owner); - case 203: + case 204: return getSwitchCaseDefaultOccurrences(owner); } } @@ -37412,13 +38738,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 93); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 94); ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 68, 74); + pushKeywordIf(keywords, clause.getFirstToken(), 69, 75); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67); + pushKeywordIf(keywords, statement.getFirstToken(), 68); } }); }); @@ -37426,13 +38752,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 97); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 98); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 69); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 82); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 83); } return ts.map(keywords, getHighlightSpanForNode); } @@ -37443,50 +38769,50 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96); }); if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92); }); } return ts.map(keywords, getHighlightSpanForNode); } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 189))) { + if (!(func && hasKind(func.body, 190))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 193) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 194) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 85); + pushKeywordIf(keywords, children[0], 86); for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 77)) { + if (pushKeywordIf(keywords, children[i], 78)) { break; } } - if (!hasKind(ifStatement.elseStatement, 193)) { + if (!hasKind(ifStatement.elseStatement, 194)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 77 && i < keywords.length - 1) { + if (keywords[i].kind === 78 && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; var shouldCombindElseAndIf = true; @@ -37564,12 +38890,12 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 66 && + if (node.kind !== 67 && !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 66 || node.kind === 7 || node.kind === 8); + ts.Debug.assert(node.kind === 67 || node.kind === 8 || node.kind === 9); return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { @@ -37583,10 +38909,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 94) { + if (node.kind === 95) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 92) { + if (node.kind === 93) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -37637,7 +38963,7 @@ var ts; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 223 || declaration.kind === 227; + return declaration.kind === 224 || declaration.kind === 228; }); } function getInternedName(symbol, location, declarations) { @@ -37650,13 +38976,13 @@ var ts; } function getSymbolScope(symbol) { var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 170 || valueDeclaration.kind === 183)) { + if (valueDeclaration && (valueDeclaration.kind === 171 || valueDeclaration.kind === 184)) { return valueDeclaration; } if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 211); + return ts.getAncestor(privateDeclaration, 212); } } if (symbol.flags & 8388608) { @@ -37677,7 +39003,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 245 && !ts.isExternalModule(container)) { + if (container.kind === 246 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -37736,15 +39062,15 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { if (node) { switch (node.kind) { - case 66: + case 67: return node.getWidth() === searchSymbolName.length; - case 8: + case 9: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { return node.getWidth() === searchSymbolName.length + 2; } break; - case 7: + case 8: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { return node.getWidth() === searchSymbolName.length; } @@ -37763,8 +39089,8 @@ var ts; cancellationToken.throwIfCancellationRequested(); var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); if (!isValidReferencePosition(referenceLocation, searchText)) { - if ((findInStrings && isInString(position)) || - (findInComments && isInComment(position))) { + if ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && isInNonReferenceComment(sourceFile, position))) { result.push({ definition: undefined, references: [{ @@ -37809,24 +39135,12 @@ var ts; } return result[index]; } - function isInString(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - return token && token.kind === 8 && position > token.getStart(); - } - function isInComment(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (token && position < token.getStart()) { - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - return ts.forEach(commentRanges, function (c) { - if (c.pos < position && position < c.end) { - var commentText = sourceFile.text.substring(c.pos, c.end); - if (!tripleSlashDirectivePrefixRegex.test(commentText)) { - return true; - } - } - }); + function isInNonReferenceComment(sourceFile, position) { + return ts.isInCommentHelper(sourceFile, position, isNonReferenceComment); + function isNonReferenceComment(c) { + var commentText = sourceFile.text.substring(c.pos, c.end); + return !tripleSlashDirectivePrefixRegex.test(commentText); } - return false; } } function getReferencesForSuperKeyword(superKeyword) { @@ -37836,13 +39150,13 @@ var ts; } var staticFlag = 128; switch (searchSpaceNode.kind) { - case 138: - case 137: - case 140: case 139: + case 138: case 141: + case 140: case 142: case 143: + case 144: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; @@ -37855,7 +39169,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 92) { + if (!node || node.kind !== 93) { return; } var container = ts.getSuperContainer(node, false); @@ -37870,32 +39184,32 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 128; switch (searchSpaceNode.kind) { + case 141: case 140: - case 139: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } + case 139: case 138: - case 137: - case 141: case 142: case 143: + case 144: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 245: + case 246: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 210: - case 170: + case 211: + case 171: break; default: return undefined; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 245) { + if (searchSpaceNode.kind === 246) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -37921,30 +39235,31 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 94) { + if (!node || node.kind !== 95) { return; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 170: - case 210: + case 171: + case 211: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; + case 141: case 140: - case 139: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 211: + case 184: + case 212: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 245: - if (container.kind === 245 && !ts.isExternalModule(container)) { + case 246: + if (container.kind === 246 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -37979,11 +39294,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 | 64)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 211) { + if (declaration.kind === 212) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 212) { + else if (declaration.kind === 213) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -38081,7 +39396,7 @@ var ts; function getReferenceEntryFromNode(node) { var start = node.getStart(); var end = node.getEnd(); - if (node.kind === 8) { + if (node.kind === 9) { start += 1; end -= 1; } @@ -38092,17 +39407,17 @@ var ts; }; } function isWriteAccess(node) { - if (node.kind === 66 && ts.isDeclarationName(node)) { + if (node.kind === 67 && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 177 || parent.kind === 176) { + if (parent.kind === 178 || parent.kind === 177) { return true; } - else if (parent.kind === 178 && parent.left === node) { + else if (parent.kind === 179 && parent.left === node) { var operator = parent.operatorToken.kind; - return 54 <= operator && operator <= 65; + return 55 <= operator && operator <= 66; } } return false; @@ -38133,34 +39448,34 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 135: - case 208: - case 160: + case 136: + case 209: + case 161: + case 139: case 138: - case 137: - case 242: case 243: case 244: - case 140: - case 139: + case 245: case 141: + case 140: case 142: case 143: - case 210: - case 170: - case 171: - case 241: - return 1; - case 134: - case 212: - case 213: - case 152: - return 2; + case 144: case 211: + case 171: + case 172: + case 242: + return 1; + case 135: + case 213: case 214: - return 1 | 2; + case 153: + return 2; + case 212: case 215: - if (node.name.kind === 8) { + return 1 | 2; + case 216: + if (node.name.kind === 9) { return 4 | 1; } else if (ts.getModuleInstanceState(node) === 1) { @@ -38169,14 +39484,14 @@ var ts; else { return 4; } - case 222: case 223: - case 218: - case 219: case 224: + case 219: + case 220: case 225: + case 226: return 1 | 2 | 4; - case 245: + case 246: return 4 | 1; } return 1 | 2 | 4; @@ -38186,8 +39501,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 148 || - (node.parent.kind === 185 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 149 || + (node.parent.kind === 186 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -38195,47 +39510,47 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 163) { - while (root.parent && root.parent.kind === 163) { + if (root.parent.kind === 164) { + while (root.parent && root.parent.kind === 164) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 185 && root.parent.parent.kind === 240) { + if (!isLastClause && root.parent.kind === 186 && root.parent.parent.kind === 241) { var decl = root.parent.parent.parent; - return (decl.kind === 211 && root.parent.parent.token === 103) || - (decl.kind === 212 && root.parent.parent.token === 80); + return (decl.kind === 212 && root.parent.parent.token === 104) || + (decl.kind === 213 && root.parent.parent.token === 81); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 132) { - while (root.parent && root.parent.kind === 132) { + if (root.parent.kind === 133) { + while (root.parent && root.parent.kind === 133) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 148 && !isLastClause; + return root.parent.kind === 149 && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 132) { + while (node.parent.kind === 133) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 66); - if (node.parent.kind === 132 && + ts.Debug.assert(node.kind === 67); + if (node.parent.kind === 133 && node.parent.right === node && - node.parent.parent.kind === 218) { + node.parent.parent.kind === 219) { return 1 | 2 | 4; } return 4; } function getMeaningFromLocation(node) { - if (node.parent.kind === 224) { + if (node.parent.kind === 225) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -38269,15 +39584,15 @@ var ts; return; } switch (node.kind) { - case 163: - case 132: - case 8: - case 81: - case 96: - case 90: - case 92: - case 94: - case 66: + case 164: + case 133: + case 9: + case 82: + case 97: + case 91: + case 93: + case 95: + case 67: break; default: return; @@ -38288,7 +39603,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 215 && + if (nodeForStartPos.parent.parent.kind === 216 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -38315,10 +39630,10 @@ var ts; } function checkForClassificationCancellation(kind) { switch (kind) { - case 215: - case 211: + case 216: case 212: - case 210: + case 213: + case 211: cancellationToken.throwIfCancellationRequested(); } } @@ -38366,7 +39681,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 215 && + return declaration.kind === 216 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -38375,7 +39690,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(kind); - if (kind === 66 && !ts.nodeIsMissing(node)) { + if (kind === 67 && !ts.nodeIsMissing(node)) { var identifier = node; if (classifiableNames[identifier.text]) { var symbol = typeChecker.getSymbolAtLocation(node); @@ -38462,7 +39777,7 @@ var ts; triviaScanner.setTextPos(end); continue; } - if (kind === 6) { + if (kind === 7) { var text = sourceFile.text; var ch = text.charCodeAt(start); if (ch === 60 || ch === 62) { @@ -38499,16 +39814,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 264: + case 265: processJSDocParameterTag(tag); break; - case 267: + case 268: processJSDocTemplateTag(tag); break; - case 266: + case 267: processElement(tag.typeExpression); break; - case 265: + case 266: processElement(tag.typeExpression); break; } @@ -38581,70 +39896,70 @@ var ts; if (ts.isKeyword(tokenKind)) { return 3; } - if (tokenKind === 24 || tokenKind === 26) { + if (tokenKind === 25 || tokenKind === 27) { if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { return 10; } } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 54) { - if (token.parent.kind === 208 || - token.parent.kind === 138 || - token.parent.kind === 135) { + if (tokenKind === 55) { + if (token.parent.kind === 209 || + token.parent.kind === 139 || + token.parent.kind === 136) { return 5; } } - if (token.parent.kind === 178 || - token.parent.kind === 176 || + if (token.parent.kind === 179 || token.parent.kind === 177 || - token.parent.kind === 179) { + token.parent.kind === 178 || + token.parent.kind === 180) { return 5; } } return 10; } - else if (tokenKind === 7) { + else if (tokenKind === 8) { return 4; } - else if (tokenKind === 8) { + else if (tokenKind === 9) { return 6; } - else if (tokenKind === 9) { + else if (tokenKind === 10) { return 6; } else if (ts.isTemplateLiteralKind(tokenKind)) { return 6; } - else if (tokenKind === 66) { + else if (tokenKind === 67) { if (token) { switch (token.parent.kind) { - case 211: + case 212: if (token.parent.name === token) { return 11; } return; - case 134: + case 135: if (token.parent.name === token) { return 15; } return; - case 212: + case 213: if (token.parent.name === token) { return 13; } return; - case 214: + case 215: if (token.parent.name === token) { return 12; } return; - case 215: + case 216: if (token.parent.name === token) { return 14; } return; - case 135: + case 136: if (token.parent.name === token) { return 17; } @@ -38705,14 +40020,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 14: return 15; - case 16: return 17; - case 18: return 19; - case 24: return 26; - case 15: return 14; - case 17: return 16; - case 19: return 18; - case 26: return 24; + case 15: return 16; + case 17: return 18; + case 19: return 20; + case 25: return 27; + case 16: return 15; + case 18: return 17; + case 20: return 19; + case 27: return 25; } return undefined; } @@ -38747,6 +40062,38 @@ var ts; } return []; } + function getDocCommentTemplateAtPosition(fileName, position) { + var start = new Date().getTime(); + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { + return undefined; + } + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); + var tokenStart = tokenAtPos.getStart(); + if (!tokenAtPos || tokenStart < position) { + return undefined; + } + var containingFunction = ts.getAncestor(tokenAtPos, 211); + if (!containingFunction || containingFunction.getStart() < position) { + return undefined; + } + var parameters = containingFunction.parameters; + var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); + var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; + var docParams = parameters.reduce(function (prev, cur, index) { + return prev + + indentationStr + " * @param " + (cur.name.kind === 67 ? cur.name.text : "param" + index) + newLine; + }, ""); + var preamble = "/**" + newLine + + indentationStr + " * "; + var result = preamble + newLine + + docParams + + indentationStr + " */" + + (tokenStart === position ? newLine + indentationStr : ""); + return { newText: result, caretOffset: preamble.length }; + } function getTodoComments(fileName, descriptors) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -38789,8 +40136,6 @@ var ts; return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); } function getTodoCommentsRegExp() { - // NOTE: ?: means 'non-capture group'. It allows us to have groups without having to - // filter them out later in the final result array. var singleLineCommentStart = /(?:\/\/+\s*)/.source; var multiLineCommentStart = /(?:\/\*+\s*)/.source; var anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source; @@ -38813,7 +40158,7 @@ var ts; var sourceFile = getValidSourceFile(fileName); var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); - if (node && node.kind === 66) { + if (node && node.kind === 67) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var declarations = symbol.getDeclarations(); @@ -38891,6 +40236,7 @@ var ts; getFormattingEditsForRange: getFormattingEditsForRange, getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, getEmitOutput: getEmitOutput, getSourceFile: getSourceFile, getProgram: getProgram @@ -38910,13 +40256,13 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 66: + case 67: nameTable[node.text] = node.text; break; + case 9: case 8: - case 7: if (ts.isDeclarationName(node) || - node.parent.kind === 229 || + node.parent.kind === 230 || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -38929,31 +40275,31 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 164 && + node.parent.kind === 165 && node.parent.argumentExpression === node; } function createClassifier() { var scanner = ts.createScanner(2, false); var noRegexTable = []; - noRegexTable[66] = true; - noRegexTable[8] = true; - noRegexTable[7] = true; + noRegexTable[67] = true; noRegexTable[9] = true; - noRegexTable[94] = true; - noRegexTable[39] = true; + noRegexTable[8] = true; + noRegexTable[10] = true; + noRegexTable[95] = true; noRegexTable[40] = true; - noRegexTable[17] = true; - noRegexTable[19] = true; - noRegexTable[15] = true; - noRegexTable[96] = true; - noRegexTable[81] = true; + noRegexTable[41] = true; + noRegexTable[18] = true; + noRegexTable[20] = true; + noRegexTable[16] = true; + noRegexTable[97] = true; + noRegexTable[82] = true; var templateStack = []; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 120 || - keyword2 === 126 || - keyword2 === 118 || - keyword2 === 110) { + if (keyword2 === 121 || + keyword2 === 127 || + keyword2 === 119 || + keyword2 === 111) { return true; } return false; @@ -38966,7 +40312,7 @@ var ts; var lastEnd = 0; for (var i = 0, n = dense.length; i < n; i += 3) { var start = dense[i]; - var length_2 = dense[i + 1]; + var length_3 = dense[i + 1]; var type = dense[i + 2]; if (lastEnd >= 0) { var whitespaceLength_1 = start - lastEnd; @@ -38974,8 +40320,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); } } - entries.push({ length: length_2, classification: convertClassification(type) }); - lastEnd = start + length_2; + entries.push({ length: length_3, classification: convertClassification(type) }); + lastEnd = start + length_3; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -39036,7 +40382,7 @@ var ts; text = "}\n" + text; offset = 2; case 6: - templateStack.push(11); + templateStack.push(12); break; } scanner.setText(text); @@ -39048,55 +40394,55 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 37 || token === 58) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 9) { - token = 9; + if ((token === 38 || token === 59) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 10) { + token = 10; } } - else if (lastNonTriviaToken === 20 && isKeyword(token)) { - token = 66; + else if (lastNonTriviaToken === 21 && isKeyword(token)) { + token = 67; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 66; + token = 67; } - else if (lastNonTriviaToken === 66 && - token === 24) { + else if (lastNonTriviaToken === 67 && + token === 25) { angleBracketStack++; } - else if (token === 26 && angleBracketStack > 0) { + else if (token === 27 && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 114 || - token === 127 || - token === 125 || - token === 117 || - token === 128) { + else if (token === 115 || + token === 128 || + token === 126 || + token === 118 || + token === 129) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 66; + token = 67; } } - else if (token === 11) { + else if (token === 12) { templateStack.push(token); } - else if (token === 14) { + else if (token === 15) { if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 15) { + else if (token === 16) { if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 11) { + if (lastTemplateStackToken === 12) { token = scanner.reScanTemplateToken(); - if (token === 13) { + if (token === 14) { templateStack.pop(); } else { - ts.Debug.assert(token === 12, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 13, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 14, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 15, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -39111,7 +40457,7 @@ var ts; var end = scanner.getTextPos(); addResult(start, end, classFromKind(token)); if (end >= text.length) { - if (token === 8) { + if (token === 9) { var tokenText = scanner.getTokenText(); if (scanner.isUnterminated()) { var lastCharIndex = tokenText.length - 1; @@ -39134,10 +40480,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 13) { + if (token === 14) { result.endOfLineState = 5; } - else if (token === 10) { + else if (token === 11) { result.endOfLineState = 4; } else { @@ -39145,7 +40491,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 11) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12) { result.endOfLineState = 6; } } @@ -39169,42 +40515,42 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 36: case 37: case 38: - case 34: + case 39: case 35: - case 41: + case 36: case 42: case 43: - case 24: - case 26: + case 44: + case 25: case 27: case 28: - case 88: - case 87: case 29: + case 89: + case 88: case 30: case 31: case 32: - case 44: - case 46: + case 33: case 45: - case 49: + case 47: + case 46: case 50: - case 64: - case 63: + case 51: case 65: - case 60: + case 64: + case 66: case 61: case 62: - case 55: + case 63: case 56: case 57: case 58: case 59: - case 54: - case 23: + case 60: + case 55: + case 24: return true; default: return false; @@ -39212,19 +40558,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 34: case 35: + case 36: + case 49: case 48: - case 47: - case 39: case 40: + case 41: return true; default: return false; } } function isKeyword(token) { - return token >= 67 && token <= 131; + return token >= 68 && token <= 132; } function classFromKind(token) { if (isKeyword(token)) { @@ -39233,24 +40579,24 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5; } - else if (token >= 14 && token <= 65) { + else if (token >= 15 && token <= 66) { return 10; } switch (token) { - case 7: - return 4; case 8: - return 6; + return 4; case 9: + return 6; + case 10: return 7; - case 6: + case 7: case 3: case 2: return 1; case 5: case 4: return 8; - case 66: + case 67: default: if (ts.isTemplateLiteralKind(token)) { return 6; @@ -39276,7 +40622,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 245 ? new SourceFileObject() : new NodeObject(); + var proto = kind === 246 ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = -1; proto.end = -1; @@ -39292,10 +40638,6 @@ var ts; } initializeServices(); })(ts || (ts = {})); -/// -/// -/// -/// var ts; (function (ts) { var server; @@ -39366,9 +40708,11 @@ var ts; CommandNames.Format = "format"; CommandNames.Formatonkey = "formatonkey"; CommandNames.Geterr = "geterr"; + CommandNames.GeterrForProject = "geterrForProject"; CommandNames.NavBar = "navbar"; CommandNames.Navto = "navto"; CommandNames.Occurrences = "occurrences"; + CommandNames.DocumentHighlights = "documentHighlights"; CommandNames.Open = "open"; CommandNames.Quickinfo = "quickinfo"; CommandNames.References = "references"; @@ -39378,6 +40722,7 @@ var ts; CommandNames.SignatureHelp = "signatureHelp"; CommandNames.TypeDefinition = "typeDefinition"; CommandNames.ProjectInfo = "projectInfo"; + CommandNames.ReloadProjects = "reloadProjects"; CommandNames.Unknown = "unknown"; })(CommandNames = server.CommandNames || (server.CommandNames = {})); var Errors; @@ -39398,57 +40743,61 @@ var ts; this.handlers = (_a = {}, _a[CommandNames.Exit] = function () { _this.exit(); - return {}; + return { responseRequired: false }; }, _a[CommandNames.Definition] = function (request) { var defArgs = request.arguments; - return { response: _this.getDefinition(defArgs.line, defArgs.offset, defArgs.file) }; + return { response: _this.getDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; }, _a[CommandNames.TypeDefinition] = function (request) { var defArgs = request.arguments; - return { response: _this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file) }; + return { response: _this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; }, _a[CommandNames.References] = function (request) { var defArgs = request.arguments; - return { response: _this.getReferences(defArgs.line, defArgs.offset, defArgs.file) }; + return { response: _this.getReferences(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; }, _a[CommandNames.Rename] = function (request) { var renameArgs = request.arguments; - return { response: _this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings) }; + return { response: _this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings), responseRequired: true }; }, _a[CommandNames.Open] = function (request) { var openArgs = request.arguments; _this.openClientFile(openArgs.file); - return {}; + return { responseRequired: false }; }, _a[CommandNames.Quickinfo] = function (request) { var quickinfoArgs = request.arguments; - return { response: _this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file) }; + return { response: _this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file), responseRequired: true }; }, _a[CommandNames.Format] = function (request) { var formatArgs = request.arguments; - return { response: _this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file) }; + return { response: _this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file), responseRequired: true }; }, _a[CommandNames.Formatonkey] = function (request) { var formatOnKeyArgs = request.arguments; - return { response: _this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file) }; + return { response: _this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file), responseRequired: true }; }, _a[CommandNames.Completions] = function (request) { var completionsArgs = request.arguments; - return { response: _this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file) }; + return { response: _this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file), responseRequired: true }; }, _a[CommandNames.CompletionDetails] = function (request) { var completionDetailsArgs = request.arguments; - return { response: _this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset, completionDetailsArgs.entryNames, completionDetailsArgs.file) }; + return { response: _this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset, completionDetailsArgs.entryNames, completionDetailsArgs.file), responseRequired: true }; }, _a[CommandNames.SignatureHelp] = function (request) { var signatureHelpArgs = request.arguments; - return { response: _this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file) }; + return { response: _this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file), responseRequired: true }; }, _a[CommandNames.Geterr] = function (request) { var geterrArgs = request.arguments; return { response: _this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; }, + _a[CommandNames.GeterrForProject] = function (request) { + var _a = request.arguments, file = _a.file, delay = _a.delay; + return { response: _this.getDiagnosticsForProject(delay, file), responseRequired: false }; + }, _a[CommandNames.Change] = function (request) { var changeArgs = request.arguments; _this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset, changeArgs.insertString, changeArgs.file); @@ -39477,23 +40826,31 @@ var ts; }, _a[CommandNames.Navto] = function (request) { var navtoArgs = request.arguments; - return { response: _this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount) }; + return { response: _this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount), responseRequired: true }; }, _a[CommandNames.Brace] = function (request) { var braceArguments = request.arguments; - return { response: _this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file) }; + return { response: _this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file), responseRequired: true }; }, _a[CommandNames.NavBar] = function (request) { var navBarArgs = request.arguments; - return { response: _this.getNavigationBarItems(navBarArgs.file) }; + return { response: _this.getNavigationBarItems(navBarArgs.file), responseRequired: true }; }, _a[CommandNames.Occurrences] = function (request) { var _a = request.arguments, line = _a.line, offset = _a.offset, fileName = _a.file; - return { response: _this.getOccurrences(line, offset, fileName) }; + return { response: _this.getOccurrences(line, offset, fileName), responseRequired: true }; + }, + _a[CommandNames.DocumentHighlights] = function (request) { + var _a = request.arguments, line = _a.line, offset = _a.offset, fileName = _a.file, filesToSearch = _a.filesToSearch; + return { response: _this.getDocumentHighlights(line, offset, fileName, filesToSearch), responseRequired: true }; }, _a[CommandNames.ProjectInfo] = function (request) { var _a = request.arguments, file = _a.file, needFileNameList = _a.needFileNameList; - return { response: _this.getProjectInfo(file, needFileNameList) }; + return { response: _this.getProjectInfo(file, needFileNameList), responseRequired: true }; + }, + _a[CommandNames.ReloadProjects] = function (request) { + _this.reloadProjects(); + return { responseRequired: false }; }, _a ); @@ -39590,6 +40947,9 @@ var ts; this.syntacticCheck(file, project); this.semanticCheck(file, project); }; + Session.prototype.reloadProjects = function () { + this.projectService.reloadProjects(); + }; Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { var _this = this; if (ms === void 0) { ms = 1500; } @@ -39599,10 +40959,11 @@ var ts; } }, ms); }; - Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs) { + Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs, requireOpen) { var _this = this; if (ms === void 0) { ms = 1500; } if (followMs === void 0) { followMs = 200; } + if (requireOpen === void 0) { requireOpen = true; } if (followMs > ms) { followMs = ms; } @@ -39617,7 +40978,7 @@ var ts; var checkOne = function () { if (matchSeq(seq)) { var checkSpec = checkList[index++]; - if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, true)) { + if (checkSpec.project.getSourceFileFromName(checkSpec.fileName, requireOpen)) { _this.syntacticCheck(checkSpec.fileName, checkSpec.project); _this.immediateId = setImmediate(function () { _this.semanticCheck(checkSpec.fileName, checkSpec.project); @@ -39696,6 +41057,33 @@ var ts; }; }); }; + Session.prototype.getDocumentHighlights = function (line, offset, fileName, filesToSearch) { + fileName = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(fileName); + if (!project) { + throw Errors.NoProject; + } + var compilerService = project.compilerService; + var position = compilerService.host.lineOffsetToPosition(fileName, line, offset); + var documentHighlights = compilerService.languageService.getDocumentHighlights(fileName, position, filesToSearch); + if (!documentHighlights) { + return undefined; + } + return documentHighlights.map(convertToDocumentHighlightsItem); + function convertToDocumentHighlightsItem(documentHighlights) { + var fileName = documentHighlights.fileName, highlightSpans = documentHighlights.highlightSpans; + return { + file: fileName, + highlightSpans: highlightSpans.map(convertHighlightSpan) + }; + function convertHighlightSpan(highlightSpan) { + var textSpan = highlightSpan.textSpan, kind = highlightSpan.kind; + var start = compilerService.host.positionToLineOffset(fileName, textSpan.start); + var end = compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(textSpan)); + return { start: start, end: end, kind: kind }; + } + } + }; Session.prototype.getProjectInfo = function (fileName, needFileNameList) { fileName = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(fileName); @@ -39703,7 +41091,7 @@ var ts; configFileName: project.projectFilename }; if (needFileNameList) { - projectInfo.fileNameList = project.getFileNameList(); + projectInfo.fileNames = project.getFileNames(); } return projectInfo; }; @@ -40116,6 +41504,45 @@ var ts; end: compilerService.host.positionToLineOffset(file, span.start + span.length) }); }); }; + Session.prototype.getDiagnosticsForProject = function (delay, fileName) { + var _this = this; + var _a = this.getProjectInfo(fileName, true), configFileName = _a.configFileName, fileNamesInProject = _a.fileNames; + fileNamesInProject = fileNamesInProject.filter(function (value, index, array) { return value.indexOf("lib.d.ts") < 0; }); + var highPriorityFiles = []; + var mediumPriorityFiles = []; + var lowPriorityFiles = []; + var veryLowPriorityFiles = []; + var normalizedFileName = ts.normalizePath(fileName); + var project = this.projectService.getProjectForFile(normalizedFileName); + for (var _i = 0; _i < fileNamesInProject.length; _i++) { + var fileNameInProject = fileNamesInProject[_i]; + if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) + highPriorityFiles.push(fileNameInProject); + else { + var info = this.projectService.getScriptInfo(fileNameInProject); + if (!info.isOpen) { + if (fileNameInProject.indexOf(".d.ts") > 0) + veryLowPriorityFiles.push(fileNameInProject); + else + lowPriorityFiles.push(fileNameInProject); + } + else + mediumPriorityFiles.push(fileNameInProject); + } + } + fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); + if (fileNamesInProject.length > 0) { + var checkList = fileNamesInProject.map(function (fileName) { + var normalizedFileName = ts.normalizePath(fileName); + return { fileName: normalizedFileName, project: project }; + }); + this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); + } + }; + Session.prototype.getCanonicalFileName = function (fileName) { + var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return ts.normalizePath(name); + }; Session.prototype.exit = function () { }; Session.prototype.addProtocolHandler = function (command, handler) { @@ -40173,10 +41600,6 @@ var ts; server.Session = Session; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -/// -/// -/// -/// var ts; (function (ts) { var server; @@ -40238,12 +41661,52 @@ var ts; server.ScriptInfo = ScriptInfo; var LSHost = (function () { function LSHost(host, project) { + var _this = this; this.host = host; this.project = project; this.ls = null; this.filenameToScript = {}; this.roots = []; + this.resolvedModuleNames = ts.createFileMap(ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + this.moduleResolutionHost = { + fileExists: function (fileName) { return _this.fileExists(fileName); }, + readFile: function (fileName) { return _this.host.readFile(fileName); } + }; } + LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { + var currentResolutionsInFile = this.resolvedModuleNames.get(containingFile); + var newResolutions = {}; + var resolvedModules = []; + var compilerOptions = this.getCompilationSettings(); + for (var _i = 0; _i < moduleNames.length; _i++) { + var moduleName = moduleNames[_i]; + var resolution = ts.lookUp(newResolutions, moduleName); + if (!resolution) { + var existingResolution = currentResolutionsInFile && ts.lookUp(currentResolutionsInFile, moduleName); + if (moduleResolutionIsValid(existingResolution)) { + resolution = existingResolution; + } + else { + resolution = ts.resolveModuleName(moduleName, containingFile, compilerOptions, this.moduleResolutionHost); + resolution.lastCheckTime = Date.now(); + newResolutions[moduleName] = resolution; + } + } + ts.Debug.assert(resolution !== undefined); + resolvedModules.push(resolution.resolvedModule); + } + this.resolvedModuleNames.set(containingFile, newResolutions); + return resolvedModules; + function moduleResolutionIsValid(resolution) { + if (!resolution) { + return false; + } + if (resolution.resolvedModule) { + return true; + } + return resolution.failedLookupLocations.length === 0; + } + }; LSHost.prototype.getDefaultLibFileName = function () { var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings)); @@ -40256,6 +41719,7 @@ var ts; }; LSHost.prototype.setCompilationSettings = function (opt) { this.compilationSettings = opt; + this.resolvedModuleNames.clear(); }; LSHost.prototype.lineAffectsRefs = function (filename, line) { var info = this.getScriptInfo(filename); @@ -40283,6 +41747,7 @@ var ts; LSHost.prototype.removeReferencedFile = function (info) { if (!info.isOpen) { this.filenameToScript[info.fileName] = undefined; + this.resolvedModuleNames.remove(info.fileName); } }; LSHost.prototype.getScriptInfo = function (filename) { @@ -40304,6 +41769,13 @@ var ts; this.roots.push(info); } }; + LSHost.prototype.removeRoot = function (info) { + var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName); + if (scriptInfo) { + this.filenameToScript[info.fileName] = undefined; + this.roots = copyListRemovingItem(info, this.roots); + } + }; LSHost.prototype.saveTo = function (filename, tmpfilename) { var script = this.getScriptInfo(filename); if (script) { @@ -40410,7 +41882,7 @@ var ts; Project.prototype.openReferencedFile = function (filename) { return this.projectService.openFile(filename, false); }; - Project.prototype.getFileNameList = function () { + Project.prototype.getFileNames = function () { var sourceFiles = this.program.getSourceFiles(); return sourceFiles.map(function (sourceFile) { return sourceFile.fileName; }); }; @@ -40455,6 +41927,10 @@ var ts; info.defaultProject = this; this.compilerService.host.addRoot(info); }; + Project.prototype.removeRoot = function (info) { + info.defaultProject = undefined; + this.compilerService.host.removeRoot(info); + }; Project.prototype.filesToString = function () { var strBuilder = ""; ts.forEachValue(this.filenameToSourceFile, function (sourceFile) { strBuilder += sourceFile.fileName + "\n"; }); @@ -40520,6 +41996,11 @@ var ts; } } }; + ProjectService.prototype.watchedProjectConfigFileChanged = function (project) { + this.log("Config File Changed: " + project.projectFilename); + this.updateConfiguredProject(project); + this.updateProjectStructure(); + }; ProjectService.prototype.log = function (msg, type) { if (type === void 0) { type = "Err"; } this.psLogger.msg(msg, type); @@ -40589,6 +42070,18 @@ var ts; } this.configuredProjects = configuredProjects; }; + ProjectService.prototype.removeConfiguredProject = function (project) { + project.projectFileWatcher.close(); + this.configuredProjects = copyListRemovingItem(project, this.configuredProjects); + var fileNames = project.getFileNames(); + for (var _i = 0; _i < fileNames.length; _i++) { + var fileName = fileNames[_i]; + var info = this.getScriptInfo(fileName); + if (info.defaultProject == project) { + info.defaultProject = undefined; + } + } + }; ProjectService.prototype.setConfiguredProjectRoot = function (info) { for (var i = 0, len = this.configuredProjects.length; i < len; i++) { var configuredProject = this.configuredProjects[i]; @@ -40707,11 +42200,31 @@ var ts; } return referencingProjects; }; + ProjectService.prototype.reloadProjects = function () { + for (var _i = 0, _a = this.openFileRoots; _i < _a.length; _i++) { + var info = _a[_i]; + this.openOrUpdateConfiguredProjectForFile(info.fileName); + } + this.updateProjectStructure(); + }; ProjectService.prototype.updateProjectStructure = function () { this.log("updating project structure from ...", "Info"); this.printProjects(); - var openFilesReferenced = []; var unattachedOpenFiles = []; + var openFileRootsConfigured = []; + for (var _i = 0, _a = this.openFileRootsConfigured; _i < _a.length; _i++) { + var info = _a[_i]; + var project = info.defaultProject; + if (!project || !(project.getSourceFile(info))) { + info.defaultProject = undefined; + unattachedOpenFiles.push(info); + } + else { + openFileRootsConfigured.push(info); + } + } + this.openFileRootsConfigured = openFileRootsConfigured; + var openFilesReferenced = []; for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { var referencedFile = this.openFilesReferenced[i]; referencedFile.defaultProject.updateGraph(); @@ -40794,32 +42307,36 @@ var ts; return undefined; }; ProjectService.prototype.openClientFile = function (fileName) { + this.openOrUpdateConfiguredProjectForFile(fileName); + var info = this.openFile(fileName, true); + this.addOpenFile(info); + this.printProjects(); + return info; + }; + ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { var searchPath = ts.normalizePath(ts.getDirectoryPath(fileName)); this.log("Search path: " + searchPath, "Info"); var configFileName = this.findConfigFile(searchPath); if (configFileName) { this.log("Config file name: " + configFileName, "Info"); - } - else { - this.log("no config file"); - } - if (configFileName) { - configFileName = getAbsolutePath(configFileName, searchPath); - } - if (configFileName && (!this.configProjectIsActive(configFileName))) { - var configResult = this.openConfigFile(configFileName, fileName); - if (!configResult.success) { - this.log("Error opening config file " + configFileName + " " + configResult.errorMsg); + var project = this.findConfiguredProjectByConfigFile(configFileName); + if (!project) { + var configResult = this.openConfigFile(configFileName, fileName); + if (!configResult.success) { + this.log("Error opening config file " + configFileName + " " + configResult.errorMsg); + } + else { + this.log("Opened configuration file " + configFileName, "Info"); + this.configuredProjects.push(configResult.project); + } } else { - this.log("Opened configuration file " + configFileName, "Info"); - this.configuredProjects.push(configResult.project); + this.updateConfiguredProject(project); } } - var info = this.openFile(fileName, true); - this.addOpenFile(info); - this.printProjects(); - return info; + else { + this.log("No config files found."); + } }; ProjectService.prototype.closeClientFile = function (filename) { var info = ts.lookUp(this.filenameToScriptInfo, filename); @@ -40888,46 +42405,105 @@ var ts; this.psLogger.endGroup(); }; ProjectService.prototype.configProjectIsActive = function (fileName) { + return this.findConfiguredProjectByConfigFile(fileName) === undefined; + }; + ProjectService.prototype.findConfiguredProjectByConfigFile = function (configFileName) { for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - if (this.configuredProjects[i].projectFilename == fileName) { - return true; + if (this.configuredProjects[i].projectFilename == configFileName) { + return this.configuredProjects[i]; } } - return false; + return undefined; }; - ProjectService.prototype.openConfigFile = function (configFilename, clientFileName) { + ProjectService.prototype.configFileToProjectOptions = function (configFilename) { configFilename = ts.normalizePath(configFilename); var dirPath = ts.getDirectoryPath(configFilename); - var rawConfig = ts.readConfigFile(configFilename); + var contents = this.host.readFile(configFilename); + var rawConfig = ts.parseConfigFileText(configFilename, contents); if (rawConfig.error) { - return rawConfig.error; + return { succeeded: false, error: rawConfig.error }; } else { var parsedCommandLine = ts.parseConfigFile(rawConfig.config, this.host, dirPath); if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { - return { errorMsg: "tsconfig option errors" }; + return { succeeded: false, error: { errorMsg: "tsconfig option errors" } }; } - else if (parsedCommandLine.fileNames) { + else if (parsedCommandLine.fileNames == null) { + return { succeeded: false, error: { errorMsg: "no files found" } }; + } + else { var projectOptions = { files: parsedCommandLine.fileNames, compilerOptions: parsedCommandLine.options }; - var proj = this.createProject(configFilename, projectOptions); - for (var i = 0, len = parsedCommandLine.fileNames.length; i < len; i++) { - var rootFilename = parsedCommandLine.fileNames[i]; - if (this.host.fileExists(rootFilename)) { - var info = this.openFile(rootFilename, clientFileName == rootFilename); - proj.addRoot(info); - } - else { - return { errorMsg: "specified file " + rootFilename + " not found" }; - } + return { succeeded: true, projectOptions: projectOptions }; + } + } + }; + ProjectService.prototype.openConfigFile = function (configFilename, clientFileName) { + var _this = this; + var _a = this.configFileToProjectOptions(configFilename), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; + if (!succeeded) { + return error; + } + else { + var proj = this.createProject(configFilename, projectOptions); + for (var i = 0, len = projectOptions.files.length; i < len; i++) { + var rootFilename = projectOptions.files[i]; + if (this.host.fileExists(rootFilename)) { + var info = this.openFile(rootFilename, clientFileName == rootFilename); + proj.addRoot(info); } - proj.finishGraph(); - return { success: true, project: proj }; + else { + return { errorMsg: "specified file " + rootFilename + " not found" }; + } + } + proj.finishGraph(); + proj.projectFileWatcher = this.host.watchFile(configFilename, function (_) { return _this.watchedProjectConfigFileChanged(proj); }); + return { success: true, project: proj }; + } + }; + ProjectService.prototype.updateConfiguredProject = function (project) { + if (!this.host.fileExists(project.projectFilename)) { + this.log("Config file deleted"); + this.removeConfiguredProject(project); + } + else { + var _a = this.configFileToProjectOptions(project.projectFilename), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; + if (!succeeded) { + return error; } else { - return { errorMsg: "no files found" }; + var oldFileNames = project.compilerService.host.roots.map(function (info) { return info.fileName; }); + var newFileNames = projectOptions.files; + var fileNamesToRemove = oldFileNames.filter(function (f) { return newFileNames.indexOf(f) < 0; }); + var fileNamesToAdd = newFileNames.filter(function (f) { return oldFileNames.indexOf(f) < 0; }); + for (var _i = 0; _i < fileNamesToRemove.length; _i++) { + var fileName = fileNamesToRemove[_i]; + var info = this.getScriptInfo(fileName); + project.removeRoot(info); + } + for (var _b = 0; _b < fileNamesToAdd.length; _b++) { + var fileName = fileNamesToAdd[_b]; + var info = this.getScriptInfo(fileName); + if (!info) { + info = this.openFile(fileName, false); + } + else { + if (info.isOpen) { + if (this.openFileRoots.indexOf(info) >= 0) { + this.openFileRoots = copyListRemovingItem(info, this.openFileRoots); + } + if (this.openFilesReferenced.indexOf(info) >= 0) { + this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced); + } + this.openFileRootsConfigured.push(info); + } + } + project.addRoot(info); + } + project.setProjectOptions(projectOptions); + project.finishGraph(); } } }; @@ -40972,6 +42548,7 @@ var ts; InsertSpaceAfterKeywordsInControlFlowStatements: true, InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false, InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, PlaceOpenBraceOnNewLineForFunctions: false, PlaceOpenBraceOnNewLineForControlBlocks: false }; @@ -41805,8 +43382,6 @@ var ts; server.LineLeaf = LineLeaf; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -/// -/// var ts; (function (ts) { var server; @@ -42029,21 +43604,6 @@ var ts; ioSession.listen(); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -// -// 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 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -/// var debugObjectHost = this; var ts; (function (ts) { @@ -42081,9 +43641,19 @@ var ts; })(); var LanguageServiceShimHostAdapter = (function () { function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; this.shimHost = shimHost; this.loggingEnabled = false; this.tracingEnabled = false; + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { + var result = ts.lookUp(resolutionsInFile, name); + return result ? { resolvedFileName: result } : undefined; + }); + }; + } } LanguageServiceShimHostAdapter.prototype.log = function (s) { if (this.loggingEnabled) { @@ -42180,10 +43750,22 @@ var ts; function CoreServicesShimHostAdapter(shimHost) { this.shimHost = shimHost; } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension) { - var encoded = this.shimHost.readDirectory(rootDir, extension); + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension, exclude) { + var encoded; + try { + encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); + } + catch (e) { + encoded = this.shimHost.readDirectory(rootDir, extension); + } return JSON.parse(encoded); }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; return CoreServicesShimHostAdapter; })(); ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; @@ -42279,7 +43861,7 @@ var ts; }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { - var newLine = this.getNewLine(); + var newLine = ts.getNewLineOrDefaultFromHost(this.host); return ts.realizeDiagnostics(diagnostics, newLine); }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { @@ -42308,9 +43890,6 @@ var ts; return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; - LanguageServiceShimObject.prototype.getNewLine = function () { - return this.host.getNewLine ? this.host.getNewLine() : "\r\n"; - }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { @@ -42419,7 +43998,9 @@ var ts; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { - return _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); }); }; LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { @@ -42460,6 +44041,10 @@ var ts; return edits; }); }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount) { var _this = this; return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ")", function () { @@ -42537,12 +44122,24 @@ var ts; CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + return { + resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); var convertResult = { referencedFiles: [], importedFiles: [], + ambientExternalModules: result.ambientExternalModules, isLibFile: result.isLibFile }; ts.forEach(result.referencedFiles, function (refFile) { @@ -42659,4 +44256,4 @@ var TypeScript; Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); -var toolsVersion = "1.5"; +var toolsVersion = "1.6"; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index ee69b9ca909..2cd3a663fce 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -13,7 +13,7 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -declare module "typescript" { +declare namespace ts { interface Map { [index: string]: T; } @@ -23,6 +23,7 @@ declare module "typescript" { contains(fileName: string): boolean; remove(fileName: string): void; forEachValue(f: (v: T) => void): void; + clear(): void; } interface TextRange { pos: number; @@ -35,293 +36,294 @@ declare module "typescript" { MultiLineCommentTrivia = 3, NewLineTrivia = 4, WhitespaceTrivia = 5, - ConflictMarkerTrivia = 6, - NumericLiteral = 7, - StringLiteral = 8, - RegularExpressionLiteral = 9, - NoSubstitutionTemplateLiteral = 10, - TemplateHead = 11, - TemplateMiddle = 12, - TemplateTail = 13, - OpenBraceToken = 14, - CloseBraceToken = 15, - OpenParenToken = 16, - CloseParenToken = 17, - OpenBracketToken = 18, - CloseBracketToken = 19, - DotToken = 20, - DotDotDotToken = 21, - SemicolonToken = 22, - CommaToken = 23, - LessThanToken = 24, - LessThanSlashToken = 25, - GreaterThanToken = 26, - LessThanEqualsToken = 27, - GreaterThanEqualsToken = 28, - EqualsEqualsToken = 29, - ExclamationEqualsToken = 30, - EqualsEqualsEqualsToken = 31, - ExclamationEqualsEqualsToken = 32, - EqualsGreaterThanToken = 33, - PlusToken = 34, - MinusToken = 35, - AsteriskToken = 36, - SlashToken = 37, - PercentToken = 38, - PlusPlusToken = 39, - MinusMinusToken = 40, - LessThanLessThanToken = 41, - GreaterThanGreaterThanToken = 42, - GreaterThanGreaterThanGreaterThanToken = 43, - AmpersandToken = 44, - BarToken = 45, - CaretToken = 46, - ExclamationToken = 47, - TildeToken = 48, - AmpersandAmpersandToken = 49, - BarBarToken = 50, - QuestionToken = 51, - ColonToken = 52, - AtToken = 53, - EqualsToken = 54, - PlusEqualsToken = 55, - MinusEqualsToken = 56, - AsteriskEqualsToken = 57, - SlashEqualsToken = 58, - PercentEqualsToken = 59, - LessThanLessThanEqualsToken = 60, - GreaterThanGreaterThanEqualsToken = 61, - GreaterThanGreaterThanGreaterThanEqualsToken = 62, - AmpersandEqualsToken = 63, - BarEqualsToken = 64, - CaretEqualsToken = 65, - Identifier = 66, - BreakKeyword = 67, - CaseKeyword = 68, - CatchKeyword = 69, - ClassKeyword = 70, - ConstKeyword = 71, - ContinueKeyword = 72, - DebuggerKeyword = 73, - DefaultKeyword = 74, - DeleteKeyword = 75, - DoKeyword = 76, - ElseKeyword = 77, - EnumKeyword = 78, - ExportKeyword = 79, - ExtendsKeyword = 80, - FalseKeyword = 81, - FinallyKeyword = 82, - ForKeyword = 83, - FunctionKeyword = 84, - IfKeyword = 85, - ImportKeyword = 86, - InKeyword = 87, - InstanceOfKeyword = 88, - NewKeyword = 89, - NullKeyword = 90, - ReturnKeyword = 91, - SuperKeyword = 92, - SwitchKeyword = 93, - ThisKeyword = 94, - ThrowKeyword = 95, - TrueKeyword = 96, - TryKeyword = 97, - TypeOfKeyword = 98, - VarKeyword = 99, - VoidKeyword = 100, - WhileKeyword = 101, - WithKeyword = 102, - ImplementsKeyword = 103, - InterfaceKeyword = 104, - LetKeyword = 105, - PackageKeyword = 106, - PrivateKeyword = 107, - ProtectedKeyword = 108, - PublicKeyword = 109, - StaticKeyword = 110, - YieldKeyword = 111, - AbstractKeyword = 112, - AsKeyword = 113, - AnyKeyword = 114, - AsyncKeyword = 115, - AwaitKeyword = 116, - BooleanKeyword = 117, - ConstructorKeyword = 118, - DeclareKeyword = 119, - GetKeyword = 120, - IsKeyword = 121, - ModuleKeyword = 122, - NamespaceKeyword = 123, - RequireKeyword = 124, - NumberKeyword = 125, - SetKeyword = 126, - StringKeyword = 127, - SymbolKeyword = 128, - TypeKeyword = 129, - FromKeyword = 130, - OfKeyword = 131, - QualifiedName = 132, - ComputedPropertyName = 133, - TypeParameter = 134, - Parameter = 135, - Decorator = 136, - PropertySignature = 137, - PropertyDeclaration = 138, - MethodSignature = 139, - MethodDeclaration = 140, - Constructor = 141, - GetAccessor = 142, - SetAccessor = 143, - CallSignature = 144, - ConstructSignature = 145, - IndexSignature = 146, - TypePredicate = 147, - TypeReference = 148, - FunctionType = 149, - ConstructorType = 150, - TypeQuery = 151, - TypeLiteral = 152, - ArrayType = 153, - TupleType = 154, - UnionType = 155, - IntersectionType = 156, - ParenthesizedType = 157, - ObjectBindingPattern = 158, - ArrayBindingPattern = 159, - BindingElement = 160, - ArrayLiteralExpression = 161, - ObjectLiteralExpression = 162, - PropertyAccessExpression = 163, - ElementAccessExpression = 164, - CallExpression = 165, - NewExpression = 166, - TaggedTemplateExpression = 167, - TypeAssertionExpression = 168, - ParenthesizedExpression = 169, - FunctionExpression = 170, - ArrowFunction = 171, - DeleteExpression = 172, - TypeOfExpression = 173, - VoidExpression = 174, - AwaitExpression = 175, - PrefixUnaryExpression = 176, - PostfixUnaryExpression = 177, - BinaryExpression = 178, - ConditionalExpression = 179, - TemplateExpression = 180, - YieldExpression = 181, - SpreadElementExpression = 182, - ClassExpression = 183, - OmittedExpression = 184, - ExpressionWithTypeArguments = 185, - AsExpression = 186, - TemplateSpan = 187, - SemicolonClassElement = 188, - Block = 189, - VariableStatement = 190, - EmptyStatement = 191, - ExpressionStatement = 192, - IfStatement = 193, - DoStatement = 194, - WhileStatement = 195, - ForStatement = 196, - ForInStatement = 197, - ForOfStatement = 198, - ContinueStatement = 199, - BreakStatement = 200, - ReturnStatement = 201, - WithStatement = 202, - SwitchStatement = 203, - LabeledStatement = 204, - ThrowStatement = 205, - TryStatement = 206, - DebuggerStatement = 207, - VariableDeclaration = 208, - VariableDeclarationList = 209, - FunctionDeclaration = 210, - ClassDeclaration = 211, - InterfaceDeclaration = 212, - TypeAliasDeclaration = 213, - EnumDeclaration = 214, - ModuleDeclaration = 215, - ModuleBlock = 216, - CaseBlock = 217, - ImportEqualsDeclaration = 218, - ImportDeclaration = 219, - ImportClause = 220, - NamespaceImport = 221, - NamedImports = 222, - ImportSpecifier = 223, - ExportAssignment = 224, - ExportDeclaration = 225, - NamedExports = 226, - ExportSpecifier = 227, - MissingDeclaration = 228, - ExternalModuleReference = 229, - JsxElement = 230, - JsxSelfClosingElement = 231, - JsxOpeningElement = 232, - JsxText = 233, - JsxClosingElement = 234, - JsxAttribute = 235, - JsxSpreadAttribute = 236, - JsxExpression = 237, - CaseClause = 238, - DefaultClause = 239, - HeritageClause = 240, - CatchClause = 241, - PropertyAssignment = 242, - ShorthandPropertyAssignment = 243, - EnumMember = 244, - SourceFile = 245, - JSDocTypeExpression = 246, - JSDocAllType = 247, - JSDocUnknownType = 248, - JSDocArrayType = 249, - JSDocUnionType = 250, - JSDocTupleType = 251, - JSDocNullableType = 252, - JSDocNonNullableType = 253, - JSDocRecordType = 254, - JSDocRecordMember = 255, - JSDocTypeReference = 256, - JSDocOptionalType = 257, - JSDocFunctionType = 258, - JSDocVariadicType = 259, - JSDocConstructorType = 260, - JSDocThisType = 261, - JSDocComment = 262, - JSDocTag = 263, - JSDocParameterTag = 264, - JSDocReturnTag = 265, - JSDocTypeTag = 266, - JSDocTemplateTag = 267, - SyntaxList = 268, - Count = 269, - FirstAssignment = 54, - LastAssignment = 65, - FirstReservedWord = 67, - LastReservedWord = 102, - FirstKeyword = 67, - LastKeyword = 131, - FirstFutureReservedWord = 103, - LastFutureReservedWord = 111, - FirstTypeNode = 148, - LastTypeNode = 157, - FirstPunctuation = 14, - LastPunctuation = 65, + ShebangTrivia = 6, + ConflictMarkerTrivia = 7, + NumericLiteral = 8, + StringLiteral = 9, + RegularExpressionLiteral = 10, + NoSubstitutionTemplateLiteral = 11, + TemplateHead = 12, + TemplateMiddle = 13, + TemplateTail = 14, + OpenBraceToken = 15, + CloseBraceToken = 16, + OpenParenToken = 17, + CloseParenToken = 18, + OpenBracketToken = 19, + CloseBracketToken = 20, + DotToken = 21, + DotDotDotToken = 22, + SemicolonToken = 23, + CommaToken = 24, + LessThanToken = 25, + LessThanSlashToken = 26, + GreaterThanToken = 27, + LessThanEqualsToken = 28, + GreaterThanEqualsToken = 29, + EqualsEqualsToken = 30, + ExclamationEqualsToken = 31, + EqualsEqualsEqualsToken = 32, + ExclamationEqualsEqualsToken = 33, + EqualsGreaterThanToken = 34, + PlusToken = 35, + MinusToken = 36, + AsteriskToken = 37, + SlashToken = 38, + PercentToken = 39, + PlusPlusToken = 40, + MinusMinusToken = 41, + LessThanLessThanToken = 42, + GreaterThanGreaterThanToken = 43, + GreaterThanGreaterThanGreaterThanToken = 44, + AmpersandToken = 45, + BarToken = 46, + CaretToken = 47, + ExclamationToken = 48, + TildeToken = 49, + AmpersandAmpersandToken = 50, + BarBarToken = 51, + QuestionToken = 52, + ColonToken = 53, + AtToken = 54, + EqualsToken = 55, + PlusEqualsToken = 56, + MinusEqualsToken = 57, + AsteriskEqualsToken = 58, + SlashEqualsToken = 59, + PercentEqualsToken = 60, + LessThanLessThanEqualsToken = 61, + GreaterThanGreaterThanEqualsToken = 62, + GreaterThanGreaterThanGreaterThanEqualsToken = 63, + AmpersandEqualsToken = 64, + BarEqualsToken = 65, + CaretEqualsToken = 66, + Identifier = 67, + BreakKeyword = 68, + CaseKeyword = 69, + CatchKeyword = 70, + ClassKeyword = 71, + ConstKeyword = 72, + ContinueKeyword = 73, + DebuggerKeyword = 74, + DefaultKeyword = 75, + DeleteKeyword = 76, + DoKeyword = 77, + ElseKeyword = 78, + EnumKeyword = 79, + ExportKeyword = 80, + ExtendsKeyword = 81, + FalseKeyword = 82, + FinallyKeyword = 83, + ForKeyword = 84, + FunctionKeyword = 85, + IfKeyword = 86, + ImportKeyword = 87, + InKeyword = 88, + InstanceOfKeyword = 89, + NewKeyword = 90, + NullKeyword = 91, + ReturnKeyword = 92, + SuperKeyword = 93, + SwitchKeyword = 94, + ThisKeyword = 95, + ThrowKeyword = 96, + TrueKeyword = 97, + TryKeyword = 98, + TypeOfKeyword = 99, + VarKeyword = 100, + VoidKeyword = 101, + WhileKeyword = 102, + WithKeyword = 103, + ImplementsKeyword = 104, + InterfaceKeyword = 105, + LetKeyword = 106, + PackageKeyword = 107, + PrivateKeyword = 108, + ProtectedKeyword = 109, + PublicKeyword = 110, + StaticKeyword = 111, + YieldKeyword = 112, + AbstractKeyword = 113, + AsKeyword = 114, + AnyKeyword = 115, + AsyncKeyword = 116, + AwaitKeyword = 117, + BooleanKeyword = 118, + ConstructorKeyword = 119, + DeclareKeyword = 120, + GetKeyword = 121, + IsKeyword = 122, + ModuleKeyword = 123, + NamespaceKeyword = 124, + RequireKeyword = 125, + NumberKeyword = 126, + SetKeyword = 127, + StringKeyword = 128, + SymbolKeyword = 129, + TypeKeyword = 130, + FromKeyword = 131, + OfKeyword = 132, + QualifiedName = 133, + ComputedPropertyName = 134, + TypeParameter = 135, + Parameter = 136, + Decorator = 137, + PropertySignature = 138, + PropertyDeclaration = 139, + MethodSignature = 140, + MethodDeclaration = 141, + Constructor = 142, + GetAccessor = 143, + SetAccessor = 144, + CallSignature = 145, + ConstructSignature = 146, + IndexSignature = 147, + TypePredicate = 148, + TypeReference = 149, + FunctionType = 150, + ConstructorType = 151, + TypeQuery = 152, + TypeLiteral = 153, + ArrayType = 154, + TupleType = 155, + UnionType = 156, + IntersectionType = 157, + ParenthesizedType = 158, + ObjectBindingPattern = 159, + ArrayBindingPattern = 160, + BindingElement = 161, + ArrayLiteralExpression = 162, + ObjectLiteralExpression = 163, + PropertyAccessExpression = 164, + ElementAccessExpression = 165, + CallExpression = 166, + NewExpression = 167, + TaggedTemplateExpression = 168, + TypeAssertionExpression = 169, + ParenthesizedExpression = 170, + FunctionExpression = 171, + ArrowFunction = 172, + DeleteExpression = 173, + TypeOfExpression = 174, + VoidExpression = 175, + AwaitExpression = 176, + PrefixUnaryExpression = 177, + PostfixUnaryExpression = 178, + BinaryExpression = 179, + ConditionalExpression = 180, + TemplateExpression = 181, + YieldExpression = 182, + SpreadElementExpression = 183, + ClassExpression = 184, + OmittedExpression = 185, + ExpressionWithTypeArguments = 186, + AsExpression = 187, + TemplateSpan = 188, + SemicolonClassElement = 189, + Block = 190, + VariableStatement = 191, + EmptyStatement = 192, + ExpressionStatement = 193, + IfStatement = 194, + DoStatement = 195, + WhileStatement = 196, + ForStatement = 197, + ForInStatement = 198, + ForOfStatement = 199, + ContinueStatement = 200, + BreakStatement = 201, + ReturnStatement = 202, + WithStatement = 203, + SwitchStatement = 204, + LabeledStatement = 205, + ThrowStatement = 206, + TryStatement = 207, + DebuggerStatement = 208, + VariableDeclaration = 209, + VariableDeclarationList = 210, + FunctionDeclaration = 211, + ClassDeclaration = 212, + InterfaceDeclaration = 213, + TypeAliasDeclaration = 214, + EnumDeclaration = 215, + ModuleDeclaration = 216, + ModuleBlock = 217, + CaseBlock = 218, + ImportEqualsDeclaration = 219, + ImportDeclaration = 220, + ImportClause = 221, + NamespaceImport = 222, + NamedImports = 223, + ImportSpecifier = 224, + ExportAssignment = 225, + ExportDeclaration = 226, + NamedExports = 227, + ExportSpecifier = 228, + MissingDeclaration = 229, + ExternalModuleReference = 230, + JsxElement = 231, + JsxSelfClosingElement = 232, + JsxOpeningElement = 233, + JsxText = 234, + JsxClosingElement = 235, + JsxAttribute = 236, + JsxSpreadAttribute = 237, + JsxExpression = 238, + CaseClause = 239, + DefaultClause = 240, + HeritageClause = 241, + CatchClause = 242, + PropertyAssignment = 243, + ShorthandPropertyAssignment = 244, + EnumMember = 245, + SourceFile = 246, + JSDocTypeExpression = 247, + JSDocAllType = 248, + JSDocUnknownType = 249, + JSDocArrayType = 250, + JSDocUnionType = 251, + JSDocTupleType = 252, + JSDocNullableType = 253, + JSDocNonNullableType = 254, + JSDocRecordType = 255, + JSDocRecordMember = 256, + JSDocTypeReference = 257, + JSDocOptionalType = 258, + JSDocFunctionType = 259, + JSDocVariadicType = 260, + JSDocConstructorType = 261, + JSDocThisType = 262, + JSDocComment = 263, + JSDocTag = 264, + JSDocParameterTag = 265, + JSDocReturnTag = 266, + JSDocTypeTag = 267, + JSDocTemplateTag = 268, + SyntaxList = 269, + Count = 270, + FirstAssignment = 55, + LastAssignment = 66, + FirstReservedWord = 68, + LastReservedWord = 103, + FirstKeyword = 68, + LastKeyword = 132, + FirstFutureReservedWord = 104, + LastFutureReservedWord = 112, + FirstTypeNode = 149, + LastTypeNode = 158, + FirstPunctuation = 15, + LastPunctuation = 66, FirstToken = 0, - LastToken = 131, + LastToken = 132, FirstTriviaToken = 2, - LastTriviaToken = 6, - FirstLiteralToken = 7, - LastLiteralToken = 10, - FirstTemplateToken = 10, - LastTemplateToken = 13, - FirstBinaryOperator = 24, - LastBinaryOperator = 65, - FirstNode = 132, + LastTriviaToken = 7, + FirstLiteralToken = 8, + LastLiteralToken = 11, + FirstTemplateToken = 11, + LastTemplateToken = 14, + FirstBinaryOperator = 25, + LastBinaryOperator = 66, + FirstNode = 133, } const enum NodeFlags { Export = 1, @@ -452,9 +454,9 @@ declare module "typescript" { * Several node kinds share function-like features such as a signature, * a name, and a body. These nodes should extend FunctionLikeDeclaration. * Examples: - * FunctionDeclaration - * MethodDeclaration - * AccessorDeclaration + * - FunctionDeclaration + * - MethodDeclaration + * - AccessorDeclaration */ interface FunctionLikeDeclaration extends SignatureDeclaration { _functionLikeDeclarationBrand: any; @@ -944,7 +946,7 @@ declare module "typescript" { getSourceFile(fileName: string): SourceFile; getCurrentDirectory(): string; } - interface ParseConfigHost { + interface ParseConfigHost extends ModuleResolutionHost { readDirectory(rootDir: string, extension: string, exclude: string[]): string[]; } interface WriteFileCallback { @@ -958,6 +960,10 @@ declare module "typescript" { throwIfCancellationRequested(): void; } interface Program extends ScriptReferenceHost { + /** + * Get a list of root file names that were passed to a 'createProgram' + */ + getRootFileNames(): string[]; /** * Get a list of files in the program */ @@ -1019,11 +1025,6 @@ declare module "typescript" { emitSkipped: boolean; diagnostics: Diagnostic[]; } - interface TypeCheckerHost { - getCompilerOptions(): CompilerOptions; - getSourceFiles(): SourceFile[]; - getSourceFile(fileName: string): SourceFile; - } interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; getDeclaredTypeOfSymbol(symbol: Symbol): Type; @@ -1031,6 +1032,7 @@ declare module "typescript" { getPropertyOfType(type: Type, propertyName: string): Symbol; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; + getBaseTypes(type: InterfaceType): ObjectType[]; getReturnTypeOfSignature(signature: Signature): Type; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; @@ -1054,6 +1056,7 @@ declare module "typescript" { getExportsOfModule(moduleSymbol: Symbol): Symbol[]; getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; + isOptionalParameter(node: ParameterDeclaration): boolean; } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1198,16 +1201,18 @@ declare module "typescript" { Anonymous = 65536, Instantiated = 131072, ObjectLiteral = 524288, - ESSymbol = 4194304, + ESSymbol = 16777216, StringLike = 258, NumberLike = 132, ObjectType = 80896, UnionOrIntersection = 49152, StructuredType = 130048, } + type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { flags: TypeFlags; symbol?: Symbol; + pattern?: DestructuringPattern; } interface StringLiteralType extends Type { text: string; @@ -1218,8 +1223,6 @@ declare module "typescript" { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; - resolvedBaseConstructorType?: Type; - resolvedBaseTypes: ObjectType[]; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1236,7 +1239,6 @@ declare module "typescript" { } interface TupleType extends ObjectType { elementTypes: Type[]; - baseArrayType: TypeReference; } interface UnionOrIntersectionType extends Type { types: Type[]; @@ -1292,6 +1294,10 @@ declare module "typescript" { Error = 1, Message = 2, } + const enum ModuleResolutionKind { + Classic = 1, + NodeJs = 2, + } interface CompilerOptions { allowNonTsExtensions?: boolean; charset?: string; @@ -1299,6 +1305,7 @@ declare module "typescript" { diagnostics?: boolean; emitBOM?: boolean; help?: boolean; + init?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; jsx?: JsxEmit; @@ -1315,6 +1322,7 @@ declare module "typescript" { noLib?: boolean; noResolve?: boolean; out?: string; + outFile?: string; outDir?: string; preserveConstEnums?: boolean; project?: string; @@ -1322,6 +1330,7 @@ declare module "typescript" { rootDir?: string; sourceMap?: boolean; sourceRoot?: string; + suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; version?: boolean; @@ -1330,6 +1339,7 @@ declare module "typescript" { experimentalDecorators?: boolean; experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; + moduleResolution?: ModuleResolutionKind; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1367,14 +1377,28 @@ declare module "typescript" { fileNames: string[]; errors: Diagnostic[]; } - interface CompilerHost { + interface ModuleResolutionHost { + fileExists(fileName: string): boolean; + readFile(fileName: string): string; + } + interface ResolvedModule { + resolvedFileName: string; + isExternalLibraryImport?: boolean; + } + interface ResolvedModuleWithFailedLookupLocations { + resolvedModule: ResolvedModule; + failedLookupLocations: string[]; + } + interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getCancellationToken?(): CancellationToken; getDefaultLibFileName(options: CompilerOptions): string; writeFile: WriteFileCallback; getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; + resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; } interface TextSpan { start: number; @@ -1385,7 +1409,7 @@ declare module "typescript" { newLength: number; } } -declare module "typescript" { +declare namespace ts { interface System { args: string[]; newLine: string; @@ -1409,7 +1433,7 @@ declare module "typescript" { } var sys: System; } -declare module "typescript" { +declare namespace ts { interface ErrorCallback { (message: DiagnosticMessage, length: number): void; } @@ -1448,10 +1472,13 @@ declare module "typescript" { function couldStartTrivia(text: string, pos: number): boolean; function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + /** Optionally, get the shebang */ + function getShebang(text: string): string; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } -declare module "typescript" { +declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; function textSpanEnd(span: TextSpan): number; function textSpanIsEmpty(span: TextSpan): boolean; @@ -1481,29 +1508,32 @@ declare module "typescript" { function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; function getTypeParameterOwner(d: Declaration): Declaration; } -declare module "typescript" { +declare namespace ts { function getNodeConstructor(kind: SyntaxKind): new () => Node; function createNode(kind: SyntaxKind): Node; function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile; function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } -declare module "typescript" { - /** The version of the TypeScript compiler release */ +declare namespace ts { const version: string; function findConfigFile(searchPath: string): string; + function resolveTripleslashReference(moduleName: string, containingFile: string): string; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; - function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; + function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; } -declare module "typescript" { - function parseCommandLine(commandLine: string[]): ParsedCommandLine; +declare namespace ts { + function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine; /** * Read tsconfig.json file * @param fileName The path to the config file */ - function readConfigFile(fileName: string): { + function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; error?: Diagnostic; }; @@ -1524,7 +1554,7 @@ declare module "typescript" { */ function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine; } -declare module "typescript" { +declare namespace ts { /** The version of the language service API */ let servicesVersion: string; interface Node { @@ -1559,6 +1589,7 @@ declare module "typescript" { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; + getBaseTypes(): ObjectType[]; } interface Signature { getDeclaration(): SignatureDeclaration; @@ -1600,6 +1631,7 @@ declare module "typescript" { interface PreProcessedFileInfo { referencedFiles: FileReference[]; importedFiles: FileReference[]; + ambientExternalModules: string[]; isLibFile: boolean; } interface HostCancellationToken { @@ -1620,6 +1652,7 @@ declare module "typescript" { trace?(s: string): void; error?(s: string): void; useCaseSensitiveFileNames?(): boolean; + resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; } interface LanguageService { cleanupSemanticCache(): void; @@ -1660,6 +1693,7 @@ declare module "typescript" { getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[]; getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; + getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; getEmitOutput(fileName: string): EmitOutput; getProgram(): Program; getSourceFile(fileName: string): SourceFile; @@ -1696,6 +1730,11 @@ declare module "typescript" { span: TextSpan; newText: string; } + interface TextInsertion { + newText: string; + /** The position in newText the caret should point to after the insertion. */ + caretOffset: number; + } interface RenameLocation { textSpan: TextSpan; fileName: string; @@ -1716,6 +1755,7 @@ declare module "typescript" { const writtenReference: string; } interface HighlightSpan { + fileName?: string; textSpan: TextSpan; kind: string; } @@ -1743,6 +1783,7 @@ declare module "typescript" { InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; [s: string]: boolean | number | string; @@ -1985,6 +2026,7 @@ declare module "typescript" { * @param compilationSettings The compilation settings used to acquire the file */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + reportStats(): string; } module ScriptElementKind { const unknown: string; @@ -2071,10 +2113,24 @@ declare module "typescript" { } function displayPartsToString(displayParts: SymbolDisplayPart[]): string; function getDefaultCompilerOptions(): CompilerOptions; + interface TranspileOptions { + compilerOptions?: CompilerOptions; + fileName?: string; + reportDiagnostics?: boolean; + moduleName?: string; + renamedDependencies?: Map; + } + interface TranspileOutput { + outputText: string; + diagnostics?: Diagnostic[]; + sourceMapText?: string; + } + function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; @@ -2086,3 +2142,5 @@ declare module "typescript" { */ function getDefaultLibFilePath(options: CompilerOptions): string; } + +export = ts; \ No newline at end of file diff --git a/lib/typescript.js b/lib/typescript.js index 6035d71fa2b..a1f9651570e 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -16,6 +16,7 @@ and limitations under the License. var ts; (function (ts) { // token > SyntaxKind.Identifer => token is a keyword + // Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync (function (SyntaxKind) { SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; @@ -23,324 +24,326 @@ var ts; SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + // We detect and preserve #! on the first line + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; // We detect and provide better error recovery when we encounter a git merge marker. This // allows us to edit files with git-conflict markers in them in a much more pleasant manner. - SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 6] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; // Literals - SyntaxKind[SyntaxKind["NumericLiteral"] = 7] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 8] = "StringLiteral"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 9] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 10] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 11] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 11] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 12] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 13] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 12] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 13] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 14] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 14] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 15] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 16] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 17] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 18] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 19] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 20] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 21] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 22] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 23] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 24] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 25] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 26] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 27] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 28] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 29] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 30] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 31] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 32] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 33] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 34] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 35] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 36] = "AsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 37] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 38] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 39] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 40] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 41] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 42] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 44] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 45] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 46] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 47] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 48] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 49] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 50] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 51] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 52] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 53] = "AtToken"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 15] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 16] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 17] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 18] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 19] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 20] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 21] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 22] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 23] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 24] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 25] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 26] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 27] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 28] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 29] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 30] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 31] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 32] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 33] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 34] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 35] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 36] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 37] = "AsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 38] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 39] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 40] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 41] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 42] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 45] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 46] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 47] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 48] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 49] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 50] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 51] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 52] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 53] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 54] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 54] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 55] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 56] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 57] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 58] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 59] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 60] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 61] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 63] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 64] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 65] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 55] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 56] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 57] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 58] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 59] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 60] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 61] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 63] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 64] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 65] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 66] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 66] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 67] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 67] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 68] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 69] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 70] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 71] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 72] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 73] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 74] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 75] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 76] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 77] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 78] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 79] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 80] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 81] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 82] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 83] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 84] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 85] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 86] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 87] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 88] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 89] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 90] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 91] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 92] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 93] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 94] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 95] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 96] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 97] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 98] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 99] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 100] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 101] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 102] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 68] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 69] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 70] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 71] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 72] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 73] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 74] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 75] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 76] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 77] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 78] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 79] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 80] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 81] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 82] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 83] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 84] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 85] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 86] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 87] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 88] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 89] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 90] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 91] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 92] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 93] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 94] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 95] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 96] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 97] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 98] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 99] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 100] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 101] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 102] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 103] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 103] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 104] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 105] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 106] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 107] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 108] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 109] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 110] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 111] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 104] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 105] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 106] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 107] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 108] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 109] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 110] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 111] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 112] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 112] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 113] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 114] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 115] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 116] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 117] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 118] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 119] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 120] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 121] = "IsKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 122] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 123] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 124] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 125] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 126] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 127] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 128] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 129] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 130] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 131] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 113] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 114] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 115] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 116] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 117] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 118] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 119] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 120] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 121] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 122] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 123] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 124] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 125] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 126] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 127] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 128] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 129] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 130] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 131] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 132] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 132] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 133] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 133] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 134] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 134] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 135] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 136] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 135] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 136] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 137] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 137] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 138] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 139] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 140] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 141] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 142] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 143] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 144] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 145] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 146] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 138] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 139] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 140] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 141] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 142] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 143] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 144] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 145] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 146] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 147] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 147] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 148] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 149] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 150] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 151] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 152] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 153] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 154] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 155] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 156] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 157] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 148] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 149] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 150] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 151] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 152] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 153] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 154] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 155] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 156] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 157] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 158] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 158] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 159] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 160] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 159] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 160] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 161] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 161] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 162] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 163] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 164] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 165] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 166] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 167] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 168] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 169] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 170] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 171] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 172] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 173] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 174] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 175] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 176] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 177] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 178] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 179] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 180] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 181] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 182] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 183] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 184] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 185] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 186] = "AsExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 162] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 163] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 164] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 165] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 166] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 167] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 168] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 169] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 170] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 171] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 172] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 173] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 174] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 175] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 176] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 177] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 178] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 179] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 180] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 181] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 182] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 183] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 184] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 185] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 186] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 187] = "AsExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 187] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 188] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 188] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 189] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 189] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 190] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 191] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 192] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 193] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 194] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 195] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 196] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 197] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 198] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 199] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 200] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 201] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 202] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 203] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 204] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 205] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 206] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 207] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 208] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 209] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 210] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 211] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 212] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 213] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 214] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 215] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 216] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 217] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 218] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 219] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 220] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 221] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 222] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 223] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 224] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 225] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 226] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 227] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 228] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 190] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 191] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 192] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 193] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 194] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 195] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 196] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 197] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 198] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 199] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 200] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 201] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 202] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 203] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 204] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 205] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 206] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 207] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 208] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 209] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 210] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 211] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 212] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 213] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 214] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 215] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 216] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 217] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 218] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 219] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 220] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 221] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 222] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 223] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 224] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 225] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 226] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 227] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 228] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 229] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 229] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 230] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 230] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 231] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 232] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 233] = "JsxText"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 234] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 235] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 236] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 237] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 231] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 232] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 233] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 234] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 235] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 236] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 237] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 238] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 238] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 239] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 240] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 241] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 239] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 240] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 241] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 242] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 242] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 243] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 243] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 244] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 244] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 245] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 245] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 246] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 246] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 247] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 247] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 248] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 248] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 249] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 250] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 251] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 252] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 253] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 254] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 255] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 256] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 257] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 258] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 259] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 260] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 261] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 262] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 263] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 264] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 265] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 266] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 267] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 249] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 250] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 251] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 252] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 253] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 254] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 255] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 256] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 257] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 258] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 259] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 260] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 261] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 262] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 263] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 264] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 265] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 266] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 267] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 268] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 268] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 269] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 269] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 270] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 54] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 65] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 67] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 102] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 67] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 131] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 103] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 111] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 148] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 157] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 65] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 55] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 66] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 68] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 103] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 68] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 132] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 104] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 112] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 149] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 158] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 66] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 131] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 132] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; - SyntaxKind[SyntaxKind["LastTriviaToken"] = 6] = "LastTriviaToken"; - SyntaxKind[SyntaxKind["FirstLiteralToken"] = 7] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 10] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 10] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 13] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 24] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 65] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 132] = "FirstNode"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 11] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 11] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 66] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 133] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -602,21 +605,27 @@ var ts; TypeFlags[TypeFlags["FromSignature"] = 262144] = "FromSignature"; TypeFlags[TypeFlags["ObjectLiteral"] = 524288] = "ObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 1048576] = "ContainsUndefinedOrNull"; + TypeFlags[TypeFlags["FreshObjectLiteral"] = 1048576] = "FreshObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 2097152] = "ContainsObjectLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 4194304] = "ESSymbol"; + TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 2097152] = "ContainsUndefinedOrNull"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 4194431] = "Intrinsic"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 4194814] = "Primitive"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; + /* @internal */ + TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; + /* @internal */ + TypeFlags[TypeFlags["Primitive"] = 16777726] = "Primitive"; TypeFlags[TypeFlags["StringLike"] = 258] = "StringLike"; TypeFlags[TypeFlags["NumberLike"] = 132] = "NumberLike"; TypeFlags[TypeFlags["ObjectType"] = 80896] = "ObjectType"; TypeFlags[TypeFlags["UnionOrIntersection"] = 49152] = "UnionOrIntersection"; TypeFlags[TypeFlags["StructuredType"] = 130048] = "StructuredType"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 3145728] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; + /* @internal */ + TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; })(ts.TypeFlags || (ts.TypeFlags = {})); var TypeFlags = ts.TypeFlags; (function (SignatureKind) { @@ -635,6 +644,11 @@ var ts; DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); var DiagnosticCategory = ts.DiagnosticCategory; + (function (ModuleResolutionKind) { + ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; + ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; + })(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); + var ModuleResolutionKind = ts.ModuleResolutionKind; (function (ModuleKind) { ModuleKind[ModuleKind["None"] = 0] = "None"; ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; @@ -822,6 +836,7 @@ var ts; set: set, contains: contains, remove: remove, + clear: clear, forEachValue: forEachValueInMap }; function set(fileName, value) { @@ -843,6 +858,9 @@ var ts; function normalizeKey(key) { return getCanonicalFileName(normalizeSlashes(key)); } + function clear() { + files = {}; + } } ts.createFileMap = createFileMap; (function (Comparison) { @@ -990,6 +1008,13 @@ var ts; return array[array.length - 1]; } ts.lastOrUndefined = lastOrUndefined; + /** + * Performs a binary search, finding the index at which 'value' occurs in 'array'. + * If no such index is found, returns the 2's-complement of first index at which + * number[index] exceeds number. + * @param array A sorted array whose first element must be no larger than number + * @param number The value to be searched for in the array. + */ function binarySearch(array, value) { var low = 0; var high = array.length - 1; @@ -1293,7 +1318,7 @@ var ts; if (path.lastIndexOf("file:///", 0) === 0) { return "file:///".length; } - var idx = path.indexOf('://'); + var idx = path.indexOf("://"); if (idx !== -1) { return idx + "://".length; } @@ -1470,7 +1495,7 @@ var ts; /** * List of supported extensions in order of file resolution precedence. */ - ts.supportedExtensions = [".tsx", ".ts", ".d.ts"]; + ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -1699,7 +1724,7 @@ var ts; function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); - var _os = require('os'); + var _os = require("os"); var platform = _os.platform(); // win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; @@ -1734,7 +1759,7 @@ var ts; function writeFile(fileName, data, writeByteOrderMark) { // If a BOM is required, emit one if (writeByteOrderMark) { - data = '\uFEFF' + data; + data = "\uFEFF" + data; } _fs.writeFileSync(fileName, data, "utf8"); } @@ -1775,7 +1800,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, 'utf8'); + var buffer = new Buffer(s, "utf8"); var offset = 0; var toWrite = buffer.length; var written = 0; @@ -1799,7 +1824,6 @@ var ts; } callback(fileName); } - ; }, resolvePath: function (path) { return _path.resolve(path); @@ -1836,7 +1860,9 @@ var ts; if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { return getWScriptSystem(); } - else if (typeof module !== "undefined" && module.exports) { + else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { + // process and process.nextTick checks if current environment is node-like + // process.browser check excludes webpack and browserify return getNodeSystem(); } else { @@ -2091,7 +2117,7 @@ var ts; Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." }, @@ -2101,6 +2127,7 @@ var ts; Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, @@ -2140,7 +2167,7 @@ var ts; Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, @@ -2261,6 +2288,7 @@ var ts; The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, + Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2271,6 +2299,12 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, + Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, + Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, + Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." }, + Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2350,20 +2384,12 @@ var ts; Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, - Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, - Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, - Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, - Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, - Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, - Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -2412,13 +2438,17 @@ var ts; Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, + Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -2459,131 +2489,137 @@ var ts; JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." } + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } }; })(ts || (ts = {})); /// /// var ts; (function (ts) { + /* @internal */ + function tokenIsIdentifierOrKeyword(token) { + return token >= 67 /* Identifier */; + } + ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = { - "abstract": 112 /* AbstractKeyword */, - "any": 114 /* AnyKeyword */, - "as": 113 /* AsKeyword */, - "boolean": 117 /* BooleanKeyword */, - "break": 67 /* BreakKeyword */, - "case": 68 /* CaseKeyword */, - "catch": 69 /* CatchKeyword */, - "class": 70 /* ClassKeyword */, - "continue": 72 /* ContinueKeyword */, - "const": 71 /* ConstKeyword */, - "constructor": 118 /* ConstructorKeyword */, - "debugger": 73 /* DebuggerKeyword */, - "declare": 119 /* DeclareKeyword */, - "default": 74 /* DefaultKeyword */, - "delete": 75 /* DeleteKeyword */, - "do": 76 /* DoKeyword */, - "else": 77 /* ElseKeyword */, - "enum": 78 /* EnumKeyword */, - "export": 79 /* ExportKeyword */, - "extends": 80 /* ExtendsKeyword */, - "false": 81 /* FalseKeyword */, - "finally": 82 /* FinallyKeyword */, - "for": 83 /* ForKeyword */, - "from": 130 /* FromKeyword */, - "function": 84 /* FunctionKeyword */, - "get": 120 /* GetKeyword */, - "if": 85 /* IfKeyword */, - "implements": 103 /* ImplementsKeyword */, - "import": 86 /* ImportKeyword */, - "in": 87 /* InKeyword */, - "instanceof": 88 /* InstanceOfKeyword */, - "interface": 104 /* InterfaceKeyword */, - "is": 121 /* IsKeyword */, - "let": 105 /* LetKeyword */, - "module": 122 /* ModuleKeyword */, - "namespace": 123 /* NamespaceKeyword */, - "new": 89 /* NewKeyword */, - "null": 90 /* NullKeyword */, - "number": 125 /* NumberKeyword */, - "package": 106 /* PackageKeyword */, - "private": 107 /* PrivateKeyword */, - "protected": 108 /* ProtectedKeyword */, - "public": 109 /* PublicKeyword */, - "require": 124 /* RequireKeyword */, - "return": 91 /* ReturnKeyword */, - "set": 126 /* SetKeyword */, - "static": 110 /* StaticKeyword */, - "string": 127 /* StringKeyword */, - "super": 92 /* SuperKeyword */, - "switch": 93 /* SwitchKeyword */, - "symbol": 128 /* SymbolKeyword */, - "this": 94 /* ThisKeyword */, - "throw": 95 /* ThrowKeyword */, - "true": 96 /* TrueKeyword */, - "try": 97 /* TryKeyword */, - "type": 129 /* TypeKeyword */, - "typeof": 98 /* TypeOfKeyword */, - "var": 99 /* VarKeyword */, - "void": 100 /* VoidKeyword */, - "while": 101 /* WhileKeyword */, - "with": 102 /* WithKeyword */, - "yield": 111 /* YieldKeyword */, - "async": 115 /* AsyncKeyword */, - "await": 116 /* AwaitKeyword */, - "of": 131 /* OfKeyword */, - "{": 14 /* OpenBraceToken */, - "}": 15 /* CloseBraceToken */, - "(": 16 /* OpenParenToken */, - ")": 17 /* CloseParenToken */, - "[": 18 /* OpenBracketToken */, - "]": 19 /* CloseBracketToken */, - ".": 20 /* DotToken */, - "...": 21 /* DotDotDotToken */, - ";": 22 /* SemicolonToken */, - ",": 23 /* CommaToken */, - "<": 24 /* LessThanToken */, - ">": 26 /* GreaterThanToken */, - "<=": 27 /* LessThanEqualsToken */, - ">=": 28 /* GreaterThanEqualsToken */, - "==": 29 /* EqualsEqualsToken */, - "!=": 30 /* ExclamationEqualsToken */, - "===": 31 /* EqualsEqualsEqualsToken */, - "!==": 32 /* ExclamationEqualsEqualsToken */, - "=>": 33 /* EqualsGreaterThanToken */, - "+": 34 /* PlusToken */, - "-": 35 /* MinusToken */, - "*": 36 /* AsteriskToken */, - "/": 37 /* SlashToken */, - "%": 38 /* PercentToken */, - "++": 39 /* PlusPlusToken */, - "--": 40 /* MinusMinusToken */, - "<<": 41 /* LessThanLessThanToken */, - ">": 42 /* GreaterThanGreaterThanToken */, - ">>>": 43 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 44 /* AmpersandToken */, - "|": 45 /* BarToken */, - "^": 46 /* CaretToken */, - "!": 47 /* ExclamationToken */, - "~": 48 /* TildeToken */, - "&&": 49 /* AmpersandAmpersandToken */, - "||": 50 /* BarBarToken */, - "?": 51 /* QuestionToken */, - ":": 52 /* ColonToken */, - "=": 54 /* EqualsToken */, - "+=": 55 /* PlusEqualsToken */, - "-=": 56 /* MinusEqualsToken */, - "*=": 57 /* AsteriskEqualsToken */, - "/=": 58 /* SlashEqualsToken */, - "%=": 59 /* PercentEqualsToken */, - "<<=": 60 /* LessThanLessThanEqualsToken */, - ">>=": 61 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 63 /* AmpersandEqualsToken */, - "|=": 64 /* BarEqualsToken */, - "^=": 65 /* CaretEqualsToken */, - "@": 53 /* AtToken */ + "abstract": 113 /* AbstractKeyword */, + "any": 115 /* AnyKeyword */, + "as": 114 /* AsKeyword */, + "boolean": 118 /* BooleanKeyword */, + "break": 68 /* BreakKeyword */, + "case": 69 /* CaseKeyword */, + "catch": 70 /* CatchKeyword */, + "class": 71 /* ClassKeyword */, + "continue": 73 /* ContinueKeyword */, + "const": 72 /* ConstKeyword */, + "constructor": 119 /* ConstructorKeyword */, + "debugger": 74 /* DebuggerKeyword */, + "declare": 120 /* DeclareKeyword */, + "default": 75 /* DefaultKeyword */, + "delete": 76 /* DeleteKeyword */, + "do": 77 /* DoKeyword */, + "else": 78 /* ElseKeyword */, + "enum": 79 /* EnumKeyword */, + "export": 80 /* ExportKeyword */, + "extends": 81 /* ExtendsKeyword */, + "false": 82 /* FalseKeyword */, + "finally": 83 /* FinallyKeyword */, + "for": 84 /* ForKeyword */, + "from": 131 /* FromKeyword */, + "function": 85 /* FunctionKeyword */, + "get": 121 /* GetKeyword */, + "if": 86 /* IfKeyword */, + "implements": 104 /* ImplementsKeyword */, + "import": 87 /* ImportKeyword */, + "in": 88 /* InKeyword */, + "instanceof": 89 /* InstanceOfKeyword */, + "interface": 105 /* InterfaceKeyword */, + "is": 122 /* IsKeyword */, + "let": 106 /* LetKeyword */, + "module": 123 /* ModuleKeyword */, + "namespace": 124 /* NamespaceKeyword */, + "new": 90 /* NewKeyword */, + "null": 91 /* NullKeyword */, + "number": 126 /* NumberKeyword */, + "package": 107 /* PackageKeyword */, + "private": 108 /* PrivateKeyword */, + "protected": 109 /* ProtectedKeyword */, + "public": 110 /* PublicKeyword */, + "require": 125 /* RequireKeyword */, + "return": 92 /* ReturnKeyword */, + "set": 127 /* SetKeyword */, + "static": 111 /* StaticKeyword */, + "string": 128 /* StringKeyword */, + "super": 93 /* SuperKeyword */, + "switch": 94 /* SwitchKeyword */, + "symbol": 129 /* SymbolKeyword */, + "this": 95 /* ThisKeyword */, + "throw": 96 /* ThrowKeyword */, + "true": 97 /* TrueKeyword */, + "try": 98 /* TryKeyword */, + "type": 130 /* TypeKeyword */, + "typeof": 99 /* TypeOfKeyword */, + "var": 100 /* VarKeyword */, + "void": 101 /* VoidKeyword */, + "while": 102 /* WhileKeyword */, + "with": 103 /* WithKeyword */, + "yield": 112 /* YieldKeyword */, + "async": 116 /* AsyncKeyword */, + "await": 117 /* AwaitKeyword */, + "of": 132 /* OfKeyword */, + "{": 15 /* OpenBraceToken */, + "}": 16 /* CloseBraceToken */, + "(": 17 /* OpenParenToken */, + ")": 18 /* CloseParenToken */, + "[": 19 /* OpenBracketToken */, + "]": 20 /* CloseBracketToken */, + ".": 21 /* DotToken */, + "...": 22 /* DotDotDotToken */, + ";": 23 /* SemicolonToken */, + ",": 24 /* CommaToken */, + "<": 25 /* LessThanToken */, + ">": 27 /* GreaterThanToken */, + "<=": 28 /* LessThanEqualsToken */, + ">=": 29 /* GreaterThanEqualsToken */, + "==": 30 /* EqualsEqualsToken */, + "!=": 31 /* ExclamationEqualsToken */, + "===": 32 /* EqualsEqualsEqualsToken */, + "!==": 33 /* ExclamationEqualsEqualsToken */, + "=>": 34 /* EqualsGreaterThanToken */, + "+": 35 /* PlusToken */, + "-": 36 /* MinusToken */, + "*": 37 /* AsteriskToken */, + "/": 38 /* SlashToken */, + "%": 39 /* PercentToken */, + "++": 40 /* PlusPlusToken */, + "--": 41 /* MinusMinusToken */, + "<<": 42 /* LessThanLessThanToken */, + ">": 43 /* GreaterThanGreaterThanToken */, + ">>>": 44 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 45 /* AmpersandToken */, + "|": 46 /* BarToken */, + "^": 47 /* CaretToken */, + "!": 48 /* ExclamationToken */, + "~": 49 /* TildeToken */, + "&&": 50 /* AmpersandAmpersandToken */, + "||": 51 /* BarBarToken */, + "?": 52 /* QuestionToken */, + ":": 53 /* ColonToken */, + "=": 55 /* EqualsToken */, + "+=": 56 /* PlusEqualsToken */, + "-=": 57 /* MinusEqualsToken */, + "*=": 58 /* AsteriskEqualsToken */, + "/=": 59 /* SlashEqualsToken */, + "%=": 60 /* PercentEqualsToken */, + "<<=": 61 /* LessThanLessThanEqualsToken */, + ">>=": 62 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 64 /* AmpersandEqualsToken */, + "|=": 65 /* BarEqualsToken */, + "^=": 66 /* CaretEqualsToken */, + "@": 54 /* AtToken */ }; /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -2730,14 +2766,21 @@ var ts; } ts.getLineStarts = getLineStarts; /* @internal */ + /** + * We assume the first line starts at position 0 and 'position' is non-negative. + */ function computeLineAndCharacterOfPosition(lineStarts, position) { var lineNumber = ts.binarySearch(lineStarts, position); if (lineNumber < 0) { // If the actual position was not found, - // the binary search returns the negative value of the next line start + // the binary search returns the 2's-complement of the next line start // e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 - // then the search will return -2 + // then the search will return -2. + // + // We want the index of the previous line start, so we subtract 1. + // Review 2's-complement if this is confusing. lineNumber = ~lineNumber - 1; + ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); } return { line: lineNumber, @@ -2809,6 +2852,9 @@ var ts; case 62 /* greaterThan */: // Starts of conflict marker trivia return true; + case 35 /* hash */: + // Only if its the beginning can we have #! trivia + return pos === 0; default: return ch > 127 /* maxAsciiCharacter */; } @@ -2867,6 +2913,12 @@ var ts; continue; } break; + case 35 /* hash */: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; default: if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { pos++; @@ -2923,13 +2975,28 @@ var ts; } return pos; } - // Extract comments from the given source text starting at the given position. If trailing is - // false, whitespace is skipped until the first line break and comments between that location - // and the next token are returned.If trailing is true, comments occurring between the given - // position and the next line break are returned.The return value is an array containing a - // TextRange for each comment. Single-line comment ranges include the beginning '//' characters - // but not the ending line break. Multi - line comment ranges include the beginning '/* and - // ending '*/' characters.The return value is undefined if no comments were found. + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + // Shebangs check must only be done at the start of the file + ts.Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); + } + function scanShebangTrivia(text, pos) { + var shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; + } + /** + * Extract comments from text prefixing the token closest following `pos`. + * The return value is an array containing a TextRange for each comment. + * Single-line comment ranges include the beginning '//' characters but not the ending line break. + * Multi - line comment ranges include the beginning '/* and ending '/' characters. + * The return value is undefined if no comments were found. + * @param trailing + * If false, whitespace is skipped until the first line break and comments between that location + * and the next token are returned. + * If true, comments occurring between the given position and the next line break are returned. + */ function getCommentRanges(text, pos, trailing) { var result; var collecting = trailing || pos === 0; @@ -3004,13 +3071,20 @@ var ts; } } function getLeadingCommentRanges(text, pos) { - return getCommentRanges(text, pos, false); + return getCommentRanges(text, pos, /*trailing*/ false); } ts.getLeadingCommentRanges = getLeadingCommentRanges; function getTrailingCommentRanges(text, pos) { - return getCommentRanges(text, pos, true); + return getCommentRanges(text, pos, /*trailing*/ true); } ts.getTrailingCommentRanges = getTrailingCommentRanges; + /** Optionally, get the shebang */ + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch === 36 /* $ */ || ch === 95 /* _ */ || @@ -3023,7 +3097,6 @@ var ts; ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; - /* @internal */ // Creates a scanner over a (possibly unspecified) range of a piece of text. function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } @@ -3050,8 +3123,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 66 /* Identifier */ || token > 102 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 67 /* FirstReservedWord */ && token <= 102 /* LastReservedWord */; }, + isIdentifier: function () { return token === 67 /* Identifier */ || token > 103 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 68 /* FirstReservedWord */ && token <= 103 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -3121,14 +3194,14 @@ var ts; * returning -1 if the given number is unavailable. */ function scanExactNumberOfHexDigits(count) { - return scanHexDigits(count, false); + return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false); } /** * Scans as many hexadecimal digits as are available in the text, * returning -1 if the given number of digits was unavailable. */ function scanMinimumNumberOfHexDigits(count) { - return scanHexDigits(count, true); + return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true); } function scanHexDigits(minCount, scanAsManyAsPossible) { var digits = 0; @@ -3203,7 +3276,7 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 10 /* NoSubstitutionTemplateLiteral */ : 13 /* TemplateTail */; + resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -3211,14 +3284,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 10 /* NoSubstitutionTemplateLiteral */ : 13 /* TemplateTail */; + resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 11 /* TemplateHead */ : 12 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 12 /* TemplateHead */ : 13 /* TemplateMiddle */; break; } // Escape character @@ -3280,10 +3353,10 @@ var ts; return scanExtendedUnicodeEscape(); } // '\uDDDD' - return scanHexadecimalEscape(4); + return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: // '\xDD' - return scanHexadecimalEscape(2); + return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". case 13 /* carriageReturn */: @@ -3395,7 +3468,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 66 /* Identifier */; + return token = 67 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -3430,6 +3503,16 @@ var ts; return token = 1 /* EndOfFileToken */; } var ch = text.charCodeAt(pos); + // Special handling for shebang + if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6 /* ShebangTrivia */; + } + } switch (ch) { case 10 /* lineFeed */: case 13 /* carriageReturn */: @@ -3465,66 +3548,66 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 32 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 33 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 30 /* ExclamationEqualsToken */; + return pos += 2, token = 31 /* ExclamationEqualsToken */; } - return pos++, token = 47 /* ExclamationToken */; + return pos++, token = 48 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); - return token = 8 /* StringLiteral */; + return token = 9 /* StringLiteral */; case 96 /* backtick */: return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* PercentEqualsToken */; + return pos += 2, token = 60 /* PercentEqualsToken */; } - return pos++, token = 38 /* PercentToken */; + return pos++, token = 39 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 49 /* AmpersandAmpersandToken */; + return pos += 2, token = 50 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* AmpersandEqualsToken */; + return pos += 2, token = 64 /* AmpersandEqualsToken */; } - return pos++, token = 44 /* AmpersandToken */; + return pos++, token = 45 /* AmpersandToken */; case 40 /* openParen */: - return pos++, token = 16 /* OpenParenToken */; + return pos++, token = 17 /* OpenParenToken */; case 41 /* closeParen */: - return pos++, token = 17 /* CloseParenToken */; + return pos++, token = 18 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* AsteriskEqualsToken */; + return pos += 2, token = 58 /* AsteriskEqualsToken */; } - return pos++, token = 36 /* AsteriskToken */; + return pos++, token = 37 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 39 /* PlusPlusToken */; + return pos += 2, token = 40 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 55 /* PlusEqualsToken */; + return pos += 2, token = 56 /* PlusEqualsToken */; } - return pos++, token = 34 /* PlusToken */; + return pos++, token = 35 /* PlusToken */; case 44 /* comma */: - return pos++, token = 23 /* CommaToken */; + return pos++, token = 24 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 40 /* MinusMinusToken */; + return pos += 2, token = 41 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* MinusEqualsToken */; + return pos += 2, token = 57 /* MinusEqualsToken */; } - return pos++, token = 35 /* MinusToken */; + return pos++, token = 36 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 21 /* DotDotDotToken */; + return pos += 3, token = 22 /* DotDotDotToken */; } - return pos++, token = 20 /* DotToken */; + return pos++, token = 21 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -3570,9 +3653,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* SlashEqualsToken */; + return pos += 2, token = 59 /* SlashEqualsToken */; } - return pos++, token = 37 /* SlashToken */; + return pos++, token = 38 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -3582,32 +3665,32 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { pos += 2; - var value = scanBinaryOrOctalDigits(2); + var value = scanBinaryOrOctalDigits(/* base */ 2); if (value < 0) { error(ts.Diagnostics.Binary_digit_expected); value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { pos += 2; - var value = scanBinaryOrOctalDigits(8); + var value = scanBinaryOrOctalDigits(/* base */ 8); if (value < 0) { error(ts.Diagnostics.Octal_digit_expected); value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being @@ -3622,11 +3705,11 @@ var ts; case 56 /* _8 */: case 57 /* _9 */: tokenValue = "" + scanNumber(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; case 58 /* colon */: - return pos++, token = 52 /* ColonToken */; + return pos++, token = 53 /* ColonToken */; case 59 /* semicolon */: - return pos++, token = 22 /* SemicolonToken */; + return pos++, token = 23 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3634,22 +3717,22 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 60 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 61 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 41 /* LessThanLessThanToken */; + return pos += 2, token = 42 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 27 /* LessThanEqualsToken */; + return pos += 2, token = 28 /* LessThanEqualsToken */; } if (text.charCodeAt(pos + 1) === 47 /* slash */ && languageVariant === 1 /* JSX */) { - return pos += 2, token = 25 /* LessThanSlashToken */; + return pos += 2, token = 26 /* LessThanSlashToken */; } - return pos++, token = 24 /* LessThanToken */; + return pos++, token = 25 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3657,19 +3740,19 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 31 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 32 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 29 /* EqualsEqualsToken */; + return pos += 2, token = 30 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 33 /* EqualsGreaterThanToken */; + return pos += 2, token = 34 /* EqualsGreaterThanToken */; } - return pos++, token = 54 /* EqualsToken */; + return pos++, token = 55 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3677,37 +3760,37 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } - return pos++, token = 26 /* GreaterThanToken */; + return pos++, token = 27 /* GreaterThanToken */; case 63 /* question */: - return pos++, token = 51 /* QuestionToken */; + return pos++, token = 52 /* QuestionToken */; case 91 /* openBracket */: - return pos++, token = 18 /* OpenBracketToken */; + return pos++, token = 19 /* OpenBracketToken */; case 93 /* closeBracket */: - return pos++, token = 19 /* CloseBracketToken */; + return pos++, token = 20 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* CaretEqualsToken */; + return pos += 2, token = 66 /* CaretEqualsToken */; } - return pos++, token = 46 /* CaretToken */; + return pos++, token = 47 /* CaretToken */; case 123 /* openBrace */: - return pos++, token = 14 /* OpenBraceToken */; + return pos++, token = 15 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 50 /* BarBarToken */; + return pos += 2, token = 51 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* BarEqualsToken */; + return pos += 2, token = 65 /* BarEqualsToken */; } - return pos++, token = 45 /* BarToken */; + return pos++, token = 46 /* BarToken */; case 125 /* closeBrace */: - return pos++, token = 15 /* CloseBraceToken */; + return pos++, token = 16 /* CloseBraceToken */; case 126 /* tilde */: - return pos++, token = 48 /* TildeToken */; + return pos++, token = 49 /* TildeToken */; case 64 /* at */: - return pos++, token = 53 /* AtToken */; + return pos++, token = 54 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -3743,27 +3826,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 26 /* GreaterThanToken */) { + if (token === 27 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 43 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 44 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 62 /* GreaterThanGreaterThanEqualsToken */; } - return pos++, token = 42 /* GreaterThanGreaterThanToken */; + return pos++, token = 43 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { - return pos++, token = 28 /* GreaterThanEqualsToken */; + return pos++, token = 29 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 37 /* SlashToken */ || token === 58 /* SlashEqualsToken */) { + if (token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -3808,7 +3891,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 9 /* RegularExpressionLiteral */; + token = 10 /* RegularExpressionLiteral */; } return token; } @@ -3816,7 +3899,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 15 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 16 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -3833,14 +3916,14 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 25 /* LessThanSlashToken */; + return token = 26 /* LessThanSlashToken */; } pos++; - return token = 24 /* LessThanToken */; + return token = 25 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 14 /* OpenBraceToken */; + return token = 15 /* OpenBraceToken */; } while (pos < end) { pos++; @@ -3849,12 +3932,12 @@ var ts; break; } } - return token = 233 /* JsxText */; + return token = 234 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes function scanJsxIdentifier() { - if (token === 66 /* Identifier */) { + if (tokenIsIdentifierOrKeyword(token)) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); @@ -3890,10 +3973,10 @@ var ts; return result; } function lookAhead(callback) { - return speculationHelper(callback, true); + return speculationHelper(callback, /*isLookahead:*/ true); } function tryScan(callback) { - return speculationHelper(callback, false); + return speculationHelper(callback, /*isLookahead:*/ false); } function setText(newText, start, length) { text = newText || ""; @@ -3937,16 +4020,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 212 /* InterfaceDeclaration */ || node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 214 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 216 /* ModuleBlock */) { + else if (node.kind === 217 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3965,7 +4048,7 @@ var ts; }); return state; } - else if (node.kind === 215 /* ModuleDeclaration */) { + else if (node.kind === 216 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -4043,10 +4126,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 215 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { - return '"' + node.name.text + '"'; + if (node.kind === 216 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + return "\"" + node.name.text + "\""; } - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -4054,22 +4137,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 141 /* Constructor */: + case 142 /* Constructor */: return "__constructor"; - case 149 /* FunctionType */: - case 144 /* CallSignature */: + case 150 /* FunctionType */: + case 145 /* CallSignature */: return "__call"; - case 150 /* ConstructorType */: - case 145 /* ConstructSignature */: + case 151 /* ConstructorType */: + case 146 /* ConstructSignature */: return "__new"; - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return "__index"; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return "__export"; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 210 /* FunctionDeclaration */: - case 211 /* ClassDeclaration */: + case 211 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: return node.flags & 1024 /* Default */ ? "default" : undefined; } } @@ -4140,7 +4223,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 227 /* ExportSpecifier */ || (node.kind === 218 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 228 /* ExportSpecifier */ || (node.kind === 219 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -4221,37 +4304,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 152 /* TypeLiteral */: - case 162 /* ObjectLiteralExpression */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 153 /* TypeLiteral */: + case 163 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 210 /* FunctionDeclaration */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 215 /* ModuleDeclaration */: - case 245 /* SourceFile */: - case 213 /* TypeAliasDeclaration */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 216 /* ModuleDeclaration */: + case 246 /* SourceFile */: + case 214 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 241 /* CatchClause */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 217 /* CaseBlock */: + case 242 /* CatchClause */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 218 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 189 /* Block */: + case 190 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -4288,38 +4371,38 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 152 /* TypeLiteral */: - case 162 /* ObjectLiteralExpression */: - case 212 /* InterfaceDeclaration */: + case 153 /* TypeLiteral */: + case 163 /* ObjectLiteralExpression */: + case 213 /* InterfaceDeclaration */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 213 /* TypeAliasDeclaration */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 214 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -4349,11 +4432,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 245 /* SourceFile */ ? node : node.body; - if (body.kind === 245 /* SourceFile */ || body.kind === 216 /* ModuleBlock */) { + var body = node.kind === 246 /* SourceFile */ ? node : node.body; + if (body.kind === 246 /* SourceFile */ || body.kind === 217 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 225 /* ExportDeclaration */ || stat.kind === 224 /* ExportAssignment */) { + if (stat.kind === 226 /* ExportDeclaration */ || stat.kind === 225 /* ExportAssignment */) { return true; } } @@ -4372,7 +4455,7 @@ var ts; } function bindModuleDeclaration(node) { setExportContextFlag(node); - if (node.name.kind === 8 /* StringLiteral */) { + if (node.name.kind === 9 /* StringLiteral */) { declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); } else { @@ -4382,14 +4465,21 @@ var ts; } else { declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); - var currentModuleIsConstEnumOnly = state === 2 /* ConstEnumOnly */; - if (node.symbol.constEnumOnlyModule === undefined) { - // non-merged case - use the current state - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + if (node.symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */)) { + // if module was already merged with some function, class or non-const enum + // treat is a non-const-enum-only + node.symbol.constEnumOnlyModule = false; } else { - // merged case: module is const enum only if all its pieces are non-instantiated or const enum - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + var currentModuleIsConstEnumOnly = state === 2 /* ConstEnumOnly */; + if (node.symbol.constEnumOnlyModule === undefined) { + // non-merged case - use the current state + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + // merged case: module is const enum only if all its pieces are non-instantiated or const enum + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } } } } @@ -4418,7 +4508,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 66 /* Identifier */) { + if (prop.name.kind !== 67 /* Identifier */) { continue; } var identifier = prop.name; @@ -4430,7 +4520,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 242 /* PropertyAssignment */ || prop.kind === 243 /* ShorthandPropertyAssignment */ || prop.kind === 140 /* MethodDeclaration */ + var currentKind = prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */ || prop.kind === 141 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -4452,10 +4542,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -4476,8 +4566,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 103 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 111 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 104 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 112 /* LastFutureReservedWord */ && !ts.isIdentifierName(node)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { @@ -4512,7 +4602,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 66 /* Identifier */) { + if (inStrictMode && node.expression.kind === 67 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -4520,11 +4610,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 66 /* Identifier */) { + if (name && name.kind === 67 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -4568,7 +4658,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 39 /* PlusPlusToken */ || node.operator === 40 /* MinusMinusToken */) { + if (node.operator === 40 /* PlusPlusToken */ || node.operator === 41 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -4612,17 +4702,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 245 /* SourceFile */: - case 216 /* ModuleBlock */: + case 246 /* SourceFile */: + case 217 /* ModuleBlock */: updateStrictModeStatementList(node.statements); return; - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return; @@ -4645,103 +4735,103 @@ var ts; var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the // string to contain unicode escapes (as per ES5). - return nodeText === '"use strict"' || nodeText === "'use strict'"; + return nodeText === "\"use strict\"" || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return checkStrictModeIdentifier(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return checkStrictModeBinaryExpression(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return checkStrictModeCatchClause(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return checkStrictModeWithStatement(node); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 135 /* Parameter */: + case 136 /* Parameter */: return bindParameter(node); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 141 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); - case 142 /* GetAccessor */: + case 142 /* Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); + case 143 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return bindModuleDeclaration(node); - case 218 /* ImportEqualsDeclaration */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return bindImportClause(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return bindExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return bindExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512 /* ValueModule */, '"' + ts.removeFileExtension(file.fileName) + '"'); + bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); } } function bindExportAssignment(node) { @@ -4749,7 +4839,7 @@ var ts; // Export assignment in some sort of block construct bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); } - else if (node.expression.kind === 66 /* Identifier */) { + else if (node.expression.kind === 67 /* Identifier */) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); } @@ -4774,12 +4864,16 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { var bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + // Add name of class expression into the map for semantic classifier + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } } var symbol = node.symbol; // TypeScript 1.0 spec (April 2014): 8.4 @@ -4846,7 +4940,7 @@ var ts; // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 141 /* Constructor */ && + node.parent.kind === 142 /* Constructor */ && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); @@ -4860,6 +4954,7 @@ var ts; } })(ts || (ts = {})); /// +/// /* @internal */ var ts; (function (ts) { @@ -4912,6 +5007,37 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(arr1, arr2, comparer) { + if (!arr1 || !arr2) { + return arr1 === arr2; + } + if (arr1.length !== arr2.length) { + return false; + } + for (var i = 0; i < arr1.length; ++i) { + var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModule(sourceFile, moduleNameText) { + return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); + } + ts.hasResolvedModule = hasResolvedModule; + function getResolvedModule(sourceFile, moduleNameText) { + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModule = getResolvedModule; + function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + sourceFile.resolvedModules[moduleNameText] = resolvedModule; + } + ts.setResolvedModule = setResolvedModule; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); @@ -4936,7 +5062,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 245 /* SourceFile */) { + while (node && node.kind !== 246 /* SourceFile */) { node = node.parent; } return node; @@ -4958,16 +5084,16 @@ var ts; return node.pos; } ts.getStartPosOfNode = getStartPosOfNode; - // Returns true if this node is missing from the actual source code. 'missing' is different - // from 'undefined/defined'. When a node is undefined (which can happen for optional nodes - // in the tree), it is definitel missing. HOwever, a node may be defined, but still be + // Returns true if this node is missing from the actual source code. A 'missing' node is different + // from 'undefined/defined'. When a node is undefined (which can happen for optional nodes + // in the tree), it is definitely missing. However, a node may be defined, but still be // missing. This happens whenever the parser knows it needs to parse something, but can't - // get anything in the source code that it expects at that location. For example: + // get anything in the source code that it expects at that location. For example: // // let a: ; // // Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source - // code). So the parser will attempt to parse out a type, and will create an actual node. + // code). So the parser will attempt to parse out a type, and will create an actual node. // However, this node will be 'missing' in the sense that no actual source-code/tokens are // contained within it. function nodeIsMissing(node) { @@ -5031,7 +5157,7 @@ var ts; // Make an identifier from an external module name by extracting the string after the last "/" and replacing // all non-alphanumeric characters with underscores function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/\W/g, "_"); + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { @@ -5048,15 +5174,15 @@ var ts; return current; } switch (current.kind) { - case 245 /* SourceFile */: - case 217 /* CaseBlock */: - case 241 /* CatchClause */: - case 215 /* ModuleDeclaration */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 246 /* SourceFile */: + case 218 /* CaseBlock */: + case 242 /* CatchClause */: + case 216 /* ModuleDeclaration */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return current; - case 189 /* Block */: + case 190 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -5069,9 +5195,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 208 /* VariableDeclaration */ && + declaration.kind === 209 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 241 /* CatchClause */; + declaration.parent.kind === 242 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -5101,7 +5227,7 @@ var ts; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); + var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); scanner.scan(); var start = scanner.getTokenPos(); return ts.createTextSpanFromBounds(start, scanner.getTextPos()); @@ -5110,8 +5236,8 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 245 /* SourceFile */: - var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); + case 246 /* SourceFile */: + var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file return ts.createTextSpan(0, 0); @@ -5119,16 +5245,16 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: errorNode = node.name; break; } @@ -5152,11 +5278,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 214 /* EnumDeclaration */ && isConst(node); + return node.kind === 215 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 160 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 161 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -5171,14 +5297,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 208 /* VariableDeclaration */) { + if (node.kind === 209 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 209 /* VariableDeclarationList */) { + if (node && node.kind === 210 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 190 /* VariableStatement */) { + if (node && node.kind === 191 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -5193,25 +5319,18 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 192 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; + return node.kind === 193 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - // If parameter/type parameter, the prev token trailing comments are part of this node too - if (node.kind === 135 /* Parameter */ || node.kind === 134 /* TypeParameter */) { - // e.g. (/** blah */ a, /** blah */ b); - // e.g.: ( - // /** blah */ a, - // /** blah */ b); - return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); - } - else { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); + var commentRanges = (node.kind === 136 /* Parameter */ || node.kind === 135 /* TypeParameter */) ? + ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return ts.filter(commentRanges, isJsDocComment); function isJsDocComment(comment) { // True if the comment starts with '/**' but not if it is '/**/' return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && @@ -5221,41 +5340,42 @@ var ts; } ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (148 /* FirstTypeNode */ <= node.kind && node.kind <= 157 /* LastTypeNode */) { + if (149 /* FirstTypeNode */ <= node.kind && node.kind <= 158 /* LastTypeNode */) { return true; } switch (node.kind) { - case 114 /* AnyKeyword */: - case 125 /* NumberKeyword */: - case 127 /* StringKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: + case 115 /* AnyKeyword */: + case 126 /* NumberKeyword */: + case 128 /* StringKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: return true; - case 100 /* VoidKeyword */: - return node.parent.kind !== 174 /* VoidExpression */; - case 8 /* StringLiteral */: + case 101 /* VoidKeyword */: + return node.parent.kind !== 175 /* VoidExpression */; + case 9 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 135 /* Parameter */; - case 185 /* ExpressionWithTypeArguments */: + return node.parent.kind === 136 /* Parameter */; + case 186 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 66 /* Identifier */: + case 67 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // fall through - case 132 /* QualifiedName */: - case 163 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 164 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */ || node.kind === 163 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 151 /* TypeQuery */) { + if (parent_1.kind === 152 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -5264,38 +5384,38 @@ var ts; // // Calling isTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (148 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 157 /* LastTypeNode */) { + if (149 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 158 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return node === parent_1.constraint; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 135 /* Parameter */: - case 208 /* VariableDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 136 /* Parameter */: + case 209 /* VariableDeclaration */: return node === parent_1.type; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 141 /* Constructor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 142 /* Constructor */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return node === parent_1.type; - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return node === parent_1.type; - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return node === parent_1.type; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -5309,23 +5429,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return visitor(node); - case 217 /* CaseBlock */: - case 189 /* Block */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: + case 218 /* CaseBlock */: + case 190 /* Block */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -5335,18 +5455,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -5354,7 +5474,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 133 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 134 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(name_5.expression); @@ -5373,14 +5493,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 160 /* BindingElement */: - case 244 /* EnumMember */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 243 /* ShorthandPropertyAssignment */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 245 /* EnumMember */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 244 /* ShorthandPropertyAssignment */: + case 209 /* VariableDeclaration */: return true; } } @@ -5388,41 +5508,55 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 142 /* GetAccessor */ || node.kind === 143 /* SetAccessor */); + return node && (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 211 /* ClassDeclaration */ || node.kind === 183 /* ClassExpression */); + return node && (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 141 /* Constructor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 142 /* Constructor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return true; } } return false; } ts.isFunctionLike = isFunctionLike; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 189 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 190 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 140 /* MethodDeclaration */ && node.parent.kind === 162 /* ObjectLiteralExpression */; + return node && node.kind === 141 /* MethodDeclaration */ && node.parent.kind === 163 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -5450,7 +5584,7 @@ var ts; return undefined; } switch (node.kind) { - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -5465,9 +5599,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 135 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5478,23 +5612,23 @@ var ts; node = node.parent; } break; - case 171 /* ArrowFunction */: + case 172 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 215 /* ModuleDeclaration */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 214 /* EnumDeclaration */: - case 245 /* SourceFile */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 216 /* ModuleDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 215 /* EnumDeclaration */: + case 246 /* SourceFile */: return node; } } @@ -5506,7 +5640,7 @@ var ts; if (!node) return node; switch (node.kind) { - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container @@ -5521,9 +5655,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 135 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5534,19 +5668,19 @@ var ts; node = node.parent; } break; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return node; } } @@ -5555,12 +5689,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 148 /* TypeReference */: + case 149 /* TypeReference */: return node.typeName; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return node.expression; - case 66 /* Identifier */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 133 /* QualifiedName */: return node; } } @@ -5568,7 +5702,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -5577,44 +5711,44 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: // classes are valid targets return true; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 211 /* ClassDeclaration */; - case 135 /* Parameter */: + return node.parent.kind === 212 /* ClassDeclaration */; + case 136 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return node.parent.body && node.parent.parent.kind === 211 /* ClassDeclaration */; - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 140 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 212 /* ClassDeclaration */; + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 141 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 211 /* ClassDeclaration */; + return node.body && node.parent.kind === 212 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: if (node.decorators) { return true; } return false; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -5625,10 +5759,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -5640,93 +5774,94 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: - case 9 /* RegularExpressionLiteral */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 167 /* TaggedTemplateExpression */: - case 186 /* AsExpression */: - case 168 /* TypeAssertionExpression */: - case 169 /* ParenthesizedExpression */: - case 170 /* FunctionExpression */: - case 183 /* ClassExpression */: - case 171 /* ArrowFunction */: - case 174 /* VoidExpression */: - case 172 /* DeleteExpression */: - case 173 /* TypeOfExpression */: - case 176 /* PrefixUnaryExpression */: - case 177 /* PostfixUnaryExpression */: - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 180 /* TemplateExpression */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 184 /* OmittedExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 181 /* YieldExpression */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: + case 10 /* RegularExpressionLiteral */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 168 /* TaggedTemplateExpression */: + case 187 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 170 /* ParenthesizedExpression */: + case 171 /* FunctionExpression */: + case 184 /* ClassExpression */: + case 172 /* ArrowFunction */: + case 175 /* VoidExpression */: + case 173 /* DeleteExpression */: + case 174 /* TypeOfExpression */: + case 177 /* PrefixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 181 /* TemplateExpression */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 185 /* OmittedExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 182 /* YieldExpression */: return true; - case 132 /* QualifiedName */: - while (node.parent.kind === 132 /* QualifiedName */) { + case 133 /* QualifiedName */: + while (node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 151 /* TypeQuery */; - case 66 /* Identifier */: - if (node.parent.kind === 151 /* TypeQuery */) { + return node.parent.kind === 152 /* TypeQuery */; + case 67 /* Identifier */: + if (node.parent.kind === 152 /* TypeQuery */) { return true; } // fall through - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: var parent_2 = node.parent; switch (parent_2.kind) { - case 208 /* VariableDeclaration */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 244 /* EnumMember */: - case 242 /* PropertyAssignment */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 245 /* EnumMember */: + case 243 /* PropertyAssignment */: + case 161 /* BindingElement */: return parent_2.initializer === node; - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 201 /* ReturnStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 205 /* ThrowStatement */: - case 203 /* SwitchStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 202 /* ReturnStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 206 /* ThrowStatement */: + case 204 /* SwitchStatement */: return parent_2.expression === node; - case 196 /* ForStatement */: + case 197 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 209 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 210 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 209 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210 /* VariableDeclarationList */) || forInStatement.expression === node; - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return node === parent_2.expression; - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return node === parent_2.expression; - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return node === parent_2.expression; - case 136 /* Decorator */: + case 137 /* Decorator */: + case 238 /* JsxExpression */: return true; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5744,7 +5879,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 229 /* ExternalModuleReference */; + return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5753,20 +5888,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 229 /* ExternalModuleReference */; + return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 230 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 219 /* ImportDeclaration */) { + if (node.kind === 220 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 229 /* ExternalModuleReference */) { + if (reference.kind === 230 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 225 /* ExportDeclaration */) { + if (node.kind === 226 /* ExportDeclaration */) { return node.moduleSpecifier; } } @@ -5774,15 +5909,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 135 /* Parameter */: - return node.questionToken !== undefined; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - return node.questionToken !== undefined; - case 243 /* ShorthandPropertyAssignment */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 136 /* Parameter */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 244 /* ShorthandPropertyAssignment */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5790,9 +5923,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 258 /* JSDocFunctionType */ && + return node.kind === 259 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 260 /* JSDocConstructorType */; + node.parameters[0].type.kind === 261 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5806,26 +5939,26 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 266 /* JSDocTypeTag */); + return getJSDocTag(node, 267 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 265 /* JSDocReturnTag */); + return getJSDocTag(node, 266 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 267 /* JSDocTemplateTag */); + return getJSDocTag(node, 268 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 66 /* Identifier */) { + if (parameter.name && parameter.name.kind === 67 /* Identifier */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 264 /* JSDocParameterTag */) { + if (t.kind === 265 /* JSDocParameterTag */) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -5844,12 +5977,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32 /* JavaScriptFile */) { - if (node.type && node.type.kind === 259 /* JSDocVariadicType */) { + if (node.type && node.type.kind === 260 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 259 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 260 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -5858,19 +5991,19 @@ var ts; } ts.isRestParameter = isRestParameter; function isLiteralKind(kind) { - return 7 /* FirstLiteralToken */ <= kind && kind <= 10 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 11 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 8 /* StringLiteral */ || kind === 10 /* NoSubstitutionTemplateLiteral */; + return kind === 9 /* StringLiteral */ || kind === 11 /* NoSubstitutionTemplateLiteral */; } ts.isTextualLiteralKind = isTextualLiteralKind; function isTemplateLiteralKind(kind) { - return 10 /* FirstTemplateToken */ <= kind && kind <= 13 /* LastTemplateToken */; + return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 159 /* ArrayBindingPattern */ || node.kind === 158 /* ObjectBindingPattern */); + return !!node && (node.kind === 160 /* ArrayBindingPattern */ || node.kind === 159 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -5885,34 +6018,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 171 /* ArrowFunction */: - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 141 /* Constructor */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 227 /* ExportSpecifier */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 142 /* GetAccessor */: - case 220 /* ImportClause */: - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 212 /* InterfaceDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 215 /* ModuleDeclaration */: - case 221 /* NamespaceImport */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 143 /* SetAccessor */: - case 243 /* ShorthandPropertyAssignment */: - case 213 /* TypeAliasDeclaration */: - case 134 /* TypeParameter */: - case 208 /* VariableDeclaration */: + case 172 /* ArrowFunction */: + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 142 /* Constructor */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 228 /* ExportSpecifier */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 143 /* GetAccessor */: + case 221 /* ImportClause */: + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 213 /* InterfaceDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 216 /* ModuleDeclaration */: + case 222 /* NamespaceImport */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 144 /* SetAccessor */: + case 244 /* ShorthandPropertyAssignment */: + case 214 /* TypeAliasDeclaration */: + case 135 /* TypeParameter */: + case 209 /* VariableDeclaration */: return true; } return false; @@ -5920,25 +6053,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: - case 207 /* DebuggerStatement */: - case 194 /* DoStatement */: - case 192 /* ExpressionStatement */: - case 191 /* EmptyStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 193 /* IfStatement */: - case 204 /* LabeledStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 95 /* ThrowKeyword */: - case 206 /* TryStatement */: - case 190 /* VariableStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 224 /* ExportAssignment */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 208 /* DebuggerStatement */: + case 195 /* DoStatement */: + case 193 /* ExpressionStatement */: + case 192 /* EmptyStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 194 /* IfStatement */: + case 205 /* LabeledStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 96 /* ThrowKeyword */: + case 207 /* TryStatement */: + case 191 /* VariableStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 225 /* ExportAssignment */: return true; default: return false; @@ -5947,13 +6080,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 141 /* Constructor */: - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: + case 142 /* Constructor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: return true; default: return false; @@ -5962,11 +6095,11 @@ var ts; ts.isClassElement = isClassElement; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 66 /* Identifier */ && name.kind !== 8 /* StringLiteral */ && name.kind !== 7 /* NumericLiteral */) { + if (name.kind !== 67 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 223 /* ImportSpecifier */ || parent.kind === 227 /* ExportSpecifier */) { + if (parent.kind === 224 /* ImportSpecifier */ || parent.kind === 228 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5981,31 +6114,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 244 /* EnumMember */: - case 242 /* PropertyAssignment */: - case 163 /* PropertyAccessExpression */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 245 /* EnumMember */: + case 243 /* PropertyAssignment */: + case 164 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 132 /* QualifiedName */) { + while (parent.kind === 133 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 151 /* TypeQuery */; + return parent.kind === 152 /* TypeQuery */; } return false; - case 160 /* BindingElement */: - case 223 /* ImportSpecifier */: + case 161 /* BindingElement */: + case 224 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 227 /* ExportSpecifier */: + case 228 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -6021,26 +6154,26 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ || - node.kind === 220 /* ImportClause */ && !!node.name || - node.kind === 221 /* NamespaceImport */ || - node.kind === 223 /* ImportSpecifier */ || - node.kind === 227 /* ExportSpecifier */ || - node.kind === 224 /* ExportAssignment */ && node.expression.kind === 66 /* Identifier */; + return node.kind === 219 /* ImportEqualsDeclaration */ || + node.kind === 221 /* ImportClause */ && !!node.name || + node.kind === 222 /* NamespaceImport */ || + node.kind === 224 /* ImportSpecifier */ || + node.kind === 228 /* ExportSpecifier */ || + node.kind === 225 /* ExportAssignment */ && node.expression.kind === 67 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 103 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 104 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -6109,11 +6242,11 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 67 /* FirstKeyword */ <= token && token <= 131 /* LastKeyword */; + return 68 /* FirstKeyword */ <= token && token <= 132 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 6 /* LastTriviaToken */; + return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { @@ -6129,7 +6262,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 133 /* ComputedPropertyName */ && + declaration.name.kind === 134 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -6139,14 +6272,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 163 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return node.kind === 164 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 66 /* Identifier */ || name.kind === 8 /* StringLiteral */ || name.kind === 7 /* NumericLiteral */) { + if (name.kind === 67 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return name.text; } - if (name.kind === 133 /* ComputedPropertyName */) { + if (name.kind === 134 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6164,21 +6297,21 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 66 /* Identifier */ && node.text === "Symbol"; + return node.kind === 67 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 112 /* AbstractKeyword */: - case 115 /* AsyncKeyword */: - case 71 /* ConstKeyword */: - case 119 /* DeclareKeyword */: - case 74 /* DefaultKeyword */: - case 79 /* ExportKeyword */: - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 113 /* AbstractKeyword */: + case 116 /* AsyncKeyword */: + case 72 /* ConstKeyword */: + case 120 /* DeclareKeyword */: + case 75 /* DefaultKeyword */: + case 80 /* ExportKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: return true; } return false; @@ -6186,20 +6319,36 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 135 /* Parameter */; + return root.kind === 136 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 160 /* BindingElement */) { + while (node.kind === 161 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 215 /* ModuleDeclaration */ || n.kind === 245 /* SourceFile */; + return isFunctionLike(n) || n.kind === 216 /* ModuleDeclaration */ || n.kind === 246 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function cloneEntityName(node) { + if (node.kind === 67 /* Identifier */) { + var clone_1 = createSynthesizedNode(67 /* Identifier */); + clone_1.text = node.text; + return clone_1; + } + else { + var clone_2 = createSynthesizedNode(133 /* QualifiedName */); + clone_2.left = cloneEntityName(node.left); + clone_2.left.parent = clone_2; + clone_2.right = cloneEntityName(node.right); + clone_2.right.parent = clone_2; + return clone_2; + } + } + ts.cloneEntityName = cloneEntityName; function nodeIsSynthesized(node) { return node.pos === -1; } @@ -6226,11 +6375,21 @@ var ts; add: add, getGlobalDiagnostics: getGlobalDiagnostics, getDiagnostics: getDiagnostics, - getModificationCount: getModificationCount + getModificationCount: getModificationCount, + reattachFileDiagnostics: reattachFileDiagnostics }; function getModificationCount() { return modificationCount; } + function reattachFileDiagnostics(newFile) { + if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { + return; + } + for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { + var diagnostic = _a[_i]; + diagnostic.file = newFile; + } + } function add(diagnostic) { var diagnostics; if (diagnostic.file) { @@ -6436,7 +6595,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 141 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 142 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -6448,7 +6607,7 @@ var ts; ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { // 1. in-browser single file compilation scenario // 2. non .js file return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); @@ -6465,10 +6624,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 142 /* GetAccessor */) { + if (accessor.kind === 143 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 143 /* SetAccessor */) { + else if (accessor.kind === 144 /* SetAccessor */) { setAccessor = accessor; } else { @@ -6477,7 +6636,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 142 /* GetAccessor */ || member.kind === 143 /* SetAccessor */) + if ((member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6488,10 +6647,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 142 /* GetAccessor */ && !getAccessor) { + if (member.kind === 143 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 143 /* SetAccessor */ && !setAccessor) { + if (member.kind === 144 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6593,7 +6752,7 @@ var ts; } function writeTrimmedCurrentLine(pos, nextLineStart) { var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { // trimmed forward and ending spaces text writer.write(currentLineText); @@ -6624,16 +6783,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 110 /* StaticKeyword */: return 128 /* Static */; - case 109 /* PublicKeyword */: return 16 /* Public */; - case 108 /* ProtectedKeyword */: return 64 /* Protected */; - case 107 /* PrivateKeyword */: return 32 /* Private */; - case 112 /* AbstractKeyword */: return 256 /* Abstract */; - case 79 /* ExportKeyword */: return 1 /* Export */; - case 119 /* DeclareKeyword */: return 2 /* Ambient */; - case 71 /* ConstKeyword */: return 32768 /* Const */; - case 74 /* DefaultKeyword */: return 1024 /* Default */; - case 115 /* AsyncKeyword */: return 512 /* Async */; + case 111 /* StaticKeyword */: return 128 /* Static */; + case 110 /* PublicKeyword */: return 16 /* Public */; + case 109 /* ProtectedKeyword */: return 64 /* Protected */; + case 108 /* PrivateKeyword */: return 32 /* Private */; + case 113 /* AbstractKeyword */: return 256 /* Abstract */; + case 80 /* ExportKeyword */: return 1 /* Export */; + case 120 /* DeclareKeyword */: return 2 /* Ambient */; + case 72 /* ConstKeyword */: return 32768 /* Const */; + case 75 /* DefaultKeyword */: return 1024 /* Default */; + case 116 /* AsyncKeyword */: return 512 /* Async */; } return 0; } @@ -6641,29 +6800,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 166 /* NewExpression */: - case 165 /* CallExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 167 /* TaggedTemplateExpression */: - case 161 /* ArrayLiteralExpression */: - case 169 /* ParenthesizedExpression */: - case 162 /* ObjectLiteralExpression */: - case 183 /* ClassExpression */: - case 170 /* FunctionExpression */: - case 66 /* Identifier */: - case 9 /* RegularExpressionLiteral */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 180 /* TemplateExpression */: - case 81 /* FalseKeyword */: - case 90 /* NullKeyword */: - case 94 /* ThisKeyword */: - case 96 /* TrueKeyword */: - case 92 /* SuperKeyword */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 167 /* NewExpression */: + case 166 /* CallExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 168 /* TaggedTemplateExpression */: + case 162 /* ArrayLiteralExpression */: + case 170 /* ParenthesizedExpression */: + case 163 /* ObjectLiteralExpression */: + case 184 /* ClassExpression */: + case 171 /* FunctionExpression */: + case 67 /* Identifier */: + case 10 /* RegularExpressionLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 181 /* TemplateExpression */: + case 82 /* FalseKeyword */: + case 91 /* NullKeyword */: + case 95 /* ThisKeyword */: + case 97 /* TrueKeyword */: + case 93 /* SuperKeyword */: return true; } } @@ -6671,12 +6830,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 54 /* FirstAssignment */ && token <= 65 /* LastAssignment */; + return token >= 55 /* FirstAssignment */ && token <= 66 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 185 /* ExpressionWithTypeArguments */ && - node.parent.token === 80 /* ExtendsKeyword */ && + return node.kind === 186 /* ExpressionWithTypeArguments */ && + node.parent.token === 81 /* ExtendsKeyword */ && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -6687,10 +6846,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 66 /* Identifier */) { + if (node.kind === 67 /* Identifier */) { return true; } - else if (node.kind === 163 /* PropertyAccessExpression */) { + else if (node.kind === 164 /* PropertyAccessExpression */) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -6698,10 +6857,21 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 163 /* ObjectLiteralExpression */) { + return expression.properties.length === 0; + } + if (kind === 162 /* ArrayLiteralExpression */) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -7004,13 +7174,13 @@ var ts; oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN); } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 134 /* TypeParameter */) { + if (d && d.kind === 135 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 212 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213 /* InterfaceDeclaration */) { return current; } } @@ -7022,7 +7192,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(269 /* Count */); + var nodeConstructors = new Array(270 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -7067,20 +7237,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -7089,24 +7259,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -7117,290 +7287,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 154 /* TupleType */: + case 155 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 155 /* UnionType */: - case 156 /* IntersectionType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 186 /* AsExpression */: + case 187 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 209 /* VariableDeclarationList */: + case 210 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 197 /* ForInStatement */: + case 198 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 198 /* ForOfStatement */: + case 199 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return visitNode(cbNode, node.label); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 238 /* CaseClause */: + case 239 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 239 /* DefaultClause */: + case 240 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 136 /* Decorator */: + case 137 /* Decorator */: return visitNode(cbNode, node.expression); - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 221 /* NamespaceImport */: + case 222 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 222 /* NamedImports */: - case 226 /* NamedExports */: + case 223 /* NamedImports */: + case 227 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 240 /* HeritageClause */: + case 241 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 229 /* ExternalModuleReference */: + case 230 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 228 /* MissingDeclaration */: + case 229 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 230 /* JsxElement */: + case 231 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 231 /* JsxSelfClosingElement */: - case 232 /* JsxOpeningElement */: + case 232 /* JsxSelfClosingElement */: + case 233 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 235 /* JsxAttribute */: + case 236 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 236 /* JsxSpreadAttribute */: + case 237 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 234 /* JsxClosingElement */: + case 235 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 246 /* JSDocTypeExpression */: + case 247 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 250 /* JSDocUnionType */: + case 251 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 251 /* JSDocTupleType */: + case 252 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 249 /* JSDocArrayType */: + case 250 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 253 /* JSDocNonNullableType */: + case 254 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 252 /* JSDocNullableType */: + case 253 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 254 /* JSDocRecordType */: + case 255 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 256 /* JSDocTypeReference */: + case 257 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 257 /* JSDocOptionalType */: + case 258 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 258 /* JSDocFunctionType */: + case 259 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 259 /* JSDocVariadicType */: + case 260 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 260 /* JSDocConstructorType */: + case 261 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 261 /* JSDocThisType */: + case 262 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 255 /* JSDocRecordMember */: + case 256 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 262 /* JSDocComment */: + case 263 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 264 /* JSDocParameterTag */: + case 265 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 265 /* JSDocReturnTag */: + case 266 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 266 /* JSDocTypeTag */: + case 267 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 267 /* JSDocTemplateTag */: + case 268 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -7408,7 +7578,7 @@ var ts; function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { if (setParentNodes === void 0) { setParentNodes = false; } var start = new Date().getTime(); - var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes); + var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes); ts.parseTime += new Date().getTime() - start; return result; } @@ -7444,7 +7614,7 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(2 /* Latest */, true); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); var disallowInAndDecoratorContext = 1 /* DisallowIn */ | 4 /* Decorator */; var sourceFile; var parseDiagnostics; @@ -7595,9 +7765,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 190 /* VariableStatement */: - case 210 /* FunctionDeclaration */: - case 135 /* Parameter */: + case 191 /* VariableStatement */: + case 211 /* FunctionDeclaration */: + case 136 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7638,7 +7808,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(245 /* SourceFile */, 0); + var sourceFile = createNode(246 /* SourceFile */, /*pos*/ 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -7792,6 +7962,9 @@ var ts; function scanJsxIdentifier() { return token = scanner.scanJsxIdentifier(); } + function scanJsxText() { + return token = scanner.scanJsxToken(); + } function speculationHelper(callback, isLookAhead) { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). @@ -7823,35 +7996,38 @@ var ts; // was in immediately prior to invoking the callback. The result of invoking the callback // is returned from this function. function lookAhead(callback) { - return speculationHelper(callback, true); + return speculationHelper(callback, /*isLookAhead*/ true); } // Invokes the provided callback. If the callback returns something falsy, then it restores // the parser to the state it was in immediately prior to invoking the callback. If the // callback returns something truthy, then the parser state is not rolled back. The result // of invoking the callback is returned from this function. function tryParse(callback) { - return speculationHelper(callback, false); + return speculationHelper(callback, /*isLookAhead*/ false); } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token === 111 /* YieldKeyword */ && inYieldContext()) { + if (token === 112 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token === 116 /* AwaitKeyword */ && inAwaitContext()) { + if (token === 117 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token > 102 /* LastReservedWord */; + return token > 103 /* LastReservedWord */; } - function parseExpected(kind, diagnosticMessage) { + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } if (token === kind) { - nextToken(); + if (shouldAdvance) { + nextToken(); + } return true; } // Report specific message if provided with one. Otherwise, report generic fallback message. @@ -7887,22 +8063,22 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token === 22 /* SemicolonToken */) { + if (token === 23 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token === 15 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token === 16 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token === 22 /* SemicolonToken */) { + if (token === 23 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(22 /* SemicolonToken */); + return parseExpected(23 /* SemicolonToken */); } } function createNode(kind, pos) { @@ -7950,75 +8126,75 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(66 /* Identifier */); + var node = createNode(67 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token !== 66 /* Identifier */) { + if (token !== 67 /* Identifier */) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(66 /* Identifier */, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); } function parseIdentifierName() { - return createIdentifier(isIdentifierOrKeyword()); + return createIdentifier(ts.tokenIsIdentifierOrKeyword(token)); } function isLiteralPropertyName() { - return isIdentifierOrKeyword() || - token === 8 /* StringLiteral */ || - token === 7 /* NumericLiteral */; + return ts.tokenIsIdentifierOrKeyword(token) || + token === 9 /* StringLiteral */ || + token === 8 /* NumericLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */) { - return parseLiteralNode(true); + if (token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */) { + return parseLiteralNode(/*internName*/ true); } - if (allowComputedPropertyNames && token === 18 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token === 19 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); } function parsePropertyName() { - return parsePropertyNameWorker(true); + return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ true); } function parseSimplePropertyName() { - return parsePropertyNameWorker(false); + return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ false); } function isSimplePropertyName() { - return token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */ || isIdentifierOrKeyword(); + return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || ts.tokenIsIdentifierOrKeyword(token); } function parseComputedPropertyName() { // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(133 /* ComputedPropertyName */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(134 /* ComputedPropertyName */); + parseExpected(19 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 71 /* ConstKeyword */) { + if (token === 72 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 78 /* EnumKeyword */; + return nextToken() === 79 /* EnumKeyword */; } - if (token === 79 /* ExportKeyword */) { + if (token === 80 /* ExportKeyword */) { nextToken(); - if (token === 74 /* DefaultKeyword */) { + if (token === 75 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunction); } - return token !== 36 /* AsteriskToken */ && token !== 14 /* OpenBraceToken */ && canFollowModifier(); + return token !== 37 /* AsteriskToken */ && token !== 15 /* OpenBraceToken */ && canFollowModifier(); } - if (token === 74 /* DefaultKeyword */) { + if (token === 75 /* DefaultKeyword */) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -8028,14 +8204,14 @@ var ts; return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token === 18 /* OpenBracketToken */ - || token === 14 /* OpenBraceToken */ - || token === 36 /* AsteriskToken */ + return token === 19 /* OpenBracketToken */ + || token === 15 /* OpenBraceToken */ + || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); } function nextTokenIsClassOrFunction() { nextToken(); - return token === 70 /* ClassKeyword */ || token === 84 /* FunctionKeyword */; + return token === 71 /* ClassKeyword */ || token === 85 /* FunctionKeyword */; } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -8053,9 +8229,9 @@ var ts; // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token === 22 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token === 23 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token === 68 /* CaseKeyword */ || token === 74 /* DefaultKeyword */; + return token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; case 4 /* TypeMembers */: return isStartOfTypeMember(); case 5 /* ClassMembers */: @@ -8063,19 +8239,19 @@ var ts; // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token === 22 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token === 23 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token === 18 /* OpenBracketToken */ || isLiteralPropertyName(); + return token === 19 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: - return token === 18 /* OpenBracketToken */ || token === 36 /* AsteriskToken */ || isLiteralPropertyName(); + return token === 19 /* OpenBracketToken */ || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); case 9 /* ObjectBindingElements */: return isLiteralPropertyName(); case 7 /* HeritageClauseElement */: // If we see { } then only consume it as an expression if it is followed by , or { // That way we won't consume the body of a class in its heritage clause. - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -8090,23 +8266,23 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isIdentifierOrPattern(); case 17 /* TypeParameters */: return isIdentifier(); case 11 /* ArgumentExpressions */: case 15 /* ArrayLiteralMembers */: - return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isStartOfExpression(); + return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(); case 18 /* TypeArguments */: case 19 /* TupleElementTypes */: - return token === 23 /* CommaToken */ || isStartOfType(); + return token === 24 /* CommaToken */ || isStartOfType(); case 20 /* HeritageClauses */: return isHeritageClause(); case 21 /* ImportOrExportSpecifiers */: - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); case 13 /* JsxAttributes */: - return isIdentifierOrKeyword() || token === 14 /* OpenBraceToken */; + return ts.tokenIsIdentifierOrKeyword(token) || token === 15 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; case 22 /* JSDocFunctionParameters */: @@ -8119,8 +8295,8 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token === 14 /* OpenBraceToken */); - if (nextToken() === 15 /* CloseBraceToken */) { + ts.Debug.assert(token === 15 /* OpenBraceToken */); + if (nextToken() === 16 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -8129,7 +8305,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 23 /* CommaToken */ || next === 14 /* OpenBraceToken */ || next === 80 /* ExtendsKeyword */ || next === 103 /* ImplementsKeyword */; + return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 81 /* ExtendsKeyword */ || next === 104 /* ImplementsKeyword */; } return true; } @@ -8139,11 +8315,11 @@ var ts; } function nextTokenIsIdentifierOrKeyword() { nextToken(); - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 103 /* ImplementsKeyword */ || - token === 80 /* ExtendsKeyword */) { + if (token === 104 /* ImplementsKeyword */ || + token === 81 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -8167,43 +8343,43 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 21 /* ImportOrExportSpecifiers */: - return token === 15 /* CloseBraceToken */; + return token === 16 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token === 15 /* CloseBraceToken */ || token === 68 /* CaseKeyword */ || token === 74 /* DefaultKeyword */; + return token === 16 /* CloseBraceToken */ || token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token === 14 /* OpenBraceToken */ || token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 17 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token === 26 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token === 17 /* CloseParenToken */ || token === 22 /* SemicolonToken */; + return token === 18 /* CloseParenToken */ || token === 23 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 19 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token === 19 /* CloseBracketToken */; + return token === 20 /* CloseBracketToken */; case 16 /* Parameters */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token === 17 /* CloseParenToken */ || token === 19 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token === 18 /* CloseParenToken */ || token === 20 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 18 /* TypeArguments */: // Tokens other than '>' are here for better error recovery - return token === 26 /* GreaterThanToken */ || token === 16 /* OpenParenToken */; + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */; case 20 /* HeritageClauses */: - return token === 14 /* OpenBraceToken */ || token === 15 /* CloseBraceToken */; + return token === 15 /* OpenBraceToken */ || token === 16 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token === 26 /* GreaterThanToken */ || token === 37 /* SlashToken */; + return token === 27 /* GreaterThanToken */ || token === 38 /* SlashToken */; case 14 /* JsxChildren */: - return token === 24 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); case 22 /* JSDocFunctionParameters */: - return token === 17 /* CloseParenToken */ || token === 52 /* ColonToken */ || token === 15 /* CloseBraceToken */; + return token === 18 /* CloseParenToken */ || token === 53 /* ColonToken */ || token === 16 /* CloseBraceToken */; case 23 /* JSDocTypeArguments */: - return token === 26 /* GreaterThanToken */ || token === 15 /* CloseBraceToken */; + return token === 27 /* GreaterThanToken */ || token === 16 /* CloseBraceToken */; case 25 /* JSDocTupleTypes */: - return token === 19 /* CloseBracketToken */ || token === 15 /* CloseBraceToken */; + return token === 20 /* CloseBracketToken */ || token === 16 /* CloseBraceToken */; case 24 /* JSDocRecordMembers */: - return token === 15 /* CloseBraceToken */; + return token === 16 /* CloseBraceToken */; } } function isVariableDeclaratorListTerminator() { @@ -8221,7 +8397,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -8231,7 +8407,7 @@ var ts; function isInSomeParsingContext() { for (var kind = 0; kind < 26 /* Count */; kind++) { if (parsingContext & (1 << kind)) { - if (isListElement(kind, true) || isListTerminator(kind)) { + if (isListElement(kind, /* inErrorRecovery */ true) || isListTerminator(kind)) { return true; } } @@ -8245,7 +8421,7 @@ var ts; var result = []; result.pos = getNodePos(); while (!isListTerminator(kind)) { - if (isListElement(kind, false)) { + if (isListElement(kind, /* inErrorRecovery */ false)) { var element = parseListElement(kind, parseElement); result.push(element); continue; @@ -8385,20 +8561,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 141 /* Constructor */: - case 146 /* IndexSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 138 /* PropertyDeclaration */: - case 188 /* SemicolonClassElement */: + case 142 /* Constructor */: + case 147 /* IndexSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 189 /* SemicolonClassElement */: return true; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 66 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 118 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 67 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 119 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -8407,8 +8583,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: return true; } } @@ -8417,58 +8593,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 190 /* VariableStatement */: - case 189 /* Block */: - case 193 /* IfStatement */: - case 192 /* ExpressionStatement */: - case 205 /* ThrowStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 191 /* EmptyStatement */: - case 206 /* TryStatement */: - case 204 /* LabeledStatement */: - case 194 /* DoStatement */: - case 207 /* DebuggerStatement */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 225 /* ExportDeclaration */: - case 224 /* ExportAssignment */: - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 213 /* TypeAliasDeclaration */: + case 211 /* FunctionDeclaration */: + case 191 /* VariableStatement */: + case 190 /* Block */: + case 194 /* IfStatement */: + case 193 /* ExpressionStatement */: + case 206 /* ThrowStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 192 /* EmptyStatement */: + case 207 /* TryStatement */: + case 205 /* LabeledStatement */: + case 195 /* DoStatement */: + case 208 /* DebuggerStatement */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + case 225 /* ExportAssignment */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 214 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 244 /* EnumMember */; + return node.kind === 245 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 145 /* ConstructSignature */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: - case 137 /* PropertySignature */: - case 144 /* CallSignature */: + case 146 /* ConstructSignature */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: + case 138 /* PropertySignature */: + case 145 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 208 /* VariableDeclaration */) { + if (node.kind !== 209 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -8489,7 +8665,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 135 /* Parameter */) { + if (node.kind !== 136 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -8544,10 +8720,10 @@ var ts; result.pos = getNodePos(); var commaStart = -1; // Meaning the previous token was not a comma while (true) { - if (isListElement(kind, false)) { + if (isListElement(kind, /* inErrorRecovery */ false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(23 /* CommaToken */)) { + if (parseOptional(24 /* CommaToken */)) { continue; } commaStart = -1; // Back to the state where the last token was not a comma @@ -8556,13 +8732,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(23 /* CommaToken */); + parseExpected(24 /* CommaToken */); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimeter && token === 22 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimeter && token === 23 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -8605,8 +8781,8 @@ var ts; // The allowReservedWords parameter controls whether reserved words are permitted after the first dot function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(20 /* DotToken */)) { - var node = createNode(132 /* QualifiedName */, entity.pos); + while (parseOptional(21 /* DotToken */)) { + var node = createNode(133 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -8633,40 +8809,40 @@ var ts; // the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword". // In the first case though, ASI will not take effect because there is not a // line terminator after the identifier or keyword. - if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { + if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(66 /* Identifier */, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(67 /* Identifier */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(180 /* TemplateExpression */); + var template = createNode(181 /* TemplateExpression */); template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 11 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 12 /* TemplateMiddle */); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 13 /* TemplateMiddle */); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(187 /* TemplateSpan */); + var span = createNode(188 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseLiteralNode(); } else { - literal = parseExpectedToken(13 /* TemplateTail */, false, ts.Diagnostics._0_expected, ts.tokenToString(15 /* CloseBraceToken */)); + literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -8690,7 +8866,7 @@ var ts; // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - if (node.kind === 7 /* NumericLiteral */ + if (node.kind === 8 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { node.flags |= 65536 /* OctalLiteral */; @@ -8699,31 +8875,31 @@ var ts; } // TYPES function parseTypeReferenceOrTypePredicate() { - var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 66 /* Identifier */ && token === 121 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); + if (typeName.kind === 67 /* Identifier */ && token === 122 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(147 /* TypePredicate */, typeName.pos); + var node_1 = createNode(148 /* TypePredicate */, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(148 /* TypeReference */, typeName.pos); + var node = createNode(149 /* TypeReference */, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(151 /* TypeQuery */); - parseExpected(98 /* TypeOfKeyword */); - node.exprName = parseEntityName(true); + var node = createNode(152 /* TypeQuery */); + parseExpected(99 /* TypeOfKeyword */); + node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(134 /* TypeParameter */); + var node = createNode(135 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(80 /* ExtendsKeyword */)) { + if (parseOptional(81 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -8745,20 +8921,20 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token === 24 /* LessThanToken */) { - return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (token === 25 /* LessThanToken */) { + return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(52 /* ColonToken */)) { - return token === 8 /* StringLiteral */ - ? parseLiteralNode(true) + if (parseOptional(53 /* ColonToken */)) { + return token === 9 /* StringLiteral */ + ? parseLiteralNode(/*internName*/ true) : parseType(); } return undefined; } function isStartOfParameter() { - return token === 21 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 53 /* AtToken */; + return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 54 /* AtToken */; } function setModifiers(node, modifiers) { if (modifiers) { @@ -8767,10 +8943,10 @@ var ts; } } function parseParameter() { - var node = createNode(135 /* Parameter */); + var node = createNode(136 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -8785,9 +8961,9 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(51 /* QuestionToken */); + node.questionToken = parseOptionalToken(52 /* QuestionToken */); node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(true); + node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not // a grammar error because the grammar allows arbitrary call signatures in // an ambient context. @@ -8802,10 +8978,10 @@ var ts; return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); } function parseParameterInitializer() { - return parseInitializer(true); + return parseInitializer(/*inParameter*/ true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 33 /* EqualsGreaterThanToken */; + var returnTokenRequired = returnToken === 34 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -8830,7 +9006,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (parseExpected(16 /* OpenParenToken */)) { + if (parseExpected(17 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -8838,7 +9014,7 @@ var ts; var result = parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(17 /* CloseParenToken */) && requireCompleteParameterList) { + if (!parseExpected(18 /* CloseParenToken */) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return // undefined here. return undefined; @@ -8853,7 +9029,7 @@ var ts; function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(23 /* CommaToken */)) { + if (parseOptional(24 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -8861,15 +9037,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 145 /* ConstructSignature */) { - parseExpected(89 /* NewKeyword */); + if (kind === 146 /* ConstructSignature */) { + parseExpected(90 /* NewKeyword */); } - fillSignature(52 /* ColonToken */, false, false, false, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - if (token !== 18 /* OpenBracketToken */) { + if (token !== 19 /* OpenBracketToken */) { return false; } return lookAhead(isUnambiguouslyIndexSignature); @@ -8892,7 +9068,7 @@ var ts; // [] // nextToken(); - if (token === 21 /* DotDotDotToken */ || token === 19 /* CloseBracketToken */) { + if (token === 22 /* DotDotDotToken */ || token === 20 /* CloseBracketToken */) { return true; } if (ts.isModifier(token)) { @@ -8911,24 +9087,24 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token === 52 /* ColonToken */ || token === 23 /* CommaToken */) { + if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token !== 51 /* QuestionToken */) { + if (token !== 52 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token === 52 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; + return token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(146 /* IndexSignature */, fullStart); + var node = createNode(147 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -8936,19 +9112,19 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { - var method = createNode(139 /* MethodSignature */, fullStart); + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { + var method = createNode(140 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(52 /* ColonToken */, false, false, false, method); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(137 /* PropertySignature */, fullStart); + var property = createNode(138 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -8958,9 +9134,9 @@ var ts; } function isStartOfTypeMember() { switch (token) { - case 16 /* OpenParenToken */: - case 24 /* LessThanToken */: - case 18 /* OpenBracketToken */: + case 17 /* OpenParenToken */: + case 25 /* LessThanToken */: + case 19 /* OpenBracketToken */: return true; default: if (ts.isModifier(token)) { @@ -8980,29 +9156,29 @@ var ts; } function isTypeMemberWithLiteralPropertyName() { nextToken(); - return token === 16 /* OpenParenToken */ || - token === 24 /* LessThanToken */ || - token === 51 /* QuestionToken */ || - token === 52 /* ColonToken */ || + return token === 17 /* OpenParenToken */ || + token === 25 /* LessThanToken */ || + token === 52 /* QuestionToken */ || + token === 53 /* ColonToken */ || canParseSemicolon(); } function parseTypeMember() { switch (token) { - case 16 /* OpenParenToken */: - case 24 /* LessThanToken */: - return parseSignatureMember(144 /* CallSignature */); - case 18 /* OpenBracketToken */: + case 17 /* OpenParenToken */: + case 25 /* LessThanToken */: + return parseSignatureMember(145 /* CallSignature */); + case 19 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() - ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) + ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) : parsePropertyOrMethodSignature(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(145 /* ConstructSignature */); + return parseSignatureMember(146 /* ConstructSignature */); } // fall through. - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: return parsePropertyOrMethodSignature(); default: // Index declaration as allowed as a type member. But as per the grammar, @@ -9017,7 +9193,7 @@ var ts; return result; } } - if (isIdentifierOrKeyword()) { + if (ts.tokenIsIdentifierOrKeyword(token)) { return parsePropertyOrMethodSignature(); } } @@ -9032,18 +9208,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */; + return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(152 /* TypeLiteral */); + var node = createNode(153 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(14 /* OpenBraceToken */)) { + if (parseExpected(15 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { members = createMissingList(); @@ -9051,48 +9227,48 @@ var ts; return members; } function parseTupleType() { - var node = createNode(154 /* TupleType */); - node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + var node = createNode(155 /* TupleType */); + node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(157 /* ParenthesizedType */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(158 /* ParenthesizedType */); + parseExpected(17 /* OpenParenToken */); node.type = parseType(); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 150 /* ConstructorType */) { - parseExpected(89 /* NewKeyword */); + if (kind === 151 /* ConstructorType */) { + parseExpected(90 /* NewKeyword */); } - fillSignature(33 /* EqualsGreaterThanToken */, false, false, false, node); + fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token === 20 /* DotToken */ ? undefined : node; + return token === 21 /* DotToken */ ? undefined : node; } function parseNonArrayType() { switch (token) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return parseTokenNode(); - case 98 /* TypeOfKeyword */: + case 99 /* TypeOfKeyword */: return parseTypeQuery(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseTypeLiteral(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseTupleType(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseParenthesizedType(); default: return parseTypeReferenceOrTypePredicate(); @@ -9100,19 +9276,19 @@ var ts; } function isStartOfType() { switch (token) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: - case 98 /* TypeOfKeyword */: - case 14 /* OpenBraceToken */: - case 18 /* OpenBracketToken */: - case 24 /* LessThanToken */: - case 89 /* NewKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: + case 99 /* TypeOfKeyword */: + case 15 /* OpenBraceToken */: + case 19 /* OpenBracketToken */: + case 25 /* LessThanToken */: + case 90 /* NewKeyword */: return true; - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -9122,13 +9298,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token === 17 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + return token === 18 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(18 /* OpenBracketToken */)) { - parseExpected(19 /* CloseBracketToken */); - var node = createNode(153 /* ArrayType */, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { + parseExpected(20 /* CloseBracketToken */); + var node = createNode(154 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -9150,28 +9326,28 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(156 /* IntersectionType */, parseArrayTypeOrHigher, 44 /* AmpersandToken */); + return parseUnionOrIntersectionType(157 /* IntersectionType */, parseArrayTypeOrHigher, 45 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(155 /* UnionType */, parseIntersectionTypeOrHigher, 45 /* BarToken */); + return parseUnionOrIntersectionType(156 /* UnionType */, parseIntersectionTypeOrHigher, 46 /* BarToken */); } function isStartOfFunctionType() { - if (token === 24 /* LessThanToken */) { + if (token === 25 /* LessThanToken */) { return true; } - return token === 16 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token === 17 /* CloseParenToken */ || token === 21 /* DotDotDotToken */) { + if (token === 18 /* CloseParenToken */ || token === 22 /* DotDotDotToken */) { // ( ) // ( ... return true; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 52 /* ColonToken */ || token === 23 /* CommaToken */ || - token === 51 /* QuestionToken */ || token === 54 /* EqualsToken */ || + if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || + token === 52 /* QuestionToken */ || token === 55 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { // ( id : // ( id , @@ -9180,9 +9356,9 @@ var ts; // ( modifier id return true; } - if (token === 17 /* CloseParenToken */) { + if (token === 18 /* CloseParenToken */) { nextToken(); - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { // ( id ) => return true; } @@ -9197,37 +9373,37 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(149 /* FunctionType */); + return parseFunctionOrConstructorType(150 /* FunctionType */); } - if (token === 89 /* NewKeyword */) { - return parseFunctionOrConstructorType(150 /* ConstructorType */); + if (token === 90 /* NewKeyword */) { + return parseFunctionOrConstructorType(151 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(52 /* ColonToken */) ? parseType() : undefined; + return parseOptional(53 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token) { - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 11 /* TemplateHead */: - case 16 /* OpenParenToken */: - case 18 /* OpenBracketToken */: - case 14 /* OpenBraceToken */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 89 /* NewKeyword */: - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - case 66 /* Identifier */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* TemplateHead */: + case 17 /* OpenParenToken */: + case 19 /* OpenBracketToken */: + case 15 /* OpenBraceToken */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 90 /* NewKeyword */: + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + case 67 /* Identifier */: return true; default: return isIdentifier(); @@ -9238,18 +9414,18 @@ var ts; return true; } switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 75 /* DeleteKeyword */: - case 98 /* TypeOfKeyword */: - case 100 /* VoidKeyword */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: - case 24 /* LessThanToken */: - case 116 /* AwaitKeyword */: - case 111 /* YieldKeyword */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 76 /* DeleteKeyword */: + case 99 /* TypeOfKeyword */: + case 101 /* VoidKeyword */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: + case 25 /* LessThanToken */: + case 117 /* AwaitKeyword */: + case 112 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -9267,10 +9443,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token !== 14 /* OpenBraceToken */ && - token !== 84 /* FunctionKeyword */ && - token !== 70 /* ClassKeyword */ && - token !== 53 /* AtToken */ && + return token !== 15 /* OpenBraceToken */ && + token !== 85 /* FunctionKeyword */ && + token !== 71 /* ClassKeyword */ && + token !== 54 /* AtToken */ && isStartOfExpression(); } function allowInAndParseExpression() { @@ -9287,7 +9463,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(23 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(24 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -9296,7 +9472,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 54 /* EqualsToken */) { + if (token !== 55 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. @@ -9305,7 +9481,7 @@ var ts; // it's more likely that a { would be a allowed (as an object literal). While this // is also allowed for parameters, the risk is that we consume the { as an object // literal when it really will be for the block following the parameter. - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14 /* OpenBraceToken */) || !isStartOfExpression()) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15 /* OpenBraceToken */) || !isStartOfExpression()) { // preceding line break, open brace in a parameter (likely a function body) or current token is not an expression - // do not try to parse initializer return undefined; @@ -9313,7 +9489,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -9347,11 +9523,11 @@ var ts; // Otherwise, we try to parse out the conditional expression bit. We want to allow any // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. - var expr = parseBinaryExpressionOrHigher(0); + var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 66 /* Identifier */ && token === 33 /* EqualsGreaterThanToken */) { + if (expr.kind === 67 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -9367,7 +9543,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 111 /* YieldKeyword */) { + if (token === 112 /* YieldKeyword */) { // If we have a 'yield' keyword, and htis is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -9396,15 +9572,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(181 /* YieldExpression */); + var node = createNode(182 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token === 36 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + (token === 37 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9415,16 +9591,16 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 33 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(171 /* ArrowFunction */, identifier.pos); - var parameter = createNode(135 /* Parameter */, identifier.pos); + ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(172 /* ArrowFunction */, identifier.pos); + var parameter = createNode(136 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(33 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(false); + node.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); + node.body = parseArrowFunctionExpressionBody(/*isAsync*/ false); return finishNode(node); } function tryParseParenthesizedArrowFunctionExpression() { @@ -9438,7 +9614,7 @@ var ts; // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. var arrowFunction = triState === 1 /* True */ - ? parseParenthesizedArrowFunctionExpressionHead(true) + ? parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ true) : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); if (!arrowFunction) { // Didn't appear to actually be a parenthesized arrow function. Just bail out. @@ -9448,8 +9624,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(33 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 33 /* EqualsGreaterThanToken */ || lastToken === 14 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 34 /* EqualsGreaterThanToken */ || lastToken === 15 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -9459,10 +9635,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */ || token === 115 /* AsyncKeyword */) { + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || token === 116 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -9472,28 +9648,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 115 /* AsyncKeyword */) { + if (token === 116 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token !== 16 /* OpenParenToken */ && token !== 24 /* LessThanToken */) { + if (token !== 17 /* OpenParenToken */ && token !== 25 /* LessThanToken */) { return 0 /* False */; } } var first = token; var second = nextToken(); - if (first === 16 /* OpenParenToken */) { - if (second === 17 /* CloseParenToken */) { + if (first === 17 /* OpenParenToken */) { + if (second === 18 /* CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 33 /* EqualsGreaterThanToken */: - case 52 /* ColonToken */: - case 14 /* OpenBraceToken */: + case 34 /* EqualsGreaterThanToken */: + case 53 /* ColonToken */: + case 15 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -9505,12 +9681,12 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 18 /* OpenBracketToken */ || second === 14 /* OpenBraceToken */) { + if (second === 19 /* OpenBracketToken */ || second === 15 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 21 /* DotDotDotToken */) { + if (second === 22 /* DotDotDotToken */) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, @@ -9523,7 +9699,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 52 /* ColonToken */) { + if (nextToken() === 53 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -9531,7 +9707,7 @@ var ts; return 2 /* Unknown */; } else { - ts.Debug.assert(first === 24 /* LessThanToken */); + ts.Debug.assert(first === 25 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -9541,17 +9717,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 80 /* ExtendsKeyword */) { + if (third === 81 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 54 /* EqualsToken */: - case 26 /* GreaterThanToken */: + case 55 /* EqualsToken */: + case 27 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 23 /* CommaToken */) { + else if (third === 24 /* CommaToken */) { return true; } return false; @@ -9566,10 +9742,10 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(false); + return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(171 /* ArrowFunction */); + var node = createNode(172 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512 /* Async */); // Arrow functions are never generators. @@ -9579,7 +9755,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(52 /* ColonToken */, false, isAsync, !allowAmbiguity, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { return undefined; @@ -9592,19 +9768,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token !== 33 /* EqualsGreaterThanToken */ && token !== 14 /* OpenBraceToken */) { + if (!allowAmbiguity && token !== 34 /* EqualsGreaterThanToken */ && token !== 15 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token === 14 /* OpenBraceToken */) { - return parseFunctionBlock(false, isAsync, false); + if (token === 15 /* OpenBraceToken */) { + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } - if (token !== 22 /* SemicolonToken */ && - token !== 84 /* FunctionKeyword */ && - token !== 70 /* ClassKeyword */ && + if (token !== 23 /* SemicolonToken */ && + token !== 85 /* FunctionKeyword */ && + token !== 71 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -9621,7 +9797,7 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. - return parseFunctionBlock(false, isAsync, true); + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ true); } return isAsync ? doInAwaitContext(parseAssignmentExpressionOrHigher) @@ -9629,17 +9805,17 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(51 /* QuestionToken */); + var questionToken = parseOptionalToken(52 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(179 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(180 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(52 /* ColonToken */, false, ts.Diagnostics._0_expected, ts.tokenToString(52 /* ColonToken */)); + node.colonToken = parseExpectedToken(53 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(53 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9648,7 +9824,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 87 /* InKeyword */ || t === 131 /* OfKeyword */; + return t === 88 /* InKeyword */ || t === 132 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9660,10 +9836,10 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 87 /* InKeyword */ && inDisallowInContext()) { + if (token === 88 /* InKeyword */ && inDisallowInContext()) { break; } - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -9684,46 +9860,46 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 87 /* InKeyword */) { + if (inDisallowInContext() && token === 88 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 50 /* BarBarToken */: + case 51 /* BarBarToken */: return 1; - case 49 /* AmpersandAmpersandToken */: + case 50 /* AmpersandAmpersandToken */: return 2; - case 45 /* BarToken */: + case 46 /* BarToken */: return 3; - case 46 /* CaretToken */: + case 47 /* CaretToken */: return 4; - case 44 /* AmpersandToken */: + case 45 /* AmpersandToken */: return 5; - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: return 6; - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: - case 88 /* InstanceOfKeyword */: - case 87 /* InKeyword */: - case 113 /* AsKeyword */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: + case 89 /* InstanceOfKeyword */: + case 88 /* InKeyword */: + case 114 /* AsKeyword */: return 7; - case 41 /* LessThanLessThanToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: + case 42 /* LessThanLessThanToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 34 /* PlusToken */: - case 35 /* MinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: return 9; - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: return 10; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -9731,45 +9907,45 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(178 /* BinaryExpression */, left.pos); + var node = createNode(179 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(186 /* AsExpression */, left.pos); + var node = createNode(187 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(176 /* PrefixUnaryExpression */); + var node = createNode(177 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(172 /* DeleteExpression */); + var node = createNode(173 /* DeleteExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(173 /* TypeOfExpression */); + var node = createNode(174 /* TypeOfExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(174 /* VoidExpression */); + var node = createNode(175 /* VoidExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function isAwaitExpression() { - if (token === 116 /* AwaitKeyword */) { + if (token === 117 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -9779,7 +9955,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(175 /* AwaitExpression */); + var node = createNode(176 /* AwaitExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -9789,25 +9965,25 @@ var ts; return parseAwaitExpression(); } switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: return parsePrefixUnaryExpression(); - case 75 /* DeleteKeyword */: + case 76 /* DeleteKeyword */: return parseDeleteExpression(); - case 98 /* TypeOfKeyword */: + case 99 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return parseVoidExpression(); - case 24 /* LessThanToken */: + case 25 /* LessThanToken */: if (sourceFile.languageVariant !== 1 /* JSX */) { return parseTypeAssertion(); } if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(); + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); } // Fall through default: @@ -9817,8 +9993,8 @@ var ts; function parsePostfixExpressionOrHigher() { var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 39 /* PlusPlusToken */ || token === 40 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(177 /* PostfixUnaryExpression */, expression.pos); + if ((token === 40 /* PlusPlusToken */ || token === 41 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(178 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -9857,7 +10033,7 @@ var ts; // the last two CallExpression productions. Or we have a MemberExpression which either // completes the LeftHandSideExpression, or starts the beginning of the first four // CallExpression productions. - var expression = token === 92 /* SuperKeyword */ + var expression = token === 93 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -9917,47 +10093,47 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token === 16 /* OpenParenToken */ || token === 20 /* DotToken */) { + if (token === 17 /* OpenParenToken */ || token === 21 /* DotToken */ || token === 19 /* OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(163 /* PropertyAccessExpression */, expression.pos); + var node = createNode(164 /* PropertyAccessExpression */, expression.pos); node.expression = expression; - node.dotToken = parseExpectedToken(20 /* DotToken */, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); - node.name = parseRightSideOfDot(true); + node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } - function parseJsxElementOrSelfClosingElement() { - var opening = parseJsxOpeningOrSelfClosingElement(); - if (opening.kind === 232 /* JsxOpeningElement */) { - var node = createNode(230 /* JsxElement */, opening.pos); + function parseJsxElementOrSelfClosingElement(inExpressionContext) { + var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + if (opening.kind === 233 /* JsxOpeningElement */) { + var node = createNode(231 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(); + node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 232 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements return opening; } } function parseJsxText() { - var node = createNode(233 /* JsxText */, scanner.getStartPos()); + var node = createNode(234 /* JsxText */, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 233 /* JsxText */: + case 234 /* JsxText */: return parseJsxText(); - case 14 /* OpenBraceToken */: - return parseJsxExpression(); - case 24 /* LessThanToken */: - return parseJsxElementOrSelfClosingElement(); + case 15 /* OpenBraceToken */: + return parseJsxExpression(/*inExpressionContext*/ false); + case 25 /* LessThanToken */: + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); } - ts.Debug.fail('Unknown JSX child kind ' + token); + ts.Debug.fail("Unknown JSX child kind " + token); } function parseJsxChildren(openingTagName) { var result = []; @@ -9966,7 +10142,7 @@ var ts; parsingContext |= 1 << 14 /* JsxChildren */; while (true) { token = scanner.reScanJsxToken(); - if (token === 25 /* LessThanSlashToken */) { + if (token === 26 /* LessThanSlashToken */) { break; } else if (token === 1 /* EndOfFileToken */) { @@ -9979,19 +10155,29 @@ var ts; parsingContext = saveParsingContext; return result; } - function parseJsxOpeningOrSelfClosingElement() { + function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(24 /* LessThanToken */); + parseExpected(25 /* LessThanToken */); var tagName = parseJsxElementName(); var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); var node; - if (parseOptional(26 /* GreaterThanToken */)) { - node = createNode(232 /* JsxOpeningElement */, fullStart); + if (token === 27 /* GreaterThanToken */) { + // Closing tag, so scan the immediately-following text with the JSX scanning instead + // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate + // scanning errors + node = createNode(233 /* JsxOpeningElement */, fullStart); + scanJsxText(); } else { - parseExpected(37 /* SlashToken */); - parseExpected(26 /* GreaterThanToken */); - node = createNode(231 /* JsxSelfClosingElement */, fullStart); + parseExpected(38 /* SlashToken */); + if (inExpressionContext) { + parseExpected(27 /* GreaterThanToken */); + } + else { + parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } + node = createNode(232 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -10000,98 +10186,110 @@ var ts; function parseJsxElementName() { scanJsxIdentifier(); var elementName = parseIdentifierName(); - while (parseOptional(20 /* DotToken */)) { + while (parseOptional(21 /* DotToken */)) { scanJsxIdentifier(); - var node = createNode(132 /* QualifiedName */, elementName.pos); + var node = createNode(133 /* QualifiedName */, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); } return elementName; } - function parseJsxExpression() { - var node = createNode(237 /* JsxExpression */); - parseExpected(14 /* OpenBraceToken */); - if (token !== 15 /* CloseBraceToken */) { + function parseJsxExpression(inExpressionContext) { + var node = createNode(238 /* JsxExpression */); + parseExpected(15 /* OpenBraceToken */); + if (token !== 16 /* CloseBraceToken */) { node.expression = parseExpression(); } - parseExpected(15 /* CloseBraceToken */); + if (inExpressionContext) { + parseExpected(16 /* CloseBraceToken */); + } + else { + parseExpected(16 /* CloseBraceToken */, /*message*/ undefined, /*advance*/ false); + scanJsxText(); + } return finishNode(node); } function parseJsxAttribute() { - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(235 /* JsxAttribute */); + var node = createNode(236 /* JsxAttribute */); node.name = parseIdentifierName(); - if (parseOptional(54 /* EqualsToken */)) { + if (parseOptional(55 /* EqualsToken */)) { switch (token) { - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: node.initializer = parseLiteralNode(); break; default: - node.initializer = parseJsxExpression(); + node.initializer = parseJsxExpression(/*inExpressionContext*/ true); break; } } return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(236 /* JsxSpreadAttribute */); - parseExpected(14 /* OpenBraceToken */); - parseExpected(21 /* DotDotDotToken */); + var node = createNode(237 /* JsxSpreadAttribute */); + parseExpected(15 /* OpenBraceToken */); + parseExpected(22 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } - function parseJsxClosingElement() { - var node = createNode(234 /* JsxClosingElement */); - parseExpected(25 /* LessThanSlashToken */); + function parseJsxClosingElement(inExpressionContext) { + var node = createNode(235 /* JsxClosingElement */); + parseExpected(26 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); - parseExpected(26 /* GreaterThanToken */); + if (inExpressionContext) { + parseExpected(27 /* GreaterThanToken */); + } + else { + parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(168 /* TypeAssertionExpression */); - parseExpected(24 /* LessThanToken */); + var node = createNode(169 /* TypeAssertionExpression */); + parseExpected(25 /* LessThanToken */); node.type = parseType(); - parseExpected(26 /* GreaterThanToken */); + parseExpected(27 /* GreaterThanToken */); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(20 /* DotToken */); + var dotToken = parseOptionalToken(21 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(163 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(164 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; - propertyAccess.name = parseRightSideOfDot(true); + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(18 /* OpenBracketToken */)) { - var indexedAccess = createNode(164 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { + var indexedAccess = createNode(165 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. - if (token !== 19 /* CloseBracketToken */) { + if (token !== 20 /* CloseBracketToken */) { indexedAccess.argumentExpression = allowInAnd(parseExpression); - if (indexedAccess.argumentExpression.kind === 8 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 7 /* NumericLiteral */) { + if (indexedAccess.argumentExpression.kind === 9 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 8 /* NumericLiteral */) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } - if (token === 10 /* NoSubstitutionTemplateLiteral */ || token === 11 /* TemplateHead */) { - var tagExpression = createNode(167 /* TaggedTemplateExpression */, expression.pos); + if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { + var tagExpression = createNode(168 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; - tagExpression.template = token === 10 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -10103,7 +10301,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token === 24 /* LessThanToken */) { + if (token === 25 /* LessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the @@ -10112,15 +10310,15 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(165 /* CallExpression */, expression.pos); + var callExpr = createNode(166 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token === 16 /* OpenParenToken */) { - var callExpr = createNode(165 /* CallExpression */, expression.pos); + else if (token === 17 /* OpenParenToken */) { + var callExpr = createNode(166 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -10130,17 +10328,17 @@ var ts; } } function parseArgumentList() { - parseExpected(16 /* OpenParenToken */); + parseExpected(17 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(24 /* LessThanToken */)) { + if (!parseOptional(25 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); - if (!parseExpected(26 /* GreaterThanToken */)) { + if (!parseExpected(27 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; } @@ -10152,32 +10350,32 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token) { - case 16 /* OpenParenToken */: // foo( + case 17 /* OpenParenToken */: // foo( // this case are the only case where this token can legally follow a type argument // list. So we definitely want to treat this as a type arg list. - case 20 /* DotToken */: // foo. - case 17 /* CloseParenToken */: // foo) - case 19 /* CloseBracketToken */: // foo] - case 52 /* ColonToken */: // foo: - case 22 /* SemicolonToken */: // foo; - case 51 /* QuestionToken */: // foo? - case 29 /* EqualsEqualsToken */: // foo == - case 31 /* EqualsEqualsEqualsToken */: // foo === - case 30 /* ExclamationEqualsToken */: // foo != - case 32 /* ExclamationEqualsEqualsToken */: // foo !== - case 49 /* AmpersandAmpersandToken */: // foo && - case 50 /* BarBarToken */: // foo || - case 46 /* CaretToken */: // foo ^ - case 44 /* AmpersandToken */: // foo & - case 45 /* BarToken */: // foo | - case 15 /* CloseBraceToken */: // foo } + case 21 /* DotToken */: // foo. + case 18 /* CloseParenToken */: // foo) + case 20 /* CloseBracketToken */: // foo] + case 53 /* ColonToken */: // foo: + case 23 /* SemicolonToken */: // foo; + case 52 /* QuestionToken */: // foo? + case 30 /* EqualsEqualsToken */: // foo == + case 32 /* EqualsEqualsEqualsToken */: // foo === + case 31 /* ExclamationEqualsToken */: // foo != + case 33 /* ExclamationEqualsEqualsToken */: // foo !== + case 50 /* AmpersandAmpersandToken */: // foo && + case 51 /* BarBarToken */: // foo || + case 47 /* CaretToken */: // foo ^ + case 45 /* AmpersandToken */: // foo & + case 46 /* BarToken */: // foo | + case 16 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. return true; - case 23 /* CommaToken */: // foo, - case 14 /* OpenBraceToken */: // foo { + case 24 /* CommaToken */: // foo, + case 15 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -10188,23 +10386,23 @@ var ts; } function parsePrimaryExpression() { switch (token) { - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: return parseTokenNode(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseParenthesizedExpression(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 115 /* AsyncKeyword */: + case 116 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -10212,59 +10410,59 @@ var ts; break; } return parseFunctionExpression(); - case 70 /* ClassKeyword */: + case 71 /* ClassKeyword */: return parseClassExpression(); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseFunctionExpression(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: return parseNewExpression(); - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - if (reScanSlashToken() === 9 /* RegularExpressionLiteral */) { + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 11 /* TemplateHead */: + case 12 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(169 /* ParenthesizedExpression */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(170 /* ParenthesizedExpression */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(182 /* SpreadElementExpression */); - parseExpected(21 /* DotDotDotToken */); + var node = createNode(183 /* SpreadElementExpression */); + parseExpected(22 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token === 21 /* DotDotDotToken */ ? parseSpreadElement() : - token === 23 /* CommaToken */ ? createNode(184 /* OmittedExpression */) : + return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : + token === 24 /* CommaToken */ ? createNode(185 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(161 /* ArrayLiteralExpression */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(162 /* ArrayLiteralExpression */); + parseExpected(19 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048 /* MultiLine */; node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(120 /* GetKeyword */)) { - return parseAccessorDeclaration(142 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(121 /* GetKeyword */)) { + return parseAccessorDeclaration(143 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(126 /* SetKeyword */)) { - return parseAccessorDeclaration(143 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(127 /* SetKeyword */)) { + return parseAccessorDeclaration(144 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -10276,39 +10474,39 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } // Parse to check if it is short-hand property assignment or normal property assignment - if ((token === 23 /* CommaToken */ || token === 15 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(243 /* ShorthandPropertyAssignment */, fullStart); + if ((token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */) && tokenIsIdentifier) { + var shorthandDeclaration = createNode(244 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(242 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(243 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(162 /* ObjectLiteralExpression */); - parseExpected(14 /* OpenBraceToken */); + var node = createNode(163 /* ObjectLiteralExpression */); + parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048 /* MultiLine */; } - node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, true); - parseExpected(15 /* CloseBraceToken */); + node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -10321,10 +10519,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(170 /* FunctionExpression */); + var node = createNode(171 /* FunctionExpression */); setModifiers(node, parseModifiers()); - parseExpected(84 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + parseExpected(85 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); node.name = @@ -10332,8 +10530,8 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, node); - node.body = parseFunctionBlock(isGenerator, isAsync, false); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -10343,21 +10541,21 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(166 /* NewExpression */); - parseExpected(89 /* NewKeyword */); + var node = createNode(167 /* NewExpression */); + parseExpected(90 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 16 /* OpenParenToken */) { + if (node.typeArguments || token === 17 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(189 /* Block */); - if (parseExpected(14 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(190 /* Block */); + if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -10384,84 +10582,84 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(191 /* EmptyStatement */); - parseExpected(22 /* SemicolonToken */); + var node = createNode(192 /* EmptyStatement */); + parseExpected(23 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(193 /* IfStatement */); - parseExpected(85 /* IfKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(194 /* IfStatement */); + parseExpected(86 /* IfKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(77 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(78 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(194 /* DoStatement */); - parseExpected(76 /* DoKeyword */); + var node = createNode(195 /* DoStatement */); + parseExpected(77 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(101 /* WhileKeyword */); - parseExpected(16 /* OpenParenToken */); + parseExpected(102 /* WhileKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(22 /* SemicolonToken */); + parseOptional(23 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(195 /* WhileStatement */); - parseExpected(101 /* WhileKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(196 /* WhileStatement */); + parseExpected(102 /* WhileKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(83 /* ForKeyword */); - parseExpected(16 /* OpenParenToken */); + parseExpected(84 /* ForKeyword */); + parseExpected(17 /* OpenParenToken */); var initializer = undefined; - if (token !== 22 /* SemicolonToken */) { - if (token === 99 /* VarKeyword */ || token === 105 /* LetKeyword */ || token === 71 /* ConstKeyword */) { - initializer = parseVariableDeclarationList(true); + if (token !== 23 /* SemicolonToken */) { + if (token === 100 /* VarKeyword */ || token === 106 /* LetKeyword */ || token === 72 /* ConstKeyword */) { + initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { initializer = disallowInAnd(parseExpression); } } var forOrForInOrForOfStatement; - if (parseOptional(87 /* InKeyword */)) { - var forInStatement = createNode(197 /* ForInStatement */, pos); + if (parseOptional(88 /* InKeyword */)) { + var forInStatement = createNode(198 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(131 /* OfKeyword */)) { - var forOfStatement = createNode(198 /* ForOfStatement */, pos); + else if (parseOptional(132 /* OfKeyword */)) { + var forOfStatement = createNode(199 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(196 /* ForStatement */, pos); + var forStatement = createNode(197 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(22 /* SemicolonToken */); - if (token !== 22 /* SemicolonToken */ && token !== 17 /* CloseParenToken */) { + parseExpected(23 /* SemicolonToken */); + if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(22 /* SemicolonToken */); - if (token !== 17 /* CloseParenToken */) { + parseExpected(23 /* SemicolonToken */); + if (token !== 18 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -10469,7 +10667,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 200 /* BreakStatement */ ? 67 /* BreakKeyword */ : 72 /* ContinueKeyword */); + parseExpected(kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -10477,8 +10675,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(201 /* ReturnStatement */); - parseExpected(91 /* ReturnKeyword */); + var node = createNode(202 /* ReturnStatement */); + parseExpected(92 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -10486,42 +10684,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(202 /* WithStatement */); - parseExpected(102 /* WithKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(203 /* WithStatement */); + parseExpected(103 /* WithKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(238 /* CaseClause */); - parseExpected(68 /* CaseKeyword */); + var node = createNode(239 /* CaseClause */); + parseExpected(69 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(239 /* DefaultClause */); - parseExpected(74 /* DefaultKeyword */); - parseExpected(52 /* ColonToken */); + var node = createNode(240 /* DefaultClause */); + parseExpected(75 /* DefaultKeyword */); + parseExpected(53 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 68 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token === 69 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(203 /* SwitchStatement */); - parseExpected(93 /* SwitchKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(204 /* SwitchStatement */); + parseExpected(94 /* SwitchKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); - var caseBlock = createNode(217 /* CaseBlock */, scanner.getStartPos()); - parseExpected(14 /* OpenBraceToken */); + parseExpected(18 /* CloseParenToken */); + var caseBlock = createNode(218 /* CaseBlock */, scanner.getStartPos()); + parseExpected(15 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -10533,39 +10731,39 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(205 /* ThrowStatement */); - parseExpected(95 /* ThrowKeyword */); + var node = createNode(206 /* ThrowStatement */); + parseExpected(96 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(206 /* TryStatement */); - parseExpected(97 /* TryKeyword */); - node.tryBlock = parseBlock(false); - node.catchClause = token === 69 /* CatchKeyword */ ? parseCatchClause() : undefined; + var node = createNode(207 /* TryStatement */); + parseExpected(98 /* TryKeyword */); + node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); + node.catchClause = token === 70 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token === 82 /* FinallyKeyword */) { - parseExpected(82 /* FinallyKeyword */); - node.finallyBlock = parseBlock(false); + if (!node.catchClause || token === 83 /* FinallyKeyword */) { + parseExpected(83 /* FinallyKeyword */); + node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(241 /* CatchClause */); - parseExpected(69 /* CatchKeyword */); - if (parseExpected(16 /* OpenParenToken */)) { + var result = createNode(242 /* CatchClause */); + parseExpected(70 /* CatchKeyword */); + if (parseExpected(17 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(17 /* CloseParenToken */); - result.block = parseBlock(false); + parseExpected(18 /* CloseParenToken */); + result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(207 /* DebuggerStatement */); - parseExpected(73 /* DebuggerKeyword */); + var node = createNode(208 /* DebuggerStatement */); + parseExpected(74 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -10575,43 +10773,40 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 66 /* Identifier */ && parseOptional(52 /* ColonToken */)) { - var labeledStatement = createNode(204 /* LabeledStatement */, fullStart); + if (expression.kind === 67 /* Identifier */ && parseOptional(53 /* ColonToken */)) { + var labeledStatement = createNode(205 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(192 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(193 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } - function isIdentifierOrKeyword() { - return token >= 66 /* Identifier */; - } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); - return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); + return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 84 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token === 85 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); - return (isIdentifierOrKeyword() || token === 7 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token) || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token) { - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -10634,36 +10829,36 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 104 /* InterfaceKeyword */: - case 129 /* TypeKeyword */: + case 105 /* InterfaceKeyword */: + case 130 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115 /* AsyncKeyword */: - case 119 /* DeclareKeyword */: + case 116 /* AsyncKeyword */: + case 120 /* DeclareKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 86 /* ImportKeyword */: + case 87 /* ImportKeyword */: nextToken(); - return token === 8 /* StringLiteral */ || token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || isIdentifierOrKeyword(); - case 79 /* ExportKeyword */: + return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token); + case 80 /* ExportKeyword */: nextToken(); - if (token === 54 /* EqualsToken */ || token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || token === 74 /* DefaultKeyword */) { + if (token === 55 /* EqualsToken */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || token === 75 /* DefaultKeyword */) { return true; } continue; - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: - case 112 /* AbstractKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: + case 113 /* AbstractKeyword */: nextToken(); continue; default: @@ -10676,47 +10871,47 @@ var ts; } function isStartOfStatement() { switch (token) { - case 53 /* AtToken */: - case 22 /* SemicolonToken */: - case 14 /* OpenBraceToken */: - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: - case 85 /* IfKeyword */: - case 76 /* DoKeyword */: - case 101 /* WhileKeyword */: - case 83 /* ForKeyword */: - case 72 /* ContinueKeyword */: - case 67 /* BreakKeyword */: - case 91 /* ReturnKeyword */: - case 102 /* WithKeyword */: - case 93 /* SwitchKeyword */: - case 95 /* ThrowKeyword */: - case 97 /* TryKeyword */: - case 73 /* DebuggerKeyword */: + case 54 /* AtToken */: + case 23 /* SemicolonToken */: + case 15 /* OpenBraceToken */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: + case 86 /* IfKeyword */: + case 77 /* DoKeyword */: + case 102 /* WhileKeyword */: + case 84 /* ForKeyword */: + case 73 /* ContinueKeyword */: + case 68 /* BreakKeyword */: + case 92 /* ReturnKeyword */: + case 103 /* WithKeyword */: + case 94 /* SwitchKeyword */: + case 96 /* ThrowKeyword */: + case 98 /* TryKeyword */: + case 74 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return true; - case 71 /* ConstKeyword */: - case 79 /* ExportKeyword */: - case 86 /* ImportKeyword */: + case 72 /* ConstKeyword */: + case 80 /* ExportKeyword */: + case 87 /* ImportKeyword */: return isStartOfDeclaration(); - case 115 /* AsyncKeyword */: - case 119 /* DeclareKeyword */: - case 104 /* InterfaceKeyword */: - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: - case 129 /* TypeKeyword */: + case 116 /* AsyncKeyword */: + case 120 /* DeclareKeyword */: + case 105 /* InterfaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: + case 130 /* TypeKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -10726,7 +10921,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */; + return isIdentifier() || token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -10735,65 +10930,65 @@ var ts; } function parseStatement() { switch (token) { - case 22 /* SemicolonToken */: + case 23 /* SemicolonToken */: return parseEmptyStatement(); - case 14 /* OpenBraceToken */: - return parseBlock(false); - case 99 /* VarKeyword */: - return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 105 /* LetKeyword */: + case 15 /* OpenBraceToken */: + return parseBlock(/*ignoreMissingOpenBrace*/ false); + case 100 /* VarKeyword */: + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 106 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(scanner.getStartPos(), undefined, undefined); + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 84 /* FunctionKeyword */: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 70 /* ClassKeyword */: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 85 /* IfKeyword */: + case 85 /* FunctionKeyword */: + return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 71 /* ClassKeyword */: + return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 86 /* IfKeyword */: return parseIfStatement(); - case 76 /* DoKeyword */: + case 77 /* DoKeyword */: return parseDoStatement(); - case 101 /* WhileKeyword */: + case 102 /* WhileKeyword */: return parseWhileStatement(); - case 83 /* ForKeyword */: + case 84 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 72 /* ContinueKeyword */: - return parseBreakOrContinueStatement(199 /* ContinueStatement */); - case 67 /* BreakKeyword */: - return parseBreakOrContinueStatement(200 /* BreakStatement */); - case 91 /* ReturnKeyword */: + case 73 /* ContinueKeyword */: + return parseBreakOrContinueStatement(200 /* ContinueStatement */); + case 68 /* BreakKeyword */: + return parseBreakOrContinueStatement(201 /* BreakStatement */); + case 92 /* ReturnKeyword */: return parseReturnStatement(); - case 102 /* WithKeyword */: + case 103 /* WithKeyword */: return parseWithStatement(); - case 93 /* SwitchKeyword */: + case 94 /* SwitchKeyword */: return parseSwitchStatement(); - case 95 /* ThrowKeyword */: + case 96 /* ThrowKeyword */: return parseThrowStatement(); - case 97 /* TryKeyword */: + case 98 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return parseTryStatement(); - case 73 /* DebuggerKeyword */: + case 74 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 53 /* AtToken */: + case 54 /* AtToken */: return parseDeclaration(); - case 115 /* AsyncKeyword */: - case 104 /* InterfaceKeyword */: - case 129 /* TypeKeyword */: - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: - case 119 /* DeclareKeyword */: - case 71 /* ConstKeyword */: - case 78 /* EnumKeyword */: - case 79 /* ExportKeyword */: - case 86 /* ImportKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 109 /* PublicKeyword */: - case 112 /* AbstractKeyword */: - case 110 /* StaticKeyword */: + case 116 /* AsyncKeyword */: + case 105 /* InterfaceKeyword */: + case 130 /* TypeKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: + case 120 /* DeclareKeyword */: + case 72 /* ConstKeyword */: + case 79 /* EnumKeyword */: + case 80 /* ExportKeyword */: + case 87 /* ImportKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 110 /* PublicKeyword */: + case 113 /* AbstractKeyword */: + case 111 /* StaticKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -10806,35 +11001,35 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 70 /* ClassKeyword */: + case 71 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 104 /* InterfaceKeyword */: + case 105 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 129 /* TypeKeyword */: + case 130 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 78 /* EnumKeyword */: + case 79 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 86 /* ImportKeyword */: + case 87 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: nextToken(); - return token === 74 /* DefaultKeyword */ || token === 54 /* EqualsToken */ ? + return token === 75 /* DefaultKeyword */ || token === 55 /* EqualsToken */ ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(228 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(229 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -10844,86 +11039,86 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token !== 14 /* OpenBraceToken */ && canParseSemicolon()) { + if (token !== 15 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } - return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); + return parseFunctionBlock(isGenerator, isAsync, /*ignoreMissingOpenBrace*/ false, diagnosticMessage); } // DECLARATIONS function parseArrayBindingElement() { - if (token === 23 /* CommaToken */) { - return createNode(184 /* OmittedExpression */); + if (token === 24 /* CommaToken */) { + return createNode(185 /* OmittedExpression */); } - var node = createNode(160 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); + var node = createNode(161 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(160 /* BindingElement */); + var node = createNode(161 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 52 /* ColonToken */) { + if (tokenIsIdentifier && token !== 53 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(158 /* ObjectBindingPattern */); - parseExpected(14 /* OpenBraceToken */); + var node = createNode(159 /* ObjectBindingPattern */); + parseExpected(15 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(159 /* ArrayBindingPattern */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(160 /* ArrayBindingPattern */); + parseExpected(19 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */ || isIdentifier(); + return token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token === 18 /* OpenBracketToken */) { + if (token === 19 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(208 /* VariableDeclaration */); + var node = createNode(209 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { - node.initializer = parseInitializer(false); + node.initializer = parseInitializer(/*inParameter*/ false); } return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(209 /* VariableDeclarationList */); + var node = createNode(210 /* VariableDeclarationList */); switch (token) { - case 99 /* VarKeyword */: + case 100 /* VarKeyword */: break; - case 105 /* LetKeyword */: + case 106 /* LetKeyword */: node.flags |= 16384 /* Let */; break; - case 71 /* ConstKeyword */: + case 72 /* ConstKeyword */: node.flags |= 32768 /* Const */; break; default: @@ -10939,7 +11134,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token === 131 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 132 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -10951,40 +11146,40 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 17 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(190 /* VariableStatement */, fullStart); + var node = createNode(191 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.declarationList = parseVariableDeclarationList(false); + node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(210 /* FunctionDeclaration */, fullStart); + var node = createNode(211 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(84 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + parseExpected(85 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(141 /* Constructor */, pos); + var node = createNode(142 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(118 /* ConstructorKeyword */); - fillSignature(52 /* ColonToken */, false, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); + parseExpected(119 /* ConstructorKeyword */); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(140 /* MethodDeclaration */, fullStart); + var method = createNode(141 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -10992,12 +11187,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512 /* Async */); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, method); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(138 /* PropertyDeclaration */, fullStart); + var property = createNode(139 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -11019,12 +11214,12 @@ var ts; return finishNode(property); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -11032,23 +11227,23 @@ var ts; } } function parseNonParameterInitializer() { - return parseInitializer(false); + return parseInitializer(/*inParameter*/ false); } function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(52 /* ColonToken */, false, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, false); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: return true; default: return false; @@ -11056,7 +11251,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 53 /* AtToken */) { + if (token === 54 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -11073,7 +11268,7 @@ var ts; } nextToken(); } - if (token === 36 /* AsteriskToken */) { + if (token === 37 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -11083,23 +11278,23 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token === 18 /* OpenBracketToken */) { + if (token === 19 /* OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 126 /* SetKeyword */ || idToken === 120 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 127 /* SetKeyword */ || idToken === 121 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token) { - case 16 /* OpenParenToken */: // Method declaration - case 24 /* LessThanToken */: // Generic Method declaration - case 52 /* ColonToken */: // Type Annotation for declaration - case 54 /* EqualsToken */: // Initializer for declaration - case 51 /* QuestionToken */: + case 17 /* OpenParenToken */: // Method declaration + case 25 /* LessThanToken */: // Generic Method declaration + case 53 /* ColonToken */: // Type Annotation for declaration + case 55 /* EqualsToken */: // Initializer for declaration + case 52 /* QuestionToken */: return true; default: // Covers @@ -11116,14 +11311,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(53 /* AtToken */)) { + if (!parseOptional(54 /* AtToken */)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(136 /* Decorator */, decoratorStart); + var decorator = createNode(137 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -11157,7 +11352,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 115 /* AsyncKeyword */) { + if (token === 116 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -11171,8 +11366,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token === 22 /* SemicolonToken */) { - var result = createNode(188 /* SemicolonClassElement */); + if (token === 23 /* SemicolonToken */) { + var result = createNode(189 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -11183,7 +11378,7 @@ var ts; if (accessor) { return accessor; } - if (token === 118 /* ConstructorKeyword */) { + if (token === 119 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -11191,17 +11386,17 @@ var ts; } // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name - if (isIdentifierOrKeyword() || - token === 8 /* StringLiteral */ || - token === 7 /* NumericLiteral */ || - token === 36 /* AsteriskToken */ || - token === 18 /* OpenBracketToken */) { + if (ts.tokenIsIdentifierOrKeyword(token) || + token === 9 /* StringLiteral */ || + token === 8 /* NumericLiteral */ || + token === 37 /* AsteriskToken */ || + token === 19 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_7 = createMissingNode(66 /* Identifier */, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); + var name_7 = createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. ts.Debug.fail("Should not have attempted to parse class member declaration."); @@ -11210,24 +11405,24 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 183 /* ClassExpression */); + /*modifiers*/ undefined, 184 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 211 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(70 /* ClassKeyword */); + parseExpected(71 /* ClassKeyword */); node.name = parseOptionalIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(14 /* OpenBraceToken */)) { + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); + if (parseExpected(15 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -11246,8 +11441,8 @@ var ts; return parseList(20 /* HeritageClauses */, parseHeritageClause); } function parseHeritageClause() { - if (token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */) { - var node = createNode(240 /* HeritageClause */); + if (token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */) { + var node = createNode(241 /* HeritageClause */); node.token = token; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -11256,38 +11451,38 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(185 /* ExpressionWithTypeArguments */); + var node = createNode(186 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (token === 25 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } return finishNode(node); } function isHeritageClause() { - return token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(212 /* InterfaceDeclaration */, fullStart); + var node = createNode(213 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(104 /* InterfaceKeyword */); + parseExpected(105 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(false); + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213 /* TypeAliasDeclaration */, fullStart); + var node = createNode(214 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(129 /* TypeKeyword */); + parseExpected(130 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -11297,20 +11492,20 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(244 /* EnumMember */, scanner.getStartPos()); + var node = createNode(245 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214 /* EnumDeclaration */, fullStart); + var node = createNode(215 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(78 /* EnumKeyword */); + parseExpected(79 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(14 /* OpenBraceToken */)) { + if (parseExpected(15 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -11318,10 +11513,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(216 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(14 /* OpenBraceToken */)) { + var node = createNode(217 /* ModuleBlock */, scanner.getStartPos()); + if (parseExpected(15 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -11329,84 +11524,87 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(215 /* ModuleDeclaration */, fullStart); + var node = createNode(216 /* ModuleDeclaration */, fullStart); + // If we are parsing a dotted namespace name, we want to + // propagate the 'Namespace' flag across the names if set. + var namespaceFlag = flags & 131072 /* Namespace */; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(20 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 /* Export */) + node.body = parseOptional(21 /* DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215 /* ModuleDeclaration */, fullStart); + var node = createNode(216 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.name = parseLiteralNode(true); + node.name = parseLiteralNode(/*internName*/ true); node.body = parseModuleBlock(); return finishNode(node); } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(123 /* NamespaceKeyword */)) { + if (parseOptional(124 /* NamespaceKeyword */)) { flags |= 131072 /* Namespace */; } else { - parseExpected(122 /* ModuleKeyword */); - if (token === 8 /* StringLiteral */) { + parseExpected(123 /* ModuleKeyword */); + if (token === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 124 /* RequireKeyword */ && + return token === 125 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 16 /* OpenParenToken */; + return nextToken() === 17 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 37 /* SlashToken */; + return nextToken() === 38 /* SlashToken */; } function nextTokenIsCommaOrFromKeyword() { nextToken(); - return token === 23 /* CommaToken */ || - token === 130 /* FromKeyword */; + return token === 24 /* CommaToken */ || + token === 131 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(86 /* ImportKeyword */); + parseExpected(87 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 /* CommaToken */ && token !== 130 /* FromKeyword */) { + if (token !== 24 /* CommaToken */ && token !== 131 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(218 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(219 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } // Import statement - var importDeclaration = createNode(219 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(220 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || - token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */) { + token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(130 /* FromKeyword */); + parseExpected(131 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -11419,7 +11617,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(220 /* ImportClause */, fullStart); + var importClause = createNode(221 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -11428,22 +11626,22 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(23 /* CommaToken */)) { - importClause.namedBindings = token === 36 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(222 /* NamedImports */); + parseOptional(24 /* CommaToken */)) { + importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(223 /* NamedImports */); } return finishNode(importClause); } function parseModuleReference() { return isExternalModuleReference() ? parseExternalModuleReference() - : parseEntityName(false); + : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(229 /* ExternalModuleReference */); - parseExpected(124 /* RequireKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(230 /* ExternalModuleReference */); + parseExpected(125 /* RequireKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { @@ -11453,7 +11651,7 @@ var ts; var result = parseExpression(); // Ensure the string being required is in our 'identifier' table. This will ensure // that features like 'find refs' will look inside this file when search for its name. - if (result.kind === 8 /* StringLiteral */) { + if (result.kind === 9 /* StringLiteral */) { internIdentifier(result.text); } return result; @@ -11461,9 +11659,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(221 /* NamespaceImport */); - parseExpected(36 /* AsteriskToken */); - parseExpected(113 /* AsKeyword */); + var namespaceImport = createNode(222 /* NamespaceImport */); + parseExpected(37 /* AsteriskToken */); + parseExpected(114 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -11476,14 +11674,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 222 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 223 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(227 /* ExportSpecifier */); + return parseImportOrExportSpecifier(228 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(223 /* ImportSpecifier */); + return parseImportOrExportSpecifier(224 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -11497,9 +11695,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(113 /* AsKeyword */); + parseExpected(114 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -11508,27 +11706,27 @@ var ts; else { node.name = identifierName; } - if (kind === 223 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 224 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225 /* ExportDeclaration */, fullStart); + var node = createNode(226 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(36 /* AsteriskToken */)) { - parseExpected(130 /* FromKeyword */); + if (parseOptional(37 /* AsteriskToken */)) { + parseExpected(131 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(226 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(227 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token === 130 /* FromKeyword */ || (token === 8 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(130 /* FromKeyword */); + if (token === 131 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(131 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -11536,21 +11734,21 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(224 /* ExportAssignment */, fullStart); + var node = createNode(225 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(54 /* EqualsToken */)) { + if (parseOptional(55 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(74 /* DefaultKeyword */); + parseExpected(75 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); return finishNode(node); } function processReferenceComments(sourceFile) { - var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, 0 /* Standard */, sourceText); + var triviaScanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, 0 /* Standard */, sourceText); var referencedFiles = []; var amdDependencies = []; var amdModuleName; @@ -11609,10 +11807,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 229 /* ExternalModuleReference */ - || node.kind === 219 /* ImportDeclaration */ - || node.kind === 224 /* ExportAssignment */ - || node.kind === 225 /* ExportDeclaration */ + || node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */ + || node.kind === 220 /* ImportDeclaration */ + || node.kind === 225 /* ExportAssignment */ + || node.kind === 226 /* ExportDeclaration */ ? node : undefined; }); @@ -11657,23 +11855,23 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token) { - case 36 /* AsteriskToken */: - case 51 /* QuestionToken */: - case 16 /* OpenParenToken */: - case 18 /* OpenBracketToken */: - case 47 /* ExclamationToken */: - case 14 /* OpenBraceToken */: - case 84 /* FunctionKeyword */: - case 21 /* DotDotDotToken */: - case 89 /* NewKeyword */: - case 94 /* ThisKeyword */: + case 37 /* AsteriskToken */: + case 52 /* QuestionToken */: + case 17 /* OpenParenToken */: + case 19 /* OpenBracketToken */: + case 48 /* ExclamationToken */: + case 15 /* OpenBraceToken */: + case 85 /* FunctionKeyword */: + case 22 /* DotDotDotToken */: + case 90 /* NewKeyword */: + case 95 /* ThisKeyword */: return true; } - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, undefined); + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); var jsDocTypeExpression = parseJSDocTypeExpression(start, length); var diagnostics = parseDiagnostics; clearState(); @@ -11687,23 +11885,23 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(246 /* JSDocTypeExpression */); - parseExpected(14 /* OpenBraceToken */); + var result = createNode(247 /* JSDocTypeExpression */); + parseExpected(15 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 45 /* BarToken */) { - var unionType = createNode(250 /* JSDocUnionType */, type.pos); + if (token === 46 /* BarToken */) { + var unionType = createNode(251 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 54 /* EqualsToken */) { - var optionalType = createNode(257 /* JSDocOptionalType */, type.pos); + if (token === 55 /* EqualsToken */) { + var optionalType = createNode(258 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -11713,21 +11911,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token === 18 /* OpenBracketToken */) { - var arrayType = createNode(249 /* JSDocArrayType */, type.pos); + if (token === 19 /* OpenBracketToken */) { + var arrayType = createNode(250 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token === 51 /* QuestionToken */) { - var nullableType = createNode(252 /* JSDocNullableType */, type.pos); + else if (token === 52 /* QuestionToken */) { + var nullableType = createNode(253 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 47 /* ExclamationToken */) { - var nonNullableType = createNode(253 /* JSDocNonNullableType */, type.pos); + else if (token === 48 /* ExclamationToken */) { + var nonNullableType = createNode(254 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -11740,85 +11938,85 @@ var ts; } function parseBasicTypeExpression() { switch (token) { - case 36 /* AsteriskToken */: + case 37 /* AsteriskToken */: return parseJSDocAllType(); - case 51 /* QuestionToken */: + case 52 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseJSDocUnionType(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseJSDocTupleType(); - case 47 /* ExclamationToken */: + case 48 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseJSDocRecordType(); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 21 /* DotDotDotToken */: + case 22 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: return parseJSDocConstructorType(); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return parseJSDocThisType(); - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(261 /* JSDocThisType */); + var result = createNode(262 /* JSDocThisType */); nextToken(); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(260 /* JSDocConstructorType */); + var result = createNode(261 /* JSDocConstructorType */); nextToken(); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(259 /* JSDocVariadicType */); + var result = createNode(260 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(258 /* JSDocFunctionType */); + var result = createNode(259 /* JSDocFunctionType */); nextToken(); - parseExpected(16 /* OpenParenToken */); + parseExpected(17 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(17 /* CloseParenToken */); - if (token === 52 /* ColonToken */) { + parseExpected(18 /* CloseParenToken */); + if (token === 53 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(135 /* Parameter */); + var parameter = createNode(136 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(257 /* JSDocOptionalType */, type.pos); + var result = createNode(258 /* JSDocOptionalType */, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(256 /* JSDocTypeReference */); + var result = createNode(257 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); - while (parseOptional(20 /* DotToken */)) { - if (token === 24 /* LessThanToken */) { + while (parseOptional(21 /* DotToken */)) { + if (token === 25 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); break; } @@ -11834,7 +12032,7 @@ var ts; var typeArguments = parseDelimitedList(23 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(26 /* GreaterThanToken */); + parseExpected(27 /* GreaterThanToken */); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -11845,40 +12043,40 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(132 /* QualifiedName */, left.pos); + var result = createNode(133 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(254 /* JSDocRecordType */); + var result = createNode(255 /* JSDocRecordType */); nextToken(); result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(255 /* JSDocRecordMember */); + var result = createNode(256 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); - if (token === 52 /* ColonToken */) { + if (token === 53 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(253 /* JSDocNonNullableType */); + var result = createNode(254 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(251 /* JSDocTupleType */); + var result = createNode(252 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(result); } function checkForTrailingComma(list) { @@ -11888,10 +12086,10 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(250 /* JSDocUnionType */); + var result = createNode(251 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(result); } function parseJSDocTypeList(firstType) { @@ -11899,14 +12097,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(45 /* BarToken */)) { + while (parseOptional(46 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(247 /* JSDocAllType */); + var result = createNode(248 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -11923,24 +12121,24 @@ var ts; // Foo // Foo(?= // (?| - if (token === 23 /* CommaToken */ || - token === 15 /* CloseBraceToken */ || - token === 17 /* CloseParenToken */ || - token === 26 /* GreaterThanToken */ || - token === 54 /* EqualsToken */ || - token === 45 /* BarToken */) { - var result = createNode(248 /* JSDocUnknownType */, pos); + if (token === 24 /* CommaToken */ || + token === 16 /* CloseBraceToken */ || + token === 18 /* CloseParenToken */ || + token === 27 /* GreaterThanToken */ || + token === 55 /* EqualsToken */ || + token === 46 /* BarToken */) { + var result = createNode(249 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(252 /* JSDocNullableType */, pos); + var result = createNode(253 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, undefined); - var jsDocComment = parseJSDocComment(undefined, start, length); + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); + var jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); var diagnostics = parseDiagnostics; clearState(); return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; @@ -12021,7 +12219,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(262 /* JSDocComment */, start); + var result = createNode(263 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -12032,7 +12230,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); - var atToken = createNode(53 /* AtToken */, pos - 1); + var atToken = createNode(54 /* AtToken */, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -12058,7 +12256,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(263 /* JSDocTag */, atToken.pos); + var result = createNode(264 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -12098,7 +12296,6 @@ var ts; } if (!name) { parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); - return undefined; } var preName, postName; if (typeExpression) { @@ -12110,7 +12307,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(264 /* JSDocParameterTag */, atToken.pos); + var result = createNode(265 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -12120,27 +12317,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 265 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(265 /* JSDocReturnTag */, atToken.pos); + var result = createNode(266 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(266 /* JSDocTypeTag */, atToken.pos); + var result = createNode(267 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -12153,7 +12350,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(134 /* TypeParameter */, name_8.pos); + var typeParameter = createNode(135 /* TypeParameter */, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -12164,7 +12361,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(267 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(268 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -12185,7 +12382,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(66 /* Identifier */, startPos); + var result = createNode(67 /* Identifier */, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -12205,7 +12402,7 @@ var ts; if (sourceFile.statements.length === 0) { // If we don't have any statements in the current source file, then there's no real // way to incrementally parse. So just do a full parse instead. - return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true); + return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setNodeParents*/ true); } // Make sure we're not trying to incrementally update a source file more than once. Once // we do an update the original source file is considered unusbale from that point onwards. @@ -12261,7 +12458,7 @@ var ts; // inconsistent tree. Setting the parents on the new tree should be very fast. We // will immediately bail out of walking any subtrees when we can see that their parents // are already correct. - var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true); + var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true); return result; } IncrementalParser.updateSourceFile = updateSourceFile; @@ -12274,7 +12471,7 @@ var ts; } return; function visitNode(node) { - var text = ''; + var text = ""; if (aggressiveChecks && shouldCheckNode(node)) { text = oldText.substring(node.pos, node.end); } @@ -12306,9 +12503,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: - case 66 /* Identifier */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 67 /* Identifier */: return true; } return false; @@ -12400,7 +12597,7 @@ var ts; if (child.pos > changeRangeOldEnd) { // Node is entirely past the change range. We need to move both its pos and // end, forward or backward appropriately. - moveElementEntirelyPastChangeRange(child, false, delta, oldText, newText, aggressiveChecks); + moveElementEntirelyPastChangeRange(child, /*isArray*/ false, delta, oldText, newText, aggressiveChecks); return; } // Check if the element intersects the change range. If it does, then it is not @@ -12424,7 +12621,7 @@ var ts; if (array.pos > changeRangeOldEnd) { // Array is entirely after the change range. We need to move it, and move any of // its children. - moveElementEntirelyPastChangeRange(array, true, delta, oldText, newText, aggressiveChecks); + moveElementEntirelyPastChangeRange(array, /*isArray*/ true, delta, oldText, newText, aggressiveChecks); return; } // Check if the element intersects the change range. If it does, then it is not @@ -12717,17 +12914,20 @@ var ts; isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, + // The language service will always care about the narrowed type of a symbol, because that is + // the type the language says the symbol should have. + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, + getBaseTypes: getBaseTypes, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeAtLocation, + getTypeAtLocation: getTypeOfNode, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -12744,7 +12944,8 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getJsxElementAttributesType: getJsxElementAttributesType, - getJsxIntrinsicTagNames: getJsxIntrinsicTagNames + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, + isOptionalParameter: isOptionalParameter }; var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); @@ -12752,16 +12953,19 @@ var ts; var stringType = createIntrinsicType(2 /* String */, "string"); var numberType = createIntrinsicType(4 /* Number */, "number"); var booleanType = createIntrinsicType(8 /* Boolean */, "boolean"); - var esSymbolType = createIntrinsicType(4194304 /* ESSymbol */, "symbol"); + var esSymbolType = createIntrinsicType(16777216 /* ESSymbol */, "symbol"); var voidType = createIntrinsicType(16 /* Void */, "void"); - var undefinedType = createIntrinsicType(32 /* Undefined */ | 1048576 /* ContainsUndefinedOrNull */, "undefined"); - var nullType = createIntrinsicType(64 /* Null */ | 1048576 /* ContainsUndefinedOrNull */, "null"); + var undefinedType = createIntrinsicType(32 /* Undefined */ | 2097152 /* ContainsUndefinedOrNull */, "undefined"); + var nullType = createIntrinsicType(64 /* Null */ | 2097152 /* ContainsUndefinedOrNull */, "null"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); var circularType = createIntrinsicType(1 /* Any */, "__circular__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated + // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. + anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); @@ -12806,6 +13010,7 @@ var ts; var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; + var resolutionPropertyNames = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -12827,7 +13032,7 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 4194304 /* ESSymbol */ + flags: 16777216 /* ESSymbol */ } }; var JsxNames = { @@ -12840,6 +13045,15 @@ var ts; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; + // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. + var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); initializeTypeChecker(); return checker; function getEmitResolver(sourceFile, cancellationToken) { @@ -12984,10 +13198,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 245 /* SourceFile */); + return ts.getAncestor(node, 246 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 245 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 246 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -13013,7 +13227,7 @@ var ts; if (file1 === file2) { return node1.pos <= node2.pos; } - if (!compilerOptions.out) { + if (!compilerOptions.outFile && !compilerOptions.out) { return true; } var sourceFiles = host.getSourceFiles(); @@ -13044,13 +13258,13 @@ var ts; } } switch (location.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 245 /* SourceFile */ || - (location.kind === 215 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { + if (location.kind === 246 /* SourceFile */ || + (location.kind === 216 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { // It's an external module. Because of module/namespace merging, a module's exports are in scope, // yet we never want to treat an export specifier as putting a member in scope. Therefore, // if the name we find is purely an export specifier, it is not actually considered in scope. @@ -13064,7 +13278,7 @@ var ts; // which is not the desired behavior. if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 227 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 228 /* ExportSpecifier */)) { break; } result = moduleExports["default"]; @@ -13078,13 +13292,13 @@ var ts; break loop; } break; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -13101,9 +13315,9 @@ var ts; } } break; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -13114,7 +13328,7 @@ var ts; } break loop; } - if (location.kind === 183 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 184 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -13130,9 +13344,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 212 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 213 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -13140,19 +13354,19 @@ var ts; } } break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 170 /* FunctionExpression */: + case 171 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -13165,7 +13379,7 @@ var ts; } } break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -13174,7 +13388,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 135 /* Parameter */) { + if (location.parent && location.parent.kind === 136 /* Parameter */) { location = location.parent; } // @@ -13209,7 +13423,18 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (result.flags & 2 /* BlockScopedVariable */) { + // Only check for block-scoped variable if we are looking for the + // name with variable meaning + // For example, + // declare module foo { + // interface bar {} + // } + // let foo/*1*/: foo/*2*/.bar; + // The foo at /*1*/ and /*2*/ will share same symbol with two meaning + // block - scope variable and namespace module. However, only when we + // try to resolve name in /*1*/ which is used in variable position, + // we want to check for block- scoped + if (meaning & 2 /* BlockScopedVariable */ && result.flags & 2 /* BlockScopedVariable */) { checkResolvedBlockScopedVariable(result, errorLocation); } } @@ -13230,16 +13455,16 @@ var ts; // for (let x in x) // for (let x of x) // climb up to the variable declaration skipping binding patterns - var variableDeclaration = ts.getAncestor(declaration, 208 /* VariableDeclaration */); + var variableDeclaration = ts.getAncestor(declaration, 209 /* VariableDeclaration */); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 190 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 196 /* ForStatement */) { + if (variableDeclaration.parent.parent.kind === 191 /* VariableStatement */ || + variableDeclaration.parent.parent.kind === 197 /* ForStatement */) { // variable statement/for statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 198 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 197 /* ForInStatement */) { + else if (variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */ || + variableDeclaration.parent.parent.kind === 198 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); @@ -13266,10 +13491,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 219 /* ImportDeclaration */) { + while (node && node.kind !== 220 /* ImportDeclaration */) { node = node.parent; } return node; @@ -13279,7 +13504,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 229 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 230 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -13386,17 +13611,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return getTargetOfImportClause(node); - case 221 /* NamespaceImport */: + case 222 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 223 /* ImportSpecifier */: + case 224 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 227 /* ExportSpecifier */: + case 228 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -13441,11 +13666,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 224 /* ExportAssignment */) { + if (node.kind === 225 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 227 /* ExportSpecifier */) { + else if (node.kind === 228 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -13458,7 +13683,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 218 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 219 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -13467,17 +13692,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 66 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 67 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 66 /* Identifier */ || entityName.parent.kind === 132 /* QualifiedName */) { + if (entityName.kind === 67 /* Identifier */ || entityName.parent.kind === 133 /* QualifiedName */) { return resolveEntityName(entityName, 1536 /* Namespace */); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 218 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 219 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -13490,16 +13715,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 132 /* QualifiedName */ || name.kind === 163 /* PropertyAccessExpression */) { - var left = name.kind === 132 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 132 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 133 /* QualifiedName */ || name.kind === 164 /* PropertyAccessExpression */) { + var left = name.kind === 133 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 133 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -13524,7 +13749,7 @@ var ts; return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; } function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 8 /* StringLiteral */) { + if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { return; } var moduleReferenceLiteral = moduleReferenceExpression; @@ -13532,29 +13757,18 @@ var ts; // Module names are escaped in our symbol table. However, string literal values aren't. // Escape the name in the "require(...)" clause to ensure we find the right symbol. var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) + if (moduleName === undefined) { return; + } var isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); if (symbol) { return symbol; } } - var fileName; - var sourceFile; - while (true) { - fileName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - sourceFile = ts.forEach(ts.supportedExtensions, function (extension) { return host.getSourceFile(fileName + extension); }); - if (sourceFile || isRelative) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } + var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); + var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { return sourceFile.symbol; @@ -13662,7 +13876,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 141 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 142 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -13732,17 +13946,17 @@ var ts; } } switch (location_1.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location_1)) { break; } - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -13783,7 +13997,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -13820,7 +14034,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -13836,7 +14050,7 @@ var ts; var meaningToLook = meaning; while (symbol) { // Symbol is accessible if it by itself is accessible - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, false); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false); if (accessibleSymbolChain) { var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); if (!hasAccessibleDeclarations) { @@ -13893,8 +14107,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 215 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || - (declaration.kind === 245 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 216 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || + (declaration.kind === 246 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -13930,12 +14144,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 151 /* TypeQuery */) { + if (entityName.parent.kind === 152 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 132 /* QualifiedName */ || entityName.kind === 163 /* PropertyAccessExpression */ || - entityName.parent.kind === 218 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 133 /* QualifiedName */ || entityName.kind === 164 /* PropertyAccessExpression */ || + entityName.parent.kind === 219 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -13945,7 +14159,7 @@ var ts; meaning = 793056 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); - var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined); + var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol)) || { accessibility: 1 /* NotAccessible */, @@ -13990,17 +14204,15 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 157 /* ParenthesizedType */) { + while (node.kind === 158 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 214 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } return undefined; } - // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. - var _displayBuilder; function getSymbolDisplayBuilder() { function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { @@ -14009,10 +14221,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return "(Anonymous class)"; - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -14042,7 +14254,7 @@ var ts; buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 20 /* DotToken */); + writePunctuation(writer, 21 /* DotToken */); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -14098,7 +14310,7 @@ var ts; return writeType(type, globalFlags); function writeType(type, flags) { // Write undefined/null type as any - if (type.flags & 4194431 /* Intrinsic */) { + if (type.flags & 16777343 /* Intrinsic */) { // Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving writer.writeKeyword(!(globalFlags & 16 /* WriteOwnNameForAnyLike */) && isTypeAny(type) ? "any" @@ -14126,23 +14338,23 @@ var ts; else { // Should never get here // { ... } - writePunctuation(writer, 14 /* OpenBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); writeSpace(writer); - writePunctuation(writer, 21 /* DotDotDotToken */); + writePunctuation(writer, 22 /* DotDotDotToken */); writeSpace(writer); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 23 /* CommaToken */) { + if (delimiter !== 24 /* CommaToken */) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 23 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); + writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end) { @@ -14152,22 +14364,22 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */); } if (pos < end) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); writeType(typeArguments[pos++], 0 /* None */); while (pos < end) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); writeType(typeArguments[pos++], 0 /* None */); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments; if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 18 /* OpenBracketToken */); - writePunctuation(writer, 19 /* CloseBracketToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writePunctuation(writer, 20 /* CloseBracketToken */); } else { // Write the type reference in the format f.g.C where A and B are type arguments @@ -14188,7 +14400,7 @@ var ts; // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_3, typeArguments, start, i); - writePunctuation(writer, 20 /* DotToken */); + writePunctuation(writer, 21 /* DotToken */); } } } @@ -14196,17 +14408,17 @@ var ts; } } function writeTupleType(type) { - writePunctuation(writer, 18 /* OpenBracketToken */); - writeTypeList(type.elementTypes, 23 /* CommaToken */); - writePunctuation(writer, 19 /* CloseBracketToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writeTypeList(type.elementTypes, 24 /* CommaToken */); + writePunctuation(writer, 20 /* CloseBracketToken */); } function writeUnionOrIntersectionType(type, flags) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } - writeTypeList(type.types, type.flags & 16384 /* Union */ ? 45 /* BarToken */ : 44 /* AmpersandToken */); + writeTypeList(type.types, type.flags & 16384 /* Union */ ? 46 /* BarToken */ : 45 /* AmpersandToken */); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } } function writeAnonymousType(type, flags) { @@ -14228,7 +14440,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 114 /* AnyKeyword */); + writeKeyword(writer, 115 /* AnyKeyword */); } } else { @@ -14252,7 +14464,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 245 /* SourceFile */ || declaration.parent.kind === 216 /* ModuleBlock */; + return declaration.parent.kind === 246 /* SourceFile */ || declaration.parent.kind === 217 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -14262,7 +14474,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 98 /* TypeOfKeyword */); + writeKeyword(writer, 99 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } @@ -14280,76 +14492,76 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 14 /* OpenBraceToken */); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } - writeKeyword(writer, 89 /* NewKeyword */); + writeKeyword(writer, 90 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } return; } } - writePunctuation(writer, 14 /* OpenBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 89 /* NewKeyword */); + writeKeyword(writer, 90 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } if (resolved.stringIndexType) { // [x: string]: - writePunctuation(writer, 18 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x")); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 127 /* StringKeyword */); - writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 52 /* ColonToken */); + writeKeyword(writer, 128 /* StringKeyword */); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } if (resolved.numberIndexType) { // [x: number]: - writePunctuation(writer, 18 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x")); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 125 /* NumberKeyword */); - writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 52 /* ColonToken */); + writeKeyword(writer, 126 /* NumberKeyword */); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(resolved.numberIndexType, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { @@ -14361,32 +14573,32 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } } else { buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */) { + if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */ || targetSymbol.flags & 524288 /* TypeAlias */) { buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } @@ -14395,7 +14607,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 80 /* ExtendsKeyword */); + writeKeyword(writer, 81 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -14403,67 +14615,67 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 21 /* DotDotDotToken */); + writePunctuation(writer, 22 /* DotDotDotToken */); } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); for (var i = 0; i < parameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 33 /* EqualsGreaterThanToken */); + writePunctuation(writer, 34 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 121 /* IsKeyword */); + writeKeyword(writer, 122 /* IsKeyword */); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -14485,15 +14697,12 @@ var ts; buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { - symbolToString: symbolToString, - typeToString: typeToString, buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildDisplayForTypeArgumentsAndDelimiters: buildDisplayForTypeArgumentsAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay @@ -14502,12 +14711,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 215 /* ModuleDeclaration */) { - if (node.name.kind === 8 /* StringLiteral */) { + if (node.kind === 216 /* ModuleDeclaration */) { + if (node.name.kind === 9 /* StringLiteral */) { return node; } } - else if (node.kind === 245 /* SourceFile */) { + else if (node.kind === 246 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -14556,70 +14765,70 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 160 /* BindingElement */: + case 161 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 210 /* FunctionDeclaration */: - case 214 /* EnumDeclaration */: - case 218 /* ImportEqualsDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 211 /* FunctionDeclaration */: + case 215 /* EnumDeclaration */: + case 219 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 218 /* ImportEqualsDeclaration */ && parent_4.kind !== 245 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 219 /* ImportEqualsDeclaration */ && parent_4.kind !== 246 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 141 /* Constructor */: - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 146 /* IndexSignature */: - case 135 /* Parameter */: - case 216 /* ModuleBlock */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 152 /* TypeLiteral */: - case 148 /* TypeReference */: - case 153 /* ArrayType */: - case 154 /* TupleType */: - case 155 /* UnionType */: - case 156 /* IntersectionType */: - case 157 /* ParenthesizedType */: + case 142 /* Constructor */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 147 /* IndexSignature */: + case 136 /* Parameter */: + case 217 /* ModuleBlock */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 153 /* TypeLiteral */: + case 149 /* TypeReference */: + case 154 /* ArrayType */: + case 155 /* TupleType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: + case 158 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: return false; // Type parameters are always visible - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: // Source file is always visible - case 245 /* SourceFile */: + case 246 /* SourceFile */: return true; // Export assignements do not create name bindings outside the module - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -14635,11 +14844,14 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 224 /* ExportAssignment */) { - exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, node); + if (node.parent && node.parent.kind === 225 /* ExportAssignment */) { + exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 227 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent); + else if (node.parent.kind === 228 /* ExportSpecifier */) { + var exportSpecifier = node.parent; + exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } var result = []; if (exportSymbol) { @@ -14663,40 +14875,71 @@ var ts; }); } } - // Push an entry on the type resolution stack. If an entry with the given target is not already on the stack, - // a new entry with that target and an associated result value of true is pushed on the stack, and the value - // true is returned. Otherwise, a circularity has occurred and the result values of the existing entry and - // all entries pushed after it are changed to false, and the value false is returned. The target object provides - // a unique identity for a particular type resolution result: Symbol instances are used to track resolution of - // SymbolLinks.type, SymbolLinks instances are used to track resolution of SymbolLinks.declaredType, and - // Signature instances are used to track resolution of Signature.resolvedReturnType. - function pushTypeResolution(target) { - var i = 0; - var count = resolutionTargets.length; - while (i < count && resolutionTargets[i] !== target) { - i++; - } - if (i < count) { - do { - resolutionResults[i++] = false; - } while (i < count); + /** + * Push an entry on the type resolution stack. If an entry with the given target and the given property name + * is already on the stack, and no entries in between already have a type, then a circularity has occurred. + * In this case, the result values of the existing entry and all entries pushed after it are changed to false, + * and the value false is returned. Otherwise, the new entry is just pushed onto the stack, and true is returned. + * In order to see if the same query has already been done before, the target object and the propertyName both + * must match the one passed in. + * + * @param target The symbol, type, or signature whose type is being queried + * @param propertyName The property name that should be used to query the target for its type + */ + function pushTypeResolution(target, propertyName) { + var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + // A cycle was found + var length_2 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_2; i++) { + resolutionResults[i] = false; + } return false; } resolutionTargets.push(target); resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); return true; } + function findResolutionCycleStartIndex(target, propertyName) { + for (var i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + return -1; + } + function hasType(target, propertyName) { + if (propertyName === 0 /* Type */) { + return getSymbolLinks(target).type; + } + if (propertyName === 2 /* DeclaredType */) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === 1 /* ResolvedBaseConstructorType */) { + ts.Debug.assert(!!(target.flags & 1024 /* Class */)); + return target.resolvedBaseConstructorType; + } + if (propertyName === 3 /* ResolvedReturnType */) { + return target.resolvedReturnType; + } + ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } // Pop an entry from the type resolution stack and return its associated result value. The result value will // be true if no circularities were detected, or false if a circularity was found. function popTypeResolution() { resolutionTargets.pop(); + resolutionPropertyNames.pop(); return resolutionResults.pop(); } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 208 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 209 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -14732,7 +14975,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 158 /* ObjectBindingPattern */) { + if (pattern.kind === 159 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_10 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, @@ -14749,11 +14992,8 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); + var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false); if (!declaration.dotDotDotToken) { - if (isTypeAny(elementType)) { - return elementType; - } // Use specific property type when parent is a tuple or numeric index type when parent is an array var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) @@ -14779,10 +15019,10 @@ var ts; // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 197 /* ForInStatement */) { + if (declaration.parent.parent.kind === 198 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 198 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 199 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -14796,11 +15036,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135 /* Parameter */) { + if (declaration.kind === 136 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 143 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 142 /* GetAccessor */); + if (func.kind === 144 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -14816,54 +15056,58 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 243 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 244 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } + // If the declaration specifies a binding pattern, use the type implied by the binding pattern + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false); + } // No type specified and nothing can be inferred return undefined; } // Return the type implied by a binding pattern element. This is the type of the initializer of the element if // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding // pattern. Otherwise, it is the type any. - function getTypeFromBindingElement(element) { + function getTypeFromBindingElement(element, includePatternInType) { if (element.initializer) { return getWidenedType(checkExpressionCached(element.initializer)); } if (ts.isBindingPattern(element.name)) { - return getTypeFromBindingPattern(element.name); + return getTypeFromBindingPattern(element.name, includePatternInType); } return anyType; } // Return the type implied by an object binding pattern - function getTypeFromObjectBindingPattern(pattern) { + function getTypeFromObjectBindingPattern(pattern, includePatternInType) { var members = {}; ts.forEach(pattern.elements, function (e) { var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0); var name = e.propertyName || e.name; var symbol = createSymbol(flags, name.text); - symbol.type = getTypeFromBindingElement(e); + symbol.type = getTypeFromBindingElement(e, includePatternInType); + symbol.bindingElement = e; members[symbol.name] = symbol; }); - return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + if (includePatternInType) { + result.pattern = pattern; + } + return result; } // Return the type implied by an array binding pattern - function getTypeFromArrayBindingPattern(pattern) { - var hasSpreadElement = false; - var elementTypes = []; - ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 184 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); - if (e.dotDotDotToken) { - hasSpreadElement = true; - } - }); - if (!elementTypes.length) { + function getTypeFromArrayBindingPattern(pattern, includePatternInType) { + var elements = pattern.elements; + if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; } - else if (hasSpreadElement) { - var unionOfElements = getUnionType(elementTypes); - return languageVersion >= 2 /* ES6 */ ? createIterableType(unionOfElements) : createArrayType(unionOfElements); - } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. + var elementTypes = ts.map(elements, function (e) { return e.kind === 185 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + if (includePatternInType) { + var result = createNewTupleType(elementTypes); + result.pattern = pattern; + return result; + } return createTupleType(elementTypes); } // Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself @@ -14873,10 +15117,10 @@ var ts; // used as the contextual type of an initializer associated with the binding pattern. Also, for a destructuring // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. - function getTypeFromBindingPattern(pattern) { - return pattern.kind === 158 /* ObjectBindingPattern */ - ? getTypeFromObjectBindingPattern(pattern) - : getTypeFromArrayBindingPattern(pattern); + function getTypeFromBindingPattern(pattern, includePatternInType) { + return pattern.kind === 159 /* ObjectBindingPattern */ + ? getTypeFromObjectBindingPattern(pattern, includePatternInType) + : getTypeFromArrayBindingPattern(pattern, includePatternInType); } // Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type // specified in a type annotation or inferred from an initializer. However, in the case of a destructuring declaration it @@ -14896,19 +15140,14 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - return declaration.kind !== 242 /* PropertyAssignment */ ? getWidenedType(type) : type; - } - // If no type was specified and nothing could be inferred, and if the declaration specifies a binding pattern, use - // the type implied by the binding pattern - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return declaration.kind !== 243 /* PropertyAssignment */ ? getWidenedType(type) : type; } // Rest parameters default to type any[], other parameters default to type any type = declaration.dotDotDotToken ? anyArrayType : anyType; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 135 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 136 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -14923,18 +15162,18 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 241 /* CatchClause */) { + if (declaration.parent.kind === 242 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 224 /* ExportAssignment */) { + if (declaration.kind === 225 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); + var type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); if (!popTypeResolution()) { if (symbol.valueDeclaration.type) { // Variable has type annotation that circularly references the variable itself @@ -14955,7 +15194,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 142 /* GetAccessor */) { + if (accessor.kind === 143 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -14968,11 +15207,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 142 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 143 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 144 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -15001,7 +15240,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 142 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -15101,9 +15340,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 211 /* ClassDeclaration */ || node.kind === 183 /* ClassExpression */ || - node.kind === 210 /* FunctionDeclaration */ || node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */ || node.kind === 171 /* ArrowFunction */) { + if (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */ || + node.kind === 211 /* FunctionDeclaration */ || node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */ || node.kind === 172 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -15113,7 +15352,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 212 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -15122,8 +15361,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 212 /* InterfaceDeclaration */ || node.kind === 211 /* ClassDeclaration */ || - node.kind === 183 /* ClassExpression */ || node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 212 /* ClassDeclaration */ || + node.kind === 184 /* ClassExpression */ || node.kind === 214 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -15166,7 +15405,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type)) { + if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -15234,7 +15473,7 @@ var ts; return; } if (type === baseType || hasBaseType(baseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); return; } type.resolvedBaseTypes = [baseType]; @@ -15243,7 +15482,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 212 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 213 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -15253,7 +15492,7 @@ var ts; type.resolvedBaseTypes.push(baseType); } else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); + error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); } } else { @@ -15289,10 +15528,10 @@ var ts; if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(links)) { + if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 213 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 214 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -15325,7 +15564,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -15487,48 +15726,75 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); + var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noSubtypeReduction*/ true))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } - function signatureListsIdentical(s, t) { - if (s.length !== t.length) { - return false; - } - for (var i = 0; i < s.length; i++) { - if (!compareSignatures(s[i], t[i], false, compareTypes)) { - return false; + function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { + for (var _i = 0; _i < signatureList.length; _i++) { + var s = signatureList[_i]; + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { + return s; } } - return true; } - // If the lists of call or construct signatures in the given types are all identical except for return types, - // and if none of the signatures are generic, return a list of signatures that has substitutes a union of the - // return types of the corresponding signatures in each resulting signature. - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var signatures = signatureLists[0]; - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; - if (signature.typeParameters) { - return emptyArray; + function findMatchingSignatures(signatureLists, signature, listIndex) { + if (signature.typeParameters) { + // We require an exact match for generic signatures, so we only return signatures from the first + // signature list and only if they have exact matches in the other signature lists. + if (listIndex > 0) { + return undefined; } - } - for (var i_1 = 1; i_1 < signatureLists.length; i_1++) { - if (!signatureListsIdentical(signatures, signatureLists[i_1])) { - return emptyArray; + for (var i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ false)) { + return undefined; + } } + return [signature]; } - var result = ts.map(signatures, cloneSignature); - for (var i = 0; i < result.length; i++) { - var s = result[i]; - // Clear resolved return type we possibly got from cloneSignature - s.resolvedReturnType = undefined; - s.unionSignatures = ts.map(signatureLists, function (signatures) { return signatures[i]; }); + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + // Allow matching non-generic signatures to have excess parameters and different return types + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreReturnTypes*/ true); + if (!match) { + return undefined; + } + if (!ts.contains(result, match)) { + (result || (result = [])).push(match); + } } return result; } + // The signatures of a union type are those signatures that are present in each of the constituent types. + // Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional + // parameters and may differ in return types. When signatures differ in return types, the resulting return + // type is the union of the constituent return types. + function getUnionSignatures(types, kind) { + var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { + var signature = _a[_i]; + // Only process signatures with parameter lists that aren't already in the result list + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true)) { + var unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + var s = signature; + // Union the result types when more than one signature matches + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + // Clear resolved return type we possibly got from cloneSignature + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } + } + } + } + return result || emptyArray; + } function getUnionIndexType(types, kind) { var indexTypes = []; for (var _i = 0; _i < types.length; _i++) { @@ -15679,9 +15945,6 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - if (type.flags & 16384 /* Union */) { - type = getReducedTypeOfUnionType(type); - } if (type.flags & 512 /* TypeParameter */) { do { type = getConstraintOfTypeParameter(type); @@ -15699,7 +15962,7 @@ var ts; else if (type.flags & 8 /* Boolean */) { type = globalBooleanType; } - else if (type.flags & 4194304 /* ESSymbol */) { + else if (type.flags & 16777216 /* ESSymbol */) { type = globalESSymbolType; } return type; @@ -15791,8 +16054,10 @@ var ts; } return emptyArray; } - // Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and - // maps primitive types and type parameters are to their apparent types. + /** + * Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and + * maps primitive types and type parameters are to their apparent types. + */ function getSignaturesOfType(type, kind) { return getSignaturesOfStructuredType(getApparentType(type), kind); } @@ -15845,12 +16110,22 @@ var ts; return result; } function isOptionalParameter(node) { - return ts.hasQuestionToken(node) || !!node.initializer; + if (ts.hasQuestionToken(node)) { + return true; + } + if (node.initializer) { + var signatureDeclaration = node.parent; + var signature = getSignatureFromDeclaration(signatureDeclaration); + var parameterIndex = signatureDeclaration.parameters.indexOf(node); + ts.Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + return false; } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 141 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 142 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -15859,14 +16134,18 @@ var ts; for (var i = 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; parameters.push(param.symbol); - if (param.type && param.type.kind === 8 /* StringLiteral */) { + if (param.type && param.type.kind === 9 /* StringLiteral */) { hasStringLiterals = true; } - if (minArgumentCount < 0) { - if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { minArgumentCount = i; } } + else { + // If we see any required parameters, it means the prior ones were not in fact optional. + minArgumentCount = -1; + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length; @@ -15878,7 +16157,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 147 /* TypePredicate */) { + if (declaration.type.kind === 148 /* TypePredicate */) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -15890,8 +16169,8 @@ var ts; else { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 142 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 143 /* SetAccessor */); + if (declaration.kind === 143 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 144 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -15909,19 +16188,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -15938,7 +16217,7 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { return unknownType; } var type; @@ -15998,7 +16277,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 141 /* Constructor */ || signature.declaration.kind === 145 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 142 /* Constructor */ || signature.declaration.kind === 146 /* ConstructSignature */; var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -16012,7 +16291,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 125 /* NumberKeyword */ : 127 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 126 /* NumberKeyword */ : 128 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -16041,13 +16320,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 134 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 134 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135 /* TypeParameter */).parent); } function getTypeListId(types) { switch (types.length) { @@ -16066,22 +16345,23 @@ var ts; return result; } } - // This function is used to propagate widening flags when creating new object types references and union types. - // It is only necessary to do so if a constituent type might be the undefined type, the null type, or the type - // of an object literal (since those types have widening related information we need to track). - function getWideningFlagsOfTypes(types) { + // This function is used to propagate certain flags when creating new object type references and union types. + // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type + // of an object literal or the anyFunctionType. This is because there are operations in the type checker + // that care about the presence of such types at arbitrary depth in a containing type. + function getPropagatingFlagsOfTypes(types) { var result = 0; for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; result |= type.flags; } - return result & 3145728 /* RequiresWidening */; + return result & 14680064 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 /* Reference */ | getWideningFlagsOfTypes(typeArguments); + var flags = 4096 /* Reference */ | getPropagatingFlagsOfTypes(typeArguments); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -16100,16 +16380,16 @@ var ts; currentNode = currentNode.parent; } // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 134 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 148 /* TypeReference */ && n.typeName.kind === 66 /* Identifier */) { + if (n.kind === 149 /* TypeReference */ && n.typeName.kind === 67 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { - var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, undefined, undefined); + var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); if (symbol && (symbol.flags & 262144 /* TypeParameter */)) { // TypeScript 1.0 spec (April 2014): 3.4.1 // Type parameters declared in a particular type parameter list @@ -16138,7 +16418,7 @@ var ts; var typeParameters = type.localTypeParameters; if (typeParameters) { if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); return unknownType; } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -16193,7 +16473,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 148 /* TypeReference */ ? node.typeName : + var typeNameOrExpression = node.kind === 149 /* TypeReference */ ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; @@ -16225,9 +16505,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: return declaration; } } @@ -16261,14 +16541,14 @@ var ts; } function tryGetGlobalType(name, arity) { if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, undefined), arity); + return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, /*diagnostic*/ undefined), arity); } /** * Returns a type that is inside a namespace at the global scope, e.g. * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type */ function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, undefined); + var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } @@ -16280,7 +16560,7 @@ var ts; */ function createTypedPropertyDescriptorType(propertyType) { var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyObjectType + return globalTypedPropertyDescriptorType !== emptyGenericType ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } @@ -16308,11 +16588,11 @@ var ts; } function createTupleType(elementTypes) { var id = getTypeListId(elementTypes); - var type = tupleTypes[id]; - if (!type) { - type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getWideningFlagsOfTypes(elementTypes)); - type.elementTypes = elementTypes; - } + return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); + } + function createNewTupleType(elementTypes) { + var type = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes)); + type.elementTypes = elementTypes; return type; } function getTypeFromTupleTypeNode(node) { @@ -16339,9 +16619,8 @@ var ts; } } function isSubtypeOfAny(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - if (candidate !== type && isTypeSubtypeOf(candidate, type)) { + for (var i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { return true; } } @@ -16374,24 +16653,23 @@ var ts; } } } - function compareTypeIds(type1, type2) { - return type1.id - type2.id; - } - // The noSubtypeReduction flag is there because it isn't possible to always do subtype reduction. The flag - // is true when creating a union type from a type node and when instantiating a union type. In both of those - // cases subtype reduction has to be deferred to properly support recursive union types. For example, a - // type alias of the form "type Item = string | (() => Item)" cannot be reduced during its declaration. + // We reduce the constituent type set to only include types that aren't subtypes of other types, unless + // the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on + // object identity. Subtype reduction is possible only when union types are known not to circularly + // reference themselves (as is the case with union types created by expression constructs such as array + // literals and the || and ?: operators). Named types can circularly reference themselves and therefore + // cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is + // a named type that circularly references itself. function getUnionType(types, noSubtypeReduction) { if (types.length === 0) { return emptyObjectType; } var typeSet = []; addTypesToSet(typeSet, types, 16384 /* Union */); - typeSet.sort(compareTypeIds); + if (containsTypeAny(typeSet)) { + return anyType; + } if (noSubtypeReduction) { - if (containsTypeAny(typeSet)) { - return anyType; - } removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } @@ -16404,37 +16682,19 @@ var ts; var id = getTypeListId(typeSet); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 /* Union */ | getWideningFlagsOfTypes(typeSet)); + type = unionTypes[id] = createObjectType(16384 /* Union */ | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; - type.reducedType = noSubtypeReduction ? undefined : type; } return type; } - // Subtype reduction is basically an optimization we do to avoid excessively large union types, which take longer - // to process and look strange in quick info and error messages. Semantically there is no difference between the - // reduced type and the type itself. So, when we detect a circularity we simply say that the reduced type is the - // type itself. - function getReducedTypeOfUnionType(type) { - if (!type.reducedType) { - type.reducedType = circularType; - var reducedType = getUnionType(type.types, false); - if (type.reducedType === circularType) { - type.reducedType = reducedType; - } - } - else if (type.reducedType === circularType) { - type.reducedType = type; - } - return type.reducedType; - } function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), true); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true); } return links.resolvedType; } - // We do not perform supertype reduction on intersection types. Intersection types are created only by the & + // We do not perform structural deduplication on intersection types. Intersection types are created only by the & // type operator and we can't reduce those because we want to support recursive intersection types. For example, // a type alias of the form "type List = T & { next: List }" cannot be reduced during its declaration. // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution @@ -16454,7 +16714,7 @@ var ts; var id = getTypeListId(typeSet); var type = intersectionTypes[id]; if (!type) { - type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getWideningFlagsOfTypes(typeSet)); + type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; } return type; @@ -16491,47 +16751,47 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 114 /* AnyKeyword */: + case 115 /* AnyKeyword */: return anyType; - case 127 /* StringKeyword */: + case 128 /* StringKeyword */: return stringType; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: return numberType; - case 117 /* BooleanKeyword */: + case 118 /* BooleanKeyword */: return booleanType; - case 128 /* SymbolKeyword */: + case 129 /* SymbolKeyword */: return esSymbolType; - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return voidType; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return getTypeFromTypeReference(node); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return booleanType; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 154 /* TupleType */: + case 155 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 155 /* UnionType */: + case 156 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 156 /* IntersectionType */: + case 157 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 152 /* TypeLiteral */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 153 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 66 /* Identifier */: - case 132 /* QualifiedName */: - var symbol = getSymbolInfo(node); + case 67 /* Identifier */: + case 133 /* QualifiedName */: + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: return unknownType; @@ -16590,7 +16850,7 @@ var ts; }; } function createInferenceMapper(context) { - return function (t) { + var mapper = function (t) { for (var i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { context.inferences[i].isFixed = true; @@ -16599,6 +16859,8 @@ var ts; } return t; }; + mapper.context = context; + return mapper; } function identityMapper(type) { return type; @@ -16659,6 +16921,15 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { + if (mapper.instantiations) { + var cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol); result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); @@ -16671,6 +16942,7 @@ var ts; result.stringIndexType = instantiateType(stringIndexType, mapper); if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper); + mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { @@ -16689,7 +16961,7 @@ var ts; return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); } if (type.flags & 16384 /* Union */) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), true); + return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noSubtypeReduction*/ true); } if (type.flags & 32768 /* Intersection */) { return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); @@ -16700,27 +16972,27 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 178 /* BinaryExpression */: - return node.operatorToken.kind === 50 /* BarBarToken */ && + case 179 /* BinaryExpression */: + return node.operatorToken.kind === 51 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -16744,16 +17016,16 @@ var ts; } // TYPE CHECKING function isTypeIdenticalTo(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined); + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined); } function compareTypes(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined) ? -1 /* True */ : 0 /* False */; + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? -1 /* True */ : 0 /* False */; } function isTypeSubtypeOf(source, target) { - return checkTypeSubtypeOf(source, target, undefined); + return checkTypeSubtypeOf(source, target, /*errorNode*/ undefined); } function isTypeAssignableTo(source, target) { - return checkTypeAssignableTo(source, target, undefined); + return checkTypeAssignableTo(source, target, /*errorNode*/ undefined); } function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); @@ -16764,7 +17036,7 @@ var ts; function isSignatureAssignableTo(source, target) { var sourceType = getOrCreateTypeFromSignature(source); var targetType = getOrCreateTypeFromSignature(target); - return checkTypeRelatedTo(sourceType, targetType, assignableRelation, undefined); + return checkTypeRelatedTo(sourceType, targetType, assignableRelation, /*errorNode*/ undefined); } /** * Checks if 'source' is related to 'target' (e.g.: is a assignable to). @@ -16772,7 +17044,7 @@ var ts; * @param target The right-hand-side of the relation. * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. * Used as both to determine which checks are performed and as a cache of previously computed results. - * @param errorNode The node upon which all errors will be reported, if defined. + * @param errorNode The suggested node upon which all errors will be reported, if defined. This may or may not be the actual node used. * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. * @param containingMessageChain A chain of errors to prepend any new errors found. */ @@ -16809,6 +17081,15 @@ var ts; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } + function reportRelationError(message, source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); + targetType = typeToString(target, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); + } + reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } // Compare two types and return // Ternary.True if they are related with no assumptions, // Ternary.Maybe if they are related with assumptions of other relationships, or @@ -16818,110 +17099,170 @@ var ts; // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return -1 /* True */; - if (relation !== identityRelation) { - if (isTypeAny(target)) + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + if (isTypeAny(target)) + return -1 /* True */; + if (source === undefinedType) + return -1 /* True */; + if (source === nullType && target !== undefinedType) + return -1 /* True */; + if (source.flags & 128 /* Enum */ && target === numberType) + return -1 /* True */; + if (source.flags & 256 /* StringLiteral */ && target === stringType) + return -1 /* True */; + if (relation === assignableRelation) { + if (isTypeAny(source)) return -1 /* True */; - if (source === undefinedType) + if (source === numberType && target.flags & 128 /* Enum */) return -1 /* True */; - if (source === nullType && target !== undefinedType) - return -1 /* True */; - if (source.flags & 128 /* Enum */ && target === numberType) - return -1 /* True */; - if (source.flags & 256 /* StringLiteral */ && target === stringType) - return -1 /* True */; - if (relation === assignableRelation) { - if (isTypeAny(source)) - return -1 /* True */; - if (source === numberType && target.flags & 128 /* Enum */) - return -1 /* True */; + } + if (source.flags & 1048576 /* FreshObjectLiteral */) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0 /* False */; + } + // Above we check for excess properties with respect to the entire target type. When union + // and intersection types are further deconstructed on the target side, we don't want to + // make the check again (as it might fail for a partial target type). Therefore we obtain + // the regular source type and proceed with that. + if (target.flags & 49152 /* UnionOrIntersection */) { + source = getRegularTypeOfObjectLiteral(source); } } var saveErrorInfo = errorInfo; - if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - // We have type references to same target type, see if relationship holds for all type arguments - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + // Note that the "each" checks must precede the "some" checks to produce the correct results + if (source.flags & 16384 /* Union */) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { return result; } } - else if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { - if (result = typeParameterRelatedTo(source, target, reportErrors)) { + else if (target.flags & 32768 /* Intersection */) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { return result; } } - else if (relation !== identityRelation) { - // Note that the "each" checks must precede the "some" checks to produce the correct results - if (source.flags & 16384 /* Union */) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 32768 /* Intersection */) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - // It is necessary to try "each" checks on both sides because there may be nested "some" checks - // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or - // A & B = (A & B) | (C & D). - if (source.flags & 32768 /* Intersection */) { - // If target is a union type the following check will report errors so we suppress them here - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { - return result; - } - } - if (target.flags & 16384 /* Union */) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - } else { - if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || - source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } + // It is necessary to try "some" checks on both sides because there may be nested "each" checks + // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or + // A & B = (A & B) | (C & D). + if (source.flags & 32768 /* Intersection */) { + // If target is a union type the following check will report errors so we suppress them here + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { + return result; + } + } + if (target.flags & 16384 /* Union */) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; } } } - // Even if relationship doesn't hold for unions, type parameters, or generic type references, - // it may hold in a structural comparison. - // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - // Identity relation does not use apparent type - var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates - // to X. Failing both of those we want to check if the aggregation of A and B's members structurally - // relates to X. Thus, we include intersection types on the source side here. - if (sourceOrApparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { - if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + if (source.flags & 512 /* TypeParameter */) { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1 /* Any */) { + constraint = emptyObjectType; + } + // Report constraint errors only if the constraint is not the empty object type + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 512 /* TypeParameter */ && sourceOrApparentType.flags & 49152 /* UnionOrIntersection */) { - // We clear the errors first because the following check often gives a better error than - // the union or intersection comparison above if it is applicable. - errorInfo = saveErrorInfo; - if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { - return result; + else { + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if relationship holds for all type arguments + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; + } + } + // Even if relationship doesn't hold for unions, intersections, or generic type references, + // it may hold in a structural comparison. + var apparentType = getApparentType(source); + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. + if (apparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { + // Report structural errors only if we haven't reported any errors yet + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } if (reportErrors) { - headMessage = headMessage || ts.Diagnostics.Type_0_is_not_assignable_to_type_1; - var sourceType = typeToString(source); - var targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, undefined, 128 /* UseFullyQualifiedType */); - targetType = typeToString(target, undefined, 128 /* UseFullyQualifiedType */); - } - reportError(headMessage, sourceType, targetType); + reportRelationError(headMessage, source, target); } return 0 /* False */; } + function isIdenticalTo(source, target) { + var result; + if (source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */) { + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if all type arguments are identical + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, /*reportErrors*/ false)) { + return result; + } + } + return objectTypeRelatedTo(source, target, /*reportErrors*/ false); + } + if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || + source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return 0 /* False */; + } + // Check if a property with the given name is known anywhere in the given type. In an object type, a property + // is considered known if the object type is empty and the check is for assignability, if the object type has + // index signatures, or if the property is actually declared in the object type. In a union or intersection + // type, a property is considered known if it is known in any constituent type. + function isKnownProperty(type, name) { + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); + if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || + resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + return true; + } + return false; + } + if (type.flags & 49152 /* UnionOrIntersection */) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } + function hasExcessProperties(source, target, reportErrors) { + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + // We know *exactly* where things went wrong when comparing the types. + // Use this property as the error node as this will be more helpful in + // reasoning about what went wrong. + errorNode = prop.valueDeclaration; + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; var sourceTypes = source.types; @@ -16992,31 +17333,18 @@ var ts; } return result; } - function typeParameterRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - if (source.symbol.name !== target.symbol.name) { - return 0 /* False */; - } - // covers case when both type parameters does not have constraint (both equal to noConstraintType) - if (source.constraint === target.constraint) { - return -1 /* True */; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0 /* False */; - } - return isRelatedTo(source.constraint, target.constraint, reportErrors); - } - else { - while (true) { - var constraint = getConstraintOfTypeParameter(source); - if (constraint === target) - return -1 /* True */; - if (!(constraint && constraint.flags & 512 /* TypeParameter */)) - break; - source = constraint; - } + function typeParameterIdenticalTo(source, target) { + if (source.symbol.name !== target.symbol.name) { return 0 /* False */; } + // covers case when both type parameters does not have constraint (both equal to noConstraintType) + if (source.constraint === target.constraint) { + return -1 /* True */; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return 0 /* False */; + } + return isIdenticalTo(source.constraint, target.constraint); } // Determine if two object types are related by structure. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. @@ -17211,26 +17539,20 @@ var ts; var targetSignatures = getSignaturesOfType(target, kind); var result = -1 /* True */; var saveErrorInfo = errorInfo; - // Because the "abstractness" of a class is the same across all construct signatures - // (internally we are checking the corresponding declaration), it is enough to perform - // the check and report an error once over all pairs of source and target construct signatures. - var sourceSig = sourceSignatures[0]; - // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. - var targetSig = targetSignatures[0]; - if (sourceSig && targetSig) { - var sourceErasedSignature = getErasedSignature(sourceSig); - var targetErasedSignature = getErasedSignature(targetSig); - var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 211 /* ClassDeclaration */); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 211 /* ClassDeclaration */); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; - if (sourceIsAbstract && !targetIsAbstract) { - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return 0 /* False */; + if (kind === 1 /* Construct */) { + // Only want to compare the construct signatures for abstractness guarantees. + // Because the "abstractness" of a class is the same across all construct signatures + // (internally we are checking the corresponding declaration), it is enough to perform + // the check and report an error once over all pairs of source and target construct signatures. + // + // sourceSig and targetSig are (possibly) undefined. + // + // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== -1 /* True */) { + return result; } } outer: for (var _i = 0; _i < targetSignatures.length; _i++) { @@ -17255,6 +17577,33 @@ var ts; } } return result; + function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { + if (sourceSig && targetSig) { + var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); + var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); + if (!sourceDecl) { + // If the source object isn't itself a class declaration, it can be freely assigned, regardless + // of whether the constructed object is abstract or not. + return -1 /* True */; + } + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + // if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment. + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0 /* False */; + } + } + return -1 /* True */; + } } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { @@ -17345,7 +17694,7 @@ var ts; } var result = -1 /* True */; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { return 0 /* False */; } @@ -17358,7 +17707,7 @@ var ts; return indexTypesIdenticalTo(0 /* String */, source, target); } var targetType = getIndexTypeOfType(target, 0 /* String */); - if (targetType) { + if (targetType && !(targetType.flags & 1 /* Any */)) { var sourceType = getIndexTypeOfType(source, 0 /* String */); if (!sourceType) { if (reportErrors) { @@ -17382,7 +17731,7 @@ var ts; return indexTypesIdenticalTo(1 /* Number */, source, target); } var targetType = getIndexTypeOfType(target, 1 /* Number */); - if (targetType) { + if (targetType && !(targetType.flags & 1 /* Any */)) { var sourceStringType = getIndexTypeOfType(source, 0 /* String */); var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */); if (!(sourceStringType || sourceNumberType)) { @@ -17469,14 +17818,18 @@ var ts; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } - function compareSignatures(source, target, compareReturnTypes, compareTypes) { + function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { if (source === target) { return -1 /* True */; } if (source.parameters.length !== target.parameters.length || source.minArgumentCount !== target.minArgumentCount || source.hasRestParameter !== target.hasRestParameter) { - return 0 /* False */; + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return 0 /* False */; + } } var result = -1 /* True */; if (source.typeParameters && target.typeParameters) { @@ -17498,16 +17851,18 @@ var ts; // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N source = getErasedSignature(source); target = getErasedSignature(target); - for (var i = 0, len = source.parameters.length; i < len; i++) { - var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var sourceLen = source.parameters.length; + var targetLen = target.parameters.length; + for (var i = 0; i < targetLen; i++) { + var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); var related = compareTypes(s, t); if (!related) { return 0 /* False */; } result &= related; } - if (compareReturnTypes) { + if (!ignoreReturnTypes) { result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; @@ -17573,6 +17928,24 @@ var ts; function isTupleType(type) { return !!(type.flags & 8192 /* Tuple */); } + function getRegularTypeOfObjectLiteral(type) { + if (type.flags & 1048576 /* FreshObjectLiteral */) { + var regularType = type.regularType; + if (!regularType) { + regularType = createType(type.flags & ~1048576 /* FreshObjectLiteral */); + regularType.symbol = type.symbol; + regularType.members = type.members; + regularType.properties = type.properties; + regularType.callSignatures = type.callSignatures; + regularType.constructSignatures = type.constructSignatures; + regularType.stringIndexType = type.stringIndexType; + regularType.numberIndexType = type.numberIndexType; + type.regularType = regularType; + } + return regularType; + } + return type; + } function getWidenedTypeOfObjectLiteral(type) { var properties = getPropertiesOfObjectType(type); var members = {}; @@ -17600,7 +17973,7 @@ var ts; return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); } function getWidenedType(type) { - if (type.flags & 3145728 /* RequiresWidening */) { + if (type.flags & 6291456 /* RequiresWidening */) { if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { return anyType; } @@ -17608,7 +17981,7 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 16384 /* Union */) { - return getUnionType(ts.map(type.types, getWidenedType)); + return getUnionType(ts.map(type.types, getWidenedType), /*noSubtypeReduction*/ true); } if (isArrayType(type)) { return createArrayType(getWidenedType(type.typeArguments[0])); @@ -17655,7 +18028,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 1048576 /* ContainsUndefinedOrNull */) { + if (t.flags & 2097152 /* ContainsUndefinedOrNull */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -17669,22 +18042,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 135 /* Parameter */: + case 136 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -17697,7 +18070,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 1048576 /* ContainsUndefinedOrNull */) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152 /* ContainsUndefinedOrNull */) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); @@ -17734,7 +18107,9 @@ var ts; var inferences = []; for (var _i = 0; _i < typeParameters.length; _i++) { var unused = typeParameters[_i]; - inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); + inferences.push({ + primary: undefined, secondary: undefined, isFixed: false + }); } return { typeParameters: typeParameters, @@ -17758,11 +18133,16 @@ var ts; return false; } function inferFromTypes(source, target) { - if (source === anyFunctionType) { - return; - } if (target.flags & 512 /* TypeParameter */) { - // If target is a type parameter, make an inference + // If target is a type parameter, make an inference, unless the source type contains + // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). + // Because the anyFunctionType is internal, it should not be exposed to the user by adding + // it as an inference candidate. Hopefully, a better candidate will come along that does + // not contain anyFunctionType when we come back to this argument for its second round + // of inference. + if (source.flags & 8388608 /* ContainsAnyFunctionType */) { + return; + } var typeParameters = context.typeParameters; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { @@ -17793,6 +18173,14 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 8192 /* Tuple */ && target.flags & 8192 /* Tuple */ && source.elementTypes.length === target.elementTypes.length) { + // If source and target are tuples of the same size, infer from element types + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } else if (target.flags & 49152 /* UnionOrIntersection */) { var targetTypes = target.types; var typeParameterCount = 0; @@ -17959,10 +18347,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return true; - case 66 /* Identifier */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 133 /* QualifiedName */: node = node.parent; continue; default: @@ -18008,12 +18396,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 54 /* FirstAssignment */ && node.operatorToken.kind <= 65 /* LastAssignment */) { + if (node.operatorToken.kind >= 55 /* FirstAssignment */ && node.operatorToken.kind <= 66 /* LastAssignment */) { var n = node.left; - while (n.kind === 169 /* ParenthesizedExpression */) { + while (n.kind === 170 /* ParenthesizedExpression */) { n = n.expression; } - if (n.kind === 66 /* Identifier */ && getResolvedSymbol(n) === symbol) { + if (n.kind === 67 /* Identifier */ && getResolvedSymbol(n) === symbol) { return true; } } @@ -18027,96 +18415,60 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: - case 169 /* ParenthesizedExpression */: - case 176 /* PrefixUnaryExpression */: - case 172 /* DeleteExpression */: - case 175 /* AwaitExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 177 /* PostfixUnaryExpression */: - case 181 /* YieldExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 189 /* Block */: - case 190 /* VariableStatement */: - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 201 /* ReturnStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 205 /* ThrowStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 235 /* JsxAttribute */: - case 236 /* JsxSpreadAttribute */: - case 232 /* JsxOpeningElement */: - case 237 /* JsxExpression */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: + case 170 /* ParenthesizedExpression */: + case 177 /* PrefixUnaryExpression */: + case 173 /* DeleteExpression */: + case 176 /* AwaitExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 178 /* PostfixUnaryExpression */: + case 182 /* YieldExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 190 /* Block */: + case 191 /* VariableStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 202 /* ReturnStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 206 /* ThrowStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + case 233 /* JsxOpeningElement */: + case 238 /* JsxExpression */: return ts.forEachChild(node, isAssignedIn); } return false; } } - function resolveLocation(node) { - // Resolve location from top down towards node if it is a context sensitive expression - // That helps in making sure not assigning types as any when resolved out of order - var containerNodes = []; - for (var parent_5 = node.parent; parent_5; parent_5 = parent_5.parent) { - if ((ts.isExpression(parent_5) || ts.isObjectLiteralMethod(node)) && - isContextSensitive(parent_5)) { - containerNodes.unshift(parent_5); - } - } - ts.forEach(containerNodes, function (node) { getTypeOfNode(node); }); - } - function getSymbolAtLocation(node) { - resolveLocation(node); - return getSymbolInfo(node); - } - function getTypeAtLocation(node) { - resolveLocation(node); - return getTypeOfNode(node); - } - function getTypeOfSymbolAtLocation(symbol, node) { - resolveLocation(node); - // Get the narrowed type of symbol at given location instead of just getting - // the type of the symbol. - // eg. - // function foo(a: string | number) { - // if (typeof a === "string") { - // a/**/ - // } - // } - // getTypeOfSymbol for a would return type of parameter symbol string | number - // Unless we provide location /**/, checker wouldn't know how to narrow the type - // By using getNarrowedTypeOfSymbol would return string since it would be able to narrow - // it by typeguard in the if true condition - return getNarrowedTypeOfSymbol(symbol, node); - } // Get the narrowed type of a given symbol at a given location function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); @@ -18128,37 +18480,37 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 193 /* IfStatement */: + case 194 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node.expression) { - narrowedType = narrowType(type, node.expression, child === node.thenStatement); + narrowedType = narrowType(type, node.expression, /*assumeTrue*/ child === node.thenStatement); } break; - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node.condition) { - narrowedType = narrowType(type, node.condition, child === node.whenTrue); + narrowedType = narrowType(type, node.condition, /*assumeTrue*/ child === node.whenTrue); } break; - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { - if (node.operatorToken.kind === 49 /* AmpersandAmpersandToken */) { - narrowedType = narrowType(type, node.left, true); + if (node.operatorToken.kind === 50 /* AmpersandAmpersandToken */) { + narrowedType = narrowType(type, node.left, /*assumeTrue*/ true); } - else if (node.operatorToken.kind === 50 /* BarBarToken */) { - narrowedType = narrowType(type, node.left, false); + else if (node.operatorToken.kind === 51 /* BarBarToken */) { + narrowedType = narrowType(type, node.left, /*assumeTrue*/ false); } } break; - case 245 /* SourceFile */: - case 215 /* ModuleDeclaration */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: + case 246 /* SourceFile */: + case 216 /* ModuleDeclaration */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -18175,23 +18527,23 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 173 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { + if (expr.left.kind !== 174 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 66 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 67 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 32 /* ExclamationEqualsEqualsToken */) { + if (expr.operatorToken.kind === 33 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue) { // Assumed result is true. If check was not for a primitive type, remove all primitive types if (!typeInfo) { - return removeTypesFromUnionType(type, 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 4194304 /* ESSymbol */, - /*isOfTypeKind*/ true, false); + return removeTypesFromUnionType(type, /*typeKind*/ 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 16777216 /* ESSymbol */, + /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); } // Check was for a primitive type, return that primitive type if it is a subtype if (isTypeSubtypeOf(typeInfo.type, type)) { @@ -18199,12 +18551,12 @@ var ts; } // Otherwise, remove all types that aren't of the primitive type kind. This can happen when the type is // union of enum types and other types. - return removeTypesFromUnionType(type, typeInfo.flags, false, false); + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false, /*allowEmptyUnionResult*/ false); } else { // Assumed result is false. If check was for a primitive type, remove that primitive type if (typeInfo) { - return removeTypesFromUnionType(type, typeInfo.flags, true, false); + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); } // Otherwise we don't have enough information to do anything. return type; @@ -18213,14 +18565,14 @@ var ts; function narrowTypeByAnd(type, expr, assumeTrue) { if (assumeTrue) { // The assumed result is true, therefore we narrow assuming each operand to be true. - return narrowType(narrowType(type, expr.left, true), expr.right, true); + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true); } else { // The assumed result is false. This means either the first operand was false, or the first operand was true // and the second operand was false. We narrow with those assumptions and union the two resulting types. return getUnionType([ - narrowType(type, expr.left, false), - narrowType(narrowType(type, expr.left, true), expr.right, false) + narrowType(type, expr.left, /*assumeTrue*/ false), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ false) ]); } } @@ -18229,18 +18581,18 @@ var ts; // The assumed result is true. This means either the first operand was true, or the first operand was false // and the second operand was true. We narrow with those assumptions and union the two resulting types. return getUnionType([ - narrowType(type, expr.left, true), - narrowType(narrowType(type, expr.left, false), expr.right, true) + narrowType(type, expr.left, /*assumeTrue*/ true), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ true) ]); } else { // The assumed result is false, therefore we narrow assuming each operand to be false. - return narrowType(narrowType(type, expr.left, false), expr.right, false); + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); } } function narrowTypeByInstanceof(type, expr, assumeTrue) { // Check that type is not any, assumed result is true, and we have variable symbol on the left - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 66 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } // Check that right operand is a function type with a prototype property @@ -18276,13 +18628,17 @@ var ts; return type; } function getNarrowedType(originalType, narrowedTypeCandidate) { - // Narrow to the target type if it's a subtype of the current type - if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { - return narrowedTypeCandidate; - } - // If the current type is a union type, remove all constituents that aren't subtypes of the target. + // If the current type is a union type, remove all constituents that aren't assignable to target. If that produces + // 0 candidates, fall back to the assignability check if (originalType.flags & 16384 /* Union */) { - return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + // Narrow to the target type if it's assignable to the current type + return narrowedTypeCandidate; } return originalType; } @@ -18308,27 +18664,27 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 165 /* CallExpression */: + case 166 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: var operator = expr.operatorToken.kind; - if (operator === 31 /* EqualsEqualsEqualsToken */ || operator === 32 /* ExclamationEqualsEqualsToken */) { + if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 49 /* AmpersandAmpersandToken */) { + else if (operator === 50 /* AmpersandAmpersandToken */) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 50 /* BarBarToken */) { + else if (operator === 51 /* BarBarToken */) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 88 /* InstanceOfKeyword */) { + else if (operator === 89 /* InstanceOfKeyword */) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 176 /* PrefixUnaryExpression */: - if (expr.operator === 47 /* ExclamationToken */) { + case 177 /* PrefixUnaryExpression */: + if (expr.operator === 48 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -18346,7 +18702,7 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 171 /* ArrowFunction */) { + if (container.kind === 172 /* ArrowFunction */) { if (languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -18377,7 +18733,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 241 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 242 /* CatchClause */) { return; } // - check if binding is used in some function @@ -18386,19 +18742,19 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 209 /* VariableDeclarationList */) { + while (container.kind !== 210 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 190 /* VariableStatement */) { + if (container.kind === 191 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } var inFunction = isInsideFunction(node.parent, container); var current = container; while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (isIterationStatement(current, false)) { + if (isIterationStatement(current, /*lookInLabeledStatements*/ false)) { if (inFunction) { grammarErrorOnFirstToken(current, ts.Diagnostics.Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher, ts.declarationNameToString(node)); } @@ -18411,7 +18767,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 138 /* PropertyDeclaration */ || container.kind === 141 /* Constructor */) { + if (container.kind === 139 /* PropertyDeclaration */ || container.kind === 142 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -18422,35 +18778,35 @@ var ts; function checkThisExpression(node) { // Stop at the first arrow function so that we can // tell whether 'this' needs to be captured. - var container = ts.getThisContainer(node, true); + var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 171 /* ArrowFunction */) { - container = ts.getThisContainer(container, false); + if (container.kind === 172 /* ArrowFunction */) { + container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); } switch (container.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 141 /* Constructor */: + case 142 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -18465,103 +18821,110 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 135 /* Parameter */) { + if (n.kind === 136 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 165 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; + var container = ts.getSuperContainer(node, /*includeFunctions*/ true); + var needToCaptureLexicalThis = false; + if (!isCallExpression) { + // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting + while (container && container.kind === 172 /* ArrowFunction */) { + container = ts.getSuperContainer(container, /*includeFunctions*/ true); + needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; + } + } + var canUseSuperExpression = isLegalUsageOfSuperExpression(container); + var nodeCheckFlag = 0; + // always set NodeCheckFlags for 'super' expression node + if (canUseSuperExpression) { + if ((container.flags & 128 /* Static */) || isCallExpression) { + nodeCheckFlag = 512 /* SuperStatic */; + } + else { + nodeCheckFlag = 256 /* SuperInstance */; + } + getNodeLinks(node).flags |= nodeCheckFlag; + if (needToCaptureLexicalThis) { + // call expressions are allowed only in constructors so they should always capture correct 'this' + // super property access expressions can also appear in arrow functions - + // in this case they should also use correct lexical this + captureLexicalThis(node.parent, container); + } + } if (!baseClassType) { if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); } return unknownType; } - var container = ts.getSuperContainer(node, true); - if (container) { - var canUseSuperExpression = false; - var needToCaptureLexicalThis; + if (!canUseSuperExpression) { + if (container && container.kind === 134 /* ComputedPropertyName */) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); + } + else if (isCallExpression) { + error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); + } + else { + error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; + } + if (container.kind === 142 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) + error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + return nodeCheckFlag === 512 /* SuperStatic */ + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + function isLegalUsageOfSuperExpression(container) { + if (!container) { + return false; + } if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - canUseSuperExpression = container.kind === 141 /* Constructor */; + return container.kind === 142 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) // 'super' property access is allowed // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor - // super property access might appear in arrow functions with arbitrary deep nesting - needToCaptureLexicalThis = false; - while (container && container.kind === 171 /* ArrowFunction */) { - container = ts.getSuperContainer(container, true); - needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; - } // topmost container must be something that is directly nested in the class declaration if (container && ts.isClassLike(container.parent)) { if (container.flags & 128 /* Static */) { - canUseSuperExpression = - container.kind === 140 /* MethodDeclaration */ || - container.kind === 139 /* MethodSignature */ || - container.kind === 142 /* GetAccessor */ || - container.kind === 143 /* SetAccessor */; + return container.kind === 141 /* MethodDeclaration */ || + container.kind === 140 /* MethodSignature */ || + container.kind === 143 /* GetAccessor */ || + container.kind === 144 /* SetAccessor */; } else { - canUseSuperExpression = - container.kind === 140 /* MethodDeclaration */ || - container.kind === 139 /* MethodSignature */ || - container.kind === 142 /* GetAccessor */ || - container.kind === 143 /* SetAccessor */ || - container.kind === 138 /* PropertyDeclaration */ || - container.kind === 137 /* PropertySignature */ || - container.kind === 141 /* Constructor */; + return container.kind === 141 /* MethodDeclaration */ || + container.kind === 140 /* MethodSignature */ || + container.kind === 143 /* GetAccessor */ || + container.kind === 144 /* SetAccessor */ || + container.kind === 139 /* PropertyDeclaration */ || + container.kind === 138 /* PropertySignature */ || + container.kind === 142 /* Constructor */; } } } - if (canUseSuperExpression) { - var returnType; - if ((container.flags & 128 /* Static */) || isCallExpression) { - getNodeLinks(node).flags |= 512 /* SuperStatic */; - returnType = getBaseConstructorTypeOfClass(classType); - } - else { - getNodeLinks(node).flags |= 256 /* SuperInstance */; - returnType = baseClassType; - } - if (container.kind === 141 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { - // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) - error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - returnType = unknownType; - } - if (!isCallExpression && needToCaptureLexicalThis) { - // call expressions are allowed only in constructors so they should always capture correct 'this' - // super property access expressions can also appear in arrow functions - - // in this case they should also use correct lexical this - captureLexicalThis(node.parent, container); - } - return returnType; - } + return false; } - if (container && container.kind === 133 /* ComputedPropertyName */) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); - } - else if (isCallExpression) { - error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); - } - else { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; } // Return contextual type of parameter or undefined if no contextual type is available function getContextuallyTypedParameterType(parameter) { - if (isFunctionExpressionOrArrowFunction(parameter.parent)) { - var func = parameter.parent; + var func = parameter.parent; + if (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) { if (isContextSensitive(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -18592,14 +18955,14 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135 /* Parameter */) { + if (declaration.kind === 136 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; } } if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true); } } return undefined; @@ -18625,7 +18988,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 135 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 136 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -18636,8 +18999,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 141 /* Constructor */ || - functionDecl.kind === 142 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 143 /* SetAccessor */))) { + functionDecl.kind === 142 /* Constructor */ || + functionDecl.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -18659,7 +19022,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 167 /* TaggedTemplateExpression */) { + if (template.parent.kind === 168 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -18667,13 +19030,13 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 54 /* FirstAssignment */ && operator <= 65 /* LastAssignment */) { + if (operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { // In an assignment expression, the right operand is contextually typed by the type of the left operand. if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 50 /* BarBarToken */) { + else if (operator === 51 /* BarBarToken */) { // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); @@ -18769,7 +19132,7 @@ var ts; var index = ts.indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, 1 /* Number */) - || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, undefined) : undefined); + || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); } return undefined; } @@ -18780,7 +19143,7 @@ var ts; } function getContextualTypeForJsxExpression(expr) { // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) - if (expr.parent.kind === 235 /* JsxAttribute */) { + if (expr.parent.kind === 236 /* JsxAttribute */) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -18790,7 +19153,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 236 /* JsxSpreadAttribute */) { + if (expr.kind === 237 /* JsxSpreadAttribute */) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -18811,38 +19174,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 208 /* VariableDeclaration */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 161 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 171 /* ArrowFunction */: - case 201 /* ReturnStatement */: + case 172 /* ArrowFunction */: + case 202 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 187 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 180 /* TemplateExpression */); + case 188 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 181 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return getContextualType(parent); - case 237 /* JsxExpression */: - case 236 /* JsxSpreadAttribute */: + case 238 /* JsxExpression */: + case 237 /* JsxSpreadAttribute */: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -18859,7 +19222,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 170 /* FunctionExpression */ || node.kind === 171 /* ArrowFunction */; + return node.kind === 171 /* FunctionExpression */ || node.kind === 172 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -18873,7 +19236,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -18887,19 +19250,13 @@ var ts; var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; - // The signature set of all constituent type with call signatures should match - // So number of signatures allowed is either 0 or 1 - if (signatureList && - getSignaturesOfStructuredType(current, 0 /* Call */).length > 1) { - return undefined; - } var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { // This signature will contribute to contextual union signature signatureList = [signature]; } - else if (!compareSignatures(signatureList[0], signature, false, compareTypes)) { + else if (!compareSignatures(signatureList[0], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true, compareTypes)) { // Signatures aren't identical, do not use return undefined; } @@ -18919,23 +19276,36 @@ var ts; } return result; } - // Presence of a contextual type mapper indicates inferential typing, except the identityMapper object is - // used as a special marker for other purposes. + /** + * Detect if the mapper implies an inference context. Specifically, there are 4 possible values + * for a mapper. Let's go through each one of them: + * + * 1. undefined - this means we are not doing inferential typing, but we may do contextual typing, + * which could cause us to assign a parameter a type + * 2. identityMapper - means we want to avoid assigning a parameter a type, whether or not we are in + * inferential typing (context is undefined for the identityMapper) + * 3. a mapper created by createInferenceMapper - we are doing inferential typing, we want to assign + * types to parameters and fix type parameters (context is defined) + * 4. an instantiation mapper created by createTypeMapper or createTypeEraser - this should never be + * passed as the contextual mapper when checking an expression (context is undefined for these) + * + * isInferentialContext is detecting if we are in case 3 + */ function isInferentialContext(mapper) { - return mapper && mapper !== identityMapper; + return mapper && mapper.context; } // A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property // assignment in an object literal that is an assignment target, or if it is parented by an array literal that is // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 178 /* BinaryExpression */ && parent.operatorToken.kind === 54 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 179 /* BinaryExpression */ && parent.operatorToken.kind === 55 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 242 /* PropertyAssignment */) { + if (parent.kind === 243 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 161 /* ArrayLiteralExpression */) { + if (parent.kind === 162 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -18948,19 +19318,20 @@ var ts; // So the fact that contextualMapper is passed is not important, because the operand of a spread // element is not contextually typed. var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); + } + function hasDefaultValue(node) { + return (node.kind === 161 /* BindingElement */ && !!node.initializer) || + (node.kind === 179 /* BinaryExpression */ && node.operatorToken.kind === 55 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; - if (!elements.length) { - return createArrayType(undefinedType); - } var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 182 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 183 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -18975,7 +19346,7 @@ var ts; // if there is no index type / iterated type. var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1 /* Number */) || - (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(restArrayType, undefined) : undefined); + (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); if (restElementType) { elementTypes.push(restElementType); } @@ -18984,18 +19355,45 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 182 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 183 /* SpreadElementExpression */; } if (!hasSpreadElement) { + // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such + // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". + if (inDestructuringPattern && elementTypes.length) { + var type = createNewTupleType(elementTypes); + type.pattern = node; + return type; + } var contextualType = getContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) { - return createTupleType(elementTypes); + if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { + var pattern = contextualType.pattern; + // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting + // tuple type with the corresponding binding or assignment element types to make the lengths equal. + if (pattern && (pattern.kind === 160 /* ArrayBindingPattern */ || pattern.kind === 162 /* ArrayLiteralExpression */)) { + var patternElements = pattern.elements; + for (var i = elementTypes.length; i < patternElements.length; i++) { + var patternElement = patternElements[i]; + if (hasDefaultValue(patternElement)) { + elementTypes.push(contextualType.elementTypes[i]); + } + else { + if (patternElement.kind !== 185 /* OmittedExpression */) { + error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + elementTypes.push(unknownType); + } + } + } + if (elementTypes.length) { + return createTupleType(elementTypes); + } } } - return createArrayType(getUnionType(elementTypes)); + return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 133 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 134 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -19035,11 +19433,11 @@ var ts; links.resolvedType = checkExpression(node.expression); // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 4194304 /* ESSymbol */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 16777216 /* ESSymbol */)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true); + checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); } } return links.resolvedType; @@ -19050,26 +19448,47 @@ var ts; var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); - var typeFlags; + var contextualTypeHasPattern = contextualType && contextualType.pattern && + (contextualType.pattern.kind === 159 /* ObjectBindingPattern */ || contextualType.pattern.kind === 163 /* ObjectLiteralExpression */); + var inDestructuringPattern = isAssignmentTarget(node); + var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 242 /* PropertyAssignment */ || - memberDecl.kind === 243 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 243 /* PropertyAssignment */ || + memberDecl.kind === 244 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 242 /* PropertyAssignment */) { + if (memberDecl.kind === 243 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 140 /* MethodDeclaration */) { + else if (memberDecl.kind === 141 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 243 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 244 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name); + if (inDestructuringPattern) { + // If object literal is an assignment pattern and if the assignment pattern specifies a default value + // for the property, make the property optional. + if (memberDecl.kind === 243 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) { + prop.flags |= 536870912 /* Optional */; + } + } + else if (contextualTypeHasPattern) { + // If object literal is contextually typed by the implied type of a binding pattern, and if the + // binding pattern specifies a default value for the property, make the property optional. + var impliedProp = getPropertyOfType(contextualType, member.name); + if (impliedProp) { + prop.flags |= impliedProp.flags & 536870912 /* Optional */; + } + else if (!compilerOptions.suppressExcessPropertyErrors) { + error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); + } + } prop.declarations = member.declarations; prop.parent = member.parent; if (member.valueDeclaration) { @@ -19085,7 +19504,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 142 /* GetAccessor */ || memberDecl.kind === 143 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 143 /* GetAccessor */ || memberDecl.kind === 144 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -19093,10 +19512,28 @@ var ts; } propertiesArray.push(member); } + // If object literal is contextually typed by the implied type of a binding pattern, augment the result + // type with those properties for which the binding pattern specifies a default value. + if (contextualTypeHasPattern) { + for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) { + var prop = _c[_b]; + if (!ts.hasProperty(propertiesTable, prop.name)) { + if (!(prop.flags & 536870912 /* Optional */)) { + error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + propertiesTable[prop.name] = prop; + propertiesArray.push(prop); + } + } + } var stringIndexType = getIndexType(0 /* String */); var numberIndexType = getIndexType(1 /* Number */); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 524288 /* ObjectLiteral */ | 2097152 /* ContainsObjectLiteral */ | (typeFlags & 1048576 /* ContainsUndefinedOrNull */); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */; + result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */); + if (inDestructuringPattern) { + result.pattern = node; + } return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -19129,35 +19566,39 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 66 /* Identifier */) { + if (lhs.kind === 67 /* Identifier */) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && tagNamesAreEquivalent(lhs.left, rhs.left); } function checkJsxElement(node) { + // Check attributes + checkJsxOpeningLikeElement(node.openingElement); // Check that the closing tag matches if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); } - // Check attributes - checkJsxOpeningLikeElement(node.openingElement); + else { + // Perform resolution on the closing tag so that rename/go to definition/etc work + getJsxElementTagSymbol(node.closingElement); + } // Check children for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: checkJsxExpression(child); break; - case 230 /* JsxElement */: + case 231 /* JsxElement */: checkJsxElement(child); break; - case 231 /* JsxSelfClosingElement */: + case 232 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; default: // No checks for JSX Text - ts.Debug.assert(child.kind === 233 /* JsxText */); + ts.Debug.assert(child.kind === 234 /* JsxText */); } } return jsxElementType || anyType; @@ -19173,7 +19614,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 132 /* QualifiedName */) { + if (tagName.kind === 133 /* QualifiedName */) { return false; } else { @@ -19190,10 +19631,19 @@ var ts; else if (elementAttributesType && !isTypeAny(elementAttributesType)) { var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - // If there's no corresponding property with this name, error - if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; + if (isUnhyphenatedJsxName(node.name.text)) { + // Maybe there's a string indexer? + var indexerType = getIndexTypeOfType(elementAttributesType, 0 /* String */); + if (indexerType) { + correspondingPropType = indexerType; + } + else { + // If there's no corresponding property with this name, error + if (!correspondingPropType) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } } } var exprType; @@ -19269,7 +19719,7 @@ var ts; return intrinsicElementsType.symbol; } // Wasn't found - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, 'JSX.' + JsxNames.IntrinsicElements); + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); return unknownSymbol; } else { @@ -19279,22 +19729,24 @@ var ts; } } function lookupClassTag(node) { - var valueSymbol; + var valueSymbol = resolveJsxTagName(node); // Look up the value in the current scope - if (node.tagName.kind === 66 /* Identifier */) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - valueSymbol = sym.exportSymbol || sym; - } - else { - valueSymbol = checkQualifiedName(node.tagName).symbol; - } if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4 /* ClassElement */; getSymbolLinks(valueSymbol).referenced = true; } return valueSymbol || unknownSymbol; } + function resolveJsxTagName(node) { + if (node.tagName.kind === 67 /* Identifier */) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } } /** * Given a JSX element that is a class element, finds the Element Instance Type. If the @@ -19302,10 +19754,9 @@ var ts; * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). */ function getJsxElementInstanceType(node) { - if (!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */)) { - // There is no such thing as an instance type for a non-class element - return undefined; - } + // There is no such thing as an instance type for a non-class element. This + // line shouldn't be hit. + ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */), "Should not call getJsxElementInstanceType on non-class Element"); var classSymbol = getJsxElementTagSymbol(node); if (classSymbol === unknownSymbol) { // Couldn't find the class instance type. Error has already been issued @@ -19324,15 +19775,10 @@ var ts; if (signatures.length === 0) { // We found no signatures at all, which is an error error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); - return undefined; + return unknownType; } } - // Check that the constructor/factory returns an object type - var returnType = getUnionType(signatures.map(function (s) { return getReturnTypeOfSignature(s); })); - if (!isTypeAny(returnType) && !(returnType.flags & 80896 /* ObjectType */)) { - error(node.tagName, ts.Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); - return undefined; - } + var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); // Issue an error if this return type isn't assignable to JSX.ElementClass var elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { @@ -19347,7 +19793,7 @@ var ts; /// non-instrinsic elements' attributes type is the element instance type) function getJsxElementPropertiesName() { // JSX - var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, undefined); + var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); // JSX.ElementAttributesProperty [symbol] var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056 /* Type */); // JSX.ElementAttributesProperty [type] @@ -19383,7 +19829,7 @@ var ts; if (links.jsxFlags & 4 /* ClassElement */) { var elemInstanceType = getJsxElementInstanceType(node); if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = anyType; + return links.resolvedJsxType = elemInstanceType; } var propsName = getJsxElementPropertiesName(); if (propsName === undefined) { @@ -19465,7 +19911,7 @@ var ts; // be marked as 'used' so we don't incorrectly elide its import. And if there // is no 'React' symbol in scope, we should issue an error. if (compilerOptions.jsx === 2 /* React */) { - var reactSym = resolveName(node.tagName, 'React', 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, 'React'); + var reactSym = resolveName(node.tagName, "React", 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, "React"); if (reactSym) { getSymbolLinks(reactSym).referenced = true; } @@ -19477,11 +19923,11 @@ var ts; // thus should have their types ignored var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 235 /* JsxAttribute */) { + if (node.attributes[i].kind === 236 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 236 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 237 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -19511,7 +19957,7 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 138 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 139 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; @@ -19527,8 +19973,8 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 92 /* SuperKeyword */) { - var errorNode = node.kind === 163 /* PropertyAccessExpression */ ? + if (left.kind === 93 /* SuperKeyword */) { + var errorNode = node.kind === 164 /* PropertyAccessExpression */ ? node.name : node.right; // TS 1.0 spec (April 2014): 4.8.2 @@ -19538,7 +19984,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (getDeclarationKindFromSymbol(prop) !== 140 /* MethodDeclaration */) { + if (getDeclarationKindFromSymbol(prop) !== 141 /* MethodDeclaration */) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -19571,7 +20017,7 @@ var ts; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (left.kind === 92 /* SuperKeyword */) { + if (left.kind === 93 /* SuperKeyword */) { return true; } // A protected property is accessible in the declaring class and classes derived from it @@ -19621,7 +20067,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 163 /* PropertyAccessExpression */ + var left = node.kind === 164 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -19637,7 +20083,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 166 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -19656,7 +20102,7 @@ var ts; } var isConstEnum = isConstEnumObjectType(objectType); if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 8 /* StringLiteral */)) { + (!node.argumentExpression || node.argumentExpression.kind !== 9 /* StringLiteral */)) { error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } @@ -19684,7 +20130,7 @@ var ts; } } // Check for compatible indexer types. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 4194304 /* ESSymbol */)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { // Try to use a number indexer. if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */)) { var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); @@ -19714,10 +20160,10 @@ var ts; * Otherwise, returns undefined. */ function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 8 /* StringLiteral */ || indexArgumentExpression.kind === 7 /* NumericLiteral */) { + if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } - if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { + if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { var rightHandSideName = indexArgumentExpression.name.text; return ts.getPropertyNameForKnownSymbolName(rightHandSideName); } @@ -19739,7 +20185,7 @@ var ts; return false; } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 4194304 /* ESSymbol */) === 0) { + if ((expressionType.flags & 16777216 /* ESSymbol */) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -19766,10 +20212,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 136 /* Decorator */) { + else if (node.kind !== 137 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -19799,13 +20245,13 @@ var ts; for (var _i = 0; _i < signatures.length; _i++) { var signature = signatures[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_6 = signature.declaration && signature.declaration.parent; + var parent_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_6 === lastParent) { + if (lastParent && parent_5 === lastParent) { index++; } else { - lastParent = parent_6; + lastParent = parent_5; index = cutoffIndex; } } @@ -19813,7 +20259,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_6; + lastParent = parent_5; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -19835,7 +20281,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 182 /* SpreadElementExpression */) { + if (arg && arg.kind === 183 /* SpreadElementExpression */) { return i; } } @@ -19847,13 +20293,13 @@ var ts; var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments var isDecorator; var spreadArgIndex = -1; - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 180 /* TemplateExpression */) { + if (tagExpression.template.kind === 181 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var templateExpression = tagExpression.template; @@ -19866,20 +20312,20 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 10 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 11 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { isDecorator = true; typeArguments = undefined; - adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); + adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); } else { var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 166 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 167 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -19922,7 +20368,7 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature.typeParameters, true); + var context = createInferenceContext(signature.typeParameters, /*inferUnionTypes*/ true); forEachMatchingParameterType(contextualSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type inferTypes(context, instantiateType(source, contextualMapper), target); @@ -19958,7 +20404,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 184 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type @@ -20017,14 +20463,14 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 184 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { - argType = arg.kind === 8 /* StringLiteral */ && !reportErrors + argType = arg.kind === 9 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -20049,16 +20495,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 180 /* TemplateExpression */) { + if (template.kind === 181 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -20083,25 +20529,25 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { switch (node.parent.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 135 /* Parameter */: + case 136 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -20126,25 +20572,25 @@ var ts; function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. switch (node.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 135 /* Parameter */: + case 136 /* Parameter */: // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } // fall-through - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -20173,35 +20619,35 @@ var ts; function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 135 /* Parameter */: + case 136 /* Parameter */: node = node.parent; - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. // fall-through - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; switch (element.name.kind) { - case 66 /* Identifier */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: + case 67 /* Identifier */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: return getStringLiteralType(element.name); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 4194304 /* ESSymbol */)) { + if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { return nameType; } else { @@ -20227,18 +20673,18 @@ var ts; // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a paramter decorator switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 135 /* Parameter */: + case 136 /* Parameter */: // The `parameterIndex` for a parameter decorator is always a number return numberType; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -20271,10 +20717,10 @@ var ts; // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { return globalTemplateStringsArrayType; } // This is not a synthetic argument, so we return 'undefined' @@ -20286,8 +20732,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 136 /* Decorator */ || - (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */)) { + if (node.kind === 137 /* Decorator */ || + (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -20296,11 +20742,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -20309,13 +20755,13 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 167 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 136 /* Decorator */; + var isTaggedTemplate = node.kind === 168 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 137 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 92 /* SuperKeyword */) { + if (node.expression.kind !== 93 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -20412,17 +20858,18 @@ var ts; // in arguments too early. If possible, we'd like to only type them once we know the correct // overload. However, this matters for the case where the call is correct. When the call is // an error, we don't need to exclude any arguments, although it would cause no harm to do so. - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); + checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); } else if (candidateForTypeArgumentError) { if (!isTaggedTemplate && !isDecorator && typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true, headMessage); + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], /*reportErrors*/ true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); - var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); + var diagnosticChainHead = ts.chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError + ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); if (headMessage) { diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); } @@ -20441,6 +20888,9 @@ var ts; for (var _i = 0; _i < candidates.length; _i++) { var candidate = candidates[_i]; if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); + } return candidate; } } @@ -20463,7 +20913,7 @@ var ts; var candidate = void 0; var typeArgumentsAreValid = void 0; var inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate.typeParameters, false) + ? createInferenceContext(originalCandidate.typeParameters, /*inferUnionTypes*/ false) : undefined; while (true) { candidate = originalCandidate; @@ -20471,7 +20921,7 @@ var ts; var typeArgumentTypes = void 0; if (typeArguments) { typeArgumentTypes = new Array(candidate.typeParameters.length); - typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); + typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); @@ -20483,7 +20933,7 @@ var ts; } candidate = getSignatureInstantiation(candidate, typeArgumentTypes); } - if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { break; } var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; @@ -20518,7 +20968,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated @@ -20592,7 +21042,7 @@ var ts; // Note, only class declarations can be declared abstract. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 211 /* ClassDeclaration */); + var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); if (valueDecl && valueDecl.flags & 256 /* Abstract */) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); @@ -20651,16 +21101,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 135 /* Parameter */: + case 136 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -20697,16 +21147,16 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 165 /* CallExpression */) { + if (node.kind === 166 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 166 /* NewExpression */) { + else if (node.kind === 167 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 168 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -20724,15 +21174,15 @@ var ts; // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { return voidType; } - if (node.kind === 166 /* NewExpression */) { + if (node.kind === 167 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 141 /* Constructor */ && - declaration.kind !== 145 /* ConstructSignature */ && - declaration.kind !== 150 /* ConstructorType */) { + declaration.kind !== 142 /* Constructor */ && + declaration.kind !== 146 /* ConstructSignature */ && + declaration.kind !== 151 /* ConstructorType */) { // When resolved signature is a call signature (and not a construct signature) the result type is any if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); @@ -20746,7 +21196,7 @@ var ts; return getReturnTypeOfSignature(getResolvedSignature(node)); } function checkAssertion(node) { - var exprType = checkExpression(node.expression); + var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { var widenedType = getWidenedType(exprType); @@ -20765,19 +21215,57 @@ var ts; var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeAtPosition(context, i), mapper); + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { var parameter = ts.lastOrUndefined(signature.parameters); - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } + } + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + var links = getSymbolLinks(parameter); + if (!links.type) { + links.type = instantiateType(contextualType, mapper); + } + else if (isInferentialContext(mapper)) { + // Even if the parameter already has a type, it might be because it was given a type while + // processing the function as an argument to a prior signature during overload resolution. + // If this was the case, it may have caused some type parameters to be fixed. So here, + // we need to ensure that type parameters at the same positions get fixed again. This is + // done by calling instantiateType to attach the mapper to the contextualType, and then + // calling inferTypes to force a walk of contextualType so that all the correct fixing + // happens. The choice to pass in links.type may seem kind of arbitrary, but it serves + // to make sure that all the correct positions in contextualType are reached by the walk. + // Here is an example: + // + // interface Base { + // baseProp; + // } + // interface Derived extends Base { + // toBase(): Base; + // } + // + // var derived: Derived; + // + // declare function foo(x: T, func: (p: T) => T): T; + // declare function foo(x: T, func: (p: T) => T): T; + // + // var result = foo(derived, d => d.toBase()); + // + // We are typing d while checking the second overload. But we've already given d + // a type (Derived) from the first overload. However, we still want to fix the + // T in the second overload so that we do not infer Base as a candidate for T + // (inferring Base would make type argument inference inconsistent between the two + // overloads). + inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); } } function createPromiseType(promisedType) { // creates a `Promise` type where `T` is the promisedType argument var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyObjectType) { + if (globalPromiseType !== emptyGenericType) { // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type promisedType = getAwaitedType(promisedType); return createTypeReference(globalPromiseType, [promisedType]); @@ -20791,7 +21279,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 189 /* Block */) { + if (func.body.kind !== 190 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -20910,7 +21398,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 205 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 206 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -20925,7 +21413,7 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 189 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 190 /* Block */) { return; } var bodyBlock = func.body; @@ -20943,10 +21431,10 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 170 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 171 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -20959,37 +21447,44 @@ var ts; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); - // Check if function expression is contextually typed and assign parameter types if so - if (!(links.flags & 1024 /* ContextChecked */)) { + var contextSensitive = isContextSensitive(node); + var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + // Check if function expression is contextually typed and assign parameter types if so. + // See the comment in assignTypeToParameterAndFixTypeParameters to understand why we need to + // check mightFixTypeParameters. + if (mightFixTypeParameters || !(links.flags & 1024 /* ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 1024 /* ContextChecked */)) { + var contextChecked = !!(links.flags & 1024 /* ContextChecked */); + if (mightFixTypeParameters || !contextChecked) { links.flags |= 1024 /* ContextChecked */; if (contextualSignature) { var signature = getSignaturesOfType(type, 0 /* Call */)[0]; - if (isContextSensitive(node)) { + if (contextSensitive) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type && !signature.resolvedReturnType) { + if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { var returnType = getReturnTypeFromBody(node, contextualMapper); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } } - checkSignatureDeclaration(node); + if (!contextChecked) { + checkSignatureDeclaration(node); + } } } - if (produceDiagnostics && node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -21011,7 +21506,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 189 /* Block */) { + if (node.body.kind === 190 /* Block */) { checkSourceElement(node.body); } else { @@ -21057,24 +21552,24 @@ var ts; // and property accesses(section 4.10). // All other expression constructs described in this chapter are classified as values. switch (n.kind) { - case 66 /* Identifier */: { + case 67 /* Identifier */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.3 // An identifier expression that references a variable or parameter is classified as a reference. // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; } - case 163 /* PropertyAccessExpression */: { + case 164 /* PropertyAccessExpression */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; } - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: // old compiler doesn't check indexed assess return true; - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -21082,22 +21577,22 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: { + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; } - case 164 /* ElementAccessExpression */: { + case 165 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 8 /* StringLiteral */) { + if (symbol && index && index.kind === 9 /* StringLiteral */) { var name_12 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768 /* Const */) !== 0; } return false; } - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -21141,17 +21636,17 @@ var ts; function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - if (someConstituentTypeHasKind(operandType, 4194304 /* ESSymbol */)) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 47 /* ExclamationToken */: + case 48 /* ExclamationToken */: return booleanType; - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -21217,7 +21712,7 @@ var ts; // and the right operand to be of type Any or a subtype of the 'Function' interface type. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported - if (allConstituentTypesHaveKind(leftType, 4194814 /* Primitive */)) { + if (allConstituentTypesHaveKind(leftType, 16777726 /* Primitive */)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -21231,7 +21726,7 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 4194304 /* ESSymbol */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { @@ -21243,7 +21738,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 242 /* PropertyAssignment */ || p.kind === 243 /* ShorthandPropertyAssignment */) { + if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_13 = p.name; var type = isTypeAny(sourceType) @@ -21268,12 +21763,12 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(sourceType, node, false) || unknownType; + var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184 /* OmittedExpression */) { - if (e.kind !== 182 /* SpreadElementExpression */) { + if (e.kind !== 185 /* OmittedExpression */) { + if (e.kind !== 183 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -21298,7 +21793,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 178 /* BinaryExpression */ && restExpression.operatorToken.kind === 54 /* EqualsToken */) { + if (restExpression.kind === 179 /* BinaryExpression */ && restExpression.operatorToken.kind === 55 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -21311,14 +21806,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 178 /* BinaryExpression */ && target.operatorToken.kind === 54 /* EqualsToken */) { + if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 162 /* ObjectLiteralExpression */) { + if (target.kind === 163 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 161 /* ArrayLiteralExpression */) { + if (target.kind === 162 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -21326,38 +21821,38 @@ var ts; function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { - checkTypeAssignableTo(sourceType, targetType, target, undefined); + checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); } return sourceType; } function checkBinaryExpression(node, contextualMapper) { var operator = node.operatorToken.kind; - if (operator === 54 /* EqualsToken */ && (node.left.kind === 162 /* ObjectLiteralExpression */ || node.left.kind === 161 /* ArrayLiteralExpression */)) { + if (operator === 55 /* EqualsToken */ && (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 36 /* AsteriskToken */: - case 57 /* AsteriskEqualsToken */: - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - case 38 /* PercentToken */: - case 59 /* PercentEqualsToken */: - case 35 /* MinusToken */: - case 56 /* MinusEqualsToken */: - case 41 /* LessThanLessThanToken */: - case 60 /* LessThanLessThanEqualsToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 45 /* BarToken */: - case 64 /* BarEqualsToken */: - case 46 /* CaretToken */: - case 65 /* CaretEqualsToken */: - case 44 /* AmpersandToken */: - case 63 /* AmpersandEqualsToken */: + case 37 /* AsteriskToken */: + case 58 /* AsteriskEqualsToken */: + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + case 39 /* PercentToken */: + case 60 /* PercentEqualsToken */: + case 36 /* MinusToken */: + case 57 /* MinusEqualsToken */: + case 42 /* LessThanLessThanToken */: + case 61 /* LessThanLessThanEqualsToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 46 /* BarToken */: + case 65 /* BarEqualsToken */: + case 47 /* CaretToken */: + case 66 /* CaretEqualsToken */: + case 45 /* AmpersandToken */: + case 64 /* AmpersandEqualsToken */: // TypeScript 1.0 spec (April 2014): 4.15.1 // These operators require their operands to be of type Any, the Number primitive type, // or an enum type. Operands of an enum type are treated @@ -21385,8 +21880,8 @@ var ts; } } return numberType; - case 34 /* PlusToken */: - case 55 /* PlusEqualsToken */: + case 35 /* PlusToken */: + case 56 /* PlusEqualsToken */: // TypeScript 1.0 spec (April 2014): 4.15.2 // The binary + operator requires both operands to be of the Number primitive type or an enum type, // or at least one of the operands to be of type Any or the String primitive type. @@ -21420,44 +21915,44 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 55 /* PlusEqualsToken */) { + if (operator === 56 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } // Fall through - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 88 /* InstanceOfKeyword */: + case 89 /* InstanceOfKeyword */: return checkInstanceOfExpression(node, leftType, rightType); - case 87 /* InKeyword */: + case 88 /* InKeyword */: return checkInExpression(node, leftType, rightType); - case 49 /* AmpersandAmpersandToken */: + case 50 /* AmpersandAmpersandToken */: return rightType; - case 50 /* BarBarToken */: + case 51 /* BarBarToken */: return getUnionType([leftType, rightType]); - case 54 /* EqualsToken */: + case 55 /* EqualsToken */: checkAssignmentOperator(rightType); - return rightType; - case 23 /* CommaToken */: + return getRegularTypeOfObjectLiteral(rightType); + case 24 /* CommaToken */: return rightType; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 4194304 /* ESSymbol */) ? node.left : - someConstituentTypeHasKind(rightType, 4194304 /* ESSymbol */) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? node.left : + someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? node.right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -21467,21 +21962,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 45 /* BarToken */: - case 64 /* BarEqualsToken */: - return 50 /* BarBarToken */; - case 46 /* CaretToken */: - case 65 /* CaretEqualsToken */: - return 32 /* ExclamationEqualsEqualsToken */; - case 44 /* AmpersandToken */: - case 63 /* AmpersandEqualsToken */: - return 49 /* AmpersandAmpersandToken */; + case 46 /* BarToken */: + case 65 /* BarEqualsToken */: + return 51 /* BarBarToken */; + case 47 /* CaretToken */: + case 66 /* CaretEqualsToken */: + return 33 /* ExclamationEqualsEqualsToken */; + case 45 /* AmpersandToken */: + case 64 /* AmpersandEqualsToken */: + return 50 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 54 /* FirstAssignment */ && operator <= 65 /* LastAssignment */) { + if (produceDiagnostics && operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr @@ -21492,7 +21987,7 @@ var ts; // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, node.left, undefined); + checkTypeAssignableTo(valueType, leftType, node.left, /*headMessage*/ undefined); } } } @@ -21530,7 +22025,7 @@ var ts; // If the user's code is syntactically correct, the func should always have a star. After all, // we are in a yield context. if (func && func.asteriskToken) { - var expressionType = checkExpressionCached(node.expression, undefined); + var expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); var expressionElementType; var nodeIsYieldStar = !!node.asteriskToken; if (nodeIsYieldStar) { @@ -21542,10 +22037,10 @@ var ts; if (func.type) { var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); } else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(expressionType, signatureElementType, node.expression, /*headMessage*/ undefined); } } } @@ -21588,7 +22083,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -21599,14 +22094,14 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (contextualMapper && contextualMapper !== identityMapper) { + if (isInferentialContext(contextualMapper)) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getContextualType(node); @@ -21629,7 +22124,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 132 /* QualifiedName */) { + if (node.kind === 133 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -21641,9 +22136,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -21657,78 +22152,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return checkIdentifier(node); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return checkThisExpression(node); - case 92 /* SuperKeyword */: + case 93 /* SuperKeyword */: return checkSuperExpression(node); - case 90 /* NullKeyword */: + case 91 /* NullKeyword */: return nullType; - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: return booleanType; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return checkNumericLiteral(node); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return checkTemplateExpression(node); - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: return stringType; - case 9 /* RegularExpressionLiteral */: + case 10 /* RegularExpressionLiteral */: return globalRegExpType; - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return checkCallExpression(node); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return checkClassExpression(node); - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return checkAssertion(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return checkDeleteExpression(node); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return checkVoidExpression(node); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return checkAwaitExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 184 /* OmittedExpression */: + case 185 /* OmittedExpression */: return undefinedType; - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return checkYieldExpression(node); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return checkJsxExpression(node); - case 230 /* JsxElement */: + case 231 /* JsxElement */: return checkJsxElement(node); - case 231 /* JsxSelfClosingElement */: + case 232 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 232 /* JsxOpeningElement */: + case 233 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -21757,7 +22252,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 141 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 142 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -21774,15 +22269,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 140 /* MethodDeclaration */ || - node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */; + return node.kind === 141 /* MethodDeclaration */ || + node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 66 /* Identifier */ && + if (param.name.kind === 67 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -21792,31 +22287,31 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 171 /* ArrowFunction */: - case 144 /* CallSignature */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 149 /* FunctionType */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 172 /* ArrowFunction */: + case 145 /* CallSignature */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 150 /* FunctionType */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 149 /* FunctionType */ || node.kind === 210 /* FunctionDeclaration */ || node.kind === 150 /* ConstructorType */ || - node.kind === 144 /* CallSignature */ || node.kind === 141 /* Constructor */ || - node.kind === 145 /* ConstructSignature */) { + else if (node.kind === 150 /* FunctionType */ || node.kind === 211 /* FunctionDeclaration */ || node.kind === 151 /* ConstructorType */ || + node.kind === 145 /* CallSignature */ || node.kind === 142 /* Constructor */ || + node.kind === 146 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 147 /* TypePredicate */) { + if (node.type.kind === 148 /* TypePredicate */) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -21825,7 +22320,7 @@ var ts; error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); } } else if (typePredicateNode.parameterName) { @@ -21835,19 +22330,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 158 /* ObjectBindingPattern */ || - param.name.kind === 159 /* ArrayBindingPattern */) { + if (param.name.kind === 159 /* ObjectBindingPattern */ || + param.name.kind === 160 /* ArrayBindingPattern */) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 66 /* Identifier */ && + if (element.name.kind === 67 /* Identifier */ && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 159 /* ArrayBindingPattern */ || - element.name.kind === 158 /* ObjectBindingPattern */) { + else if (element.name.kind === 160 /* ArrayBindingPattern */ || + element.name.kind === 159 /* ObjectBindingPattern */) { checkBindingPattern(element.name); } } @@ -21871,10 +22366,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 144 /* CallSignature */: + case 145 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -21902,7 +22397,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 212 /* InterfaceDeclaration */) { + if (node.kind === 213 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -21922,7 +22417,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 127 /* StringKeyword */: + case 128 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -21930,7 +22425,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -21979,56 +22474,80 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 165 /* CallExpression */ && n.expression.kind === 92 /* SuperKeyword */; + return n.kind === 166 /* CallExpression */ && n.expression.kind === 93 /* SuperKeyword */; + } + function containsSuperCallAsComputedPropertyName(n) { + return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } - switch (n.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 162 /* ObjectLiteralExpression */: return false; - default: return ts.forEachChild(n, containsSuperCall); + else if (ts.isFunctionLike(n)) { + return false; } + else if (ts.isClassLike(n)) { + return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); + } + return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 94 /* ThisKeyword */) { + if (n.kind === 95 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 170 /* FunctionExpression */ && n.kind !== 210 /* FunctionDeclaration */) { + else if (n.kind !== 171 /* FunctionExpression */ && n.kind !== 211 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 138 /* PropertyDeclaration */ && + return n.kind === 139 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } // TS 1.0 spec (April 2014): 8.3.2 // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. - if (ts.getClassExtendsHeritageClauseElement(node.parent)) { + var containingClassDecl = node.parent; + if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + var containingClassSymbol = getSymbolOfNode(containingClassDecl); + var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); if (containsSuperCall(node.body)) { - // The first statement in the body of a constructor must be a super call if both of the following are true: + if (baseConstructorType === nullType) { + error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } + // The first statement in the body of a constructor (excluding prologue directives) must be a super call + // if both of the following are true: // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); + // Skip past any prologue directives to find the first statement + // to ensure that it was a super call. if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 192 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + var superCallStatement; + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (statement.kind === 193 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { + superCallStatement = statement; + break; + } + if (!ts.isPrologueDirective(statement)) { + break; + } + } + if (!superCallStatement) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { // In such a required super call, it is a compile-time error for argument expressions to reference this. - markThisReferencesAsErrors(statements[0].expression); + markThisReferencesAsErrors(superCallStatement.expression); } } } - else { + else if (baseConstructorType !== nullType) { error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -22037,7 +22556,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 142 /* GetAccessor */) { + if (node.kind === 143 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } @@ -22045,7 +22564,7 @@ var ts; if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 142 /* GetAccessor */ ? 143 /* SetAccessor */ : 142 /* GetAccessor */; + var otherKind = node.kind === 143 /* GetAccessor */ ? 144 /* SetAccessor */ : 143 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -22141,9 +22660,9 @@ var ts; var signaturesToCheck; // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 212 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 144 /* CallSignature */ || signatureDeclarationNode.kind === 145 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 144 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 145 /* CallSignature */ || signatureDeclarationNode.kind === 146 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 145 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -22161,7 +22680,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 212 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 213 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -22247,7 +22766,7 @@ var ts; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */); + ts.Debug.assert(node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -22283,7 +22802,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 212 /* InterfaceDeclaration */ || node.parent.kind === 152 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 213 /* InterfaceDeclaration */ || node.parent.kind === 153 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -22294,7 +22813,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 210 /* FunctionDeclaration */ || node.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */ || node.kind === 141 /* Constructor */) { + if (node.kind === 211 /* FunctionDeclaration */ || node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */ || node.kind === 142 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -22378,8 +22897,6 @@ var ts; if (!produceDiagnostics) { return; } - // Exports should be checked only if enclosing module contains both exported and non exported declarations. - // In case if all declarations are non-exported check is unnecessary. // if localSymbol is defined on node then node itself is exported - check is required var symbol = node.localSymbol; if (!symbol) { @@ -22397,38 +22914,55 @@ var ts; } // we use SymbolFlags.ExportValue, SymbolFlags.ExportType and SymbolFlags.ExportNamespace // to denote disjoint declarationSpaces (without making new enum type). - var exportedDeclarationSpaces = 0; - var nonExportedDeclarationSpaces = 0; - ts.forEach(symbol.declarations, function (d) { + var exportedDeclarationSpaces = 0 /* None */; + var nonExportedDeclarationSpaces = 0 /* None */; + var defaultExportedDeclarationSpaces = 0 /* None */; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - if (getEffectiveDeclarationFlags(d, 1 /* Export */)) { - exportedDeclarationSpaces |= declarationSpaces; + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); + if (effectiveDeclarationFlags & 1 /* Export */) { + if (effectiveDeclarationFlags & 1024 /* Default */) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } } else { nonExportedDeclarationSpaces |= declarationSpaces; } - }); - var commonDeclarationSpace = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - if (commonDeclarationSpace) { + } + // Spaces for anyting not declared a 'default export'. + var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { // declaration spaces for exported and non-exported declarations intersect - ts.forEach(symbol.declarations, function (d) { - if (getDeclarationSpaces(d) & commonDeclarationSpace) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declarationSpaces = getDeclarationSpaces(d); + // Only error on the declarations that conributed to the intersecting spaces. + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); } - }); + } } function getDeclarationSpaces(d) { switch (d.kind) { - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 215 /* ModuleDeclaration */: - return d.name.kind === 8 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ + case 216 /* ModuleDeclaration */: + return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -22505,7 +23039,7 @@ var ts; * The runtime behavior of the `await` keyword. */ function getAwaitedType(type) { - return checkAwaitedType(type, undefined, undefined); + return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); } function checkAwaitedType(type, location, message) { return checkAwaitedTypeWorker(type); @@ -22672,22 +23206,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 135 /* Parameter */: + case 136 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -22700,11 +23234,18 @@ var ts; // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 148 /* TypeReference */) { + if (node && node.kind === 149 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var rootSymbol = resolveName(root, root.text, 107455 /* Value */, undefined, undefined); - if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); + var meaning = root.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + // Resolve type so we know which symbol is referenced + var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + // Resolved symbol is alias + if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */) { + var aliasTarget = resolveAlias(rootSymbol); + // If alias has value symbol - mark alias as referenced + if (aliasTarget.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } } } } @@ -22714,19 +23255,19 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 135 /* Parameter */: + case 136 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -22755,25 +23296,25 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 143 /* SetAccessor */: - case 142 /* GetAccessor */: - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 144 /* SetAccessor */: + case 143 /* GetAccessor */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 135 /* Parameter */) { + if (node.kind === 136 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -22799,7 +23340,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 134 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -22848,11 +23389,11 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 189 /* Block */) { + if (node.kind === 190 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 216 /* ModuleBlock */) { + if (ts.isFunctionBlock(node) || node.kind === 217 /* ModuleBlock */) { checkFunctionAndClassExpressionBodies(node); } } @@ -22871,12 +23412,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 138 /* PropertyDeclaration */ || - node.kind === 137 /* PropertySignature */ || - node.kind === 140 /* MethodDeclaration */ || - node.kind === 139 /* MethodSignature */ || - node.kind === 142 /* GetAccessor */ || - node.kind === 143 /* SetAccessor */) { + if (node.kind === 139 /* PropertyDeclaration */ || + node.kind === 138 /* PropertySignature */ || + node.kind === 141 /* MethodDeclaration */ || + node.kind === 140 /* MethodSignature */ || + node.kind === 143 /* GetAccessor */ || + node.kind === 144 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -22885,7 +23426,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 135 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 136 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -22901,7 +23442,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 66 /* Identifier */; + var isDeclaration_1 = node.kind !== 67 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -22924,7 +23465,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 66 /* Identifier */; + var isDeclaration_2 = node.kind !== 67 /* Identifier */; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -22938,12 +23479,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 215 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 216 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 245 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 246 /* SourceFile */ && ts.isExternalModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -22978,27 +23519,27 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 208 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 209 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); if (symbol.flags & 1 /* FunctionScopedVariable */) { - var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, undefined, undefined); + var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 209 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 190 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 191 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 189 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 216 /* ModuleBlock */ || - container.kind === 215 /* ModuleDeclaration */ || - container.kind === 245 /* SourceFile */); + (container.kind === 190 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 217 /* ModuleBlock */ || + container.kind === 216 /* ModuleDeclaration */ || + container.kind === 246 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -23013,18 +23554,18 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 135 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 136 /* Parameter */) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 66 /* Identifier */) { + if (n.kind === 67 /* Identifier */) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 135 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 136 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -23050,7 +23591,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -23061,14 +23602,14 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 135 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 136 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } return; @@ -23078,7 +23619,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -23090,13 +23631,13 @@ var ts; error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); } } - if (node.kind !== 138 /* PropertyDeclaration */ && node.kind !== 137 /* PropertySignature */) { + if (node.kind !== 139 /* PropertyDeclaration */ && node.kind !== 138 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 208 /* VariableDeclaration */ || node.kind === 160 /* BindingElement */) { + if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -23119,7 +23660,7 @@ var ts; } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && node.parent.kind === 162 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 163 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -23157,12 +23698,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -23182,14 +23723,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 161 /* ArrayLiteralExpression */ || varExpr.kind === 162 /* ObjectLiteralExpression */) { + if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -23197,14 +23738,14 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, + checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, /*constantVariableMessage*/ ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); + checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); } } } @@ -23218,7 +23759,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -23232,7 +23773,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 161 /* ArrayLiteralExpression */ || varExpr.kind === 162 /* ObjectLiteralExpression */) { + if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -23261,7 +23802,7 @@ var ts; } function checkRightHandSideOfForOf(rhsExpression) { var expressionType = getTypeOfExpression(rhsExpression); - return checkIteratedTypeOrElementType(expressionType, rhsExpression, true); + return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true); } function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { if (isTypeAny(inputType)) { @@ -23404,8 +23945,8 @@ var ts; if ((type.flags & 4096 /* Reference */) && type.target === globalIterableIteratorType) { return type.typeArguments[0]; } - return getElementTypeOfIterable(type, undefined) || - getElementTypeOfIterator(type, undefined); + return getElementTypeOfIterable(type, /*errorNode*/ undefined) || + getElementTypeOfIterator(type, /*errorNode*/ undefined); } /** * This function does the following steps: @@ -23428,7 +23969,7 @@ var ts; ts.Debug.assert(languageVersion < 2 /* ES6 */); // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the remaining type is the same as the initial type. - var arrayType = removeTypesFromUnionType(arrayOrStringType, 258 /* StringLike */, true, true); + var arrayType = removeTypesFromUnionType(arrayOrStringType, 258 /* StringLike */, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true); var hasStringConstituent = arrayOrStringType !== arrayType; var reportedError = false; if (hasStringConstituent) { @@ -23471,7 +24012,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 142 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 143 /* SetAccessor */))); + return !!(node.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -23494,10 +24035,10 @@ var ts; // for generators. return; } - if (func.kind === 143 /* SetAccessor */) { + if (func.kind === 144 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 141 /* Constructor */) { + else if (func.kind === 142 /* Constructor */) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -23533,7 +24074,7 @@ var ts; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 239 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 240 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -23545,14 +24086,14 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 238 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 239 /* CaseClause */) { var caseClause = clause; // TypeScript 1.0 spec (April 2014):5.9 // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { // check 'expressionType isAssignableTo caseType' failed, try the reversed check and report errors if it fails - checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); + checkTypeAssignableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined); } } ts.forEach(clause.statements, checkSourceElement); @@ -23566,7 +24107,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 204 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 205 /* LabeledStatement */ && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -23596,7 +24137,7 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 66 /* Identifier */) { + if (catchClause.variableDeclaration.name.kind !== 67 /* Identifier */) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -23671,7 +24212,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 133 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 134 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -23756,6 +24297,7 @@ var ts; if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; var staticBaseType = getBaseConstructorTypeOfClass(type); + checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { @@ -23811,6 +24353,9 @@ var ts; // so we'll need to get back original 'target' symbol to work with correct set of flags return s.flags & 16777216 /* Instantiated */ ? getSymbolLinks(s).target : s; } + function getClassLikeDeclarationOfSymbol(symbol) { + return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); + } function checkKindsOfPropertyMemberOverrides(type, baseType) { // TypeScript 1.0 spec (April 2014): 8.2.3 // A derived class inherits all members from its base class it doesn't override. @@ -23842,12 +24387,17 @@ var ts; // type declaration, derived and base resolve to the same symbol even in the case of generic classes. if (derived === base) { // derived class inherits base without override/redeclaration - var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 211 /* ClassDeclaration */); + var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + if (derivedClassDecl.kind === 184 /* ClassExpression */) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } } } else { @@ -23890,7 +24440,7 @@ var ts; } } function isAccessor(kind) { - return kind === 142 /* GetAccessor */ || kind === 143 /* SetAccessor */; + return kind === 143 /* GetAccessor */ || kind === 144 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -23960,7 +24510,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 212 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -23981,7 +24531,7 @@ var ts; if (symbol && symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 211 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { + if (declaration.kind === 212 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -24014,32 +24564,12 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 133 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 134 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer); - if (autoValue === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (!ambient) { - // Only here do we need to check that the initializer is assignable to the enum type. - // If it is a constant value (not undefined), it is syntactically constrained to be a number. - // Also, we do not need to check this for ambients because there is already - // a syntax error if it is not a constant. - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); - } - } - else if (enumIsConst) { - if (isNaN(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { autoValue = undefined; @@ -24050,22 +24580,48 @@ var ts; }); nodeLinks.flags |= 8192 /* EnumValuesComputed */; } - function getConstantValueForEnumMemberInitializer(initializer) { - return evalConstant(initializer); + function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { + // Controls if error should be reported after evaluation of constant value is completed + // Can be false if another more precise error was already reported during evaluation. + var reportError = true; + var value = evalConstant(initializer); + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + // Only here do we need to check that the initializer is assignable to the enum type. + // If it is a constant value (not undefined), it is syntactically constrained to be a number. + // Also, we do not need to check this for ambients because there is already + // a syntax error if it is not a constant. + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + return value; function evalConstant(e) { switch (e.kind) { - case 176 /* PrefixUnaryExpression */: - var value = evalConstant(e.operand); - if (value === undefined) { + case 177 /* PrefixUnaryExpression */: + var value_1 = evalConstant(e.operand); + if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 34 /* PlusToken */: return value; - case 35 /* MinusToken */: return -value; - case 48 /* TildeToken */: return ~value; + case 35 /* PlusToken */: return value_1; + case 36 /* MinusToken */: return -value_1; + case 49 /* TildeToken */: return ~value_1; } return undefined; - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -24075,41 +24631,41 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 45 /* BarToken */: return left | right; - case 44 /* AmpersandToken */: return left & right; - case 42 /* GreaterThanGreaterThanToken */: return left >> right; - case 43 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 41 /* LessThanLessThanToken */: return left << right; - case 46 /* CaretToken */: return left ^ right; - case 36 /* AsteriskToken */: return left * right; - case 37 /* SlashToken */: return left / right; - case 34 /* PlusToken */: return left + right; - case 35 /* MinusToken */: return left - right; - case 38 /* PercentToken */: return left % right; + case 46 /* BarToken */: return left | right; + case 45 /* AmpersandToken */: return left & right; + case 43 /* GreaterThanGreaterThanToken */: return left >> right; + case 44 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 42 /* LessThanLessThanToken */: return left << right; + case 47 /* CaretToken */: return left ^ right; + case 37 /* AsteriskToken */: return left * right; + case 38 /* SlashToken */: return left / right; + case 35 /* PlusToken */: return left + right; + case 36 /* MinusToken */: return left - right; + case 39 /* PercentToken */: return left % right; } return undefined; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return +e.text; - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 66 /* Identifier */: - case 164 /* ElementAccessExpression */: - case 163 /* PropertyAccessExpression */: + case 67 /* Identifier */: + case 165 /* ElementAccessExpression */: + case 164 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType; + var enumType_1; var propertyName; - if (e.kind === 66 /* Identifier */) { + if (e.kind === 67 /* Identifier */) { // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. // instead pick current enum type and later try to fetch member from the type - enumType = currentType; + enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 164 /* ElementAccessExpression */) { + if (e.kind === 165 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || - e.argumentExpression.kind !== 8 /* StringLiteral */) { + e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; } expression = e.expression; @@ -24122,26 +24678,26 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 66 /* Identifier */) { + if (current.kind === 67 /* Identifier */) { break; } - else if (current.kind === 163 /* PropertyAccessExpression */) { + else if (current.kind === 164 /* PropertyAccessExpression */) { current = current.expression; } else { return undefined; } } - enumType = checkExpression(expression); + enumType_1 = checkExpression(expression); // allow references to constant members of other enums - if (!(enumType.symbol && (enumType.symbol.flags & 384 /* Enum */))) { + if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384 /* Enum */))) { return undefined; } } if (propertyName === undefined) { return undefined; } - var property = getPropertyOfObjectType(enumType, propertyName); + var property = getPropertyOfObjectType(enumType_1, propertyName); if (!property || !(property.flags & 8 /* EnumMember */)) { return undefined; } @@ -24152,6 +24708,8 @@ var ts; } // illegal case: forward reference if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; } return getNodeLinks(propertyDecl).enumMemberValue; @@ -24194,7 +24752,7 @@ var ts; var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 214 /* EnumDeclaration */) { + if (declaration.kind !== 215 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -24217,8 +24775,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 211 /* ClassDeclaration */ || - (declaration.kind === 210 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 212 /* ClassDeclaration */ || + (declaration.kind === 211 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -24241,7 +24799,7 @@ var ts; function checkModuleDeclaration(node) { if (produceDiagnostics) { // Grammar checking - var isAmbientExternalModule = node.name.kind === 8 /* StringLiteral */; + var isAmbientExternalModule = node.name.kind === 9 /* StringLiteral */; var contextErrorMessage = isAmbientExternalModule ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -24250,7 +24808,7 @@ var ts; return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 8 /* StringLiteral */) { + if (!ts.isInAmbientContext(node) && node.name.kind === 9 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -24274,7 +24832,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 211 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 212 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -24294,28 +24852,28 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 132 /* QualifiedName */) { + if (node.kind === 133 /* QualifiedName */) { node = node.left; } - else if (node.kind === 163 /* PropertyAccessExpression */) { + else if (node.kind === 164 /* PropertyAccessExpression */) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 66 /* Identifier */); + ts.Debug.assert(node.kind === 67 /* Identifier */); return node; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 8 /* StringLiteral */) { + if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9 /* StringLiteral */) { error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 216 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 245 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 225 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 226 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -24338,7 +24896,7 @@ var ts; (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 227 /* ExportSpecifier */ ? + var message = node.kind === 228 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -24365,7 +24923,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -24402,7 +24960,7 @@ var ts; } } else { - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES6 */ && !ts.isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); } @@ -24422,8 +24980,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 216 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 245 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -24437,7 +24995,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 245 /* SourceFile */ && node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 215 /* ModuleDeclaration */) { + if (node.parent.kind !== 246 /* SourceFile */ && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 216 /* ModuleDeclaration */) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -24452,8 +25010,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 245 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 215 /* ModuleDeclaration */ && container.name.kind === 66 /* Identifier */) { + var container = node.parent.kind === 246 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 216 /* ModuleDeclaration */ && container.name.kind === 67 /* Identifier */) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -24461,7 +25019,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { markExportAsReferenced(node); } else { @@ -24480,10 +25038,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 245 /* SourceFile */) { + if (node.kind === 246 /* SourceFile */) { return node.statements; } - if (node.kind === 215 /* ModuleDeclaration */ && node.body.kind === 216 /* ModuleBlock */) { + if (node.kind === 216 /* ModuleDeclaration */ && node.body.kind === 217 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -24522,118 +25080,118 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessivly // hitting the cancellation token on every node we check. switch (kind) { - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return checkTypeParameter(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return checkParameter(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return checkPropertyDeclaration(node); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return checkSignatureDeclaration(node); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return checkMethodDeclaration(node); - case 141 /* Constructor */: + case 142 /* Constructor */: return checkConstructorDeclaration(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return checkAccessorDeclaration(node); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return checkTypeReferenceNode(node); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return checkTypePredicate(node); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return checkTypeQuery(node); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return checkTypeLiteral(node); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return checkArrayType(node); - case 154 /* TupleType */: + case 155 /* TupleType */: return checkTupleType(node); - case 155 /* UnionType */: - case 156 /* IntersectionType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return checkSourceElement(node.type); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return checkBlock(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return checkVariableStatement(node); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return checkExpressionStatement(node); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return checkIfStatement(node); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return checkDoStatement(node); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return checkWhileStatement(node); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return checkForStatement(node); - case 197 /* ForInStatement */: + case 198 /* ForInStatement */: return checkForInStatement(node); - case 198 /* ForOfStatement */: + case 199 /* ForOfStatement */: return checkForOfStatement(node); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return checkReturnStatement(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return checkWithStatement(node); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return checkSwitchStatement(node); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return checkLabeledStatement(node); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return checkThrowStatement(node); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return checkTryStatement(node); - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 160 /* BindingElement */: + case 161 /* BindingElement */: return checkBindingElement(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return checkClassDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return checkImportDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return checkExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return checkExportAssignment(node); - case 191 /* EmptyStatement */: + case 192 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 228 /* MissingDeclaration */: + case 229 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -24648,95 +25206,97 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: ts.forEach(node.members, checkSourceElement); break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 202 /* WithStatement */: + case 203 /* WithStatement */: checkFunctionAndClassExpressionBodies(node.expression); break; - case 136 /* Decorator */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 160 /* BindingElement */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 242 /* PropertyAssignment */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 167 /* TaggedTemplateExpression */: - case 180 /* TemplateExpression */: - case 187 /* TemplateSpan */: - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: - case 169 /* ParenthesizedExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 175 /* AwaitExpression */: - case 172 /* DeleteExpression */: - case 176 /* PrefixUnaryExpression */: - case 177 /* PostfixUnaryExpression */: - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 181 /* YieldExpression */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 190 /* VariableStatement */: - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 217 /* CaseBlock */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 205 /* ThrowStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: - case 208 /* VariableDeclaration */: - case 209 /* VariableDeclarationList */: - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 224 /* ExportAssignment */: - case 245 /* SourceFile */: - case 237 /* JsxExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 235 /* JsxAttribute */: - case 236 /* JsxSpreadAttribute */: - case 232 /* JsxOpeningElement */: + case 137 /* Decorator */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 161 /* BindingElement */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 243 /* PropertyAssignment */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 168 /* TaggedTemplateExpression */: + case 181 /* TemplateExpression */: + case 188 /* TemplateSpan */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: + case 170 /* ParenthesizedExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 176 /* AwaitExpression */: + case 173 /* DeleteExpression */: + case 177 /* PrefixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 182 /* YieldExpression */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 191 /* VariableStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 218 /* CaseBlock */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 206 /* ThrowStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: + case 209 /* VariableDeclaration */: + case 210 /* VariableDeclarationList */: + case 212 /* ClassDeclaration */: + case 241 /* HeritageClause */: + case 186 /* ExpressionWithTypeArguments */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 225 /* ExportAssignment */: + case 246 /* SourceFile */: + case 238 /* JsxExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + case 233 /* JsxOpeningElement */: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -24822,7 +25382,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 202 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 203 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -24845,25 +25405,25 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } // fall through; this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -24872,13 +25432,16 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 170 /* FunctionExpression */: + case 171 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); } break; } + if (ts.introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } memberFlags = location.flags; location = location.parent; } @@ -24912,43 +25475,43 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 66 /* Identifier */ && + return name.kind === 67 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 134 /* TypeParameter */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: + case 135 /* TypeParameter */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 132 /* QualifiedName */) { + while (node.parent && node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 148 /* TypeReference */; + return node.parent && node.parent.kind === 149 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 163 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 164 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 185 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 186 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 132 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 133 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 218 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 219 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 224 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 225 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -24960,11 +25523,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 224 /* ExportAssignment */) { + if (entityName.parent.kind === 225 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 163 /* PropertyAccessExpression */) { + if (entityName.kind !== 164 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -24974,11 +25537,13 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 185 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 186 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 232 /* JsxOpeningElement */) || (entityName.parent.kind === 231 /* JsxSelfClosingElement */)) { + else if ((entityName.parent.kind === 233 /* JsxOpeningElement */) || + (entityName.parent.kind === 232 /* JsxSelfClosingElement */) || + (entityName.parent.kind === 235 /* JsxClosingElement */)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { @@ -24986,20 +25551,20 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 66 /* Identifier */) { + if (entityName.kind === 67 /* Identifier */) { // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 163 /* PropertyAccessExpression */) { + else if (entityName.kind === 164 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 132 /* QualifiedName */) { + else if (entityName.kind === 133 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -25008,22 +25573,22 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 148 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 235 /* JsxAttribute */) { + else if (entityName.parent.kind === 236 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 147 /* TypePredicate */) { - return resolveEntityName(entityName, 1 /* FunctionScopedVariable */); + if (entityName.parent.kind === 148 /* TypePredicate */) { + return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } - function getSymbolInfo(node) { + function getSymbolAtLocation(node) { if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; @@ -25032,39 +25597,50 @@ var ts; // This is a declaration, call getSymbolOfNode return getSymbolOfNode(node.parent); } - if (node.kind === 66 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 224 /* ExportAssignment */ - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); + if (node.kind === 67 /* Identifier */) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 225 /* ExportAssignment */ + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === 161 /* BindingElement */ && + node.parent.parent.kind === 159 /* ObjectBindingPattern */ && + node === node.parent.propertyName) { + var typeOfPattern = getTypeOfNode(node.parent.parent); + var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } } switch (node.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: var type = checkExpression(node); return type.symbol; - case 118 /* ConstructorKeyword */: + case 119 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 141 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 142 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 219 /* ImportDeclaration */ || node.parent.kind === 225 /* ExportDeclaration */) && + ((node.parent.kind === 220 /* ImportDeclaration */ || node.parent.kind === 226 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Fall through - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -25081,7 +25657,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 243 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 244 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -25103,28 +25679,28 @@ var ts; return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; } if (isTypeDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); } if (ts.isDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); return getTypeOfSymbol(symbol); } if (ts.isDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getTypeOfSymbol(symbol); } if (ts.isBindingPattern(node)) { return getTypeForVariableLikeDeclaration(node.parent); } if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } @@ -25165,7 +25741,10 @@ var ts; var symbols = []; var name_15 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - symbols.push(getPropertyOfType(t, name_15)); + var symbol = getPropertyOfType(t, name_15); + if (symbol) { + symbols.push(symbol); + } }); return symbols; } @@ -25195,11 +25774,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 245 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 246 /* SourceFile */) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 215 /* ModuleDeclaration */ || n.kind === 214 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 216 /* ModuleDeclaration */ || n.kind === 215 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -25214,11 +25793,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 189 /* Block */: - case 217 /* CaseBlock */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 190 /* Block */: + case 218 /* CaseBlock */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return true; } return false; @@ -25229,7 +25808,7 @@ var ts; if (links.isNestedRedeclaration === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, 107455 /* Value */, undefined, undefined); + !!resolveName(container.parent, symbol.name, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); } return links.isNestedRedeclaration; } @@ -25248,22 +25827,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 224 /* ExportAssignment */: - return node.expression && node.expression.kind === 66 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 225 /* ExportAssignment */: + return node.expression && node.expression.kind === 67 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 245 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 246 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -25276,7 +25855,11 @@ var ts; return true; } // const enums and modules that contain only const enums are not considered values from the emit perespective - return target !== unknownSymbol && target && target.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(target); + // unless 'preserveConstEnums' option is set to true + return target !== unknownSymbol && + target && + target.flags & 107455 /* Value */ && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || s.constEnumOnlyModule; @@ -25321,7 +25904,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 244 /* EnumMember */) { + if (node.kind === 245 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -25336,14 +25919,20 @@ var ts; function isFunctionType(type) { return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 0 /* Call */).length > 0; } - function getTypeReferenceSerializationKind(node) { + function getTypeReferenceSerializationKind(typeName) { // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var symbol = resolveEntityName(node.typeName, 107455 /* Value */, true); - var constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + var valueSymbol = resolveEntityName(typeName, 107455 /* Value */, /*ignoreErrors*/ true); + var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; if (constructorType && isConstructorType(constructorType)) { return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; } - var type = getTypeFromTypeNode(node); + // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. + var typeSymbol = resolveEntityName(typeName, 793056 /* Type */, /*ignoreErrors*/ true); + // We might not be able to resolve type symbol so use unknown type in that case (eg error case) + if (!typeSymbol) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + var type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } @@ -25365,7 +25954,7 @@ var ts; else if (allConstituentTypesHaveKind(type, 8192 /* Tuple */)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, 4194304 /* ESSymbol */)) { + else if (allConstituentTypesHaveKind(type, 16777216 /* ESSymbol */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -25400,7 +25989,7 @@ var ts; function getReferencedValueSymbol(reference) { return getNodeLinks(reference).resolvedSymbol || resolveName(reference, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, - /*nodeNotFoundMessage*/ undefined, undefined); + /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); } function getReferencedValueDeclaration(reference) { ts.Debug.assert(!ts.nodeIsSynthesized(reference)); @@ -25409,13 +25998,13 @@ var ts; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 160 /* BindingElement */ || (n.parent.kind === 208 /* VariableDeclaration */ && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 161 /* BindingElement */ || (n.parent.kind === 209 /* VariableDeclaration */ && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || - resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); + resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); var isLetOrConst = symbol && (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 241 /* CatchClause */; + symbol.valueDeclaration.parent.kind !== 242 /* CatchClause */; if (isLetOrConst) { // side-effect of calling this method: // assign id to symbol if it was not yet set @@ -25457,7 +26046,8 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter }; } function initializeTypeChecker() { @@ -25477,7 +26067,7 @@ var ts; getSymbolLinks(unknownSymbol).type = unknownType; globals[undefinedSymbol.name] = undefinedSymbol; // Initialize special types - globalArrayType = getGlobalType("Array", 1); + globalArrayType = getGlobalType("Array", /*arity*/ 1); globalObjectType = getGlobalType("Object"); globalFunctionType = getGlobalType("Function"); globalStringType = getGlobalType("String"); @@ -25489,10 +26079,10 @@ var ts; getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); - getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); - getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); - tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, undefined) && getGlobalPromiseType(); }); - getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); + getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", /*arity*/ 1); }); + getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", /*arity*/ 1); }); + tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, /*diagnostic*/ undefined) && getGlobalPromiseType(); }); + getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", /*arity*/ 1); }); getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); @@ -25503,9 +26093,9 @@ var ts; globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); - globalIterableType = getGlobalType("Iterable", 1); - globalIteratorType = getGlobalType("Iterator", 1); - globalIterableIteratorType = getGlobalType("IterableIterator", 1); + globalIterableType = getGlobalType("Iterable", /*arity*/ 1); + globalIteratorType = getGlobalType("Iterator", /*arity*/ 1); + globalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1); } else { globalTemplateStringsArrayType = unknownType; @@ -25522,7 +26112,7 @@ var ts; } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyObjectType) { + if (promiseLikeType !== emptyGenericType) { return createTypeReference(promiseLikeType, [anyType]); } return emptyObjectType; @@ -25549,7 +26139,7 @@ var ts; else if (languageVersion < 1 /* ES5 */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 142 /* GetAccessor */ || node.kind === 143 /* SetAccessor */) { + else if (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -25559,38 +26149,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: - case 215 /* ModuleDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 225 /* ExportDeclaration */: - case 224 /* ExportAssignment */: - case 135 /* Parameter */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: + case 216 /* ModuleDeclaration */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + case 225 /* ExportAssignment */: + case 136 /* Parameter */: break; - case 210 /* FunctionDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 115 /* AsyncKeyword */) && - node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 211 /* FunctionDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116 /* AsyncKeyword */) && + node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 190 /* VariableStatement */: - case 213 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 191 /* VariableStatement */: + case 214 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 214 /* EnumDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 71 /* ConstKeyword */) && - node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 215 /* EnumDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72 /* ConstKeyword */) && + node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -25605,14 +26195,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { - case 109 /* PublicKeyword */: - case 108 /* ProtectedKeyword */: - case 107 /* PrivateKeyword */: + case 110 /* PublicKeyword */: + case 109 /* ProtectedKeyword */: + case 108 /* PrivateKeyword */: var text = void 0; - if (modifier.kind === 109 /* PublicKeyword */) { + if (modifier.kind === 110 /* PublicKeyword */) { text = "public"; } - else if (modifier.kind === 108 /* ProtectedKeyword */) { + else if (modifier.kind === 109 /* ProtectedKeyword */) { text = "protected"; lastProtected = modifier; } @@ -25629,11 +26219,11 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256 /* Abstract */) { - if (modifier.kind === 107 /* PrivateKeyword */) { + if (modifier.kind === 108 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -25642,17 +26232,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 110 /* StaticKeyword */: + case 111 /* StaticKeyword */: if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256 /* Abstract */) { @@ -25661,7 +26251,7 @@ var ts; flags |= 128 /* Static */; lastStatic = modifier; break; - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -25674,42 +26264,42 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 119 /* DeclareKeyword */: + case 120 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 216 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 112 /* AbstractKeyword */: + case 113 /* AbstractKeyword */: if (flags & 256 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 211 /* ClassDeclaration */) { - if (node.kind !== 140 /* MethodDeclaration */) { + if (node.kind !== 212 /* ClassDeclaration */) { + if (node.kind !== 141 /* MethodDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 211 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + if (!(node.parent.kind === 212 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128 /* Static */) { @@ -25721,14 +26311,14 @@ var ts; } flags |= 256 /* Abstract */; break; - case 115 /* AsyncKeyword */: + case 116 /* AsyncKeyword */: if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512 /* Async */; @@ -25736,7 +26326,7 @@ var ts; break; } } - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -25754,10 +26344,10 @@ var ts; } return; } - else if ((node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 135 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 136 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512 /* Async */) { @@ -25769,10 +26359,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 140 /* MethodDeclaration */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -25820,16 +26410,14 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken || parameter.initializer) { + else if (parameter.questionToken) { seenOptionalParameter = true; - if (parameter.questionToken && parameter.initializer) { + if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } - else { - if (seenOptionalParameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); } } } @@ -25840,7 +26428,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 171 /* ArrowFunction */) { + if (node.kind === 172 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -25875,7 +26463,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 127 /* StringKeyword */ && parameter.type.kind !== 125 /* NumberKeyword */) { + if (parameter.type.kind !== 128 /* StringKeyword */ && parameter.type.kind !== 126 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -25908,7 +26496,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 184 /* OmittedExpression */) { + if (arg.kind === 185 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -25935,7 +26523,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80 /* ExtendsKeyword */) { + if (heritageClause.token === 81 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -25948,7 +26536,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -25964,14 +26552,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80 /* ExtendsKeyword */) { + if (heritageClause.token === 81 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -25982,19 +26570,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 133 /* ComputedPropertyName */) { + if (node.kind !== 134 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 178 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { + if (computedPropertyName.expression.kind === 179 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -26020,8 +26608,8 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_16 = prop.name; - if (prop.kind === 184 /* OmittedExpression */ || - name_16.kind === 133 /* ComputedPropertyName */) { + if (prop.kind === 185 /* OmittedExpression */ || + name_16.kind === 134 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_16); continue; @@ -26035,21 +26623,21 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 242 /* PropertyAssignment */ || prop.kind === 243 /* ShorthandPropertyAssignment */) { + if (prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_16.kind === 7 /* NumericLiteral */) { + if (name_16.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name_16); } currentKind = Property; } - else if (prop.kind === 140 /* MethodDeclaration */) { + else if (prop.kind === 141 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 142 /* GetAccessor */) { + else if (prop.kind === 143 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 143 /* SetAccessor */) { + else if (prop.kind === 144 /* SetAccessor */) { currentKind = SetAccesor; } else { @@ -26081,7 +26669,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 236 /* JsxSpreadAttribute */) { + if (attr.kind === 237 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; @@ -26093,7 +26681,7 @@ var ts; return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 237 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 238 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -26102,24 +26690,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 209 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 210 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -26142,10 +26730,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 142 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 143 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 143 /* SetAccessor */) { + else if (kind === 144 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -26170,7 +26758,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 133 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 134 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -26180,7 +26768,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 162 /* ObjectLiteralExpression */) { + if (node.parent.kind === 163 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -26204,22 +26792,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 212 /* InterfaceDeclaration */) { + else if (node.parent.kind === 213 /* InterfaceDeclaration */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 152 /* TypeLiteral */) { + else if (node.parent.kind === 153 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: return true; - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -26231,26 +26819,26 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 199 /* ContinueStatement */ - && !isIterationStatement(current.statement, true); + var isMisplacedContinueLabel = node.kind === 200 /* ContinueStatement */ + && !isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); } return false; } break; - case 203 /* SwitchStatement */: - if (node.kind === 200 /* BreakStatement */ && !node.label) { + case 204 /* SwitchStatement */: + if (node.kind === 201 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } break; default: - if (isIterationStatement(current, false) && !node.label) { + if (isIterationStatement(current, /*lookInLabeledStatement*/ false) && !node.label) { // unlabeled break or continue within iteration statement - ok return false; } @@ -26259,13 +26847,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 200 /* BreakStatement */ + var message = node.kind === 201 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 200 /* BreakStatement */ + var message = node.kind === 201 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -26277,7 +26865,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 159 /* ArrayBindingPattern */ || node.name.kind === 158 /* ObjectBindingPattern */) { + if (node.name.kind === 160 /* ArrayBindingPattern */ || node.name.kind === 159 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -26287,7 +26875,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 197 /* ForInStatement */ && node.parent.parent.kind !== 198 /* ForOfStatement */) { + if (node.parent.parent.kind !== 198 /* ForInStatement */ && node.parent.parent.kind !== 199 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -26314,7 +26902,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -26323,7 +26911,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 184 /* OmittedExpression */) { + if (element.kind !== 185 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -26340,15 +26928,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return false; - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -26364,13 +26952,13 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 176 /* PrefixUnaryExpression */) { + if (expression.kind === 177 /* PrefixUnaryExpression */) { var unaryExpression = expression; - if (unaryExpression.operator === 34 /* PlusToken */ || unaryExpression.operator === 35 /* MinusToken */) { + if (unaryExpression.operator === 35 /* PlusToken */ || unaryExpression.operator === 36 /* MinusToken */) { expression = unaryExpression.operand; } } - if (expression.kind === 7 /* NumericLiteral */) { + if (expression.kind === 8 /* NumericLiteral */) { // Allows for scientific notation since literalExpression.text was formed by // coercing a number to a string. Sometimes this coercion can yield a string // in scientific notation. @@ -26393,7 +26981,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -26436,7 +27024,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -26456,12 +27044,12 @@ var ts; return true; } } - else if (node.parent.kind === 212 /* InterfaceDeclaration */) { + else if (node.parent.kind === 213 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 152 /* TypeLiteral */) { + else if (node.parent.kind === 153 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -26481,11 +27069,11 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 212 /* InterfaceDeclaration */ || - node.kind === 219 /* ImportDeclaration */ || - node.kind === 218 /* ImportEqualsDeclaration */ || - node.kind === 225 /* ExportDeclaration */ || - node.kind === 224 /* ExportAssignment */ || + if (node.kind === 213 /* InterfaceDeclaration */ || + node.kind === 220 /* ImportDeclaration */ || + node.kind === 219 /* ImportEqualsDeclaration */ || + node.kind === 226 /* ExportDeclaration */ || + node.kind === 225 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || (node.flags & (1 /* Export */ | 1024 /* Default */))) { return false; @@ -26495,7 +27083,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 190 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 191 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -26521,7 +27109,7 @@ var ts; // to prevent noisyness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 189 /* Block */ || node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + if (node.parent.kind === 190 /* Block */ || node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -26542,7 +27130,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), /*length*/ 0, message, arg0, arg1, arg2)); return true; } } @@ -26603,7 +27191,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 219 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 220 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -26679,10 +27267,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 208 /* VariableDeclaration */) { + if (declaration.kind === 209 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 222 /* NamedImports */ || declaration.kind === 223 /* ImportSpecifier */ || declaration.kind === 220 /* ImportClause */) { + else if (declaration.kind === 223 /* NamedImports */ || declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 221 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -26700,7 +27288,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 219 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 220 /* ImportDeclaration */) { // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; @@ -26710,12 +27298,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 215 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 215 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -26798,7 +27386,7 @@ var ts; var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); // jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, jsDocComments, true, newLine, ts.writeCommentRange); + ts.emitComments(currentSourceFile, writer, jsDocComments, /*trailingSeparator*/ true, newLine, ts.writeCommentRange); } } function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { @@ -26807,49 +27395,49 @@ var ts; } function emitType(type) { switch (type.kind) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: - case 8 /* StringLiteral */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: + case 9 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return emitTypeReference(type); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return emitTypeQuery(type); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return emitArrayType(type); - case 154 /* TupleType */: + case 155 /* TupleType */: return emitTupleType(type); - case 155 /* UnionType */: + case 156 /* UnionType */: return emitUnionType(type); - case 156 /* IntersectionType */: + case 157 /* IntersectionType */: return emitIntersectionType(type); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return emitParenType(type); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return emitTypeLiteral(type); - case 66 /* Identifier */: + case 67 /* Identifier */: return emitEntityName(type); - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return emitEntityName(type); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 66 /* Identifier */) { + if (entityName.kind === 67 /* Identifier */) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 132 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 132 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 133 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 133 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -26858,13 +27446,13 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 218 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 219 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 66 /* Identifier */ || node.expression.kind === 163 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 67 /* Identifier */ || node.expression.kind === 164 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -26945,7 +27533,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -26965,7 +27553,7 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); @@ -26984,10 +27572,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 218 /* ImportEqualsDeclaration */ || - (node.parent.kind === 245 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 219 /* ImportEqualsDeclaration */ || + (node.parent.kind === 246 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 245 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -26997,7 +27585,7 @@ var ts; }); } else { - if (node.kind === 219 /* ImportDeclaration */) { + if (node.kind === 220 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -27015,23 +27603,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return writeVariableStatement(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return writeClassDeclaration(node); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -27047,7 +27635,7 @@ var ts; if (node.flags & 1024 /* Default */) { write("default "); } - else if (node.kind !== 212 /* InterfaceDeclaration */) { + else if (node.kind !== 213 /* InterfaceDeclaration */) { write("declare "); } } @@ -27096,7 +27684,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 221 /* NamespaceImport */) { + if (namedBindings.kind === 222 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -27124,7 +27712,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -27182,7 +27770,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 216 /* ModuleBlock */) { + while (node.body.kind !== 217 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -27199,14 +27787,18 @@ var ts; enclosingDeclaration = prevEnclosingDeclaration; } function writeTypeAliasDeclaration(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; emitJsDocComments(node); emitModuleElementDeclarationFlags(node); write("type "); writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); write(" = "); emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, @@ -27243,7 +27835,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 140 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 141 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -27254,15 +27846,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 152 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 140 /* MethodDeclaration */ || - node.parent.kind === 139 /* MethodSignature */ || - node.parent.kind === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - node.parent.kind === 144 /* CallSignature */ || - node.parent.kind === 145 /* ConstructSignature */); + if (node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 153 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 141 /* MethodDeclaration */ || + node.parent.kind === 140 /* MethodSignature */ || + node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + node.parent.kind === 145 /* CallSignature */ || + node.parent.kind === 146 /* ConstructSignature */); emitType(node.constraint); } else { @@ -27273,31 +27865,31 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 144 /* CallSignature */: + case 145 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 212 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -27325,10 +27917,13 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } + else if (!isImplementsList && node.expression.kind === 91 /* NullKeyword */) { + write("null"); + } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 211 /* ClassDeclaration */) { + if (node.parent.parent.kind === 212 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -27368,9 +27963,9 @@ var ts; emitTypeParameters(node.typeParameters); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); + emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), true); + emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); write(" {"); writeLine(); increaseIndent(); @@ -27389,7 +27984,7 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false); write(" {"); writeLine(); increaseIndent(); @@ -27412,7 +28007,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 208 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 209 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -27422,10 +28017,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) && node.parent.kind === 152 /* TypeLiteral */) { + if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && node.parent.kind === 153 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -27434,14 +28029,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 208 /* VariableDeclaration */) { + if (node.kind === 209 /* VariableDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) { + else if (node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -27450,7 +28045,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -27482,7 +28077,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 184 /* OmittedExpression */) { + if (element.kind !== 185 /* OmittedExpression */) { elements.push(element); } } @@ -27503,7 +28098,7 @@ var ts; } else { writeTextOfNode(currentSourceFile, bindingElement.name); - writeTypeOfDeclaration(bindingElement, undefined, getBindingElementTypeVisibilityError); + writeTypeOfDeclaration(bindingElement, /*type*/ undefined, getBindingElementTypeVisibilityError); } } } @@ -27552,7 +28147,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 142 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 143 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -27565,7 +28160,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 142 /* GetAccessor */ + return accessor.kind === 143 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -27574,7 +28169,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 143 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 144 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -27624,17 +28219,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 140 /* MethodDeclaration */) { + else if (node.kind === 141 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 141 /* Constructor */) { + else if (node.kind === 142 /* Constructor */) { write("constructor"); } else { @@ -27652,11 +28247,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 145 /* ConstructSignature */ || node.kind === 150 /* ConstructorType */) { + if (node.kind === 146 /* ConstructSignature */ || node.kind === 151 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { write("["); } else { @@ -27666,22 +28261,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 149 /* FunctionType */ || node.kind === 150 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 152 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 150 /* FunctionType */ || node.kind === 151 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 153 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 141 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 142 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -27692,26 +28287,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 144 /* CallSignature */: + case 145 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -27719,7 +28314,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -27733,7 +28328,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -27764,13 +28359,13 @@ var ts; else { writeTextOfNode(currentSourceFile, node.name); } - if (node.initializer || ts.hasQuestionToken(node)) { + if (resolver.isOptionalParameter(node)) { write("?"); } decreaseIndent(); - if (node.parent.kind === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - node.parent.parent.kind === 152 /* TypeLiteral */) { + if (node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + node.parent.parent.kind === 153 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -27786,24 +28381,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 141 /* Constructor */: + case 142 /* Constructor */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 144 /* CallSignature */: + case 145 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -27811,7 +28406,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 212 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -27824,7 +28419,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -27836,12 +28431,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 158 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 159 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 159 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 160 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -27860,7 +28455,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 184 /* OmittedExpression */) { + if (bindingElement.kind === 185 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -27869,7 +28464,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 160 /* BindingElement */) { + else if (bindingElement.kind === 161 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -27879,10 +28474,8 @@ var ts; // emit : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void; writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); - // If bindingElement has propertyName property, then its name must be another bindingPattern of SyntaxKind.ObjectBindingPattern - emitBindingPattern(bindingElement.name); } - else if (bindingElement.name) { + if (bindingElement.name) { if (ts.isBindingPattern(bindingElement.name)) { // If it is a nested binding pattern, we will recursively descend into each element and emit each one separately. // In the case of rest element, we will omit rest element. @@ -27894,7 +28487,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 66 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 67 /* Identifier */); // If the node is just an identifier, we will simply emit the text associated with the node's name // Example: // original: function foo({y = 10, x}) {} @@ -27910,40 +28503,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 215 /* ModuleDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 212 /* InterfaceDeclaration */: - case 211 /* ClassDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: + case 211 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 213 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible - return emitModuleElement(node, !node.importClause); - case 225 /* ExportDeclaration */: + return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); + case 226 /* ExportDeclaration */: return emitExportDeclaration(node); - case 141 /* Constructor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 142 /* Constructor */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return writeFunctionDeclaration(node); - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 146 /* IndexSignature */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 147 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return emitAccessorDeclaration(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return emitPropertyDeclaration(node); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return emitExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return emitSourceFile(node); } } @@ -27952,7 +28545,7 @@ var ts; ? referencedFile.fileName // Declaration file, use declaration file name : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file - : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; // Global out file + : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; // Global out file declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); referencePathsOutput += "/// " + newLine; @@ -28026,18 +28619,18 @@ var ts; emitFile(jsFilePath, sourceFile); } }); - if (compilerOptions.out) { - emitFile(compilerOptions.out); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } else { // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ts.forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } - else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { - emitFile(compilerOptions.out); + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } // Sort and make the unique list of diagnostics @@ -28068,11 +28661,7 @@ var ts; } function emitJavaScript(jsFilePath, root) { var writer = ts.createTextWriter(newLine); - var write = writer.write; - var writeTextOfNode = writer.writeTextOfNode; - var writeLine = writer.writeLine; - var increaseIndent = writer.increaseIndent; - var decreaseIndent = writer.decreaseIndent; + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var currentSourceFile; // name of an exporter function if file is a System external module // System.register([...], function () {...}) @@ -28100,7 +28689,7 @@ var ts; var detachedCommentsInfo; var writeComment = ts.writeCommentRange; /** Emit a node */ - var emit = emitNodeWithoutSourceMap; + var emit = emitNodeWithCommentsAndWithoutSourcemap; /** Called just before starting emit of a node */ var emitStart = function (node) { }; /** Called once the emit of the node is done */ @@ -28120,6 +28709,8 @@ var ts; var scopeEmitEnd = function () { }; /** Sourcemap data that will get encoded */ var sourceMapData; + /** If removeComments is true, no leading-comments needed to be emitted **/ + var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); } @@ -28135,7 +28726,7 @@ var ts; }); } writeLine(); - writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); + writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); return; function emitSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -28195,7 +28786,7 @@ var ts; } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 /* StringLiteral */ ? + var baseName = expr.kind === 9 /* StringLiteral */ ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; return makeUniqueName(baseName); } @@ -28207,19 +28798,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return makeUniqueName(node.text); - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 219 /* ImportDeclaration */: - case 225 /* ExportDeclaration */: + case 220 /* ImportDeclaration */: + case 226 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 210 /* FunctionDeclaration */: - case 211 /* ClassDeclaration */: - case 224 /* ExportAssignment */: + case 211 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: + case 225 /* ExportAssignment */: return generateNameForExportDefault(); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return generateNameForClassExpression(); } } @@ -28285,7 +28876,7 @@ var ts; function base64VLQFormatEncode(inValue) { function base64FormatEncode(inValue) { if (inValue < 64) { - return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue); + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); } throw TypeError(inValue + ": not a 64 based value"); } @@ -28391,7 +28982,7 @@ var ts; // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. var name_21 = node.name; - if (!name_21 || name_21.kind !== 133 /* ComputedPropertyName */) { + if (!name_21 || name_21.kind !== 134 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -28409,20 +29000,20 @@ var ts; // The scope was already given a name use it recordScopeNameStart(scopeName); } - else if (node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */ || - node.kind === 139 /* MethodSignature */ || - node.kind === 142 /* GetAccessor */ || - node.kind === 143 /* SetAccessor */ || - node.kind === 215 /* ModuleDeclaration */ || - node.kind === 211 /* ClassDeclaration */ || - node.kind === 214 /* EnumDeclaration */) { + else if (node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */ || + node.kind === 140 /* MethodSignature */ || + node.kind === 143 /* GetAccessor */ || + node.kind === 144 /* SetAccessor */ || + node.kind === 216 /* ModuleDeclaration */ || + node.kind === 212 /* ClassDeclaration */ || + node.kind === 215 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { var name_22 = node.name; // For computed property names, the text will include the brackets - scopeName = name_22.kind === 133 /* ComputedPropertyName */ + scopeName = name_22.kind === 134 /* ComputedPropertyName */ ? ts.getTextOfNode(name_22) : node.name.text; } @@ -28481,7 +29072,7 @@ var ts; } else { // Write source map file - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false); sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; } // Write sourcemap url to the js file and write the js file @@ -28517,7 +29108,9 @@ var ts; if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { // The relative paths are relative to the common directory sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath + ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap + host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ true); } else { @@ -28532,7 +29125,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 245 /* SourceFile */) { + if (node.kind !== 246 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -28543,8 +29136,11 @@ var ts; } } } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -28557,7 +29153,7 @@ var ts; } // Create a temporary variable with a unique unused name. function createTempVariable(flags) { - var result = ts.createSynthesizedNode(66 /* Identifier */); + var result = ts.createSynthesizedNode(67 /* Identifier */); result.text = makeTempVariableName(flags); return result; } @@ -28667,7 +29263,14 @@ var ts; write(", "); } } - emitNode(nodes[start + i]); + var node = nodes[start + i]; + // This emitting is to make sure we emit following comment properly + // ...(x, /*comment1*/ y)... + // ^ => node.pos + // "comment1" is not considered leading comment for "y" but rather + // considered as trailing comment of the previous node. + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); leadingComma = true; } if (trailingComma) { @@ -28680,11 +29283,11 @@ var ts; } function emitCommaList(nodes) { if (nodes) { - emitList(nodes, 0, nodes.length, false, false); + emitList(nodes, 0, nodes.length, /*multiline*/ false, /*trailingComma*/ false); } } function emitLines(nodes) { - emitLinesStartingAt(nodes, 0); + emitLinesStartingAt(nodes, /*startIndex*/ 0); } function emitLinesStartingAt(nodes, startIndex) { for (var i = startIndex; i < nodes.length; i++) { @@ -28693,7 +29296,7 @@ var ts; } } function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 7 /* NumericLiteral */ && text.length > 1) { + if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { switch (text.charCodeAt(1)) { case 98 /* b */: case 66 /* B */: @@ -28706,7 +29309,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 8 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { @@ -28720,7 +29323,7 @@ var ts; // Any template literal or string literal with an extended escape // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. if (languageVersion < 2 /* ES6 */ && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); + return getQuotedEscapedLiteralText("\"", node.text, "\""); } // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. @@ -28730,17 +29333,17 @@ var ts; // If we can't reach the original source text, use the canonical form if it's a number, // or an escaped quoted form of the original text if it's string-like. switch (node.kind) { - case 8 /* StringLiteral */: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 10 /* NoSubstitutionTemplateLiteral */: - return getQuotedEscapedLiteralText('`', node.text, '`'); - case 11 /* TemplateHead */: - return getQuotedEscapedLiteralText('`', node.text, '${'); - case 12 /* TemplateMiddle */: - return getQuotedEscapedLiteralText('}', node.text, '${'); - case 13 /* TemplateTail */: - return getQuotedEscapedLiteralText('}', node.text, '`'); - case 7 /* NumericLiteral */: + case 9 /* StringLiteral */: + return getQuotedEscapedLiteralText("\"", node.text, "\""); + case 11 /* NoSubstitutionTemplateLiteral */: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 12 /* TemplateHead */: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 13 /* TemplateMiddle */: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14 /* TemplateTail */: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8 /* NumericLiteral */: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -28757,18 +29360,18 @@ var ts; // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - var isLast = node.kind === 10 /* NoSubstitutionTemplateLiteral */ || node.kind === 13 /* TemplateTail */; + var isLast = node.kind === 11 /* NoSubstitutionTemplateLiteral */ || node.kind === 14 /* TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's // and LineTerminatorSequences are normalized to for both TV and TRV. text = text.replace(/\r\n?/g, "\n"); text = ts.escapeString(text); - write('"' + text + '"'); + write("\"" + text + "\""); } function emitDownlevelTaggedTemplateArray(node, literalEmitter) { write("["); - if (node.template.kind === 10 /* NoSubstitutionTemplateLiteral */) { + if (node.template.kind === 11 /* NoSubstitutionTemplateLiteral */) { literalEmitter(node.template); } else { @@ -28795,11 +29398,11 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 180 /* TemplateExpression */) { + if (node.template.kind === 181 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 178 /* BinaryExpression */ - && templateSpan.expression.operatorToken.kind === 23 /* CommaToken */; + var needsParens = templateSpan.expression.kind === 179 /* BinaryExpression */ + && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); } @@ -28833,7 +29436,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 169 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 170 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; if (i > 0 || headEmitted) { // If this is the first span and the head was not emitted, then this templateSpan's @@ -28875,11 +29478,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return parent.expression === template; - case 167 /* TaggedTemplateExpression */: - case 169 /* ParenthesizedExpression */: + case 168 /* TaggedTemplateExpression */: + case 170 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -28900,20 +29503,20 @@ var ts; // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. switch (expression.kind) { - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: switch (expression.operatorToken.kind) { - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: return 1 /* GreaterThan */; - case 34 /* PlusToken */: - case 35 /* MinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: return 0 /* EqualTo */; default: return -1 /* LessThan */; } - case 181 /* YieldExpression */: - case 179 /* ConditionalExpression */: + case 182 /* YieldExpression */: + case 180 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -28928,10 +29531,10 @@ var ts; /// Emit a tag name, which is either '"div"' for lower-cased names, or /// 'Div' for upper-cased or dotted names function emitTagName(name) { - if (name.kind === 66 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { - write('"'); + if (name.kind === 67 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -28942,9 +29545,9 @@ var ts; /// about keywords, just non-identifier characters function emitAttributeName(name) { if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write('"'); + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -28962,9 +29565,13 @@ var ts; } } function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(67 /* Identifier */); + syntheticReactRef.text = 'React'; + syntheticReactRef.parent = openingNode; // Call React.createElement(tag, ... emitLeadingComments(openingNode); - write("React.createElement("); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); emitTagName(openingNode.tagName); write(", "); // Attribute list @@ -28976,37 +29583,38 @@ var ts; // Either emit one big object literal (no spread attribs), or // a call to React.__spread var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 236 /* JsxSpreadAttribute */; })) { - write("React.__spread("); + if (ts.forEach(attrs, function (attr) { return attr.kind === 237 /* JsxSpreadAttribute */; })) { + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); var haveOpenedObjectLiteral = false; - for (var i_2 = 0; i_2 < attrs.length; i_2++) { - if (attrs[i_2].kind === 236 /* JsxSpreadAttribute */) { + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 237 /* JsxSpreadAttribute */) { // If this is the first argument, we need to emit a {} as the first argument - if (i_2 === 0) { + if (i_1 === 0) { write("{}, "); } if (haveOpenedObjectLiteral) { write("}"); haveOpenedObjectLiteral = false; } - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } - emit(attrs[i_2].expression); + emit(attrs[i_1].expression); } else { - ts.Debug.assert(attrs[i_2].kind === 235 /* JsxAttribute */); + ts.Debug.assert(attrs[i_1].kind === 236 /* JsxAttribute */); if (haveOpenedObjectLiteral) { write(", "); } else { haveOpenedObjectLiteral = true; - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } write("{"); } - emitJsxAttribute(attrs[i_2]); + emitJsxAttribute(attrs[i_1]); } } if (haveOpenedObjectLiteral) @@ -29029,16 +29637,16 @@ var ts; if (children) { for (var i = 0; i < children.length; i++) { // Don't emit empty expressions - if (children[i].kind === 237 /* JsxExpression */ && !(children[i].expression)) { + if (children[i].kind === 238 /* JsxExpression */ && !(children[i].expression)) { continue; } // Don't emit empty strings - if (children[i].kind === 233 /* JsxText */) { + if (children[i].kind === 234 /* JsxText */) { var text = getTextToEmit(children[i]); if (text !== undefined) { - write(', "'); + write(", \""); write(text); - write('"'); + write("\""); } } else { @@ -29051,19 +29659,21 @@ var ts; write(")"); // closes "React.createElement(" emitTrailingComments(openingNode); } - if (node.kind === 230 /* JsxElement */) { + if (node.kind === 231 /* JsxElement */) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); emitJsxElement(node); } } function jsxEmitPreserve(node) { function emitJsxAttribute(node) { emit(node.name); - write("="); - emit(node.initializer); + if (node.initializer) { + write("="); + emit(node.initializer); + } } function emitJsxSpreadAttribute(node) { write("{..."); @@ -29075,11 +29685,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 236 /* JsxSpreadAttribute */) { + if (attribs[i].kind === 237 /* JsxSpreadAttribute */) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 235 /* JsxAttribute */); + ts.Debug.assert(attribs[i].kind === 236 /* JsxAttribute */); emitJsxAttribute(attribs[i]); } } @@ -29087,11 +29697,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 231 /* JsxSelfClosingElement */)) { + if (node.attributes.length > 0 || (node.kind === 232 /* JsxSelfClosingElement */)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 231 /* JsxSelfClosingElement */) { + if (node.kind === 232 /* JsxSelfClosingElement */) { write("/>"); } else { @@ -29110,11 +29720,11 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 230 /* JsxElement */) { + if (node.kind === 231 /* JsxElement */) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); emitJsxOpeningOrSelfClosingElement(node); } } @@ -29122,11 +29732,11 @@ var ts; // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 160 /* BindingElement */); - if (node.kind === 8 /* StringLiteral */) { + ts.Debug.assert(node.kind !== 161 /* BindingElement */); + if (node.kind === 9 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 133 /* ComputedPropertyName */) { + else if (node.kind === 134 /* ComputedPropertyName */) { // if this is a decorated computed property, we will need to capture the result // of the property expression so that we can apply decorators later. This is to ensure // we don't introduce unintended side effects: @@ -29158,7 +29768,7 @@ var ts; } else { write("\""); - if (node.kind === 7 /* NumericLiteral */) { + if (node.kind === 8 /* NumericLiteral */) { write(node.text); } else { @@ -29170,58 +29780,60 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 161 /* ArrayLiteralExpression */: - case 178 /* BinaryExpression */: - case 165 /* CallExpression */: - case 238 /* CaseClause */: - case 133 /* ComputedPropertyName */: - case 179 /* ConditionalExpression */: - case 136 /* Decorator */: - case 172 /* DeleteExpression */: - case 194 /* DoStatement */: - case 164 /* ElementAccessExpression */: - case 224 /* ExportAssignment */: - case 192 /* ExpressionStatement */: - case 185 /* ExpressionWithTypeArguments */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 193 /* IfStatement */: - case 231 /* JsxSelfClosingElement */: - case 232 /* JsxOpeningElement */: - case 166 /* NewExpression */: - case 169 /* ParenthesizedExpression */: - case 177 /* PostfixUnaryExpression */: - case 176 /* PrefixUnaryExpression */: - case 201 /* ReturnStatement */: - case 243 /* ShorthandPropertyAssignment */: - case 182 /* SpreadElementExpression */: - case 203 /* SwitchStatement */: - case 167 /* TaggedTemplateExpression */: - case 187 /* TemplateSpan */: - case 205 /* ThrowStatement */: - case 168 /* TypeAssertionExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 181 /* YieldExpression */: + case 162 /* ArrayLiteralExpression */: + case 179 /* BinaryExpression */: + case 166 /* CallExpression */: + case 239 /* CaseClause */: + case 134 /* ComputedPropertyName */: + case 180 /* ConditionalExpression */: + case 137 /* Decorator */: + case 173 /* DeleteExpression */: + case 195 /* DoStatement */: + case 165 /* ElementAccessExpression */: + case 225 /* ExportAssignment */: + case 193 /* ExpressionStatement */: + case 186 /* ExpressionWithTypeArguments */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 194 /* IfStatement */: + case 232 /* JsxSelfClosingElement */: + case 233 /* JsxOpeningElement */: + case 237 /* JsxSpreadAttribute */: + case 238 /* JsxExpression */: + case 167 /* NewExpression */: + case 170 /* ParenthesizedExpression */: + case 178 /* PostfixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: + case 202 /* ReturnStatement */: + case 244 /* ShorthandPropertyAssignment */: + case 183 /* SpreadElementExpression */: + case 204 /* SwitchStatement */: + case 168 /* TaggedTemplateExpression */: + case 188 /* TemplateSpan */: + case 206 /* ThrowStatement */: + case 169 /* TypeAssertionExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 182 /* YieldExpression */: return true; - case 160 /* BindingElement */: - case 244 /* EnumMember */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 245 /* EnumMember */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 209 /* VariableDeclaration */: return parent.initializer === node; - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return parent.expression === node; - case 171 /* ArrowFunction */: - case 170 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 171 /* FunctionExpression */: return parent.body === node; - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return parent.moduleReference === node; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return parent.left === node; } return false; @@ -29233,7 +29845,7 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 245 /* SourceFile */) { + if (container.kind === 246 /* SourceFile */) { // Identifier references module export if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { write("exports."); @@ -29248,17 +29860,24 @@ var ts; else if (languageVersion < 2 /* ES6 */) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 220 /* ImportClause */) { + if (declaration.kind === 221 /* ImportClause */) { // Identifier references default import write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 /* ES3 */ ? '["default"]' : ".default"); + write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 223 /* ImportSpecifier */) { + else if (declaration.kind === 224 /* ImportSpecifier */) { // Identifier references named import write(getGeneratedNameForNode(declaration.parent.parent.parent)); - write("."); - writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); + var name = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name); + if (languageVersion === 0 /* ES3 */ && identifier === "default") { + write("[\"default\"]"); + } + else { + write("."); + write(identifier); + } return; } } @@ -29268,17 +29887,22 @@ var ts; return; } } - writeTextOfNode(currentSourceFile, node); + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } } function isNameOfNestedRedeclaration(node) { if (languageVersion < 2 /* ES6 */) { - var parent_7 = node.parent; - switch (parent_7.kind) { - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 208 /* VariableDeclaration */: - return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + var parent_6 = node.parent; + switch (parent_6.kind) { + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 209 /* VariableDeclaration */: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); } } return false; @@ -29293,6 +29917,9 @@ var ts; else if (isNameOfNestedRedeclaration(node)) { write(getGeneratedNameForNode(node)); } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } else { writeTextOfNode(currentSourceFile, node); } @@ -29322,13 +29949,13 @@ var ts; function emitObjectBindingPattern(node) { write("{ "); var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); write(" }"); } function emitArrayBindingPattern(node) { write("["); var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); write("]"); } function emitBindingElement(node) { @@ -29352,7 +29979,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(111 /* YieldKeyword */)); + write(ts.tokenToString(112 /* YieldKeyword */)); if (node.asteriskToken) { write("*"); } @@ -29366,7 +29993,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(111 /* YieldKeyword */)); + write(ts.tokenToString(112 /* YieldKeyword */)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -29374,22 +30001,22 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 178 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 179 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 179 /* ConditionalExpression */ && node.parent.condition === node) { + else if (node.parent.kind === 180 /* ConditionalExpression */ && node.parent.condition === node) { return true; } return false; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 66 /* Identifier */: - case 161 /* ArrayLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 169 /* ParenthesizedExpression */: + case 67 /* Identifier */: + case 162 /* ArrayLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 170 /* ParenthesizedExpression */: // This list is not exhaustive and only includes those cases that are relevant // to the check in emitArrayLiteral. More cases can be added as needed. return false; @@ -29409,17 +30036,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 182 /* SpreadElementExpression */) { + if (e.kind === 183 /* SpreadElementExpression */) { e = e.expression; - emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 161 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 182 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 183 /* SpreadElementExpression */) { i++; } write("["); @@ -29442,7 +30069,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 182 /* SpreadElementExpression */; + return node.kind === 183 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -29451,12 +30078,12 @@ var ts; } else if (languageVersion >= 2 /* ES6 */ || !ts.forEach(elements, isSpreadElementExpression)) { write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, /*spacesBetweenBraces:*/ false); write("]"); } else { - emitListWithSpread(elements, true, (node.flags & 2048 /* MultiLine */) !== 0, - /*trailingComma*/ elements.hasTrailingComma, true); + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, + /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); } } function emitObjectLiteralBody(node, numElements) { @@ -29471,7 +30098,7 @@ var ts; // then try to preserve the original shape of the object literal. // Otherwise just try to preserve the formatting. if (numElements === properties.length) { - emitLinePreservingList(node, properties, languageVersion >= 1 /* ES5 */, true); + emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); } else { var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; @@ -29481,7 +30108,7 @@ var ts; else { increaseIndent(); } - emitList(properties, 0, numElements, multiLine, false); + emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false); if (!multiLine) { write(" "); } @@ -29512,7 +30139,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 142 /* GetAccessor */ || property.kind === 143 /* SetAccessor */) { + if (property.kind === 143 /* GetAccessor */ || property.kind === 144 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -29564,13 +30191,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 242 /* PropertyAssignment */) { + if (property.kind === 243 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 243 /* ShorthandPropertyAssignment */) { + else if (property.kind === 244 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 140 /* MethodDeclaration */) { + else if (property.kind === 141 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -29604,7 +30231,7 @@ var ts; // Everything until that point can be emitted as part of the initial object literal. var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 133 /* ComputedPropertyName */) { + if (properties[i].name.kind === 134 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -29620,21 +30247,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(178 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(179 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(163 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(164 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(20 /* DotToken */); + result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(164 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(165 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -29642,7 +30269,7 @@ var ts; function parenthesizeForAccess(expr) { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 168 /* TypeAssertionExpression */ || expr.kind === 186 /* AsExpression */) { + while (expr.kind === 169 /* TypeAssertionExpression */ || expr.kind === 187 /* AsExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -29654,11 +30281,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 166 /* NewExpression */ && - expr.kind !== 7 /* NumericLiteral */) { + expr.kind !== 167 /* NewExpression */ && + expr.kind !== 8 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(169 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(170 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -29680,12 +30307,20 @@ var ts; function emitPropertyAssignment(node) { emit(node.name); write(": "); + // This is to ensure that we emit comment in the following case: + // For example: + // obj = { + // id: /*comment1*/ ()=>void + // } + // "comment1" is not considered to be leading comment for node.initializer + // but rather a trailing comment on the previous node. + emitTrailingCommentsOfPosition(node.initializer.pos); emit(node.initializer); } // Return true if identifier resolves to an exported member of a namespace function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 245 /* SourceFile */; + return container && container.kind !== 246 /* SourceFile */; } function emitShorthandPropertyAssignment(node) { // The name property of a short-hand property assignment is considered an expression position, so here @@ -29707,21 +30342,25 @@ var ts; } } function tryEmitConstantValue(node) { - if (compilerOptions.isolatedModules) { - // do not inline enum values in separate compilation mode - return false; - } - var constantValue = resolver.getConstantValue(node); + var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 163 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 164 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; } return false; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 164 /* PropertyAccessExpression */ || node.kind === 165 /* ElementAccessExpression */ + ? resolver.getConstantValue(node) + : undefined; + } // Returns 'true' if the code was actually indented, false otherwise. // If the code is not indented, an optional valueToWriteWhenNotIndenting will be // emitted instead. @@ -29748,10 +30387,20 @@ var ts; emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); // 1 .toString is a valid property access, emit a space after the literal + // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal var shouldEmitSpace; - if (!indentedBeforeDot && node.expression.kind === 7 /* NumericLiteral */) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(20 /* DotToken */)) < 0; + if (!indentedBeforeDot) { + if (node.expression.kind === 8 /* NumericLiteral */) { + // check if numeric literal was originally written with a dot + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; + } + else { + // check if constant enum value is integer + var constantValue = tryGetConstEnumValue(node.expression); + // isFinite handles cases when constantValue is undefined + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } } if (shouldEmitSpace) { write(" ."); @@ -29769,7 +30418,7 @@ var ts; emit(node.right); } function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 66 /* Identifier */) { + if (node.left.kind === 67 /* Identifier */) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -29777,19 +30426,19 @@ var ts; write("("); emitNodeWithoutSourceMap(temp); write(" = "); - emitEntityNameAsExpression(node.left, true); + emitEntityNameAsExpression(node.left, /*useFallback*/ true); write(") && "); emitNodeWithoutSourceMap(temp); } else { - emitEntityNameAsExpression(node.left, false); + emitEntityNameAsExpression(node.left, /*useFallback*/ false); } write("."); - emitNodeWithoutSourceMap(node.right); + emit(node.right); } function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); @@ -29797,7 +30446,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -29812,16 +30461,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 182 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 183 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 169 /* ParenthesizedExpression */ || node.kind === 168 /* TypeAssertionExpression */ || node.kind === 186 /* AsExpression */) { + while (node.kind === 170 /* ParenthesizedExpression */ || node.kind === 169 /* TypeAssertionExpression */ || node.kind === 187 /* AsExpression */) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 66 /* Identifier */ || node.kind === 94 /* ThisKeyword */ || node.kind === 92 /* SuperKeyword */) { + if (node.kind === 67 /* Identifier */ || node.kind === 95 /* ThisKeyword */ || node.kind === 93 /* SuperKeyword */) { emit(node); return node; } @@ -29836,20 +30485,20 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 163 /* PropertyAccessExpression */) { + if (expr.kind === 164 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 164 /* ElementAccessExpression */) { + else if (expr.kind === 165 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 92 /* SuperKeyword */) { + else if (expr.kind === 93 /* SuperKeyword */) { target = expr; write("_super"); } @@ -29858,7 +30507,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 92 /* SuperKeyword */) { + if (target.kind === 93 /* SuperKeyword */) { // Calls of form super(...) and super.foo(...) emitThis(target); } @@ -29872,7 +30521,7 @@ var ts; write("void 0"); } write(", "); - emitListWithSpread(node.arguments, false, false, false, true); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); write(")"); } function emitCallExpression(node) { @@ -29881,13 +30530,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 163 /* PropertyAccessExpression */ && node.expression.expression.kind === 92 /* SuperKeyword */; + superCall = node.expression.kind === 164 /* PropertyAccessExpression */ && node.expression.expression.kind === 93 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -29929,7 +30578,7 @@ var ts; write(".bind.apply("); emit(target); write(", [void 0].concat("); - emitListWithSpread(node.arguments, false, false, false, false); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false); write(")))"); write("()"); } @@ -29956,12 +30605,12 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 171 /* ArrowFunction */) { - if (node.expression.kind === 168 /* TypeAssertionExpression */ || node.expression.kind === 186 /* AsExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172 /* ArrowFunction */) { + if (node.expression.kind === 169 /* TypeAssertionExpression */ || node.expression.kind === 187 /* AsExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind === 168 /* TypeAssertionExpression */ || operand.kind === 186 /* AsExpression */) { + while (operand.kind === 169 /* TypeAssertionExpression */ || operand.kind === 187 /* AsExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -29972,14 +30621,15 @@ var ts; // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 176 /* PrefixUnaryExpression */ && - operand.kind !== 174 /* VoidExpression */ && - operand.kind !== 173 /* TypeOfExpression */ && - operand.kind !== 172 /* DeleteExpression */ && - operand.kind !== 177 /* PostfixUnaryExpression */ && - operand.kind !== 166 /* NewExpression */ && - !(operand.kind === 165 /* CallExpression */ && node.parent.kind === 166 /* NewExpression */) && - !(operand.kind === 170 /* FunctionExpression */ && node.parent.kind === 165 /* CallExpression */)) { + if (operand.kind !== 177 /* PrefixUnaryExpression */ && + operand.kind !== 175 /* VoidExpression */ && + operand.kind !== 174 /* TypeOfExpression */ && + operand.kind !== 173 /* DeleteExpression */ && + operand.kind !== 178 /* PostfixUnaryExpression */ && + operand.kind !== 167 /* NewExpression */ && + !(operand.kind === 166 /* CallExpression */ && node.parent.kind === 167 /* NewExpression */) && + !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */) && + !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 164 /* PropertyAccessExpression */)) { emit(operand); return; } @@ -29990,29 +30640,29 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(75 /* DeleteKeyword */)); + write(ts.tokenToString(76 /* DeleteKeyword */)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(100 /* VoidKeyword */)); + write(ts.tokenToString(101 /* VoidKeyword */)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(98 /* TypeOfKeyword */)); + write(ts.tokenToString(99 /* TypeOfKeyword */)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 66 /* Identifier */ || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 67 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 208 /* VariableDeclaration */ || node.parent.kind === 160 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 /* VariableDeclaration */ || node.parent.kind === 161 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); } function emitPrefixUnaryExpression(node) { var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); @@ -30038,12 +30688,12 @@ var ts; // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operand.kind === 176 /* PrefixUnaryExpression */) { + if (node.operand.kind === 177 /* PrefixUnaryExpression */) { var operand = node.operand; - if (node.operator === 34 /* PlusToken */ && (operand.operator === 34 /* PlusToken */ || operand.operator === 39 /* PlusPlusToken */)) { + if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 40 /* PlusPlusToken */)) { write(" "); } - else if (node.operator === 35 /* MinusToken */ && (operand.operator === 35 /* MinusToken */ || operand.operator === 40 /* MinusMinusToken */)) { + else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 41 /* MinusMinusToken */)) { write(" "); } } @@ -30063,7 +30713,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 39 /* PlusPlusToken */) { + if (node.operator === 40 /* PlusPlusToken */) { write(") - 1)"); } else { @@ -30076,7 +30726,7 @@ var ts; } } function shouldHoistDeclarationInSystemJsModule(node) { - return isSourceFileLevelDeclarationInSystemJsModule(node, false); + return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); } /* * Checks if given node is a source file level declaration (not nested in module/function). @@ -30094,10 +30744,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 245 /* SourceFile */) { + if (current.kind === 246 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 216 /* ModuleBlock */) { + else if (ts.isFunctionLike(current) || current.kind === 217 /* ModuleBlock */) { return false; } else { @@ -30106,13 +30756,13 @@ var ts; } } function emitBinaryExpression(node) { - if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 54 /* EqualsToken */ && - (node.left.kind === 162 /* ObjectLiteralExpression */ || node.left.kind === 161 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 192 /* ExpressionStatement */); + if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 55 /* EqualsToken */ && + (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 193 /* ExpressionStatement */); } else { - var exportChanged = node.operatorToken.kind >= 54 /* FirstAssignment */ && - node.operatorToken.kind <= 65 /* LastAssignment */ && + var exportChanged = node.operatorToken.kind >= 55 /* FirstAssignment */ && + node.operatorToken.kind <= 66 /* LastAssignment */ && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { // emit assignment 'x y' as 'exports("x", x y)' @@ -30121,7 +30771,7 @@ var ts; write("\", "); } emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 /* CommaToken */ ? " " : undefined); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); write(ts.tokenToString(node.operatorToken.kind)); var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); @@ -30160,36 +30810,36 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 189 /* Block */) { + if (node && node.kind === 190 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } } function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - emitToken(14 /* OpenBraceToken */, node.pos); + emitToken(15 /* OpenBraceToken */, node.pos); write(" "); - emitToken(15 /* CloseBraceToken */, node.statements.end); + emitToken(16 /* CloseBraceToken */, node.statements.end); return; } - emitToken(14 /* OpenBraceToken */, node.pos); + emitToken(15 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 216 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 215 /* ModuleDeclaration */); + if (node.kind === 217 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 216 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 216 /* ModuleBlock */) { - emitTempDeclarations(true); + if (node.kind === 217 /* ModuleBlock */) { + emitTempDeclarations(/*newLine*/ true); } decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.statements.end); + emitToken(16 /* CloseBraceToken */, node.statements.end); scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 189 /* Block */) { + if (node.kind === 190 /* Block */) { write(" "); emit(node); } @@ -30201,20 +30851,20 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 171 /* ArrowFunction */); + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 172 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(85 /* IfKeyword */, node.pos); + var endPos = emitToken(86 /* IfKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); + endPos = emitToken(17 /* OpenParenToken */, endPos); emit(node.expression); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(77 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 193 /* IfStatement */) { + emitToken(78 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 194 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -30226,7 +30876,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 189 /* Block */) { + if (node.statement.kind === 190 /* Block */) { write(" "); } else { @@ -30248,17 +30898,17 @@ var ts; * in system modules where such variable declarations are hoisted. */ function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, true)) { + if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { // variables in variable declaration list were already hoisted return false; } - var tokenKind = 99 /* VarKeyword */; + var tokenKind = 100 /* VarKeyword */; if (decl && languageVersion >= 2 /* ES6 */) { if (ts.isLet(decl)) { - tokenKind = 105 /* LetKeyword */; + tokenKind = 106 /* LetKeyword */; } else if (ts.isConst(decl)) { - tokenKind = 71 /* ConstKeyword */; + tokenKind = 72 /* ConstKeyword */; } } if (startPos !== undefined) { @@ -30267,13 +30917,13 @@ var ts; } else { switch (tokenKind) { - case 99 /* VarKeyword */: + case 100 /* VarKeyword */: write("var "); break; - case 105 /* LetKeyword */: + case 106 /* LetKeyword */: write("let "); break; - case 71 /* ConstKeyword */: + case 72 /* ConstKeyword */: write("const "); break; } @@ -30298,10 +30948,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 209 /* VariableDeclarationList */) { + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -30322,13 +30972,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 198 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 199 /* ForOfStatement */) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -30338,14 +30988,14 @@ var ts; else { emit(node.initializer); } - if (node.kind === 197 /* ForInStatement */) { + if (node.kind === 198 /* ForInStatement */) { write(" in "); } else { write(" of "); } emit(node.expression); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { @@ -30369,9 +31019,9 @@ var ts; // all destructuring. // Note also that because an extra statement is needed to assign to the LHS, // for-of bodies are always emitted as blocks. - var endPos = emitToken(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); + endPos = emitToken(17 /* OpenParenToken */, endPos); // Do not emit the LHS let declaration yet, because it might contain destructuring. // Do not call recordTempDeclaration because we are declaring the temps // right here. Recording means they will be declared later. @@ -30380,7 +31030,7 @@ var ts; // for (let v of arr) { } // // we don't want to emit a temporary variable for the RHS, just use it directly. - var rhsIsIdentifier = node.expression.kind === 66 /* Identifier */; + var rhsIsIdentifier = node.expression.kind === 67 /* Identifier */; var counter = createTempVariable(268435456 /* _i */); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); // This is the let keyword for the counter and rhsReference. The let keyword for @@ -30405,7 +31055,7 @@ var ts; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); write("; "); @@ -30414,7 +31064,7 @@ var ts; emitNodeWithoutSourceMap(counter); write("++"); emitEnd(node.initializer); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); // Body write(" {"); writeLine(); @@ -30423,7 +31073,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -30431,12 +31081,12 @@ var ts; if (ts.isBindingPattern(declaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. - emitDestructuring(declaration, false, rhsIterationValue); + emitDestructuring(declaration, /*isAssignmentExpressionStatement*/ false, rhsIterationValue); } else { // The following call does not include the initializer, so we have // to emit it separately. - emitNodeWithoutSourceMap(declaration); + emitNodeWithCommentsAndWithoutSourcemap(declaration); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } @@ -30452,19 +31102,19 @@ var ts; else { // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. - var assignmentExpression = createBinaryExpression(node.initializer, 54 /* EqualsToken */, rhsIterationValue, false); - if (node.initializer.kind === 161 /* ArrayLiteralExpression */ || node.initializer.kind === 162 /* ObjectLiteralExpression */) { + var assignmentExpression = createBinaryExpression(node.initializer, 55 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); + if (node.initializer.kind === 162 /* ArrayLiteralExpression */ || node.initializer.kind === 163 /* ObjectLiteralExpression */) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. - emitDestructuring(assignmentExpression, true, undefined); + emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); } else { - emitNodeWithoutSourceMap(assignmentExpression); + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); } } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 189 /* Block */) { + if (node.statement.kind === 190 /* Block */) { emitLines(node.statement.statements); } else { @@ -30476,12 +31126,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 200 /* BreakStatement */ ? 67 /* BreakKeyword */ : 72 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(91 /* ReturnKeyword */, node.pos); + emitToken(92 /* ReturnKeyword */, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -30492,21 +31142,21 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(93 /* SwitchKeyword */, node.pos); + var endPos = emitToken(94 /* SwitchKeyword */, node.pos); write(" "); - emitToken(16 /* OpenParenToken */, endPos); + emitToken(17 /* OpenParenToken */, endPos); emit(node.expression); - endPos = emitToken(17 /* CloseParenToken */, node.expression.end); + endPos = emitToken(18 /* CloseParenToken */, node.expression.end); write(" "); emitCaseBlock(node.caseBlock, endPos); } function emitCaseBlock(node, startPos) { - emitToken(14 /* OpenBraceToken */, startPos); + emitToken(15 /* OpenBraceToken */, startPos); increaseIndent(); emitLines(node.clauses); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.clauses.end); + emitToken(16 /* CloseBraceToken */, node.clauses.end); } function nodeStartPositionsAreOnSameLine(node1, node2) { return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === @@ -30521,7 +31171,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 238 /* CaseClause */) { + if (node.kind === 239 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -30556,16 +31206,16 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(69 /* CatchKeyword */, node.pos); + var endPos = emitToken(70 /* CatchKeyword */, node.pos); write(" "); - emitToken(16 /* OpenParenToken */, endPos); + emitToken(17 /* OpenParenToken */, endPos); emit(node.variableDeclaration); - emitToken(17 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); + emitToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); write(" "); emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(73 /* DebuggerKeyword */, node.pos); + emitToken(74 /* DebuggerKeyword */, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -30576,7 +31226,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 215 /* ModuleDeclaration */); + } while (node && node.kind !== 216 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -30595,16 +31245,35 @@ var ts; write("exports."); } } - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); emitEnd(node.name); } function createVoidZero() { - var zero = ts.createSynthesizedNode(7 /* NumericLiteral */); + var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(174 /* VoidExpression */); + var result = ts.createSynthesizedNode(175 /* VoidExpression */); result.expression = zero; return result; } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 246 /* SourceFile */) { + ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 225 /* ExportAssignment */); + // only allow export default at a source file level + if (compilerOptions.module === 1 /* CommonJS */ || compilerOptions.module === 2 /* AMD */ || compilerOptions.module === 3 /* UMD */) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1 /* ES5 */) { + // default value of configurable, enumerable, writable are `false`. + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0 /* ES3 */) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } function emitExportMemberAssignment(node) { if (node.flags & 1 /* Export */) { writeLine(); @@ -30618,7 +31287,7 @@ var ts; write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write("\", "); emitDeclarationName(node); @@ -30626,6 +31295,7 @@ var ts; } else { if (node.flags & 1024 /* Default */) { + emitEs6ExportDefaultCompat(node); if (languageVersion === 0 /* ES3 */) { write("exports[\"default\"]"); } @@ -30644,32 +31314,39 @@ var ts; } } function emitExportMemberAssignments(name) { + if (compilerOptions.module === 4 /* System */) { + return; + } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { var specifier = _b[_a]; writeLine(); - if (compilerOptions.module === 4 /* System */) { - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(specifier.name); - write("\", "); - emitExpressionIdentifier(name); - write(")"); - emitEnd(specifier.name); - } - else { - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - } + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); write(";"); } } } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(compilerOptions.module === 4 /* System */); + if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { + return; + } + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; // An exported declaration is actually emitted as an assignment (to a property on the module object), so @@ -30677,15 +31354,15 @@ var ts; // Also temporary variables should be explicitly allocated for source level declarations when module target is system // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; - if (root.kind === 208 /* VariableDeclaration */) { + if (root.kind === 209 /* VariableDeclaration */) { var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 135 /* Parameter */) { + else if (root.kind === 136 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 178 /* BinaryExpression */) { + if (root.kind === 179 /* BinaryExpression */) { emitAssignmentExpression(root); } else { @@ -30696,11 +31373,11 @@ var ts; if (emitCount++) { write(", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 208 /* VariableDeclaration */ || name.parent.kind === 160 /* BindingElement */); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 /* VariableDeclaration */ || name.parent.kind === 161 /* BindingElement */); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(name); + emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } if (isVariableDeclarationOrBindingElement) { @@ -30715,39 +31392,48 @@ var ts; write(")"); } } - function ensureIdentifier(expr) { - if (expr.kind !== 66 /* Identifier */) { - var identifier = createTempVariable(0 /* Auto */); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expr); - expr = identifier; + /** + * Ensures that there exists a declared identifier whose value holds the given expression. + * This function is useful to ensure that the expression's value can be read from in subsequent expressions. + * Unless 'reuseIdentifierExpressions' is false, 'expr' will be returned if it is just an identifier. + * + * @param expr the expression whose value needs to be bound. + * @param reuseIdentifierExpressions true if identifier expressions can simply be returned; + * false if it is necessary to always emit an identifier. + */ + function ensureIdentifier(expr, reuseIdentifierExpressions) { + if (expr.kind === 67 /* Identifier */ && reuseIdentifierExpressions) { + return expr; } - return expr; + var identifier = createTempVariable(0 /* Auto */); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expr); + return identifier; } function createDefaultValueCheck(value, defaultValue) { // The value expression will be evaluated twice, so for anything but a simple identifier // we need to generate a temporary variable - value = ensureIdentifier(value); + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(178 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(179 /* BinaryExpression */); equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(31 /* EqualsEqualsEqualsToken */); + equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(179 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(180 /* ConditionalExpression */); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(51 /* QuestionToken */); + cond.questionToken = ts.createSynthesizedNode(52 /* QuestionToken */); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(52 /* ColonToken */); + cond.colonToken = ts.createSynthesizedNode(53 /* ColonToken */); cond.whenFalse = whenFalse; return cond; } function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(7 /* NumericLiteral */); + var node = ts.createSynthesizedNode(8 /* NumericLiteral */); node.text = "" + value; return node; } @@ -30756,14 +31442,14 @@ var ts; // otherwise occur when the identifier is emitted. var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 66 /* Identifier */) { + if (syntheticName.kind !== 67 /* Identifier */) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(165 /* CallExpression */); - var sliceIdentifier = ts.createSynthesizedNode(66 /* Identifier */); + var call = ts.createSynthesizedNode(166 /* CallExpression */); + var sliceIdentifier = ts.createSynthesizedNode(67 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -30775,11 +31461,11 @@ var ts; if (properties.length !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. - value = ensureIdentifier(value); + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 242 /* PropertyAssignment */ || p.kind === 243 /* ShorthandPropertyAssignment */) { + if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -30790,12 +31476,12 @@ var ts; if (elements.length !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. - value = ensureIdentifier(value); + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184 /* OmittedExpression */) { - if (e.kind !== 182 /* SpreadElementExpression */) { + if (e.kind !== 185 /* OmittedExpression */) { + if (e.kind !== 183 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -30805,14 +31491,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 178 /* BinaryExpression */ && target.operatorToken.kind === 54 /* EqualsToken */) { + if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 162 /* ObjectLiteralExpression */) { + if (target.kind === 163 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 161 /* ArrayLiteralExpression */) { + else if (target.kind === 162 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value); } else { @@ -30822,18 +31508,21 @@ var ts; function emitAssignmentExpression(root) { var target = root.left; var value = root.right; - if (isAssignmentExpressionStatement) { + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 169 /* ParenthesizedExpression */) { + if (root.parent.kind !== 170 /* ParenthesizedExpression */) { write("("); } - value = ensureIdentifier(value); + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 169 /* ParenthesizedExpression */) { + if (root.parent.kind !== 170 /* ParenthesizedExpression */) { write(")"); } } @@ -30850,24 +31539,27 @@ var ts; if (ts.isBindingPattern(target.name)) { var pattern = target.name; var elements = pattern.elements; - if (elements.length !== 1) { - // For anything but a single element destructuring we need to generate a temporary - // to ensure value is evaluated exactly once. - value = ensureIdentifier(value); + var numElements = elements.length; + if (numElements !== 1) { + // For anything other than a single-element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. Additionally, if we have zero elements + // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, + // so in that case, we'll intentionally create that temporary. + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0); } - for (var i = 0; i < elements.length; i++) { + for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (pattern.kind === 158 /* ObjectBindingPattern */) { + if (pattern.kind === 159 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 184 /* OmittedExpression */) { + else if (element.kind !== 185 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } - else if (i === elements.length - 1) { + else if (i === numElements - 1) { emitBindingElement(element, createSliceCall(value, i)); } } @@ -30881,7 +31573,7 @@ var ts; function emitVariableDeclaration(node) { if (ts.isBindingPattern(node.name)) { if (languageVersion < 2 /* ES6 */) { - emitDestructuring(node, false); + emitDestructuring(node, /*isAssignmentExpressionStatement*/ false); } else { emit(node.name); @@ -30901,15 +31593,15 @@ var ts; (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet && - node.parent.parent.kind !== 197 /* ForInStatement */ && - node.parent.parent.kind !== 198 /* ForOfStatement */) { + node.parent.parent.kind !== 198 /* ForInStatement */ && + node.parent.parent.kind !== 199 /* ForOfStatement */) { initializer = createVoidZero(); } } var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); write("\", "); } emitModuleMemberName(node); @@ -30920,11 +31612,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 184 /* OmittedExpression */) { + if (node.kind === 185 /* OmittedExpression */) { return; } var name = node.name; - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -30932,7 +31624,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 208 /* VariableDeclaration */ && node.parent.kind !== 160 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 209 /* VariableDeclaration */ && node.parent.kind !== 161 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -30940,7 +31632,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1 /* Export */) && languageVersion >= 2 /* ES6 */ && - node.parent.kind === 245 /* SourceFile */; + node.parent.kind === 246 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -31029,7 +31721,7 @@ var ts; writeLine(); write("var "); if (hasBindingElements) { - emitDestructuring(parameter, false, tempParameters[tempIndex]); + emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); } else { emit(tempParameters[tempIndex]); @@ -31049,9 +31741,9 @@ var ts; emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -31071,7 +31763,7 @@ var ts; emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -31092,7 +31784,7 @@ var ts; increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -31101,39 +31793,54 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 142 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 143 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 171 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 172 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } else { write(getGeneratedNameForNode(node)); } } function shouldEmitFunctionName(node) { - if (node.kind === 170 /* FunctionExpression */) { + if (node.kind === 171 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) return !!node.name || languageVersion < 2 /* ES6 */; } } function emitFunctionDeclaration(node) { if (ts.nodeIsMissing(node.body)) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } - if (node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { - // Methods will emit the comments as part of emitting method declaration + // TODO (yuisu) : we should not have special cases to condition emitting comments + // but have one place to fix check for these conditions. + if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */ && + node.parent && node.parent.kind !== 243 /* PropertyAssignment */ && + node.parent.kind !== 166 /* CallExpression */) { + // 1. Methods will emit the comments as part of emitting method declaration + // 2. If the function is a property of object literal, emitting leading-comments + // is done by emitNodeWithoutSourceMap which then call this function. + // In particular, we would like to avoid emit comments twice in following case: + // For example: + // var obj = { + // id: + // /*comment*/ () => void + // } + // 3. If the function is an argument in call expression, emitting of comments will be + // taken care of in emit list of arguments inside of emitCallexpression emitLeadingComments(node); } + emitStart(node); // For targeting below es6, emit functions-like declaration including arrow function using function keyword. // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead if (!shouldEmitAsArrowFunction(node)) { @@ -31153,10 +31860,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 210 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 /* ES6 */ && node.kind === 211 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { + emitEnd(node); + if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { emitTrailingComments(node); } } @@ -31174,7 +31882,7 @@ var ts; if (node) { var parameters = node.parameters; var omitCount = languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, false, false); + emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); } write(")"); decreaseIndent(); @@ -31189,7 +31897,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 171 /* ArrowFunction */; + var isArrowFunction = node.kind === 172 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; var args; // An async function is emit as an outer function that calls an inner @@ -31310,7 +32018,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 189 /* Block */) { + if (node.body.kind === 190 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -31365,10 +32073,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 168 /* TypeAssertionExpression */) { + while (current.kind === 169 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 162 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 163 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -31388,7 +32096,7 @@ var ts; emit(body); emitEnd(body); write(";"); - emitTempDeclarations(false); + emitTempDeclarations(/*newLine*/ false); write(" "); } else { @@ -31399,7 +32107,7 @@ var ts; emit(body); write(";"); emitTrailingComments(node.body); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); decreaseIndent(); writeLine(); } @@ -31416,7 +32124,7 @@ var ts; emitDetachedComments(body.statements); // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). - var startIndex = emitDirectivePrologues(body.statements, true); + var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); emitFunctionBodyPreamble(node); decreaseIndent(); var preambleEmitted = writer.getTextPos() !== initialTextPos; @@ -31426,29 +32134,29 @@ var ts; write(" "); emit(statement); } - emitTempDeclarations(false); + emitTempDeclarations(/*newLine*/ false); write(" "); emitLeadingCommentsOfPosition(body.statements.end); } else { increaseIndent(); emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); writeLine(); emitLeadingCommentsOfPosition(body.statements.end); decreaseIndent(); } - emitToken(15 /* CloseBraceToken */, body.statements.end); + emitToken(16 /* CloseBraceToken */, body.statements.end); scopeEmitEnd(); } function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 192 /* ExpressionStatement */) { + if (statement && statement.kind === 193 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 165 /* CallExpression */) { + if (expr && expr.kind === 166 /* CallExpression */) { var func = expr.expression; - if (func && func.kind === 92 /* SuperKeyword */) { + if (func && func.kind === 93 /* SuperKeyword */) { return statement; } } @@ -31472,25 +32180,27 @@ var ts; }); } function emitMemberAccessForPropertyName(memberName) { - // TODO: (jfreeman,drosen): comment on why this is emitNodeWithoutSourceMap instead of emit here. - if (memberName.kind === 8 /* StringLiteral */ || memberName.kind === 7 /* NumericLiteral */) { + // This does not emit source map because it is emitted by caller as caller + // is aware how the property name changes to the property access + // eg. public x = 10; becomes this.x and static x = 10 becomes className.x + if (memberName.kind === 9 /* StringLiteral */ || memberName.kind === 8 /* NumericLiteral */) { write("["); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 133 /* ComputedPropertyName */) { + else if (memberName.kind === 134 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { write("."); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); } } function getInitializedProperties(node, isStatic) { var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 138 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 139 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -31530,13 +32240,13 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 188 /* SemicolonClassElement */) { + if (member.kind === 189 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */) { + else if (member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) { if (!member.body) { - return emitOnlyPinnedOrTripleSlashComments(member); + return emitCommentsOnNotEmittedNode(member); } writeLine(); emitLeadingComments(member); @@ -31546,14 +32256,12 @@ var ts; emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); - emitStart(member); emitFunctionDeclaration(member); emitEnd(member); - emitEnd(member); write(";"); emitTrailingComments(member); } - else if (member.kind === 142 /* GetAccessor */ || member.kind === 143 /* SetAccessor */) { + else if (member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -31603,22 +32311,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */) && !member.body) { - emitOnlyPinnedOrTripleSlashComments(member); + if ((member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) && !member.body) { + emitCommentsOnNotEmittedNode(member); } - else if (member.kind === 140 /* MethodDeclaration */ || - member.kind === 142 /* GetAccessor */ || - member.kind === 143 /* SetAccessor */) { + else if (member.kind === 141 /* MethodDeclaration */ || + member.kind === 143 /* GetAccessor */ || + member.kind === 144 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128 /* Static */) { write("static "); } - if (member.kind === 142 /* GetAccessor */) { + if (member.kind === 143 /* GetAccessor */) { write("get "); } - else if (member.kind === 143 /* SetAccessor */) { + else if (member.kind === 144 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -31629,7 +32337,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 188 /* SemicolonClassElement */) { + else if (member.kind === 189 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -31654,11 +32362,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 141 /* Constructor */ && !member.body) { - emitOnlyPinnedOrTripleSlashComments(member); + if (member.kind === 142 /* Constructor */ && !member.body) { + emitCommentsOnNotEmittedNode(member); } // Check if there is any non-static property assignment - if (member.kind === 138 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 139 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -31697,18 +32405,23 @@ var ts; } } } + var startIndex = 0; write(" {"); scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). + startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); + var superCall; if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - var superCall = findInitialSuperCall(ctor); + superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); emit(superCall); @@ -31729,21 +32442,21 @@ var ts; emitEnd(baseTypeElement); } } - emitPropertyDeclarations(node, getInitializedProperties(node, false)); + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ false)); if (ctor) { var statements = ctor.body.statements; if (superCall) { statements = statements.slice(1); } - emitLines(statements); + emitLinesStartingAt(statements, startIndex); } - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); writeLine(); if (ctor) { emitLeadingCommentsOfPosition(ctor.body.statements.end); } decreaseIndent(); - emitToken(15 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); + emitToken(16 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); if (ctor) { @@ -31766,7 +32479,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { if (thisNodeIsDecorated) { // To preserve the correct runtime semantics when decorators are applied to the class, // the emit needs to follow one of the following rules: @@ -31845,8 +32558,8 @@ var ts; // // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. - var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 183 /* ClassExpression */; + var staticProperties = getInitializedProperties(node, /*static:*/ true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -31874,7 +32587,7 @@ var ts; emitMemberFunctionsForES6AndHigher(node); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. // For a decorated class, we need to assign its name (if it has one). This is because we emit @@ -31897,7 +32610,7 @@ var ts; var property = staticProperties[_a]; write(","); writeLine(); - emitPropertyDeclaration(node, property, tempVariable, true); + emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); } write(","); writeLine(); @@ -31930,7 +32643,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -31965,23 +32678,23 @@ var ts; writeLine(); emitConstructor(node, baseTypeNode); emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, true)); + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ true)); writeLine(); emitDecoratorsOfClass(node); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end, function () { + emitToken(16 /* CloseBraceToken */, node.members.end, function () { write("return "); emitDeclarationName(node); }); write(";"); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); tempFlags = saveTempFlags; tempVariables = saveTempVariables; tempParameters = saveTempParameters; computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); @@ -31989,11 +32702,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { emitExportMemberAssignment(node); } if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { @@ -32007,7 +32720,7 @@ var ts; } } function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, /*staticFlag*/ 0); emitDecoratorsOfMembers(node, 128 /* Static */); emitDecoratorsOfConstructor(node); } @@ -32036,13 +32749,13 @@ var ts; increaseIndent(); writeLine(); var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); emit(decorator.expression); emitEnd(decorator); }); - argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); - emitSerializedTypeMetadata(node, argumentsWritten >= 0); + argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); + emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); decreaseIndent(); writeLine(); write("], "); @@ -32085,7 +32798,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 140 /* MethodDeclaration */) { + if (member.kind === 141 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -32123,7 +32836,7 @@ var ts; // writeLine(); emitStart(member); - if (member.kind !== 138 /* PropertyDeclaration */) { + if (member.kind !== 139 /* PropertyDeclaration */) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -32138,7 +32851,7 @@ var ts; increaseIndent(); writeLine(); var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); emit(decorator.expression); emitEnd(decorator); @@ -32153,7 +32866,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 138 /* PropertyDeclaration */) { + if (member.kind !== 139 /* PropertyDeclaration */) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -32176,7 +32889,7 @@ var ts; var parameter = _b[_a]; if (ts.nodeIsDecorated(parameter)) { var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { + argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); write("__param(" + parameterIndex + ", "); emit(decorator.expression); @@ -32195,10 +32908,10 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 138 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 139 /* PropertyDeclaration */: return true; } return false; @@ -32208,7 +32921,7 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: return true; } return false; @@ -32218,9 +32931,9 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 211 /* ClassDeclaration */: - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 212 /* ClassDeclaration */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: return true; } return false; @@ -32235,22 +32948,22 @@ var ts; // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. // * The serialized type of any other FunctionLikeDeclaration is "Function". // * The serialized type of any other node is "void 0". - // + // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: write("Function"); return; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: emitSerializedTypeNode(node.type); return; - case 135 /* Parameter */: + case 136 /* Parameter */: emitSerializedTypeNode(node.type); return; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: emitSerializedTypeNode(node.type); return; - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -32261,67 +32974,75 @@ var ts; write("void 0"); } function emitSerializedTypeNode(node) { - switch (node.kind) { - case 100 /* VoidKeyword */: - write("void 0"); - return; - case 157 /* ParenthesizedType */: - emitSerializedTypeNode(node.type); - return; - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - write("Function"); - return; - case 153 /* ArrayType */: - case 154 /* TupleType */: - write("Array"); - return; - case 147 /* TypePredicate */: - case 117 /* BooleanKeyword */: - write("Boolean"); - return; - case 127 /* StringKeyword */: - case 8 /* StringLiteral */: - write("String"); - return; - case 125 /* NumberKeyword */: - write("Number"); - return; - case 128 /* SymbolKeyword */: - write("Symbol"); - return; - case 148 /* TypeReference */: - emitSerializedTypeReferenceNode(node); - return; - case 151 /* TypeQuery */: - case 152 /* TypeLiteral */: - case 155 /* UnionType */: - case 156 /* IntersectionType */: - case 114 /* AnyKeyword */: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; + if (node) { + switch (node.kind) { + case 101 /* VoidKeyword */: + write("void 0"); + return; + case 158 /* ParenthesizedType */: + emitSerializedTypeNode(node.type); + return; + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + write("Function"); + return; + case 154 /* ArrayType */: + case 155 /* TupleType */: + write("Array"); + return; + case 148 /* TypePredicate */: + case 118 /* BooleanKeyword */: + write("Boolean"); + return; + case 128 /* StringKeyword */: + case 9 /* StringLiteral */: + write("String"); + return; + case 126 /* NumberKeyword */: + write("Number"); + return; + case 129 /* SymbolKeyword */: + write("Symbol"); + return; + case 149 /* TypeReference */: + emitSerializedTypeReferenceNode(node); + return; + case 152 /* TypeQuery */: + case 153 /* TypeLiteral */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: + case 115 /* AnyKeyword */: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } } write("Object"); } /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ function emitSerializedTypeReferenceNode(node) { - var typeName = node.typeName; - var result = resolver.getTypeReferenceSerializationKind(node); + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + // Clone the type name and parent it to a location outside of the current declaration. + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); switch (result) { case ts.TypeReferenceSerializationKind.Unknown: var temp = createAndRecordTempVariable(0 /* Auto */); write("(typeof ("); emitNodeWithoutSourceMap(temp); write(" = "); - emitEntityNameAsExpression(typeName, true); + emitEntityNameAsExpression(typeName, /*useFallback*/ true); write(") === 'function' && "); emitNodeWithoutSourceMap(temp); write(") || Object"); break; case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - emitEntityNameAsExpression(typeName, false); + emitEntityNameAsExpression(typeName, /*useFallback*/ false); break; case ts.TypeReferenceSerializationKind.VoidType: write("void 0"); @@ -32360,11 +33081,11 @@ var ts; // // * If the declaration is a class, the parameters of the first constructor with a body are used. // * If the declaration is function-like and has a body, the parameters of the function are used. - // + // // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -32380,10 +33101,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 153 /* ArrayType */) { + if (parameterType.kind === 154 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 148 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 149 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -32401,7 +33122,7 @@ var ts; } /** Serializes the return type of function. Used by the __metadata decorator for a method. */ function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { + if (node && ts.isFunctionLike(node) && node.type) { emitSerializedTypeNode(node.type); return; } @@ -32446,7 +33167,7 @@ var ts; return argumentsWritten; } function emitInterfaceDeclaration(node) { - emitOnlyPinnedOrTripleSlashComments(node); + emitCommentsOnNotEmittedNode(node); } function shouldEmitEnumDeclaration(node) { var isConstEnum = ts.isConst(node); @@ -32482,7 +33203,7 @@ var ts; emitLines(node.members); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -32543,7 +33264,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 215 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -32558,7 +33279,7 @@ var ts; // Emit only if this module is non-ambient. var shouldEmit = shouldEmitModuleDeclaration(node); if (!shouldEmit) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); @@ -32579,7 +33300,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 216 /* ModuleBlock */) { + if (node.body.kind === 217 /* ModuleBlock */) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -32598,7 +33319,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(15 /* CloseBraceToken */, moduleBlock.statements.end); + emitToken(16 /* CloseBraceToken */, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -32612,7 +33333,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 66 /* Identifier */ && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 67 /* Identifier */ && node.parent === currentSourceFile) { if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); @@ -32624,29 +33345,45 @@ var ts; emitExportMemberAssignments(node.name); } } + /* + * Some bundlers (SystemJS builder) sometimes want to rename dependencies. + * Here we check if alternative name was provided for a given moduleName and return it if possible. + */ + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } function emitRequire(moduleName) { - if (moduleName.kind === 8 /* StringLiteral */) { + if (moduleName.kind === 9 /* StringLiteral */) { write("require("); - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - emitToken(17 /* CloseParenToken */, moduleName.end); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18 /* CloseParenToken */, moduleName.end); } else { write("require()"); } } function getNamespaceDeclarationNode(node) { - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 219 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 220 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -32661,7 +33398,7 @@ var ts; // ES6 import if (node.importClause) { var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { write("import "); emitStart(node.importClause); @@ -32674,7 +33411,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -32700,7 +33437,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 218 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 219 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2 /* AMD */) { emitLeadingComments(node); @@ -32719,7 +33456,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 219 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 220 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -32770,16 +33507,33 @@ var ts; (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); + // variable declaration for import-equals declaration can be hoisted in system modules + // in this case 'var' should be omitted and emit should contain only initialization + var variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); + // is it top level export import v = a.b.c in system module? + // if yes - it needs to be rewritten as exporter('v', v = a.b.c) + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1 /* Export */)) { + write("var "); + } } - else if (!(node.flags & 1 /* Export */)) { - write("var "); + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); + if (isExported) { + write(")"); + } write(";"); emitEnd(node); emitExportImportAssignments(node); @@ -32808,11 +33562,11 @@ var ts; emitStart(specifier); emitContainingModuleName(specifier); write("."); - emitNodeWithoutSourceMap(specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); write(" = "); write(generatedName); write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); write(";"); emitEnd(specifier); } @@ -32835,7 +33589,6 @@ var ts; } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { // export { x, y, ... } @@ -32848,10 +33601,9 @@ var ts; } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -32864,13 +33616,11 @@ var ts; if (needsComma) { write(", "); } - emitStart(specifier); if (specifier.propertyName) { - emitNodeWithoutSourceMap(specifier.propertyName); + emit(specifier.propertyName); write(" as "); } - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier); + emit(specifier.name); needsComma = true; } } @@ -32883,8 +33633,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 210 /* FunctionDeclaration */ && - expression.kind !== 211 /* ClassDeclaration */) { + if (expression.kind !== 211 /* FunctionDeclaration */ && + expression.kind !== 212 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -32898,6 +33648,7 @@ var ts; write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0 /* ES3 */) { write("[\"default\"] = "); @@ -32920,9 +33671,9 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { + resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { // import "mod" // import x from "mod" where x is referenced // import * as x from "mod" where x is referenced @@ -32930,13 +33681,13 @@ var ts; externalImports.push(node); } break; - case 218 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 229 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 219 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 230 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -32957,7 +33708,7 @@ var ts; } } break; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -32983,17 +33734,17 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 219 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 220 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 225 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 226 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8 /* StringLiteral */) { - return getLiteralText(moduleName); + if (moduleName.kind === 9 /* StringLiteral */) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); } return undefined; } @@ -33006,8 +33757,8 @@ var ts; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 225 /* ExportDeclaration */ || - (importNode.kind === 219 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 226 /* ExportDeclaration */ || + (importNode.kind === 220 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -33040,14 +33791,14 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 225 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 226 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } } if (!hasExportDeclarationWithExportClause) { // we still need to emit exportStar helper - return emitExportStarFunction(undefined); + return emitExportStarFunction(/*localNames*/ undefined); } } var exportedNamesStorageRef = makeUniqueName("exportedNames"); @@ -33072,7 +33823,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 225 /* ExportDeclaration */) { + if (externalImport.kind !== 226 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -33097,6 +33848,8 @@ var ts; write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); + write("var exports = {};"); + writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); @@ -33104,10 +33857,12 @@ var ts; if (localNames) { write("&& !" + localNames + ".hasOwnProperty(n)"); } - write(") " + exportFunctionForFile + "(n, m[n]);"); + write(") exports[n] = m[n];"); decreaseIndent(); writeLine(); write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); decreaseIndent(); writeLine(); write("}"); @@ -33116,7 +33871,7 @@ var ts; function writeExportedName(node) { // do not record default exports // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 66 /* Identifier */ && node.flags & 1024 /* Default */) { + if (node.kind !== 67 /* Identifier */ && node.flags & 1024 /* Default */) { return; } if (started) { @@ -33127,8 +33882,8 @@ var ts; } writeLine(); write("'"); - if (node.kind === 66 /* Identifier */) { - emitNodeWithoutSourceMap(node); + if (node.kind === 67 /* Identifier */) { + emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); @@ -33156,7 +33911,7 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 66 /* Identifier */ + var name_25 = local.kind === 67 /* Identifier */ ? local : local.name; if (name_25) { @@ -33172,13 +33927,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 211 /* ClassDeclaration */ || local.kind === 215 /* ModuleDeclaration */ || local.kind === 214 /* EnumDeclaration */) { + if (local.kind === 212 /* ClassDeclaration */ || local.kind === 216 /* ModuleDeclaration */ || local.kind === 215 /* EnumDeclaration */) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 66 /* Identifier */ ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 67 /* Identifier */ ? local.parent : local); if (flags & 1 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -33206,21 +33961,21 @@ var ts; if (node.flags & 2 /* Ambient */) { return; } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 214 /* EnumDeclaration */) { + if (node.kind === 215 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33229,7 +33984,7 @@ var ts; } return; } - if (node.kind === 215 /* ModuleDeclaration */) { + if (node.kind === 216 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33238,10 +33993,10 @@ var ts; } return; } - if (node.kind === 208 /* VariableDeclaration */ || node.kind === 160 /* BindingElement */) { - if (shouldHoistVariable(node, false)) { + if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { + if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { var name_26 = node.name; - if (name_26.kind === 66 /* Identifier */) { + if (name_26.kind === 67 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } @@ -33253,6 +34008,13 @@ var ts; } return; } + if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } if (ts.isBindingPattern(node)) { ts.forEach(node.elements, visit); return; @@ -33272,12 +34034,12 @@ var ts; // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 245 /* SourceFile */; + ts.getEnclosingBlockScopeContainer(node).kind === 246 /* SourceFile */; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); } - function emitSystemModuleBody(node, startIndex) { + function emitSystemModuleBody(node, dependencyGroups, startIndex) { // shape of the body in system modules: // function (exports) { // @@ -33322,105 +34084,86 @@ var ts; write("return {"); increaseIndent(); writeLine(); - emitSetters(exportStarFunction); + emitSetters(exportStarFunction, dependencyGroups); writeLine(); emitExecute(node, startIndex); decreaseIndent(); writeLine(); write("}"); // return - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); } - function emitSetters(exportStarFunction) { + function emitSetters(exportStarFunction, dependencyGroups) { write("setters:["); - for (var i = 0; i < externalImports.length; ++i) { + for (var i = 0; i < dependencyGroups.length; ++i) { if (i !== 0) { write(","); } writeLine(); increaseIndent(); - var importNode = externalImports[i]; - var importVariableName = getLocalNameForExternalImport(importNode) || ""; - var parameterName = "_" + importVariableName; + var group = dependencyGroups[i]; + // derive a unique name for parameter from the first named entry in the group + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); - switch (importNode.kind) { - case 219 /* ImportDeclaration */: - if (!importNode.importClause) { - // 'import "..."' case - // module is imported only for side-effects, setter body will be empty - break; - } - // fall-through - case 218 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - writeLine(); - // save import into the local - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - var defaultName = importNode.kind === 219 /* ImportDeclaration */ - ? importNode.importClause.name - : importNode.name; - if (defaultName) { - // emit re-export for imported default name - // import n1 from 'foo1' - // import n2 = require('foo2') - // export {n1} - // export {n2} - emitExportMemberAssignments(defaultName); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 220 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 219 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== ""); writeLine(); - } - if (importNode.kind === 219 /* ImportDeclaration */ && - importNode.importClause.namedBindings) { - var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 221 /* NamespaceImport */) { - // emit re-export for namespace - // import * as n from 'foo' - // export {n} - emitExportMemberAssignments(namedBindings.name); + // save import into the local + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 226 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { + // export {a, b as c} from 'foo' + // emit as: + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); } else { - // emit re-exports for named imports - // import {a, b} from 'foo' - // export {a, b as c} - for (var _a = 0, _b = namedBindings.elements; _a < _b.length; _a++) { - var element = _b[_a]; - emitExportMemberAssignments(element.name || element.propertyName); - writeLine(); - } - } - } - decreaseIndent(); - break; - case 225 /* ExportDeclaration */: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - if (importNode.exportClause) { - // export {a, b as c} from 'foo' - // emit as: - // exports('a', _foo["a"]) - // exports('c', _foo["b"]) - for (var _c = 0, _d = importNode.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; writeLine(); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(e.name); - write("\", " + parameterName + "[\""); - emitNodeWithoutSourceMap(e.propertyName || e.name); - write("\"]);"); + // export * from 'foo' + // emit as: + // exportStar(_foo); + write(exportStarFunction + "(" + parameterName + ");"); } - } - else { writeLine(); - // export * from 'foo' - // emit as: - // exportStar(_foo); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - decreaseIndent(); - break; + break; + } } + decreaseIndent(); write("}"); decreaseIndent(); } @@ -33432,17 +34175,33 @@ var ts; writeLine(); for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; - // - imports/exports are not emitted for system modules - // - function declarations are not emitted because they were already hoisted switch (statement.kind) { - case 225 /* ExportDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 210 /* FunctionDeclaration */: + // - function declarations are not emitted because they were already hoisted + // - import declarations are not emitted since they are already handled in setters + // - export declarations with module specifiers are not emitted since they were already written in setters + // - export declarations without module specifiers are emitted preserving the order + case 211 /* FunctionDeclaration */: + case 220 /* ImportDeclaration */: continue; + case 226 /* ExportDeclaration */: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + // write call to exporter function for every export specifier in exports list + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 219 /* ImportEqualsDeclaration */: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + // - import equals declarations that import external modules are not emitted + continue; + } + // fall-though for import declarations that import internal modules + default: + writeLine(); + emit(statement); } - writeLine(); - emit(statement); } decreaseIndent(); writeLine(); @@ -33467,8 +34226,20 @@ var ts; write("\"" + node.moduleName + "\", "); } write("["); + var groupIndices = {}; + var dependencyGroups = []; for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } if (i !== 0) { write(", "); } @@ -33477,8 +34248,9 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); + emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); @@ -33543,33 +34315,36 @@ var ts; } } function emitAMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); write("define("); if (node.moduleName) { write("\"" + node.moduleName + "\", "); } - emitAMDDependencies(node, true); + emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); write(") {"); increaseIndent(); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); decreaseIndent(); writeLine(); write("});"); } function emitCommonJSModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(false); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ false); } function emitUMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); // Module is detected first to support Browserify users that load into a browser with an AMD loader writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); @@ -33579,8 +34354,8 @@ var ts; emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); decreaseIndent(); writeLine(); write("});"); @@ -33590,9 +34365,10 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); // Emit exportDefault if it exists will happen as part // or normal statement emit. } @@ -33618,9 +34394,9 @@ var ts; break; } } - function trimReactWhitespace(node) { + function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; - var text = ts.getTextOfNode(node); + var text = ts.getTextOfNode(node, /*includeTrivia*/ true); var firstNonWhitespace = 0; var lastNonWhitespace = -1; // JSX trims whitespace at the end and beginning of lines, except that the @@ -33631,7 +34407,7 @@ var ts; if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; } firstNonWhitespace = -1; } @@ -33644,15 +34420,26 @@ var ts; } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; + } + if (result) { + // Replace entities like   + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); } return result; } function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2 /* React */: - var text = trimReactWhitespace(node); - if (text.length === 0) { + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { return undefined; } else { @@ -33660,19 +34447,19 @@ var ts; } case 1 /* Preserve */: default: - return ts.getTextOfNode(node, true); + return ts.getTextOfNode(node, /*includeTrivia*/ true); } } function emitJsxText(node) { switch (compilerOptions.jsx) { case 2 /* React */: - write('"'); - write(trimReactWhitespace(node)); - write('"'); + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); break; case 1 /* Preserve */: default: - write(ts.getTextOfNode(node, true)); + writer.writeLiteral(ts.getTextOfNode(node, /*includeTrivia*/ true)); break; } } @@ -33681,9 +34468,9 @@ var ts; switch (compilerOptions.jsx) { case 1 /* Preserve */: default: - write('{'); + write("{"); emit(node.expression); - write('}'); + write("}"); break; case 2 /* React */: emit(node.expression); @@ -33716,12 +34503,7 @@ var ts; } } } - function emitSourceFileNode(node) { - // Start new file on new line - writeLine(); - emitDetachedComments(node); - // emit prologue directives prior to __extends - var startIndex = emitDirectivePrologues(node.statements, false); + function emitEmitHelpers(node) { // Only emit helpers if the user did not say otherwise. if (!compilerOptions.noEmitHelpers) { // Only Emit __extends function when target ES5. @@ -33746,6 +34528,14 @@ var ts; awaiterEmitted = true; } } + } + function emitSourceFileNode(node) { + // Start new file on new line + writeLine(); + emitShebang(); + emitDetachedComments(node); + // emit prologue directives prior to __extends + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2 /* ES6 */) { emitES6Module(node, startIndex); @@ -33768,57 +34558,76 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); } emitLeadingComments(node.endOfFileToken); } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2 /* Ambient */) { + return emitCommentsOnNotEmittedNode(node); + } + if (isSpecializedCommentHandling(node)) { + // This is the node that will handle its own comments and sourcemap + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } function emitNodeWithoutSourceMap(node) { - if (!node) { - return; + if (node) { + emitJavaScriptWorker(node); } - if (node.flags & 2 /* Ambient */) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - var emitComments = shouldEmitLeadingAndTrailingComments(node); - if (emitComments) { - emitLeadingComments(node); - } - emitJavaScriptWorker(node); - if (emitComments) { - emitTrailingComments(node); + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + // All of these entities are emitted in a specialized fashion. As such, we allow + // the specialized methods for each to handle the comments on the nodes. + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 225 /* ExportAssignment */: + return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - // All of these entities are emitted in a specialized fashion. As such, we allow - // the specialized methods for each to handle the comments on the nodes. - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 224 /* ExportAssignment */: - return false; - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); } + // If the node is emitted in specialized fashion, dont emit comments as this node will handle + // emitting comments when emitting itself + ts.Debug.assert(!isSpecializedCommentHandling(node)); // If this is the expression body of an arrow function that we're down-leveling, // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. - if (node.kind !== 189 /* Block */ && + if (node.kind !== 190 /* Block */ && node.parent && - node.parent.kind === 171 /* ArrowFunction */ && + node.parent.kind === 172 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -33829,170 +34638,170 @@ var ts; function emitJavaScriptWorker(node) { // Check if the node can be emitted regardless of the ScriptTarget switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return emitIdentifier(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return emitParameter(node); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return emitMethod(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return emitAccessor(node); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return emitThis(node); - case 92 /* SuperKeyword */: + case 93 /* SuperKeyword */: return emitSuper(node); - case 90 /* NullKeyword */: + case 91 /* NullKeyword */: return write("null"); - case 96 /* TrueKeyword */: + case 97 /* TrueKeyword */: return write("true"); - case 81 /* FalseKeyword */: + case 82 /* FalseKeyword */: return write("false"); - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 9 /* RegularExpressionLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 11 /* TemplateHead */: - case 12 /* TemplateMiddle */: - case 13 /* TemplateTail */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 10 /* RegularExpressionLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* TemplateHead */: + case 13 /* TemplateMiddle */: + case 14 /* TemplateTail */: return emitLiteral(node); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return emitTemplateExpression(node); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return emitTemplateSpan(node); - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: return emitJsxElement(node); - case 233 /* JsxText */: + case 234 /* JsxText */: return emitJsxText(node); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return emitJsxExpression(node); - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return emitQualifiedName(node); - case 158 /* ObjectBindingPattern */: + case 159 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 159 /* ArrayBindingPattern */: + case 160 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 160 /* BindingElement */: + case 161 /* BindingElement */: return emitBindingElement(node); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 243 /* ShorthandPropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 165 /* CallExpression */: + case 166 /* CallExpression */: return emitCallExpression(node); - case 166 /* NewExpression */: + case 167 /* NewExpression */: return emitNewExpression(node); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return emit(node.expression); - case 186 /* AsExpression */: + case 187 /* AsExpression */: return emit(node.expression); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return emitParenExpression(node); - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return emitDeleteExpression(node); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return emitVoidExpression(node); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return emitAwaitExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return emitBinaryExpression(node); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return emitConditionalExpression(node); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return emitYieldExpression(node); - case 184 /* OmittedExpression */: + case 185 /* OmittedExpression */: return; - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return emitBlock(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return emitVariableStatement(node); - case 191 /* EmptyStatement */: + case 192 /* EmptyStatement */: return write(";"); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return emitExpressionStatement(node); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return emitIfStatement(node); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return emitDoStatement(node); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return emitWhileStatement(node); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return emitForStatement(node); - case 198 /* ForOfStatement */: - case 197 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 198 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return emitReturnStatement(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return emitWithStatement(node); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return emitSwitchStatement(node); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return emitLabelledStatement(node); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return emitThrowStatement(node); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return emitTryStatement(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return emitCatchClause(node); - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return emitClassExpression(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return emitClassDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return emitEnumMember(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return emitImportDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return emitExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return emitExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return emitSourceFileNode(node); } } @@ -34010,21 +34819,32 @@ var ts; } return leadingComments; } - function filterComments(ranges, onlyPinnedOrTripleSlashComments) { - // If we're removing comments, then we want to strip out all but the pinned or - // triple slash comments. - if (ranges && onlyPinnedOrTripleSlashComments) { - ranges = ts.filter(ranges, isPinnedOrTripleSlashComment); - if (ranges.length === 0) { - return undefined; - } + function isPinnedComments(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; + } + /** + * Determine if the given comment is a triple-slash + * + * @return true if the comment is a triple-slash comment else false + **/ + function isTripleSlashComment(comment) { + // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text + // so that we don't end up computing comment string and doing match for all // comments + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */) { + var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? + true : false; } - return ranges; + return false; } function getLeadingCommentsToEmit(node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 245 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 246 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -34039,32 +34859,71 @@ var ts; function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 245 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 246 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } } - function emitOnlyPinnedOrTripleSlashComments(node) { - emitLeadingCommentsWorker(node, true); + /** + * Emit comments associated with node that will not be emitted into JS file + */ + function emitCommentsOnNotEmittedNode(node) { + emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false); } function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, compilerOptions.removeComments); + return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true); } - function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) { - // If the caller only wants pinned or triple slash comments, then always filter - // down to that set. Otherwise, filter based on the current compiler options. - var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); + function emitLeadingCommentsWorker(node, isEmittedNode) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, + // unless it is a triple slash comment at the top of the file. + // For Example: + // /// + // declare var x; + // /// + // interface F {} + // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted + if (node.pos === 0) { + leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); + } + } ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment); } function emitTrailingComments(node) { + if (compilerOptions.removeComments) { + return; + } // Emit the trailing comments only if the parent's end doesn't match - var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); + var trailingComments = getTrailingCommentsToEmit(node); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ - ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); } - function emitLeadingCommentsOfPosition(pos) { + /** + * Emit trailing comments at the position. The term trailing comment is used here to describe following comment: + * x, /comment1/ y + * ^ => pos; the function will emit "comment1" in the emitJS + */ + function emitTrailingCommentsOfPosition(pos) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); + } + function emitLeadingCommentsOfPositionWorker(pos) { + if (compilerOptions.removeComments) { + return; + } var leadingComments; if (hasDetachedComments(pos)) { // get comments without detached comments @@ -34074,13 +34933,26 @@ var ts; // get the leading comments from the node leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); } - leadingComments = filterComments(leadingComments, compilerOptions.removeComments); ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); } function emitDetachedComments(node) { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + var leadingComments; + if (compilerOptions.removeComments) { + // removeComments is true, only reserve pinned comment at the top of file + // For example: + // /*! Pinned Comment */ + // + // var x = 10; + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } + } + else { + // removeComments is false, just get detached as normal and bypass the process to filter comment + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } if (leadingComments) { var detachedComments = []; var lastComment; @@ -34107,7 +34979,7 @@ var ts; if (nodeLine >= lastCommentLine + 2) { // Valid detachedComments ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -34119,15 +34991,10 @@ var ts; } } } - function isPinnedOrTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; - } - else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */ && - currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { - return true; + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); } } } @@ -34139,9 +35006,265 @@ var ts; } } ts.emitFiles = emitFiles; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; })(ts || (ts = {})); /// /// +/// var ts; (function (ts) { /* @internal */ ts.programTime = 0; @@ -34149,7 +35272,8 @@ var ts; /* @internal */ ts.ioReadTime = 0; /* @internal */ ts.ioWriteTime = 0; /** The version of the TypeScript compiler release */ - ts.version = "1.5.3"; + var emptyArray = []; + ts.version = "1.7.0"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -34166,6 +35290,161 @@ var ts; return undefined; } ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === 1 /* CommonJS */ ? 2 /* NodeJs */ : 1 /* Classic */; + switch (moduleResolution) { + case 2 /* NodeJs */: return nodeModuleNameResolver(moduleName, containingFile, host); + case 1 /* Classic */: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + ts.resolveModuleName = resolveModuleName; + function nodeModuleNameResolver(moduleName, containingFile, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + var failedLookupLocations = []; + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + if (resolvedFileName) { + return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; + } + resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + return resolvedFileName + ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { + if (loadOnlyDts) { + return tryLoad(".d.ts"); + } + else { + return ts.forEach(ts.supportedExtensions, tryLoad); + } + function tryLoad(ext) { + var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + var packageJsonPath = ts.combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + var jsonContent; + try { + var jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + // gracefully handle if readFile fails or returns not JSON + jsonContent = { typings: undefined }; + } + if (jsonContent.typings) { + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocation.push(packageJsonPath); + } + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + } + function loadModuleFromNodeModules(moduleName, directory, host) { + var failedLookupLocations = []; + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + } + result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + directory = parentPath; + } + return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + function nameStartsWithDotSlashOrDotDotSlash(name) { + var i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === 46 /* dot */); + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + // module names that contain '!' are used to reference resources and are not resolved to actual files on disk + if (moduleName.indexOf('!') != -1) { + return { resolvedModule: undefined, failedLookupLocations: [] }; + } + var searchPath = ts.getDirectoryPath(containingFile); + var searchName; + var failedLookupLocations = []; + var referencedSourceFile; + while (true) { + searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); + referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + if (extension === ".tsx" && !compilerOptions.jsx) { + // resolve .tsx files only if jsx support is enabled + // 'logical not' handles both undefined and None cases + return undefined; + } + var candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + if (referencedSourceFile) { + break; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + /* @internal */ + ts.defaultInitCompilerOptions = { + module: 1 /* CommonJS */, + target: 0 /* ES3 */, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false + }; function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; @@ -34231,7 +35510,9 @@ var ts; getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); } }; } ts.createCompilerHost = createCompilerHost; @@ -34266,10 +35547,11 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function createProgram(rootNames, options, host) { + function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; - var diagnostics = ts.createDiagnosticCollection(); + var fileProcessingDiagnostics = ts.createDiagnosticCollection(); + var programDiagnostics = ts.createDiagnosticCollection(); var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; @@ -34277,18 +35559,38 @@ var ts; var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var resolveModuleNamesWorker = host.resolveModuleNames + ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) + : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - // Do not process the default library if: - // - The '--noLib' flag is used. - // - A 'no-default-lib' reference comment is encountered in - // processing the root files. - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); + if (oldProgram) { + // check properties that can affect structure of the program or module resolution strategy + // if any of these properties has changed - structure cannot be reused + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + // Do not process the default library if: + // - The '--noLib' flag is used. + // - A 'no-default-lib' reference comment is encountered in + // processing the root files. + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } } verifyCompilerOptions(); + // unconditionally set oldProgram to undefined to prevent it from being captured in closure + oldProgram = undefined; ts.programTime += new Date().getTime() - start; program = { + getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, @@ -34306,7 +35608,8 @@ var ts; getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, - getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); } + getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, + getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; } }; return program; function getClassifiableNames() { @@ -34321,6 +35624,84 @@ var ts; } return classifiableNames; } + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; + } + ts.Debug.assert(!oldProgram.structureIsReused); + // there is an old program, check if we can reuse its structure + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + // check if program source files has changed in the way that can affect structure of the program + var newSourceFiles = []; + var modifiedSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + // value of no-default-lib has changed + // this will affect if default library is injected into the list of files + return false; + } + // check tripleslash references + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + // tripleslash references has changed + return false; + } + // check imports + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + // imports has changed + return false; + } + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); + // ensure that module resolution results are still correct + for (var i = 0; i < moduleNames.length; ++i) { + var newResolution = resolutions[i]; + var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]); + var resolutionChanged = oldResolution + ? !newResolution || + oldResolution.resolvedFileName !== newResolution.resolvedFileName || + !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport + : newResolution; + if (resolutionChanged) { + return false; + } + } + } + // pass the cache of module resolutions from the old source file + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + modifiedSourceFiles.push(newSourceFile); + } + else { + // file has no changes - use it as is + newSourceFile = oldSourceFile; + } + // if file has passed all checks it should be safe to reuse it + newSourceFiles.push(newSourceFile); + } + // update fileName -> file mapping + for (var _b = 0; _b < newSourceFiles.length; _b++) { + var file = newSourceFiles[_b]; + filesByName.set(file.fileName, file); + } + files = newSourceFiles; + fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); + for (var _c = 0; _c < modifiedSourceFiles.length; _c++) { + var modifiedFile = modifiedSourceFiles[_c]; + fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + } + oldProgram.structureIsReused = true; + return true; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -34334,10 +35715,10 @@ var ts; }; } function getDiagnosticsProducingTypeChecker() { - return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); + return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); } function getTypeChecker() { - return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); + return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } function emit(sourceFile, writeFileCallback, cancellationToken) { var _this = this; @@ -34347,7 +35728,7 @@ var ts; // If the noEmitOnError flag is set, then check if we have any errors so far. If so, // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones - if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { + if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } // Create the emit resolver outside of the "emitTime" tracking code below. That way @@ -34358,7 +35739,7 @@ var ts; // This is because in the -out scenario all files need to be emitted, and therefore all // files need to be type checked. And the way to specify that all files need to be type // checked is to not pass the file to getEmitResolver. - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); var start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); ts.emitTime += new Date().getTime() - start; @@ -34419,8 +35800,9 @@ var ts; ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); - var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); + var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); + var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); + return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); }); } function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { @@ -34435,7 +35817,8 @@ var ts; } function getOptionsDiagnostics() { var allDiagnostics = []; - ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function getGlobalDiagnostics() { @@ -34449,14 +35832,59 @@ var ts; function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var start; - var length; - var diagnosticArgument; - if (refEnd !== undefined && refPos !== undefined) { - start = refPos; - length = refEnd - refPos; + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; } + var imports; + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { + break; + } + if (!moduleNameExpr.text) { + break; + } + (imports || (imports = [])).push(moduleNameExpr); + break; + case 216 /* ModuleDeclaration */: + if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An AmbientExternalModuleDeclaration declares an external module. + // This type of declaration is permitted only in the global module. + // The StringLiteral must specify a top - level external module name. + // Relative external module names are not permitted + ts.forEachChild(node.body, function (node) { + if (ts.isExternalModuleImportEqualsDeclaration(node) && + ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9 /* StringLiteral */) { + var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + if (moduleName) { + (imports || (imports = [])).push(moduleName); + } + } + }); + } + break; + } + } + file.imports = imports || emptyArray; + } + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { @@ -34487,34 +35915,34 @@ var ts; } } if (diagnostic) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, start, length, diagnostic].concat(diagnosticArgument))); + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); } else { - diagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); } } } // Get source file from normalized fileName - function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { + function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); if (filesByName.contains(canonicalName)) { // We've already looked for this file, use cached result - return getSourceFileFromCache(fileName, canonicalName, false); + return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false); } else { var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); + return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true); } // We haven't looked for this file, do so now and cache result var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } else { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); filesByName.set(canonicalName, file); @@ -34522,11 +35950,12 @@ var ts; skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; // Set the source file for normalized absolute path filesByName.set(canonicalAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); - processImportedModules(file, basePath); } + // always process imported modules to record module name resolutions + processImportedModules(file, basePath); if (isDefaultLib) { file.isDefaultLib = true; files.unshift(file); @@ -34542,7 +35971,12 @@ var ts; if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } } } return file; @@ -34550,57 +35984,45 @@ var ts; } function processReferencedFiles(file, basePath) { ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = ts.isRootedDiskPath(ref.fileName) ? ref.fileName : ts.combinePaths(basePath, ref.fileName); - processSourceFile(ts.normalizePath(referencedFileName), false, file, ref.pos, ref.end); + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, /* isDefaultLib */ false, file, ref.pos, ref.end); }); } function processImportedModules(file, basePath) { - ts.forEach(file.statements, function (node) { - if (node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */ || node.kind === 225 /* ExportDeclaration */) { - var moduleNameExpr = ts.getExternalModuleName(node); - if (moduleNameExpr && moduleNameExpr.kind === 8 /* StringLiteral */) { - var moduleNameText = moduleNameExpr.text; - if (moduleNameText) { - var searchPath = basePath; - var searchName; - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleNameText)); - if (ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, moduleNameExpr); })) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); + for (var i = 0; i < file.imports.length; ++i) { + var resolution = resolutions[i]; + ts.setResolvedModule(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + var importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]); + if (importedFile && resolution.isExternalLibraryImport) { + if (!ts.isExternalModule(importedFile)) { + var start_2 = ts.getTokenPosOfNode(file.imports[i], file); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.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 (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) { + var start_3 = ts.getTokenPosOfNode(file.imports[i], file); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_3, file.imports[i].end - start_3, ts.Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition)); + } + else if (importedFile.referencedFiles.length) { + var firstRef = importedFile.referencedFiles[0]; + fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); } } } } - else if (node.kind === 215 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An AmbientExternalModuleDeclaration declares an external module. - // This type of declaration is permitted only in the global module. - // The StringLiteral must specify a top - level external module name. - // Relative external module names are not permitted - ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8 /* StringLiteral */) { - var nameLiteral = ts.getExternalModuleImportEqualsDeclarationExpression(node); - var moduleName = nameLiteral.text; - if (moduleName) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); - ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, nameLiteral); }); - } - } - }); - } - }); + } + else { + // no imports - drop cached module resolutions + file.resolvedModules = undefined; + } + return; function findModuleSourceFile(fileName, nameLiteral) { - return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); + return findSourceFile(fileName, /* isDefaultLib */ false, file, ts.skipTrivia(file.text, nameLiteral.pos), nameLiteral.end); } } function computeCommonSourceDirectory(sourceFiles) { @@ -34621,7 +36043,7 @@ var ts; for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { if (commonPathComponents[i] !== sourcePathComponents[i]) { if (i === 0) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); return; } // New common path found that is 0 -> i-1 @@ -34646,7 +36068,7 @@ var ts; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); allFilesBelongToPath = false; } } @@ -34656,72 +36078,76 @@ var ts; } function verifyCompilerOptions() { if (options.isolatedModules) { - if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); - } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); } if (options.noEmitOnError) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); } if (options.out) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); } } if (options.inlineSourceMap) { if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); } if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); } } if (options.inlineSources) { if (!options.sourceMap && !options.inlineSourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); } } + if (options.out && options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { // Error to specify --mapRoot or --sourceRoot without mapSourceFiles if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); } return; } var languageVersion = options.target || 0 /* ES3 */; + var outFile = options.outFile || options.out; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (options.isolatedModules) { if (!options.module && languageVersion < 2 /* ES6 */) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); } var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); + programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && !options.module) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); + programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } // Cannot specify module gen target when in es6 or above if (options.module && languageVersion >= 2 /* ES6 */) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); } // there has to be common source directory if user specified --outdir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted if (options.outDir || options.sourceRoot || (options.mapRoot && - (!options.out || firstExternalModuleSourceFile !== undefined))) { + (!outFile || firstExternalModuleSourceFile !== undefined))) { if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); @@ -34738,20 +36164,26 @@ var ts; } } if (options.noEmit) { - if (options.out || options.outDir) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir)); + if (options.out) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + if (options.outDir) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); } } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.experimentalAsyncFunctions && options.target !== 2 /* ES6 */) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); } } } @@ -34789,6 +36221,11 @@ var ts; type: "boolean", description: ts.Diagnostics.Print_this_message }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + }, { name: "inlineSourceMap", type: "boolean" @@ -34879,6 +36316,13 @@ var ts; { name: "out", type: "string", + isFilePath: false, + // for correct behaviour, please use outFile + paramType: ts.Diagnostics.FILE + }, + { + name: "outFile", + type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE @@ -34931,6 +36375,12 @@ var ts; description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, paramType: ts.Diagnostics.LOCATION }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", @@ -34977,20 +36427,40 @@ var ts; type: "boolean", experimental: true, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: { + "node": 2 /* NodeJs */, + "classic": 1 /* Classic */ + }, + description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic } ]; - function parseCommandLine(commandLine) { - var options = {}; - var fileNames = []; - var errors = []; - var shortOptionNames = {}; + var optionNameMapCache; + /* @internal */ + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } var optionNameMap = {}; + var shortOptionNames = {}; ts.forEach(ts.optionDeclarations, function (option) { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { shortOptionNames[option.shortName] = option.name; } }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function parseCommandLine(commandLine, readFile) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; parseStrings(commandLine); return { options: options, @@ -35048,7 +36518,7 @@ var ts; } } function parseResponseFile(fileName) { - var text = ts.sys.readFile(fileName); + var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); if (!text) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); return; @@ -35087,10 +36557,10 @@ var ts; * Read tsconfig.json file * @param fileName The path to the config file */ - function readConfigFile(fileName) { - var text = ''; + function readConfigFile(fileName, readFile) { + var text = ""; try { - text = ts.sys.readFile(fileName); + text = readFile(fileName); } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; @@ -35172,6 +36642,9 @@ var ts; if (json["files"] instanceof Array) { fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } } else { var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; @@ -35250,7 +36723,7 @@ var ts; } else if (currentComment.kind === 3 /* MultiLineCommentTrivia */) { combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); - addOutliningSpanComments(currentComment, false); + addOutliningSpanComments(currentComment, /*autoCollapse*/ false); singleLineCommentCount = 0; lastSingleLineCommentEnd = -1; isFirstSingleLineComment = true; @@ -35267,11 +36740,11 @@ var ts; end: end, kind: 2 /* SingleLineCommentTrivia */ }; - addOutliningSpanComments(multipleSingleLineComments, false); + addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false); } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 171 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 172 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -35283,34 +36756,34 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 189 /* Block */: + case 190 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_8 = n.parent; - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + var parent_7 = n.parent; + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_8.kind === 194 /* DoStatement */ || - parent_8.kind === 197 /* ForInStatement */ || - parent_8.kind === 198 /* ForOfStatement */ || - parent_8.kind === 196 /* ForStatement */ || - parent_8.kind === 193 /* IfStatement */ || - parent_8.kind === 195 /* WhileStatement */ || - parent_8.kind === 202 /* WithStatement */ || - parent_8.kind === 241 /* CatchClause */) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + if (parent_7.kind === 195 /* DoStatement */ || + parent_7.kind === 198 /* ForInStatement */ || + parent_7.kind === 199 /* ForOfStatement */ || + parent_7.kind === 197 /* ForStatement */ || + parent_7.kind === 194 /* IfStatement */ || + parent_7.kind === 196 /* WhileStatement */ || + parent_7.kind === 203 /* WithStatement */ || + parent_7.kind === 242 /* CatchClause */) { + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_8.kind === 206 /* TryStatement */) { + if (parent_7.kind === 207 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_8; + var tryStatement = parent_7; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -35329,25 +36802,25 @@ var ts; break; } // Fallthrough. - case 216 /* ModuleBlock */: { - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + case 217 /* ModuleBlock */: { + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 162 /* ObjectLiteralExpression */: - case 217 /* CaseBlock */: { - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 163 /* ObjectLiteralExpression */: + case 218 /* CaseBlock */: { + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 161 /* ArrayLiteralExpression */: - var openBracket = ts.findChildOfKind(n, 18 /* OpenBracketToken */, sourceFile); - var closeBracket = ts.findChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); + case 162 /* ArrayLiteralExpression */: + var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -35422,9 +36895,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 8 /* StringLiteral */ || - node.kind === 7 /* NumericLiteral */) { + if (node.kind === 67 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || + node.kind === 8 /* NumericLiteral */) { return node.text; } } @@ -35436,8 +36909,8 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 133 /* ComputedPropertyName */) { - return tryAddComputedPropertyName(declaration.name.expression, containers, true); + else if (declaration.name.kind === 134 /* ComputedPropertyName */) { + return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ true); } else { // Don't know how to add this. @@ -35457,12 +36930,12 @@ var ts; } return true; } - if (expression.kind === 163 /* PropertyAccessExpression */) { + if (expression.kind === 164 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); } - return tryAddComputedPropertyName(propertyAccess.expression, containers, true); + return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion:*/ true); } return false; } @@ -35470,8 +36943,8 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 133 /* ComputedPropertyName */) { - if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { + if (declaration.name.kind === 134 /* ComputedPropertyName */) { + if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ false)) { return undefined; } } @@ -35546,17 +37019,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: // If we have a module declared as A.B.C, it is more "intuitive" // to say it only has a single layer of depth do { current = current.parent; - } while (current.kind === 215 /* ModuleDeclaration */); + } while (current.kind === 216 /* ModuleDeclaration */); // fall through - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -35567,21 +37040,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -35593,7 +37066,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -35602,21 +37075,21 @@ var ts; } } break; - case 160 /* BindingElement */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 209 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 210 /* FunctionDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 211 /* FunctionDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: childNodes.push(node); break; } @@ -35664,17 +37137,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -35685,12 +37158,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 210 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 211 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 189 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 190 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 210 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -35750,7 +37223,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 135 /* Parameter */: + case 136 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -35758,36 +37231,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 144 /* CallSignature */: + case 145 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: var variableDeclarationNode; var name_29; - if (node.kind === 160 /* BindingElement */) { + if (node.kind === 161 /* BindingElement */) { name_29 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 208 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 209 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -35806,13 +37279,13 @@ var ts; else { return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); } - case 141 /* Constructor */: + case 142 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 227 /* ExportSpecifier */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: + case 228 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -35842,29 +37315,29 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: return createSourceFileItem(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return createClassItem(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return createEnumItem(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return createModuleItem(node); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; function getModuleName(moduleDeclaration) { // We want to maintain quotation marks. - if (moduleDeclaration.name.kind === 8 /* StringLiteral */) { + if (moduleDeclaration.name.kind === 9 /* StringLiteral */) { return getTextOfNode(moduleDeclaration.name); } // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 215 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -35876,7 +37349,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 189 /* Block */) { + if (node.body && node.body.kind === 190 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -35897,7 +37370,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 141 /* Constructor */ && member; + return member.kind === 142 /* 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 @@ -35921,7 +37394,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 133 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -35930,13 +37403,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 215 /* ModuleDeclaration */) { + while (node.body.kind === 216 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 245 /* SourceFile */ + return node.kind === 246 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -36039,12 +37512,12 @@ var ts; if (chunk.text.length === candidate.length) { // a) Check if the part matches the candidate entirely, in an case insensitive or // sensitive manner. If it does, return that there was an exact match. - return createPatternMatch(PatternMatchKind.exact, punctuationStripped, candidate === chunk.text); + return createPatternMatch(PatternMatchKind.exact, punctuationStripped, /*isCaseSensitive:*/ candidate === chunk.text); } else { // b) Check if the part is a prefix of the candidate, in a case insensitive or sensitive // manner. If it does, return that there was a prefix match. - return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, startsWith(candidate, chunk.text)); + return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, /*isCaseSensitive:*/ startsWith(candidate, chunk.text)); } } var isLowercase = chunk.isLowerCase; @@ -36060,9 +37533,9 @@ var ts; var wordSpans = getWordSpans(candidate); for (var _i = 0; _i < wordSpans.length; _i++) { var span = wordSpans[_i]; - if (partStartsWith(candidate, span, chunk.text, true)) { + if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) { return createPatternMatch(PatternMatchKind.substring, punctuationStripped, - /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, false)); + /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false)); } } } @@ -36072,20 +37545,20 @@ var ts; // candidate in a case *sensitive* manner. If so, return that there was a substring // match. if (candidate.indexOf(chunk.text) > 0) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, true); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ true); } } if (!isLowercase) { // e) If the part was not entirely lowercase, then attempt a camel cased match as well. if (chunk.characterSpans.length > 0) { var candidateParts = getWordSpans(candidate); - var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, false); + var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false); if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, true, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ true, /*camelCaseWeight:*/ camelCaseWeight); } - camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, true); + camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ true); if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, false, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ false, /*camelCaseWeight:*/ camelCaseWeight); } } } @@ -36098,7 +37571,7 @@ var ts; // (Pattern: fogbar, Candidate: quuxfogbarFogBar). if (chunk.text.length < candidate.length) { if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, false); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ false); } } } @@ -36122,7 +37595,7 @@ var ts; // Note: if the segment contains a space or an asterisk then we must assume that it's a // multi-word segment. if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) { - var match = matchTextChunk(candidate, segment.totalTextChunk, false); + var match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false); if (match) { return [match]; } @@ -36168,7 +37641,7 @@ var ts; for (var _i = 0; _i < subWordTextChunks.length; _i++) { var subWordTextChunk = subWordTextChunks[_i]; // Try to match the candidate with this word - var result = matchTextChunk(candidate, subWordTextChunk, true); + var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true); if (!result) { return undefined; } @@ -36434,11 +37907,11 @@ var ts; }; } /* @internal */ function breakIntoCharacterSpans(identifier) { - return breakIntoSpans(identifier, false); + return breakIntoSpans(identifier, /*word:*/ false); } ts.breakIntoCharacterSpans = breakIntoCharacterSpans; /* @internal */ function breakIntoWordSpans(identifier) { - return breakIntoSpans(identifier, true); + return breakIntoSpans(identifier, /*word:*/ true); } ts.breakIntoWordSpans = breakIntoWordSpans; function breakIntoSpans(identifier, word) { @@ -36731,15 +38204,15 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 165 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 166 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 66 /* Identifier */ + var name = expression.kind === 67 /* Identifier */ ? expression - : expression.kind === 163 /* PropertyAccessExpression */ + : expression.kind === 164 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -36772,7 +38245,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 165 /* CallExpression */ || node.parent.kind === 166 /* NewExpression */) { + if (node.parent.kind === 166 /* CallExpression */ || node.parent.kind === 167 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -36788,8 +38261,8 @@ var ts; // Case 3: // foo(a#, #b#) -> The token is buried inside a list, and should give sig help // Find out if 'node' is an argument, a type argument, or neither - if (node.kind === 24 /* LessThanToken */ || - node.kind === 16 /* OpenParenToken */) { + if (node.kind === 25 /* LessThanToken */ || + node.kind === 17 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); @@ -36825,27 +38298,27 @@ var ts; }; } } - else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 168 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { - return getArgumentListInfoForTemplate(node.parent, 0); + return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); } } - else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 168 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 187 /* TemplateSpan */ && node.parent.parent.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 188 /* TemplateSpan */ && node.parent.parent.parent.kind === 168 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. - if (node.kind === 13 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -36873,7 +38346,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 23 /* CommaToken */) { + if (child.kind !== 24 /* CommaToken */) { argumentIndex++; } } @@ -36892,8 +38365,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, givin us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 23 /* CommaToken */; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 23 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24 /* CommaToken */; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24 /* CommaToken */) { argumentCount++; } return argumentCount; @@ -36923,7 +38396,7 @@ var ts; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex) { // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. - var argumentCount = tagExpression.template.kind === 10 /* NoSubstitutionTemplateLiteral */ + var argumentCount = tagExpression.template.kind === 11 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -36945,7 +38418,7 @@ var ts; // The applicable span is from the first bar to the second bar (inclusive, // but not including parentheses) var applicableSpanStart = argumentsList.getFullStart(); - var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), false); + var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), /*stopAfterLineBreak*/ false); return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getApplicableSpanForTaggedTemplate(taggedTemplate) { @@ -36961,16 +38434,16 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 180 /* TemplateExpression */) { + if (template.kind === 181 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { - applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); + applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); } } return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 245 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 246 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -37021,7 +38494,7 @@ var ts; var invocation = argumentListInfo.invocation; var callTarget = ts.getInvokedExpression(invocation); var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); - var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, undefined, undefined); + var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); var items = ts.map(candidates, function (candidateSignature) { var signatureHelpParameters; var prefixDisplayParts = []; @@ -37030,10 +38503,10 @@ var ts; ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(24 /* LessThanToken */)); + prefixDisplayParts.push(ts.punctuationPart(25 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(26 /* GreaterThanToken */)); + suffixDisplayParts.push(ts.punctuationPart(27 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); }); @@ -37044,10 +38517,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + prefixDisplayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + suffixDisplayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -37057,7 +38530,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(23 /* CommaToken */), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(24 /* CommaToken */), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -37081,12 +38554,11 @@ var ts; var displayParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); }); - var isOptional = ts.hasQuestionToken(parameter.valueDeclaration); return { name: parameter.name, documentation: parameter.getDocumentationComment(), displayParts: displayParts, - isOptional: isOptional + isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) }; } function createSignatureHelpParameterForTypeParameter(typeParameter) { @@ -37171,40 +38643,40 @@ var ts; return false; } switch (n.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 162 /* ObjectLiteralExpression */: - case 158 /* ObjectBindingPattern */: - case 152 /* TypeLiteral */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 217 /* CaseBlock */: - return nodeEndsWith(n, 15 /* CloseBraceToken */, sourceFile); - case 241 /* CatchClause */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 163 /* ObjectLiteralExpression */: + case 159 /* ObjectBindingPattern */: + case 153 /* TypeLiteral */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 218 /* CaseBlock */: + return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); + case 242 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 166 /* NewExpression */: + case 167 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 165 /* CallExpression */: - case 169 /* ParenthesizedExpression */: - case 157 /* ParenthesizedType */: - return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 166 /* CallExpression */: + case 170 /* ParenthesizedExpression */: + case 158 /* ParenthesizedType */: + return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 171 /* ArrowFunction */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 172 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -37213,64 +38685,64 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 17 /* CloseParenToken */, sourceFile); - case 215 /* ModuleDeclaration */: + return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile); + case 216 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 193 /* IfStatement */: + case 194 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile); - case 161 /* ArrayLiteralExpression */: - case 159 /* ArrayBindingPattern */: - case 164 /* ElementAccessExpression */: - case 133 /* ComputedPropertyName */: - case 154 /* TupleType */: - return nodeEndsWith(n, 19 /* CloseBracketToken */, sourceFile); - case 146 /* IndexSignature */: + case 162 /* ArrayLiteralExpression */: + case 160 /* ArrayBindingPattern */: + case 165 /* ElementAccessExpression */: + case 134 /* ComputedPropertyName */: + case 155 /* TupleType */: + return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); + case 147 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + case 239 /* CaseClause */: + case 240 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 194 /* DoStatement */: + case 195 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - var hasWhileKeyword = findChildOfKind(n, 101 /* WhileKeyword */, sourceFile); + var hasWhileKeyword = findChildOfKind(n, 102 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); + return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 173 /* TypeOfExpression */: - case 172 /* DeleteExpression */: - case 174 /* VoidExpression */: - case 181 /* YieldExpression */: - case 182 /* SpreadElementExpression */: + case 174 /* TypeOfExpression */: + case 173 /* DeleteExpression */: + case 175 /* VoidExpression */: + case 182 /* YieldExpression */: + case 183 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -37288,7 +38760,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 22 /* SemicolonToken */ && children.length !== 1) { + else if (last.kind === 23 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -37326,7 +38798,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 268 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 269 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -37351,12 +38823,12 @@ var ts; ts.getTouchingPropertyName = getTouchingPropertyName; /** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */ function getTouchingToken(sourceFile, position, includeItemAtEndPosition) { - return getTokenAtPositionWorker(sourceFile, position, false, includeItemAtEndPosition); + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includeItemAtEndPosition); } ts.getTouchingToken = getTouchingToken; /** Returns a token if position is in [start-of-leading-trivia, end) */ function getTokenAtPosition(sourceFile, position) { - return getTokenAtPositionWorker(sourceFile, position, true, undefined); + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includeItemAtEndPosition*/ undefined); } ts.getTokenAtPosition = getTokenAtPosition; /** Get the token whose text contains the position */ @@ -37432,41 +38904,50 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n)) { + if (isToken(n) || n.kind === 234 /* JsxText */) { return n; } var children = n.getChildren(); - var candidate = findRightmostChildNodeWithTokens(children, children.length); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n)) { + if (isToken(n) || n.kind === 234 /* JsxText */) { return n; } var children = n.getChildren(); for (var i = 0, len = children.length; i < len; i++) { var child = children[i]; - if (nodeHasTokens(child)) { - if (position <= child.end) { - if (child.getStart(sourceFile) >= position) { - // actual start of the node is past the position - previous token should be at the end of previous child - var candidate = findRightmostChildNodeWithTokens(children, i); - return candidate && findRightmostToken(candidate); - } - else { - // candidate should be in this node - return find(child); - } + // condition 'position < child.end' checks if child node end after the position + // in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc' + // aaaa___bbbb___$__ccc + // after we found child node with end after the position we check if start of the node is after the position. + // if yes - then position is in the trivia and we need to look into the previous child to find the token in question. + // if no - position is in the node itself so we should recurse in it. + // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia). + // if this is the case - then we should assume that token in question is located in previous child. + if (position < child.end && (nodeHasTokens(child) || child.kind === 234 /* JsxText */)) { + var start = child.getStart(sourceFile); + var lookInPreviousChild = (start >= position) || + (child.kind === 234 /* JsxText */ && start === child.end); // whitespace only JsxText + if (lookInPreviousChild) { + // actual start of the node is past the position - previous token should be at the end of previous child + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); + return candidate && findRightmostToken(candidate); + } + else { + // candidate should be in this node + return find(child); } } } - ts.Debug.assert(startNode !== undefined || n.kind === 245 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 246 /* SourceFile */); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. // Namely we are skipping the check: 'position < node.end' if (children.length) { - var candidate = findRightmostChildNodeWithTokens(children, children.length); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); return candidate && findRightmostToken(candidate); } } @@ -37480,6 +38961,86 @@ var ts; } } ts.findPrecedingToken = findPrecedingToken; + function isInString(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + return token && token.kind === 9 /* StringLiteral */ && position > token.getStart(); + } + ts.isInString = isInString; + function isInComment(sourceFile, position) { + return isInCommentHelper(sourceFile, position, /*predicate*/ undefined); + } + ts.isInComment = isInComment; + /** + * Returns true if the cursor at position in sourceFile is within a comment that additionally + * satisfies predicate, and false otherwise. + */ + function isInCommentHelper(sourceFile, position, predicate) { + var token = getTokenAtPosition(sourceFile, position); + if (token && position <= token.getStart()) { + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + // The end marker of a single-line comment does not include the newline character. + // In the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + return predicate ? + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end) && + predicate(c); }) : + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end); }); + } + return false; + } + ts.isInCommentHelper = isInCommentHelper; + function hasDocComment(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + // First, we have to see if this position actually landed in a comment. + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return ts.forEach(commentRanges, jsDocPrefix); + function jsDocPrefix(c) { + var text = sourceFile.text; + return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*'; + } + } + ts.hasDocComment = hasDocComment; + /** + * Get the corresponding JSDocTag node if the position is in a jsDoc comment + */ + function getJsDocTagAtPosition(sourceFile, position) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (isToken(node)) { + switch (node.kind) { + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + // if the current token is var, let or const, skip the VariableDeclarationList + node = node.parent === undefined ? undefined : node.parent.parent; + break; + default: + node = node.parent; + break; + } + } + if (node) { + var jsDocComment = node.jsDocComment; + if (jsDocComment) { + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.pos <= position && position <= tag.end) { + return tag; + } + } + } + } + return undefined; + } + ts.getJsDocTagAtPosition = getJsDocTagAtPosition; function nodeHasTokens(n) { // If we have a token or node that has a non-zero width, it must have tokens. // Note, that getWidth() does not take trivia into account. @@ -37506,32 +39067,32 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 148 /* TypeReference */ || node.kind === 165 /* CallExpression */) { + if (node.kind === 149 /* TypeReference */ || node.kind === 166 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 211 /* ClassDeclaration */ || node.kind === 212 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 212 /* ClassDeclaration */ || node.kind === 213 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 131 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 132 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 66 /* Identifier */ || ts.isKeyword(kind); + return kind === 67 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { - return kind === 8 /* StringLiteral */ || kind === 7 /* NumericLiteral */ || isWord(kind); + return kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ || isWord(kind); } function isComment(kind) { return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; } ts.isComment = isComment; function isPunctuation(kind) { - return 14 /* FirstPunctuation */ <= kind && kind <= 65 /* LastPunctuation */; + return 15 /* FirstPunctuation */ <= kind && kind <= 66 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -37541,9 +39102,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: return true; } return false; @@ -37571,7 +39132,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 135 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -37706,6 +39267,14 @@ var ts; return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; + var carriageReturnLineFeed = "\r\n"; + /** + * The default is CRLF. + */ + function getNewLineOrDefaultFromHost(host) { + return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + } + ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; function lineBreakPart() { return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); } @@ -37750,7 +39319,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 223 /* ImportSpecifier */ || location.parent.kind === 227 /* ExportSpecifier */) && + (location.parent.kind === 224 /* ImportSpecifier */ || location.parent.kind === 228 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -37778,13 +39347,14 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var scanner = ts.createScanner(2 /* Latest */, false); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; ScanAction[ScanAction["RescanGreaterThanToken"] = 1] = "RescanGreaterThanToken"; ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken"; ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken"; + ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { scanner.setText(sourceFile.text); @@ -37848,25 +39418,37 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 28 /* GreaterThanEqualsToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 42 /* GreaterThanGreaterThanToken */: + case 29 /* GreaterThanEqualsToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 43 /* GreaterThanGreaterThanToken */: return true; } } return false; } + function shouldRescanJsxIdentifier(node) { + if (node.parent) { + switch (node.parent.kind) { + case 236 /* JsxAttribute */: + case 233 /* JsxOpeningElement */: + case 235 /* JsxClosingElement */: + case 232 /* JsxSelfClosingElement */: + return node.kind === 67 /* Identifier */; + } + } + return false; + } function shouldRescanSlashToken(container) { - return container.kind === 9 /* RegularExpressionLiteral */; + return container.kind === 10 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 12 /* TemplateMiddle */ || - container.kind === 13 /* TemplateTail */; + return container.kind === 13 /* TemplateMiddle */ || + container.kind === 14 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 37 /* SlashToken */ || t === 58 /* SlashEqualsToken */; + return t === 38 /* SlashToken */ || t === 59 /* SlashEqualsToken */; } function readTokenInfo(n) { if (!isOnToken()) { @@ -37885,7 +39467,9 @@ var ts; ? 2 /* RescanSlashToken */ : shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ - : 0 /* Scan */; + : shouldRescanJsxIdentifier(n) + ? 4 /* RescanJsxIdentifier */ + : 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -37902,7 +39486,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 26 /* GreaterThanToken */) { + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 27 /* GreaterThanToken */) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1 /* RescanGreaterThanToken */; @@ -37912,10 +39496,14 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2 /* RescanSlashToken */; } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 15 /* CloseBraceToken */) { + else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 16 /* CloseBraceToken */) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } + else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 67 /* Identifier */) { + currentToken = scanner.scanJsxIdentifier(); + lastScanAction = 4 /* RescanJsxIdentifier */; + } else { lastScanAction = 0 /* Scan */; } @@ -38041,8 +39629,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 14 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 15 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 15 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 16 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -38233,112 +39821,116 @@ var ts; this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1 /* Ignore */)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2 /* SingleLineCommentTrivia */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1 /* Ignore */)); // Space after keyword but not before ; or : or ? - this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Space after }. - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 77 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 101 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 19 /* CloseBracketToken */, 23 /* CommaToken */, 22 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // No space for indexer and dot - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 78 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 102 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // No space for dot + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // No space before and after indexer + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); // Place a space before open brace in a function declaration this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; - this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([66 /* Identifier */, 3 /* MultiLineCommentTrivia */]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 3 /* MultiLineCommentTrivia */, 71 /* ClassKeyword */]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 76 /* DoKeyword */, 97 /* TryKeyword */, 82 /* FinallyKeyword */, 77 /* ElseKeyword */]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 77 /* DoKeyword */, 98 /* TryKeyword */, 83 /* FinallyKeyword */, 78 /* ElseKeyword */]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* OpenBraceToken */, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); // Insert new line after { and before } in multi-line contexts. - this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // For functions and control block place } on a new line [multi-line rule] - this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(39 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 39 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 40 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(39 /* PlusPlusToken */, 34 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* PlusToken */, 34 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* PlusToken */, 39 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* MinusMinusToken */, 35 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* MinusToken */, 35 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* MinusToken */, 40 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([99 /* VarKeyword */, 95 /* ThrowKeyword */, 89 /* NewKeyword */, 75 /* DeleteKeyword */, 91 /* ReturnKeyword */, 98 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105 /* LetKeyword */, 71 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(84 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(100 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(91 /* ReturnKeyword */, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */, 117 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106 /* LetKeyword */, 72 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 76 /* DoKeyword */, 77 /* ElseKeyword */, 68 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 77 /* DoKeyword */, 78 /* ElseKeyword */, 69 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([97 /* TryKeyword */, 82 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([98 /* TryKeyword */, 83 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([120 /* GetKeyword */, 126 /* SetKeyword */]), 66 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121 /* GetKeyword */, 127 /* SetKeyword */]), 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); // TypeScript-specific higher priority rules // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([122 /* ModuleKeyword */, 124 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* ModuleKeyword */, 125 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* AbstractKeyword */, 70 /* ClassKeyword */, 119 /* DeclareKeyword */, 74 /* DefaultKeyword */, 78 /* EnumKeyword */, 79 /* ExportKeyword */, 80 /* ExtendsKeyword */, 120 /* GetKeyword */, 103 /* ImplementsKeyword */, 86 /* ImportKeyword */, 104 /* InterfaceKeyword */, 122 /* ModuleKeyword */, 123 /* NamespaceKeyword */, 107 /* PrivateKeyword */, 109 /* PublicKeyword */, 108 /* ProtectedKeyword */, 126 /* SetKeyword */, 110 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([80 /* ExtendsKeyword */, 103 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */, 130 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81 /* ExtendsKeyword */, 104 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8 /* StringLiteral */, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(33 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21 /* DotDotDotToken */, 66 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - // generics - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseParenToken */, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* LessThanToken */, formatting.Shared.TokenRange.TypeNames), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 26 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([16 /* OpenParenToken */, 18 /* OpenBracketToken */, 26 /* GreaterThanToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + // generics and type assertions + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([17 /* OpenParenToken */, 19 /* OpenBracketToken */, 27 /* GreaterThanToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); // Remove spaces in empty interface literals. e.g.: x: {} - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* OpenBraceToken */, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([112 /* AbstractKeyword */, 66 /* Identifier */, 79 /* ExportKeyword */, 74 /* DefaultKeyword */, 70 /* ClassKeyword */, 110 /* StaticKeyword */, 109 /* PublicKeyword */, 107 /* PrivateKeyword */, 108 /* ProtectedKeyword */, 120 /* GetKeyword */, 126 /* SetKeyword */, 18 /* OpenBracketToken */, 36 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 36 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(36 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(111 /* YieldKeyword */, 36 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([111 /* YieldKeyword */, 36 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 67 /* Identifier */, 80 /* ExportKeyword */, 75 /* DefaultKeyword */, 71 /* ClassKeyword */, 111 /* StaticKeyword */, 110 /* PublicKeyword */, 108 /* PrivateKeyword */, 109 /* ProtectedKeyword */, 121 /* GetKeyword */, 127 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + // Async-await + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + // template string + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -38365,6 +39957,8 @@ var ts; this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, + this.SpaceBetweenAsyncAndFunctionKeyword, + this.SpaceBetweenTagAndTemplateString, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, @@ -38378,6 +39972,7 @@ var ts; this.NoSpaceAfterOpenAngularBracket, this.NoSpaceBeforeCloseAngularBracket, this.NoSpaceAfterCloseAngularBracket, + this.NoSpaceAfterTypeAssertion, this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, @@ -38388,8 +39983,8 @@ var ts; this.NoSpaceBeforeSemicolon, this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, this.NoSpaceBeforeComma, - this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterOpenBracket, - this.NoSpaceBeforeCloseBracket, this.NoSpaceAfterCloseBracket, + this.NoSpaceBeforeOpenBracket, + this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally @@ -38398,35 +39993,41 @@ var ts; /// Rules controlled by user options /// // Insert space after comma delimiter - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space before and after binary operators this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); // Insert space after keywords in control flow statements - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); // Open Brace braces after function //TypeScript: Function can have return types, which can be made of tons of different token kinds - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after TypeScript module/class/interface - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after control block - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Insert space after semicolon in for statement - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); // Insert space after opening and before closing nonempty parenthesis - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenParenToken */, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenParenToken */, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Insert space after opening and before closing nonempty brackets + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenBracketToken */, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -38441,38 +40042,40 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 196 /* ForStatement */; + return context.contextNode.kind === 197 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 186 /* AsExpression */: - case 147 /* TypePredicate */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 187 /* AsExpression */: + case 148 /* TypePredicate */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 160 /* BindingElement */: + case 161 /* BindingElement */: // equals in type X = ... - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: // equal in p = 0; - case 135 /* Parameter */: - case 244 /* EnumMember */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - return context.currentTokenSpan.kind === 54 /* EqualsToken */ || context.nextTokenSpan.kind === 54 /* EqualsToken */; + case 136 /* Parameter */: + case 245 /* EnumMember */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + return context.currentTokenSpan.kind === 55 /* EqualsToken */ || context.nextTokenSpan.kind === 55 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 197 /* ForInStatement */: - return context.currentTokenSpan.kind === 87 /* InKeyword */ || context.nextTokenSpan.kind === 87 /* InKeyword */; + case 198 /* ForInStatement */: + return context.currentTokenSpan.kind === 88 /* InKeyword */ || context.nextTokenSpan.kind === 88 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 198 /* ForOfStatement */: - return context.currentTokenSpan.kind === 131 /* OfKeyword */ || context.nextTokenSpan.kind === 131 /* OfKeyword */; + case 199 /* ForOfStatement */: + return context.currentTokenSpan.kind === 132 /* OfKeyword */ || context.nextTokenSpan.kind === 132 /* OfKeyword */; } return false; }; @@ -38480,7 +40083,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 179 /* ConditionalExpression */; + return context.contextNode.kind === 180 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -38524,98 +40127,99 @@ var ts; return true; } switch (node.kind) { - case 189 /* Block */: - case 217 /* CaseBlock */: - case 162 /* ObjectLiteralExpression */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 218 /* CaseBlock */: + case 163 /* ObjectLiteralExpression */: + case 217 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 144 /* CallSignature */: - case 170 /* FunctionExpression */: - case 141 /* Constructor */: - case 171 /* ArrowFunction */: + case 145 /* CallSignature */: + case 171 /* FunctionExpression */: + case 142 /* Constructor */: + case 172 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 210 /* FunctionDeclaration */ || context.contextNode.kind === 170 /* FunctionExpression */; + return context.contextNode.kind === 211 /* FunctionDeclaration */ || context.contextNode.kind === 171 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 152 /* TypeLiteral */: - case 215 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 153 /* TypeLiteral */: + case 216 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 211 /* ClassDeclaration */: - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: - case 189 /* Block */: - case 241 /* CatchClause */: - case 216 /* ModuleBlock */: - case 203 /* SwitchStatement */: + case 212 /* ClassDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: + case 190 /* Block */: + case 242 /* CatchClause */: + case 217 /* ModuleBlock */: + case 204 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 193 /* IfStatement */: - case 203 /* SwitchStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: - case 206 /* TryStatement */: - case 194 /* DoStatement */: - case 202 /* WithStatement */: + case 194 /* IfStatement */: + case 204 /* SwitchStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 207 /* TryStatement */: + case 195 /* DoStatement */: + case 203 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 241 /* CatchClause */: + case 242 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 162 /* ObjectLiteralExpression */; + return context.contextNode.kind === 163 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 165 /* CallExpression */; + return context.contextNode.kind === 166 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 166 /* NewExpression */; + return context.contextNode.kind === 167 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 23 /* CommaToken */; + return context.currentTokenSpan.kind !== 24 /* CommaToken */; }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); @@ -38633,52 +40237,58 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 136 /* Decorator */; + return node.kind === 137 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 209 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 210 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 215 /* ModuleDeclaration */; + return context.contextNode.kind === 216 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 152 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 153 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; - Rules.IsTypeArgumentOrParameter = function (token, parent) { - if (token.kind !== 24 /* LessThanToken */ && token.kind !== 26 /* GreaterThanToken */) { + Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { + if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 148 /* TypeReference */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 149 /* TypeReference */: + case 169 /* TypeAssertionExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 186 /* ExpressionWithTypeArguments */: return true; default: return false; } }; - Rules.IsTypeArgumentOrParameterContext = function (context) { - return Rules.IsTypeArgumentOrParameter(context.currentTokenSpan, context.currentTokenParent) || - Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); + Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { + return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || + Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); + }; + Rules.IsTypeAssertionContext = function (context) { + return context.contextNode.kind === 169 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 100 /* VoidKeyword */ && context.currentTokenParent.kind === 174 /* VoidExpression */; + return context.currentTokenSpan.kind === 101 /* VoidKeyword */ && context.currentTokenParent.kind === 175 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 181 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 182 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -38702,7 +40312,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 131 /* LastToken */ + 1; + this.mapRowLength = 132 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); @@ -38897,7 +40507,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 131 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 132 /* LastToken */; token++) { result.push(token); } return result; @@ -38939,17 +40549,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(67 /* FirstKeyword */, 131 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 65 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([87 /* InKeyword */, 88 /* InstanceOfKeyword */, 131 /* OfKeyword */, 113 /* AsKeyword */, 121 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([39 /* PlusPlusToken */, 40 /* MinusMinusToken */, 48 /* TildeToken */, 47 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 66 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 89 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 89 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(68 /* FirstKeyword */, 132 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 66 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88 /* InKeyword */, 89 /* InstanceOfKeyword */, 132 /* OfKeyword */, 114 /* AsKeyword */, 122 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40 /* PlusPlusToken */, 41 /* MinusMinusToken */, 49 /* TildeToken */, 48 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 67 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([66 /* Identifier */, 125 /* NumberKeyword */, 127 /* StringKeyword */, 117 /* BooleanKeyword */, 128 /* SymbolKeyword */, 100 /* VoidKeyword */, 114 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([67 /* Identifier */, 126 /* NumberKeyword */, 128 /* StringKeyword */, 118 /* BooleanKeyword */, 129 /* SymbolKeyword */, 101 /* VoidKeyword */, 115 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -39027,6 +40637,16 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeCloseParen); rules.push(this.globalRules.NoSpaceBetweenParens); } + if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { + rules.push(this.globalRules.SpaceAfterOpenBracket); + rules.push(this.globalRules.SpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBracket); + rules.push(this.globalRules.NoSpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } if (options.InsertSpaceAfterSemicolonInForStatements) { rules.push(this.globalRules.SpaceAfterSemicolonInFor); } @@ -39085,11 +40705,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 22 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); + return formatOutermostParent(position, 23 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 15 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); + return formatOutermostParent(position, 16 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -39153,17 +40773,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 189 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 245 /* SourceFile */: - case 189 /* Block */: - case 216 /* ModuleBlock */: + return body && body.kind === 190 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 246 /* SourceFile */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -39336,9 +40956,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 245 /* SourceFile */ || - parent.kind === 238 /* CaseClause */ || - parent.kind === 239 /* DefaultClause */) { + parent.kind === 246 /* SourceFile */ || + parent.kind === 239 /* CaseClause */ || + parent.kind === 240 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -39374,35 +40994,36 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 211 /* ClassDeclaration */: return 70 /* ClassKeyword */; - case 212 /* InterfaceDeclaration */: return 104 /* InterfaceKeyword */; - case 210 /* FunctionDeclaration */: return 84 /* FunctionKeyword */; - case 214 /* EnumDeclaration */: return 214 /* EnumDeclaration */; - case 142 /* GetAccessor */: return 120 /* GetKeyword */; - case 143 /* SetAccessor */: return 126 /* SetKeyword */; - case 140 /* MethodDeclaration */: + case 212 /* ClassDeclaration */: return 71 /* ClassKeyword */; + case 213 /* InterfaceDeclaration */: return 105 /* InterfaceKeyword */; + case 211 /* FunctionDeclaration */: return 85 /* FunctionKeyword */; + case 215 /* EnumDeclaration */: return 215 /* EnumDeclaration */; + case 143 /* GetAccessor */: return 121 /* GetKeyword */; + case 144 /* SetAccessor */: return 127 /* SetKeyword */; + case 141 /* MethodDeclaration */: if (node.asteriskToken) { - return 36 /* AsteriskToken */; + return 37 /* AsteriskToken */; } // fall-through - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: return node.name.kind; } } function getDynamicIndentation(node, nodeStartLine, indentation, delta) { return { - getIndentationForComment: function (kind) { + getIndentationForComment: function (kind, tokenIndentation) { switch (kind) { // preceding comment to the token that closes the indentation scope inherits the indentation from the scope // .. { // // comment // } - case 15 /* CloseBraceToken */: - case 19 /* CloseBracketToken */: + case 16 /* CloseBraceToken */: + case 20 /* CloseBracketToken */: + case 18 /* CloseParenToken */: return indentation + delta; } - return indentation; + return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; }, getIndentationForToken: function (line, kind) { if (nodeStartLine !== line && node.decorators) { @@ -39413,15 +41034,15 @@ var ts; } switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 14 /* OpenBraceToken */: - case 15 /* CloseBraceToken */: - case 18 /* OpenBracketToken */: - case 19 /* CloseBracketToken */: - case 16 /* OpenParenToken */: - case 17 /* CloseParenToken */: - case 77 /* ElseKeyword */: - case 101 /* WhileKeyword */: - case 53 /* AtToken */: + case 15 /* OpenBraceToken */: + case 16 /* CloseBraceToken */: + case 19 /* OpenBracketToken */: + case 20 /* CloseBracketToken */: + case 17 /* OpenParenToken */: + case 18 /* CloseParenToken */: + case 78 /* ElseKeyword */: + case 102 /* WhileKeyword */: + case 54 /* AtToken */: return indentation; default: // if token line equals to the line of containing node (this is a first token in the node) - use node indentation @@ -39468,7 +41089,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, false); + processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListElement*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -39521,7 +41142,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 136 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 137 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -39556,7 +41177,7 @@ var ts; var inheritedIndentation = -1 /* Unknown */; for (var _i = 0; _i < nodes.length; _i++) { var child = nodes[_i]; - inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, true); + inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true); } if (listEndToken !== 0 /* Unknown */) { if (formattingScanner.isOnToken()) { @@ -39604,8 +41225,12 @@ var ts; processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation); } if (indentToken) { - var indentNextTokenOrTrivia = true; + var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) : + -1 /* Unknown */; if (currentTokenInfo.leadingTrivia) { + var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation); + var indentNextTokenOrTrivia = true; for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) { var triviaItem = _a[_i]; if (!ts.rangeContainsRange(originalRange, triviaItem)) { @@ -39613,14 +41238,12 @@ var ts; } switch (triviaItem.kind) { case 3 /* MultiLineCommentTrivia */: - var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - indentMultilineComment(triviaItem, commentIndentation, !indentNextTokenOrTrivia); + indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); indentNextTokenOrTrivia = false; break; case 2 /* SingleLineCommentTrivia */: if (indentNextTokenOrTrivia) { - var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - insertIndentation(triviaItem.pos, commentIndentation_1, false); + insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false); indentNextTokenOrTrivia = false; } break; @@ -39631,8 +41254,7 @@ var ts; } } // indent token only if is it is in target range and does not overlap with any error ranges - if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) { - var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind); + if (tokenIndentation !== -1 /* Unknown */) { insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); lastIndentedLine = tokenStart.line; indentationOnLastIndentedLine = tokenIndentation; @@ -39683,7 +41305,7 @@ var ts; // 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(false); + dynamicIndentation.recomputeIndentation(/*lineAdded*/ false); } } else if (rule.Operation.Action & 4 /* NewLine */ && currentStartLine === previousStartLine) { @@ -39692,7 +41314,7 @@ var ts; // 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) { - dynamicIndentation.recomputeIndentation(true); + dynamicIndentation.recomputeIndentation(/*lineAdded*/ true); } } // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -39732,7 +41354,7 @@ var ts; if (startLine === endLine) { if (!firstLineIsIndented) { // treat as single line comment - insertIndentation(commentRange.pos, indentation, false); + insertIndentation(commentRange.pos, indentation, /*lineAdded*/ false); } return; } @@ -39844,49 +41466,49 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 141 /* Constructor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 171 /* ArrowFunction */: + case 142 /* Constructor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 172 /* ArrowFunction */: if (node.typeParameters === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } else if (node.parameters === list) { - return 16 /* OpenParenToken */; + return 17 /* OpenParenToken */; } break; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: if (node.typeArguments === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } else if (node.arguments === list) { - return 16 /* OpenParenToken */; + return 17 /* OpenParenToken */; } break; - case 148 /* TypeReference */: + case 149 /* TypeReference */: if (node.typeArguments === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 16 /* OpenParenToken */: - return 17 /* CloseParenToken */; - case 24 /* LessThanToken */: - return 26 /* GreaterThanToken */; + case 17 /* OpenParenToken */: + return 18 /* CloseParenToken */; + case 25 /* LessThanToken */: + return 27 /* GreaterThanToken */; } return 0 /* Unknown */; } @@ -39963,17 +41585,17 @@ var ts; return 0; } // no indentation in string \regex\template literals - var precedingTokenIsLiteral = precedingToken.kind === 8 /* StringLiteral */ || - precedingToken.kind === 9 /* RegularExpressionLiteral */ || - precedingToken.kind === 10 /* NoSubstitutionTemplateLiteral */ || - precedingToken.kind === 11 /* TemplateHead */ || - precedingToken.kind === 12 /* TemplateMiddle */ || - precedingToken.kind === 13 /* TemplateTail */; + var precedingTokenIsLiteral = precedingToken.kind === 9 /* StringLiteral */ || + precedingToken.kind === 10 /* RegularExpressionLiteral */ || + precedingToken.kind === 11 /* NoSubstitutionTemplateLiteral */ || + precedingToken.kind === 12 /* TemplateHead */ || + precedingToken.kind === 13 /* TemplateMiddle */ || + precedingToken.kind === 14 /* TemplateTail */; if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 178 /* BinaryExpression */) { + if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 179 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -40013,12 +41635,12 @@ var ts; // no parent was found - return 0 to be indented on the level of SourceFile return 0; } - return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); + return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); } SmartIndenter.getIndentation = getIndentation; function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); - return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, 0, sourceFile, options); + return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options); } SmartIndenter.getIndentationForNode = getIndentationForNode; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { @@ -40092,7 +41714,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 245 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 246 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -40103,11 +41725,11 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 14 /* OpenBraceToken */) { + if (nextToken.kind === 15 /* OpenBraceToken */) { // open braces are always indented at the parent level return true; } - else if (nextToken.kind === 15 /* CloseBraceToken */) { + else if (nextToken.kind === 16 /* CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -40125,8 +41747,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 193 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 77 /* ElseKeyword */, sourceFile); + if (parent.kind === 194 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 78 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -40137,23 +41759,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 148 /* TypeReference */: + case 149 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return node.parent.properties; - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return node.parent.elements; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: { + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -40164,8 +41786,8 @@ var ts; } break; } - case 166 /* NewExpression */: - case 165 /* CallExpression */: { + case 167 /* NewExpression */: + case 166 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -40192,11 +41814,11 @@ var ts; function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { // actual indentation should not be used when: // - node is close parenthesis - this is the end of the expression - if (node.kind === 17 /* CloseParenToken */) { + if (node.kind === 18 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 165 /* CallExpression */ || - node.parent.kind === 166 /* NewExpression */) && + if (node.parent && (node.parent.kind === 166 /* CallExpression */ || + node.parent.kind === 167 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -40214,10 +41836,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: node = node.expression; break; default: @@ -40234,7 +41856,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; --i) { - if (list[i].kind === 23 /* CommaToken */) { + if (list[i].kind === 24 /* CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -40282,28 +41904,42 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 161 /* ArrayLiteralExpression */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 162 /* ObjectLiteralExpression */: - case 152 /* TypeLiteral */: - case 154 /* TupleType */: - case 217 /* CaseBlock */: - case 239 /* DefaultClause */: - case 238 /* CaseClause */: - case 169 /* ParenthesizedExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 190 /* VariableStatement */: - case 208 /* VariableDeclaration */: - case 224 /* ExportAssignment */: - case 201 /* ReturnStatement */: - case 179 /* ConditionalExpression */: - case 159 /* ArrayBindingPattern */: - case 158 /* ObjectBindingPattern */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 162 /* ArrayLiteralExpression */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 163 /* ObjectLiteralExpression */: + case 153 /* TypeLiteral */: + case 155 /* TupleType */: + case 218 /* CaseBlock */: + case 240 /* DefaultClause */: + case 239 /* CaseClause */: + case 170 /* ParenthesizedExpression */: + case 164 /* PropertyAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 191 /* VariableStatement */: + case 209 /* VariableDeclaration */: + case 225 /* ExportAssignment */: + case 202 /* ReturnStatement */: + case 180 /* ConditionalExpression */: + case 160 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 136 /* Parameter */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 158 /* ParenthesizedType */: + case 168 /* TaggedTemplateExpression */: + case 176 /* AwaitExpression */: return true; } return false; @@ -40313,22 +41949,20 @@ var ts; return true; } switch (parent) { - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 193 /* IfStatement */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 171 /* ArrowFunction */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - return child !== 189 /* Block */; + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 194 /* IfStatement */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 172 /* ArrowFunction */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + return child !== 190 /* Block */; default: return false; } @@ -40380,8 +42014,47 @@ var ts; } ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); - var scanner = ts.createScanner(2 /* Latest */, true); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); var emptyArray = []; + var jsDocTagNames = [ + "augments", + "author", + "argument", + "borrows", + "class", + "constant", + "constructor", + "constructs", + "default", + "deprecated", + "description", + "event", + "example", + "extends", + "field", + "fileOverview", + "function", + "ignore", + "inner", + "lends", + "link", + "memberOf", + "name", + "namespace", + "param", + "private", + "property", + "public", + "requires", + "returns", + "see", + "since", + "static", + "throws", + "type", + "version" + ]; + var jsDocCompletionEntries; function createNode(kind, pos, end, flags, parent) { var node = new (ts.getNodeConstructor(kind))(); node.pos = pos; @@ -40431,7 +42104,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(268 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); + var list = createNode(269 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -40450,7 +42123,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 132 /* FirstNode */) { + if (this.kind >= 133 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -40492,24 +42165,20 @@ var ts; return this._children; }; NodeObject.prototype.getFirstToken = function (sourceFile) { - var children = this.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; - if (child.kind < 132 /* FirstNode */) { - return child; - } - return child.getFirstToken(sourceFile); + var children = this.getChildren(sourceFile); + if (!children.length) { + return undefined; } + var child = children[0]; + return child.kind < 133 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); - for (var i = children.length - 1; i >= 0; i--) { - var child = children[i]; - if (child.kind < 132 /* FirstNode */) { - return child; - } - return child.getLastToken(sourceFile); + var child = ts.lastOrUndefined(children); + if (!child) { + return undefined; } + return child.kind < 133 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; })(); @@ -40550,15 +42219,15 @@ var ts; var jsDocCommentParts = []; ts.forEach(declarations, function (declaration, indexOfDeclaration) { // Make sure we are collecting doc comment from declaration once, - // In case of union property there might be same declaration multiple times + // In case of union property there might be same declaration multiple times // which only varies in type parameter // Eg. let a: Array | Array; a.length - // The property length will have two declarations of property length coming + // The property length will have two declarations of property length coming // from Array - Array and Array if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 135 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 136 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -40567,15 +42236,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 215 /* ModuleDeclaration */ && declaration.body.kind === 215 /* ModuleDeclaration */) { + if (declaration.kind === 216 /* ModuleDeclaration */ && declaration.body.kind === 216 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 215 /* ModuleDeclaration */ && declaration.parent.kind === 215 /* ModuleDeclaration */) { + while (declaration.kind === 216 /* ModuleDeclaration */ && declaration.parent.kind === 216 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 208 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -40588,7 +42257,7 @@ var ts; return ts.map(ts.getJsDocComments(node, sourceFile), function (jsDocComment) { return { pos: jsDocComment.pos + "/*".length, - end: jsDocComment.end - "*/".length // Trim off comment end indicator + end: jsDocComment.end - "*/".length // Trim off comment end indicator }; }); } @@ -40690,7 +42359,7 @@ var ts; if (isParamTag(pos, end, sourceFile)) { var blankLineCount = 0; var recordedParamTag = false; - // Consume leading spaces + // Consume leading spaces pos = consumeWhiteSpaces(pos + paramTag.length); if (pos >= end) { break; @@ -40740,7 +42409,7 @@ var ts; var firstLineParamHelpStringPos = pos; while (pos < end) { var ch = sourceFile.text.charCodeAt(pos); - // at line break, set this comment line text and go to next line + // at line break, set this comment line text and go to next line if (ts.isLineBreak(ch)) { if (paramHelpString) { pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); @@ -40793,7 +42462,7 @@ var ts; if (paramHelpStringMargin === undefined) { paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character; } - // Now consume white spaces max + // Now consume white spaces max var startOfLinePos = pos; pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile, paramHelpStringMargin); if (pos >= end) { @@ -40843,6 +42512,11 @@ var ts; TypeObject.prototype.getNumberIndexType = function () { return this.checker.getIndexTypeOfType(this, 1 /* Number */); }; + TypeObject.prototype.getBaseTypes = function () { + return this.flags & (1024 /* Class */ | 2048 /* Interface */) + ? this.checker.getBaseTypes(this) + : undefined; + }; return TypeObject; })(); var SignatureObject = (function () { @@ -40914,9 +42588,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 133 /* ComputedPropertyName */) { + if (declaration.name.kind === 134 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 163 /* PropertyAccessExpression */) { + if (expr.kind === 164 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -40926,9 +42600,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 8 /* StringLiteral */ || - node.kind === 7 /* NumericLiteral */) { + if (node.kind === 67 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || + node.kind === 8 /* NumericLiteral */) { return node.text; } } @@ -40936,9 +42610,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -40958,60 +42632,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: - case 215 /* ModuleDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 227 /* ExportSpecifier */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 152 /* TypeLiteral */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 228 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 153 /* TypeLiteral */: addDeclaration(node); // fall through - case 141 /* Constructor */: - case 190 /* VariableStatement */: - case 209 /* VariableDeclarationList */: - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 216 /* ModuleBlock */: + case 142 /* Constructor */: + case 191 /* VariableStatement */: + case 210 /* VariableDeclarationList */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 217 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 135 /* Parameter */: + case 136 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 244 /* EnumMember */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 245 /* EnumMember */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: addDeclaration(node); break; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -41023,7 +42697,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -41227,16 +42901,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 170 /* FunctionExpression */) { + if (declaration.kind === 171 /* FunctionExpression */) { return true; } - if (declaration.kind !== 208 /* VariableDeclaration */ && declaration.kind !== 210 /* FunctionDeclaration */) { + if (declaration.kind !== 209 /* VariableDeclaration */ && declaration.kind !== 211 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { + for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { // Reached source file or module block - if (parent_9.kind === 245 /* SourceFile */ || parent_9.kind === 216 /* ModuleBlock */) { + if (parent_8.kind === 246 /* SourceFile */ || parent_8.kind === 217 /* ModuleBlock */) { return false; } } @@ -41253,8 +42927,8 @@ var ts; }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - // Cache host information about scrip Should be refreshed - // at each language service public entry point, since we don't know when + // Cache host information about scrip Should be refreshed + // at each language service public entry point, since we don't know when // set of scripts handled by the host changes. var HostCache = (function () { function HostCache(host, getCanonicalFileName) { @@ -41331,7 +43005,7 @@ var ts; var sourceFile; if (this.currentFileName !== fileName) { // This is a new file, just parse it - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, true); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents:*/ true); } else if (this.currentFileVersion !== version) { // This is the same file, just a newer version. Incrementally parse the file. @@ -41356,52 +43030,76 @@ var ts; /* * This function will compile source text from 'input' argument using specified compiler options. * If not options are provided - it will use a set of default compiler options. - * Extra compiler options that will unconditionally be used bu this function are: + * Extra compiler options that will unconditionally be used by this function are: * - isolatedModules = true * - allowNonTsExtensions = true * - noLib = true * - noResolve = true */ - function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { - var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); + function transpileModule(input, transpileOptions) { + var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, + // We are not returning a sourceFile for lib file when asked by the program, // so pass --noLib to avoid reporting a file not found error. options.noLib = true; // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. options.noResolve = true; // Parse - var inputFileName = fileName || "module.ts"; + var inputFileName = transpileOptions.fileName || "module.ts"; var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - if (moduleName) { - sourceFile.moduleName = moduleName; + if (transpileOptions.moduleName) { + sourceFile.moduleName = transpileOptions.moduleName; } + sourceFile.renamedDependencies = transpileOptions.renamedDependencies; var newLine = ts.getNewLineCharacter(options); // Output var outputText; + var sourceMapText; // Create a compilerHost object to allow the compiler to read and write files var compilerHost = { - getSourceFile: function (fileName, target) { return fileName === inputFileName ? sourceFile : undefined; }, + getSourceFile: function (fileName, target) { return fileName === ts.normalizeSlashes(inputFileName) ? sourceFile : undefined; }, writeFile: function (name, text, writeByteOrderMark) { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); - outputText = text; + if (ts.fileExtensionIs(name, ".map")) { + ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + sourceMapText = text; + } + else { + ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); + outputText = text; + } }, getDefaultLibFileName: function () { return "lib.d.ts"; }, useCaseSensitiveFileNames: function () { return false; }, getCanonicalFileName: function (fileName) { return fileName; }, getCurrentDirectory: function () { return ""; }, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return fileName === inputFileName; }, + readFile: function (fileName) { return ""; } }; var program = ts.createProgram([inputFileName], options, compilerHost); - ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); - ts.addRange(diagnostics, program.getOptionsDiagnostics()); + var diagnostics; + if (transpileOptions.reportDiagnostics) { + diagnostics = []; + ts.addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics()); + } // Emit program.emit(); ts.Debug.assert(outputText !== undefined, "Output generation failed"); - return outputText; + return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; + } + ts.transpileModule = transpileModule; + /* + * This is a shortcut function for transpileModule - it accepts transpileOptions as parameters and returns only outputText part of the result. + */ + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { + var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); + // addRange correctly handles cases when wither 'from' or 'to' argument is missing + ts.addRange(diagnostics, output.diagnostics); + return output.outputText; } ts.transpile = transpile; function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { @@ -41415,7 +43113,7 @@ var ts; ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; ts.disableIncrementalParsing = false; function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { - // If we were given a text change range, and our version or open-ness changed, then + // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. if (textChangeRange) { if (version !== sourceFile.version) { @@ -41461,7 +43159,7 @@ var ts; } } // Otherwise, just create a new source file. - return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true); + return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents:*/ true); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; function createGetCanonicalFileName(useCaseSensitivefileNames) { @@ -41469,13 +43167,14 @@ var ts; ? (function (fileName) { return fileName; }) : (function (fileName) { return fileName.toLowerCase(); }); } + ts.createGetCanonicalFileName = createGetCanonicalFileName; function createDocumentRegistry(useCaseSensitiveFileNames) { // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. var buckets = {}; var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { - return "_" + settings.target; // + "|" + settings.propagateEnumConstantoString() + return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx; } function getBucketForCompilationSettings(settings, createIfMissing) { var key = getKeyFromCompilationSettings(settings); @@ -41506,18 +43205,18 @@ var ts; return JSON.stringify(bucketInfoArray, null, 2); } function acquireDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, true); + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ true); } function updateDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, false); + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ false); } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { - var bucket = getBucketForCompilationSettings(compilationSettings, true); + var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); var entry = bucket.get(fileName); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. - var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); + var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents:*/ false); entry = { sourceFile: sourceFile, languageServiceRefCount: 0, @@ -41526,7 +43225,7 @@ var ts; bucket.set(fileName, entry); } else { - // We have an entry for this file. However, it may be for a different version of + // We have an entry for this file. However, it may be for a different version of // the script snapshot. If so, update it appropriately. Otherwise, we can just // return it as is. if (entry.sourceFile.version !== version) { @@ -41565,6 +43264,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } var referencedFiles = []; var importedFiles = []; + var ambientExternalModules; var isNoDefaultLib = false; function processTripleSlashDirectives() { var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); @@ -41580,6 +43280,12 @@ var ts; } }); } + function recordAmbientExternalModule() { + if (!ambientExternalModules) { + ambientExternalModules = []; + } + ambientExternalModules.push(scanner.getTokenValue()); + } function recordModuleName() { var importPath = scanner.getTokenValue(); var pos = scanner.getTokenPos(); @@ -41602,32 +43308,44 @@ var ts; // // export * from "mod" // export {a as b} from "mod" + // export import i = require("mod") while (token !== 1 /* EndOfFileToken */) { - if (token === 86 /* ImportKeyword */) { + if (token === 120 /* DeclareKeyword */) { + // declare module "mod" token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 123 /* ModuleKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + recordAmbientExternalModule(); + continue; + } + } + } + else if (token === 87 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { // import "mod"; recordModuleName(); continue; } else { - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */ || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import d from "mod"; recordModuleName(); continue; } } - else if (token === 54 /* EqualsToken */) { + else if (token === 55 /* EqualsToken */) { token = scanner.scan(); - if (token === 124 /* RequireKeyword */) { + if (token === 125 /* RequireKeyword */) { token = scanner.scan(); - if (token === 16 /* OpenParenToken */) { + if (token === 17 /* OpenParenToken */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import i = require("mod"); recordModuleName(); continue; @@ -41635,7 +43353,7 @@ var ts; } } } - else if (token === 23 /* CommaToken */) { + else if (token === 24 /* CommaToken */) { // consume comma and keep going token = scanner.scan(); } @@ -41644,17 +43362,17 @@ var ts; continue; } } - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== 15 /* CloseBraceToken */) { + while (token !== 16 /* CloseBraceToken */) { token = scanner.scan(); } - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -41662,15 +43380,15 @@ var ts; } } } - else if (token === 36 /* AsteriskToken */) { + else if (token === 37 /* AsteriskToken */) { token = scanner.scan(); - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { token = scanner.scan(); - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */ || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -41681,19 +43399,19 @@ var ts; } } } - else if (token === 79 /* ExportKeyword */) { + else if (token === 80 /* ExportKeyword */) { token = scanner.scan(); - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== 15 /* CloseBraceToken */) { + while (token !== 16 /* CloseBraceToken */) { token = scanner.scan(); } - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -41701,16 +43419,35 @@ var ts; } } } - else if (token === 36 /* AsteriskToken */) { + else if (token === 37 /* AsteriskToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // export * from "mod" recordModuleName(); } } } + else if (token === 87 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 67 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 55 /* EqualsToken */) { + token = scanner.scan(); + if (token === 125 /* RequireKeyword */) { + token = scanner.scan(); + if (token === 17 /* OpenParenToken */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // export import i = require("mod"); + recordModuleName(); + } + } + } + } + } + } } token = scanner.scan(); } @@ -41720,13 +43457,13 @@ var ts; processImport(); } processTripleSlashDirectives(); - return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib }; + return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; } ts.preProcessFile = preProcessFile; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 204 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 205 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -41734,13 +43471,13 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 66 /* Identifier */ && - (node.parent.kind === 200 /* BreakStatement */ || node.parent.kind === 199 /* ContinueStatement */) && + return node.kind === 67 /* Identifier */ && + (node.parent.kind === 201 /* BreakStatement */ || node.parent.kind === 200 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 66 /* Identifier */ && - node.parent.kind === 204 /* LabeledStatement */ && + return node.kind === 67 /* Identifier */ && + node.parent.kind === 205 /* LabeledStatement */ && node.parent.label === node; } /** @@ -41748,7 +43485,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 204 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 205 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -41759,56 +43496,56 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 165 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 166 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 215 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 216 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && ts.isFunctionLike(node.parent) && 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) { - return (node.kind === 66 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && - (node.parent.kind === 242 /* PropertyAssignment */ || node.parent.kind === 243 /* ShorthandPropertyAssignment */) && node.parent.name === node; + return (node.kind === 67 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + (node.parent.kind === 243 /* PropertyAssignment */ || node.parent.kind === 244 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { + if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 244 /* EnumMember */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 215 /* ModuleDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 245 /* EnumMember */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 216 /* ModuleDeclaration */: return node.parent.name === node; - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } return false; } function isNameOfExternalModuleImportOrDeclaration(node) { - if (node.kind === 8 /* StringLiteral */) { + if (node.kind === 9 /* StringLiteral */) { return isNameOfModuleDeclaration(node) || (ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node); } @@ -41860,7 +43597,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 67 /* FirstKeyword */; i <= 131 /* LastKeyword */; i++) { + for (var i = 68 /* FirstKeyword */; i <= 132 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -41875,17 +43612,17 @@ var ts; return undefined; } switch (node.kind) { - case 245 /* SourceFile */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 215 /* ModuleDeclaration */: + case 246 /* SourceFile */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: return node; } } @@ -41893,38 +43630,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 215 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 211 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 212 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 213 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 214 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 208 /* VariableDeclaration */: + case 216 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 212 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 213 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 214 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 215 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 209 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 210 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 142 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 143 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 143 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 144 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 146 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 145 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 144 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 141 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 134 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 244 /* EnumMember */: return ScriptElementKind.variableElement; - case 135 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 220 /* ImportClause */: - case 227 /* ExportSpecifier */: - case 221 /* NamespaceImport */: + case 147 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 146 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 145 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 142 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 135 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 245 /* EnumMember */: return ScriptElementKind.variableElement; + case 136 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 221 /* ImportClause */: + case 228 /* ExportSpecifier */: + case 222 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -41995,26 +43732,44 @@ var ts; if (programUpToDate()) { return; } - // IMPORTANT - It is critical from this moment onward that we do not check + // IMPORTANT - It is critical from this moment onward that we do not check // cancellation tokens. We are about to mutate source files from a previous program // instance. If we cancel midway through, we may end up in an inconsistent state where - // the program points to old source files that have been invalidated because of + // the program points to old source files that have been invalidated because of // incremental parsing. var oldSettings = program && program.getCompilerOptions(); var newSettings = hostCache.compilationSettings(); - var changesInCompilationSettingsAffectSyntax = oldSettings && oldSettings.target !== newSettings.target; + var changesInCompilationSettingsAffectSyntax = oldSettings && + (oldSettings.target !== newSettings.target || + oldSettings.module !== newSettings.module || + oldSettings.noResolve !== newSettings.noResolve || + oldSettings.jsx !== newSettings.jsx); // Now create a new compiler - var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, { + var compilerHost = { getSourceFile: getOrCreateSourceFile, getCancellationToken: function () { return cancellationToken; }, getCanonicalFileName: getCanonicalFileName, useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, - getNewLine: function () { return host.getNewLine ? host.getNewLine() : "\r\n"; }, + getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); } - }); - // Release any files we have acquired in the old program but are + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + fileExists: function (fileName) { + // stub missing host functionality + ts.Debug.assert(!host.resolveModuleNames); + return hostCache.getOrCreateEntry(fileName) !== undefined; + }, + readFile: function (fileName) { + // stub missing host functionality + var entry = hostCache.getOrCreateEntry(fileName); + return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); + } + }; + if (host.resolveModuleNames) { + compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + } + var newProgram = ts.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) { var oldSourceFiles = program.getSourceFiles(); @@ -42030,7 +43785,7 @@ var ts; // It needs to be cleared to allow all collected snapshots to be released hostCache = undefined; program = newProgram; - // Make sure all the nodes in the program are both bound, and have their parent + // Make sure all the nodes in the program are both bound, and have their parent // pointers set property. program.getTypeChecker(); return; @@ -42050,7 +43805,7 @@ var ts; // Check if the old program had this file already var oldSourceFile = program && program.getSourceFile(fileName); if (oldSourceFile) { - // We already had a source file for this file name. Go to the registry to + // 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 // address the following 'race'. Specifically, say we have the following: // @@ -42061,15 +43816,15 @@ var ts; // LS2 // // Each LS has a reference to file 'foo.ts' at version 1. LS2 then updates - // it's version of 'foo.ts' to version 2. This will cause LS2 and the - // DocumentRegistry to have version 2 of the document. HOwever, LS1 will + // it's version of 'foo.ts' to version 2. This will cause LS2 and the + // DocumentRegistry to have version 2 of the document. HOwever, LS1 will // have version 1. And *importantly* this source file will be *corrupt*. // The act of creating version 2 of the file irrevocably damages the version // 1 file. // // So, later when we call into LS1, we need to make sure that it doesn't use // it's source file any more, and instead defers to DocumentRegistry to get - // either version 1, version 2 (or some other version) depending on what the + // either version 1, version 2 (or some other version) depending on what the // host says should be used. return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } @@ -42128,7 +43883,7 @@ var ts; synchronizeHostData(); var targetSourceFile = getValidSourceFile(fileName); // For JavaScript files, we don't want to report the normal typescript semantic errors. - // Instead, we just report errors for using TypeScript-only constructs from within a + // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. if (ts.isJavaScript(fileName)) { return getJavaScriptSemanticDiagnostics(targetSourceFile); @@ -42152,44 +43907,44 @@ var ts; return false; } switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 240 /* HeritageClause */: + case 241 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 103 /* ImplementsKeyword */) { + if (heritageClause.token === 104 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 210 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -42197,20 +43952,20 @@ var ts; return true; } break; - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -42218,7 +43973,7 @@ var ts; return true; } break; - case 135 /* Parameter */: + case 136 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -42234,17 +43989,17 @@ var ts; return true; } break; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 136 /* Decorator */: + case 137 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -42270,18 +44025,18 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 119 /* DeclareKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 120 /* DeclareKeyword */: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; // These are all legal modifiers. - case 110 /* StaticKeyword */: - case 79 /* ExportKeyword */: - case 71 /* ConstKeyword */: - case 74 /* DefaultKeyword */: - case 112 /* AbstractKeyword */: + case 111 /* StaticKeyword */: + case 80 /* ExportKeyword */: + case 72 /* ConstKeyword */: + case 75 /* DefaultKeyword */: + case 113 /* AbstractKeyword */: } } } @@ -42343,6 +44098,7 @@ var ts; var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); var isJavaScriptFile = ts.isJavaScript(fileName); + var isJsDocTagName = false; var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); log("getCompletionData: Get current token: " + (new Date().getTime() - start)); @@ -42351,8 +44107,40 @@ var ts; var insideComment = isInsideComment(sourceFile, currentToken, position); log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); if (insideComment) { - log("Returning an empty list because completion was inside a comment."); - return undefined; + // The current position is next to the '@' sign, when no tag name being provided yet. + // Provide a full list of tag names + if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + isJsDocTagName = true; + } + // Completion should work inside certain JsDoc tags. For example: + // /** @type {number | string} */ + // Completion should work in the brackets + var insideJsDocTagExpression = false; + var tag = ts.getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (tag.tagName.pos <= position && position <= tag.tagName.end) { + isJsDocTagName = true; + } + switch (tag.kind) { + case 267 /* JSDocTypeTag */: + case 265 /* JSDocParameterTag */: + case 266 /* JSDocReturnTag */: + var tagWithExpression = tag; + if (tagWithExpression.typeExpression) { + insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; + } + break; + } + } + if (isJsDocTagName) { + return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + } + if (!insideJsDocTagExpression) { + // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal + // comment or the plain text part of a jsDoc comment, so no completion should be available + log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); + return undefined; + } } start = new Date().getTime(); var previousToken = ts.findPrecedingToken(position, sourceFile); @@ -42363,9 +44151,9 @@ var ts; // Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| // Skip this partial identifier and adjust the contextToken to the token that precedes it. if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) { - var start_2 = new Date().getTime(); + var start_4 = new Date().getTime(); contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); - log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_2)); + log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_4)); } // Find the node where completion is requested on. // Also determine whether we are trying to complete with members of that node @@ -42380,13 +44168,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_10 = contextToken.parent, kind = contextToken.kind; - if (kind === 20 /* DotToken */) { - if (parent_10.kind === 163 /* PropertyAccessExpression */) { + var parent_9 = contextToken.parent, kind = contextToken.kind; + if (kind === 21 /* DotToken */) { + if (parent_9.kind === 164 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_10.kind === 132 /* QualifiedName */) { + else if (parent_9.kind === 133 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -42396,7 +44184,7 @@ var ts; return undefined; } } - else if (kind === 24 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { + else if (kind === 25 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { isRightOfOpenTag = true; location = contextToken; } @@ -42428,12 +44216,12 @@ var ts; } } log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; function getTypeScriptMemberSymbols() { // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */ || node.kind === 163 /* PropertyAccessExpression */) { + if (node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -42462,7 +44250,7 @@ var ts; } } if (isJavaScriptFile && type.flags & 16384 /* Union */) { - // In javascript files, for union types, we don't just get the members that + // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that // each individual type has. This is because we're going to add all identifiers // anyways. So we might as well elevate the members that were at least part @@ -42489,7 +44277,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 231 /* JsxSelfClosingElement */) || (jsxContainer.kind === 232 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 232 /* JsxSelfClosingElement */) || (jsxContainer.kind === 233 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -42510,10 +44298,10 @@ var ts; // aggregating completion candidates. This is achieved in 'getScopeNode' // by finding the first node that encompasses a position, accounting for whether a node // is "complete" to decide whether a position belongs to the node. - // + // // However, at the end of an identifier, we are interested in the scope of the identifier // itself, but fall outside of the identifier. For instance: - // + // // xyz => x$ // // the cursor is outside of both the 'x' and the arrow function 'xyz => x', @@ -42563,41 +44351,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 23 /* CommaToken */: - return containingNodeKind === 165 /* CallExpression */ // func( a, | - || containingNodeKind === 141 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 166 /* NewExpression */ // new C(a, | - || containingNodeKind === 161 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 178 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 149 /* FunctionType */; // var x: (s: string, list| - case 16 /* OpenParenToken */: - return containingNodeKind === 165 /* CallExpression */ // func( | - || containingNodeKind === 141 /* Constructor */ // constructor( | - || containingNodeKind === 166 /* NewExpression */ // new C(a| - || containingNodeKind === 169 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 157 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 18 /* OpenBracketToken */: - return containingNodeKind === 161 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 146 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 133 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 122 /* ModuleKeyword */: // module | - case 123 /* NamespaceKeyword */: + case 24 /* CommaToken */: + return containingNodeKind === 166 /* CallExpression */ // func( a, | + || containingNodeKind === 142 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 167 /* NewExpression */ // new C(a, | + || containingNodeKind === 162 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 179 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 150 /* FunctionType */; // var x: (s: string, list| + case 17 /* OpenParenToken */: + return containingNodeKind === 166 /* CallExpression */ // func( | + || containingNodeKind === 142 /* Constructor */ // constructor( | + || containingNodeKind === 167 /* NewExpression */ // new C(a| + || containingNodeKind === 170 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 158 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 19 /* OpenBracketToken */: + return containingNodeKind === 162 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 147 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 134 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 123 /* ModuleKeyword */: // module | + case 124 /* NamespaceKeyword */: return true; - case 20 /* DotToken */: - return containingNodeKind === 215 /* ModuleDeclaration */; // module A.| - case 14 /* OpenBraceToken */: - return containingNodeKind === 211 /* ClassDeclaration */; // class A{ | - case 54 /* EqualsToken */: - return containingNodeKind === 208 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 178 /* BinaryExpression */; // x = a| - case 11 /* TemplateHead */: - return containingNodeKind === 180 /* TemplateExpression */; // `aa ${| - case 12 /* TemplateMiddle */: - return containingNodeKind === 187 /* TemplateSpan */; // `aa ${10} dd ${| - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - return containingNodeKind === 138 /* PropertyDeclaration */; // class A{ public | + case 21 /* DotToken */: + return containingNodeKind === 216 /* ModuleDeclaration */; // module A.| + case 15 /* OpenBraceToken */: + return containingNodeKind === 212 /* ClassDeclaration */; // class A{ | + case 55 /* EqualsToken */: + return containingNodeKind === 209 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 179 /* BinaryExpression */; // x = a| + case 12 /* TemplateHead */: + return containingNodeKind === 181 /* TemplateExpression */; // `aa ${| + case 13 /* TemplateMiddle */: + return containingNodeKind === 188 /* TemplateSpan */; // `aa ${10} dd ${| + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + return containingNodeKind === 139 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -42610,21 +44398,21 @@ var ts; return false; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 8 /* StringLiteral */ - || contextToken.kind === 9 /* RegularExpressionLiteral */ + if (contextToken.kind === 9 /* StringLiteral */ + || contextToken.kind === 10 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(contextToken.kind)) { - var start_3 = contextToken.getStart(); + var start_5 = contextToken.getStart(); var end = contextToken.getEnd(); // To be "in" one of these literals, the position has to be: // 1. entirely within the token text. // 2. at the end position of an unterminated token. // 3. at the end of a regular expression (due to trailing flags like '/foo/g'). - if (start_3 < position && position < end) { + if (start_5 < position && position < end) { return true; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 9 /* RegularExpressionLiteral */; + || contextToken.kind === 10 /* RegularExpressionLiteral */; } } return false; @@ -42640,18 +44428,29 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 162 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 163 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 158 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 159 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = objectLikeContainer.elements; + var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); + if (ts.isVariableLike(rootDeclaration)) { + // We don't want to complete using the type acquired by the shape + // of the binding pattern; we are only interested in types acquired + // through type declaration or inference. + if (rootDeclaration.initializer || rootDeclaration.type) { + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = objectLikeContainer.elements; + } + } + else { + ts.Debug.fail("Root declaration is not variable-like."); + } } else { ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); @@ -42682,9 +44481,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 222 /* NamedImports */ ? - 219 /* ImportDeclaration */ : - 225 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 223 /* NamedImports */ ? + 220 /* ImportDeclaration */ : + 226 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -42707,11 +44506,11 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14 /* OpenBraceToken */: // let x = { | - case 23 /* CommaToken */: - var parent_11 = contextToken.parent; - if (parent_11 && (parent_11.kind === 162 /* ObjectLiteralExpression */ || parent_11.kind === 158 /* ObjectBindingPattern */)) { - return parent_11; + case 15 /* OpenBraceToken */: // let x = { | + case 24 /* CommaToken */: + var parent_10 = contextToken.parent; + if (parent_10 && (parent_10.kind === 163 /* ObjectLiteralExpression */ || parent_10.kind === 159 /* ObjectBindingPattern */)) { + return parent_10; } break; } @@ -42725,11 +44524,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14 /* OpenBraceToken */: // import { | - case 23 /* CommaToken */: + case 15 /* OpenBraceToken */: // import { | + case 24 /* CommaToken */: switch (contextToken.parent.kind) { - case 222 /* NamedImports */: - case 226 /* NamedExports */: + case 223 /* NamedImports */: + case 227 /* NamedExports */: return contextToken.parent; } } @@ -42738,24 +44537,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_12 = contextToken.parent; + var parent_11 = contextToken.parent; switch (contextToken.kind) { - case 25 /* LessThanSlashToken */: - case 37 /* SlashToken */: - case 66 /* Identifier */: - if (parent_12 && (parent_12.kind === 231 /* JsxSelfClosingElement */ || parent_12.kind === 232 /* JsxOpeningElement */)) { - return parent_12; + case 26 /* LessThanSlashToken */: + case 38 /* SlashToken */: + case 67 /* Identifier */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + if (parent_11 && (parent_11.kind === 232 /* JsxSelfClosingElement */ || parent_11.kind === 233 /* JsxOpeningElement */)) { + return parent_11; } break; - case 15 /* CloseBraceToken */: - // The context token is the closing } of an attribute, which means - // its parent is a JsxExpression, whose parent is a JsxAttribute, - // whose parent is a JsxOpeningLikeElement - if (parent_12 && - parent_12.kind === 237 /* JsxExpression */ && - parent_12.parent && - parent_12.parent.kind === 235 /* JsxAttribute */) { - return parent_12.parent.parent; + // The context token is the closing } or " of an attribute, which means + // its parent is a JsxExpression, whose parent is a JsxAttribute, + // whose parent is a JsxOpeningLikeElement + case 9 /* StringLiteral */: + if (parent_11 && ((parent_11.kind === 236 /* JsxAttribute */) || (parent_11.kind === 237 /* JsxSpreadAttribute */))) { + return parent_11.parent; + } + break; + case 16 /* CloseBraceToken */: + if (parent_11 && + parent_11.kind === 238 /* JsxExpression */ && + parent_11.parent && + (parent_11.parent.kind === 236 /* JsxAttribute */)) { + return parent_11.parent.parent; + } + if (parent_11 && parent_11.kind === 237 /* JsxSpreadAttribute */) { + return parent_11.parent; } break; } @@ -42764,16 +44573,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return true; } return false; @@ -42784,65 +44593,67 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 23 /* CommaToken */: - return containingNodeKind === 208 /* VariableDeclaration */ || - containingNodeKind === 209 /* VariableDeclarationList */ || - containingNodeKind === 190 /* VariableStatement */ || - containingNodeKind === 214 /* EnumDeclaration */ || + case 24 /* CommaToken */: + return containingNodeKind === 209 /* VariableDeclaration */ || + containingNodeKind === 210 /* VariableDeclarationList */ || + containingNodeKind === 191 /* VariableStatement */ || + containingNodeKind === 215 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 211 /* ClassDeclaration */ || - containingNodeKind === 210 /* FunctionDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || - containingNodeKind === 159 /* ArrayBindingPattern */; // var [x, y| - case 20 /* DotToken */: - return containingNodeKind === 159 /* ArrayBindingPattern */; // var [.| - case 52 /* ColonToken */: - return containingNodeKind === 160 /* BindingElement */; // var {x :html| - case 18 /* OpenBracketToken */: - return containingNodeKind === 159 /* ArrayBindingPattern */; // var [x| - case 16 /* OpenParenToken */: - return containingNodeKind === 241 /* CatchClause */ || + containingNodeKind === 212 /* ClassDeclaration */ || + containingNodeKind === 184 /* ClassExpression */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 160 /* ArrayBindingPattern */ || + containingNodeKind === 214 /* TypeAliasDeclaration */; // type Map, K, | + case 21 /* DotToken */: + return containingNodeKind === 160 /* ArrayBindingPattern */; // var [.| + case 53 /* ColonToken */: + return containingNodeKind === 161 /* BindingElement */; // var {x :html| + case 19 /* OpenBracketToken */: + return containingNodeKind === 160 /* ArrayBindingPattern */; // var [x| + case 17 /* OpenParenToken */: + return containingNodeKind === 242 /* CatchClause */ || isFunction(containingNodeKind); - case 14 /* OpenBraceToken */: - return containingNodeKind === 214 /* EnumDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || - containingNodeKind === 152 /* TypeLiteral */; // let x : { | - case 22 /* SemicolonToken */: - return containingNodeKind === 137 /* PropertySignature */ && + case 15 /* OpenBraceToken */: + return containingNodeKind === 215 /* EnumDeclaration */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 153 /* TypeLiteral */; // let x : { | + case 23 /* SemicolonToken */: + return containingNodeKind === 138 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 212 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 152 /* TypeLiteral */); // let x : { a; | - case 24 /* LessThanToken */: - return containingNodeKind === 211 /* ClassDeclaration */ || - containingNodeKind === 210 /* FunctionDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || + (contextToken.parent.parent.kind === 213 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 153 /* TypeLiteral */); // let x : { a; | + case 25 /* LessThanToken */: + return containingNodeKind === 212 /* ClassDeclaration */ || + containingNodeKind === 184 /* ClassExpression */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 214 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); - case 110 /* StaticKeyword */: - return containingNodeKind === 138 /* PropertyDeclaration */; - case 21 /* DotDotDotToken */: - return containingNodeKind === 135 /* Parameter */ || + case 111 /* StaticKeyword */: + return containingNodeKind === 139 /* PropertyDeclaration */; + case 22 /* DotDotDotToken */: + return containingNodeKind === 136 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 159 /* ArrayBindingPattern */); // var [...z| - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - return containingNodeKind === 135 /* Parameter */; - case 113 /* AsKeyword */: - containingNodeKind === 223 /* ImportSpecifier */ || - containingNodeKind === 227 /* ExportSpecifier */ || - containingNodeKind === 221 /* NamespaceImport */; - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: - case 104 /* InterfaceKeyword */: - case 84 /* FunctionKeyword */: - case 99 /* VarKeyword */: - case 120 /* GetKeyword */: - case 126 /* SetKeyword */: - case 86 /* ImportKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: - case 111 /* YieldKeyword */: - case 129 /* TypeKeyword */: + contextToken.parent.parent.kind === 160 /* ArrayBindingPattern */); // var [...z| + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + return containingNodeKind === 136 /* Parameter */; + case 114 /* AsKeyword */: + containingNodeKind === 224 /* ImportSpecifier */ || + containingNodeKind === 228 /* ExportSpecifier */ || + containingNodeKind === 222 /* NamespaceImport */; + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: + case 105 /* InterfaceKeyword */: + case 85 /* FunctionKeyword */: + case 100 /* VarKeyword */: + case 121 /* GetKeyword */: + case 127 /* SetKeyword */: + case 87 /* ImportKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + case 112 /* YieldKeyword */: + case 130 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -42861,7 +44672,7 @@ var ts; return false; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 7 /* NumericLiteral */) { + if (contextToken.kind === 8 /* NumericLiteral */) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } @@ -42906,9 +44717,9 @@ var ts; for (var _i = 0; _i < existingMembers.length; _i++) { var m = existingMembers[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 242 /* PropertyAssignment */ && - m.kind !== 243 /* ShorthandPropertyAssignment */ && - m.kind !== 160 /* BindingElement */) { + if (m.kind !== 243 /* PropertyAssignment */ && + m.kind !== 244 /* ShorthandPropertyAssignment */ && + m.kind !== 161 /* BindingElement */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -42916,7 +44727,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 160 /* BindingElement */ && m.propertyName) { + if (m.kind === 161 /* BindingElement */ && m.propertyName) { existingName = m.propertyName.text; } else { @@ -42943,7 +44754,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 235 /* JsxAttribute */) { + if (attr.kind === 236 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -42956,8 +44767,12 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot; + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; var entries; + if (isJsDocTagName) { + // If the current position is a jsDoc tag name, only tag names should be provided for completion + return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; + } if (isRightOfDot && ts.isJavaScript(fileName)) { entries = getCompletionEntriesFromSymbols(symbols); ts.addRange(entries, getJavaScriptCompletionEntries()); @@ -42969,7 +44784,7 @@ var ts; entries = getCompletionEntriesFromSymbols(symbols); } // Add keywords if this is not a member completion list - if (!isMemberCompletion) { + if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; @@ -42983,7 +44798,7 @@ var ts; for (var name_32 in nameTable) { if (!allNames[name_32]) { allNames[name_32] = name_32; - var displayName = getCompletionEntryDisplayName(name_32, target, true); + var displayName = getCompletionEntryDisplayName(name_32, target, /*performCharacterChecks:*/ true); if (displayName) { var entry = { name: displayName, @@ -42998,18 +44813,28 @@ var ts; } return entries; } + function getAllJsDocCompletionEntries() { + return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } function createCompletionEntry(symbol, location) { - // Try to get a valid display name for this symbol, if we could not find one, then ignore it. + // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true, location); + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true, location); if (!displayName) { return undefined; } - // TODO(drosen): Right now we just permit *all* semantic meanings when calling - // 'getSymbolKind' which is permissible given that it is backwards compatible; but + // TODO(drosen): Right now we just permit *all* semantic meanings when calling + // 'getSymbolKind' which is permissible given that it is backwards compatible; but // really we should consider passing the meaning for the node so that we don't report - // that a suggestion for a value is an interface. We COULD also just do what + // that a suggestion for a value is an interface. We COULD also just do what // 'getSymbolModifiers' does, which is to use the first declaration. // Use a 'sortText' of 0' so that all symbol completion entries come before any other // entries (like JavaScript identifier entries). @@ -43049,10 +44874,10 @@ var ts; var symbols = completionData.symbols, location_2 = completionData.location; // Find the symbol with the matching entry name. var target = program.getCompilerOptions().target; - // We don't need to perform character checks here because we're only comparing the - // name against 'entryName' (which is known to be good), not building a new + // We don't need to perform character checks here because we're only comparing the + // name against 'entryName' (which is known to be good), not building a new // completion entry. - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false, location_2) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false, location_2) === entryName ? s : undefined; }); if (symbol) { var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { @@ -43081,7 +44906,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 183 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; @@ -43145,7 +44970,7 @@ var ts; ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); }); if (!unionPropertyKind) { - // If this was union of all methods, + // If this was union of all methods, //make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { @@ -43183,7 +45008,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 163 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 164 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -43192,7 +45017,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 165 /* CallExpression */ || location.kind === 166 /* NewExpression */) { + if (location.kind === 166 /* CallExpression */ || location.kind === 167 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -43205,10 +45030,10 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 166 /* NewExpression */ || callExpression.expression.kind === 92 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 167 /* NewExpression */ || callExpression.expression.kind === 93 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { - // Get the first signature if there + // Get the first signature if there signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { @@ -43222,7 +45047,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -43238,14 +45063,14 @@ var ts; case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(52 /* ColonToken */)); + displayParts.push(ts.punctuationPart(53 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); displayParts.push(ts.spacePart()); } if (!(type.flags & 65536 /* Anonymous */)) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */)); + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */)); } addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); break; @@ -43257,24 +45082,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 118 /* ConstructorKeyword */ && location.parent.kind === 141 /* Constructor */)) { + (location.kind === 119 /* ConstructorKeyword */ && location.parent.kind === 142 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 141 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 142 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 141 /* Constructor */) { + if (functionDeclaration.kind === 142 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 144 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -43283,7 +45108,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 183 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class @@ -43291,7 +45116,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(70 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(71 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -43299,48 +45124,49 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(104 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(105 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(129 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(71 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(72 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(78 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(79 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 215 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 66 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 123 /* NamespaceKeyword */ : 122 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 216 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 67 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 124 /* NamespaceKeyword */ : 123 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(87 /* InKeyword */)); + displayParts.push(ts.keywordPart(88 /* InKeyword */)); displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter @@ -43349,26 +45175,39 @@ var ts; } else { // Method/function type parameter - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).parent; - var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 145 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + var container = ts.getContainingFunction(location); + if (container) { + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; + var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === 146 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + displayParts.push(ts.spacePart()); + } + else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) { + addFullSymbolName(signatureDeclaration.symbol); + } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + } + else { + // Type aliash type parameter + // For example + // type list = T[]; // Both T will go through same code path + var declaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; + displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); displayParts.push(ts.spacePart()); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); } - else if (signatureDeclaration.kind !== 144 /* CallSignature */ && signatureDeclaration.name) { - addFullSymbolName(signatureDeclaration.symbol); - } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } } if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 244 /* EnumMember */) { + if (declaration.kind === 245 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -43376,26 +45215,26 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(86 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(87 /* ImportKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 218 /* ImportEqualsDeclaration */) { + if (declaration.kind === 219 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(124 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(125 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -43412,7 +45251,7 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(52 /* ColonToken */)); + displayParts.push(ts.punctuationPart(53 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -43450,7 +45289,7 @@ var ts; } } function addFullSymbolName(symbol, enclosingDeclaration) { - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); ts.addRange(displayParts, fullSymbolDisplayParts); } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -43471,9 +45310,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); return; } } @@ -43481,12 +45320,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(34 /* PlusToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(35 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); } @@ -43512,11 +45351,11 @@ var ts; if (!symbol) { // Try getting just type at this position and show switch (node.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -43560,7 +45399,7 @@ var ts; var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { - // Just add all the declarations. + // Just add all the declarations. ts.forEach(declarations, function (declaration) { result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); }); @@ -43569,18 +45408,24 @@ var ts; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (isNewExpressionTarget(location) || location.kind === 118 /* ConstructorKeyword */) { + if (isNewExpressionTarget(location) || location.kind === 119 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { - var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 211 /* ClassDeclaration */); - return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); + // Find the first class-like declaration and try to get the construct signature. + for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isClassLike(declaration)) { + return tryAddSignature(declaration.members, + /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); + } + } + ts.Debug.fail("Expected declaration to have at least one class-like declaration"); } } return false; } function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { - return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result); + return tryAddSignature(symbol.declarations, /*selectConstructors*/ false, symbolKind, symbolName, containerName, result); } return false; } @@ -43588,8 +45433,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 141 /* Constructor */) || - (!selectConstructors && (d.kind === 210 /* FunctionDeclaration */ || d.kind === 140 /* MethodDeclaration */ || d.kind === 139 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 142 /* Constructor */) || + (!selectConstructors && (d.kind === 211 /* FunctionDeclaration */ || d.kind === 141 /* MethodDeclaration */ || d.kind === 140 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -43618,7 +45463,7 @@ var ts; if (isJumpStatementTarget(node)) { var labelName = node.text; var label = getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, undefined)] : undefined; + return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } /// Triple slash reference comments var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; }); @@ -43649,16 +45494,16 @@ var ts; // to jump to the implementation directly. if (symbol.flags & 8388608 /* Alias */) { var declaration = symbol.declarations[0]; - if (node.kind === 66 /* Identifier */ && node.parent === declaration) { + if (node.kind === 67 /* Identifier */ && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } // Because name in short-hand property assignment has two different meanings: property name and property value, // using go-to-definition at such position should go to the variable declaration of the property value rather than - // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition + // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 243 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 244 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -43692,7 +45537,7 @@ var ts; var result = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(result, getDefinitionFromSymbol(t.symbol, node)); + ts.addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node)); } }); return result; @@ -43706,7 +45551,7 @@ var ts; var results = getOccurrencesAtPositionCore(fileName, position); if (results) { var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName)); - // Get occurrences only supports reporting occurrences for the file queried. So + // Get occurrences only supports reporting occurrences for the file queried. So // filter down to that list. results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; }); } @@ -43732,12 +45577,12 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 94 /* ThisKeyword */ || - node.kind === 92 /* SuperKeyword */ || + if (node.kind === 67 /* Identifier */ || + node.kind === 95 /* ThisKeyword */ || + node.kind === 93 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { - var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); + var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferencedSymbols(referencedSymbols); } return undefined; @@ -43785,77 +45630,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 85 /* IfKeyword */: - case 77 /* ElseKeyword */: - if (hasKind(node.parent, 193 /* IfStatement */)) { + case 86 /* IfKeyword */: + case 78 /* ElseKeyword */: + if (hasKind(node.parent, 194 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 91 /* ReturnKeyword */: - if (hasKind(node.parent, 201 /* ReturnStatement */)) { + case 92 /* ReturnKeyword */: + if (hasKind(node.parent, 202 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 95 /* ThrowKeyword */: - if (hasKind(node.parent, 205 /* ThrowStatement */)) { + case 96 /* ThrowKeyword */: + if (hasKind(node.parent, 206 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 69 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 206 /* TryStatement */)) { + case 70 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 207 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 97 /* TryKeyword */: - case 82 /* FinallyKeyword */: - if (hasKind(parent(node), 206 /* TryStatement */)) { + case 98 /* TryKeyword */: + case 83 /* FinallyKeyword */: + if (hasKind(parent(node), 207 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 93 /* SwitchKeyword */: - if (hasKind(node.parent, 203 /* SwitchStatement */)) { + case 94 /* SwitchKeyword */: + if (hasKind(node.parent, 204 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 68 /* CaseKeyword */: - case 74 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 203 /* SwitchStatement */)) { + case 69 /* CaseKeyword */: + case 75 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 204 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 67 /* BreakKeyword */: - case 72 /* ContinueKeyword */: - if (hasKind(node.parent, 200 /* BreakStatement */) || hasKind(node.parent, 199 /* ContinueStatement */)) { - return getBreakOrContinueStatementOccurences(node.parent); + case 68 /* BreakKeyword */: + case 73 /* ContinueKeyword */: + if (hasKind(node.parent, 201 /* BreakStatement */) || hasKind(node.parent, 200 /* ContinueStatement */)) { + return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 83 /* ForKeyword */: - if (hasKind(node.parent, 196 /* ForStatement */) || - hasKind(node.parent, 197 /* ForInStatement */) || - hasKind(node.parent, 198 /* ForOfStatement */)) { + case 84 /* ForKeyword */: + if (hasKind(node.parent, 197 /* ForStatement */) || + hasKind(node.parent, 198 /* ForInStatement */) || + hasKind(node.parent, 199 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 101 /* WhileKeyword */: - case 76 /* DoKeyword */: - if (hasKind(node.parent, 195 /* WhileStatement */) || hasKind(node.parent, 194 /* DoStatement */)) { + case 102 /* WhileKeyword */: + case 77 /* DoKeyword */: + if (hasKind(node.parent, 196 /* WhileStatement */) || hasKind(node.parent, 195 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 118 /* ConstructorKeyword */: - if (hasKind(node.parent, 141 /* Constructor */)) { + case 119 /* ConstructorKeyword */: + if (hasKind(node.parent, 142 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 120 /* GetKeyword */: - case 126 /* SetKeyword */: - if (hasKind(node.parent, 142 /* GetAccessor */) || hasKind(node.parent, 143 /* SetAccessor */)) { + case 121 /* GetKeyword */: + case 127 /* SetKeyword */: + if (hasKind(node.parent, 143 /* GetAccessor */) || hasKind(node.parent, 144 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 190 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 191 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -43871,10 +45716,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 205 /* ThrowStatement */) { + if (node.kind === 206 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 206 /* TryStatement */) { + else if (node.kind === 207 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -43902,19 +45747,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_13 = child.parent; - if (ts.isFunctionBlock(parent_13) || parent_13.kind === 245 /* SourceFile */) { - return parent_13; + var parent_12 = child.parent; + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246 /* SourceFile */) { + return parent_12; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_13.kind === 206 /* TryStatement */) { - var tryStatement = parent_13; + if (parent_12.kind === 207 /* TryStatement */) { + var tryStatement = parent_12; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_13; + child = parent_12; } return undefined; } @@ -43923,7 +45768,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 200 /* BreakStatement */ || node.kind === 199 /* ContinueStatement */) { + if (node.kind === 201 /* BreakStatement */ || node.kind === 200 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -43939,16 +45784,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 203 /* SwitchStatement */: - if (statement.kind === 199 /* ContinueStatement */) { + case 204 /* SwitchStatement */: + if (statement.kind === 200 /* ContinueStatement */) { continue; } // Fall through. - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: - case 194 /* DoStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 195 /* DoStatement */: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -43967,24 +45812,24 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 211 /* ClassDeclaration */ || - container.kind === 183 /* ClassExpression */ || - (declaration.kind === 135 /* Parameter */ && hasKind(container, 141 /* Constructor */)))) { + if (!(container.kind === 212 /* ClassDeclaration */ || + container.kind === 184 /* ClassExpression */ || + (declaration.kind === 136 /* Parameter */ && hasKind(container, 142 /* Constructor */)))) { return undefined; } } - else if (modifier === 110 /* StaticKeyword */) { - if (!(container.kind === 211 /* ClassDeclaration */ || container.kind === 183 /* ClassExpression */)) { + else if (modifier === 111 /* StaticKeyword */) { + if (!(container.kind === 212 /* ClassDeclaration */ || container.kind === 184 /* ClassExpression */)) { return undefined; } } - else if (modifier === 79 /* ExportKeyword */ || modifier === 119 /* DeclareKeyword */) { - if (!(container.kind === 216 /* ModuleBlock */ || container.kind === 245 /* SourceFile */)) { + else if (modifier === 80 /* ExportKeyword */ || modifier === 120 /* DeclareKeyword */) { + if (!(container.kind === 217 /* ModuleBlock */ || container.kind === 246 /* SourceFile */)) { return undefined; } } - else if (modifier === 112 /* AbstractKeyword */) { - if (!(container.kind === 211 /* ClassDeclaration */ || declaration.kind === 211 /* ClassDeclaration */)) { + else if (modifier === 113 /* AbstractKeyword */) { + if (!(container.kind === 212 /* ClassDeclaration */ || declaration.kind === 212 /* ClassDeclaration */)) { return undefined; } } @@ -43996,8 +45841,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 216 /* ModuleBlock */: - case 245 /* SourceFile */: + case 217 /* ModuleBlock */: + case 246 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 256 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -44006,17 +45851,17 @@ var ts; nodes = container.statements; } break; - case 141 /* Constructor */: + case 142 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 141 /* Constructor */ && member; + return member.kind === 142 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -44037,19 +45882,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 109 /* PublicKeyword */: + case 110 /* PublicKeyword */: return 16 /* Public */; - case 107 /* PrivateKeyword */: + case 108 /* PrivateKeyword */: return 32 /* Private */; - case 108 /* ProtectedKeyword */: + case 109 /* ProtectedKeyword */: return 64 /* Protected */; - case 110 /* StaticKeyword */: + case 111 /* StaticKeyword */: return 128 /* Static */; - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: return 1 /* Export */; - case 119 /* DeclareKeyword */: + case 120 /* DeclareKeyword */: return 2 /* Ambient */; - case 112 /* AbstractKeyword */: + case 113 /* AbstractKeyword */: return 256 /* Abstract */; default: ts.Debug.fail(); @@ -44069,13 +45914,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 142 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 144 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 120 /* GetKeyword */, 126 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 121 /* GetKeyword */, 127 /* SetKeyword */); }); } } } @@ -44084,19 +45929,19 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 118 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 119 /* ConstructorKeyword */); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 83 /* ForKeyword */, 101 /* WhileKeyword */, 76 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84 /* ForKeyword */, 102 /* WhileKeyword */, 77 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 194 /* DoStatement */) { + if (loopNode.kind === 195 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 101 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 102 /* WhileKeyword */)) { break; } } @@ -44105,22 +45950,22 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67 /* BreakKeyword */, 72 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */, 73 /* ContinueKeyword */); } }); return ts.map(keywords, getHighlightSpanForNode); } - function getBreakOrContinueStatementOccurences(breakOrContinueStatement) { + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -44128,14 +45973,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 93 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 94 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 68 /* CaseKeyword */, 74 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 69 /* CaseKeyword */, 75 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */); } }); }); @@ -44143,13 +45988,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 97 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 98 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 69 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 82 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 83 /* FinallyKeyword */); } return ts.map(keywords, getHighlightSpanForNode); } @@ -44160,13 +46005,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); }); } return ts.map(keywords, getHighlightSpanForNode); @@ -44174,36 +46019,36 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 189 /* Block */))) { + if (!(func && hasKind(func.body, 190 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 193 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 194 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 85 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 86 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 77 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 78 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 193 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 194 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -44212,7 +46057,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 77 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 78 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -44279,11 +46124,11 @@ var ts; return convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferences(referencedSymbols); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); // Only include referenced symbols that have a valid definition. return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); } @@ -44294,7 +46139,7 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 66 /* Identifier */ && + if (node.kind !== 67 /* Identifier */ && // TODO (drosen): This should be enabled in a later release - currently breaks rename. //node.kind !== SyntaxKind.ThisKeyword && //node.kind !== SyntaxKind.SuperKeyword && @@ -44302,7 +46147,7 @@ var ts; !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 66 /* Identifier */ || node.kind === 7 /* NumericLiteral */ || node.kind === 8 /* StringLiteral */); + ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { @@ -44320,10 +46165,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 94 /* ThisKeyword */) { + if (node.kind === 95 /* ThisKeyword */) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 92 /* SuperKeyword */) { + if (node.kind === 93 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -44383,7 +46228,7 @@ var ts; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 223 /* ImportSpecifier */ || declaration.kind === 227 /* ExportSpecifier */; + return declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 228 /* ExportSpecifier */; }); } function getInternedName(symbol, location, declarations) { @@ -44410,14 +46255,14 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 170 /* FunctionExpression */ || valueDeclaration.kind === 183 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 171 /* FunctionExpression */ || valueDeclaration.kind === 184 /* ClassExpression */)) { return valueDeclaration; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 211 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 212 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -44443,7 +46288,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 245 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -44471,12 +46316,12 @@ var ts; // If we are past the end, stop looking if (position > end) break; - // We found a match. Make sure it's not part of a larger word (i.e. the char + // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 2 /* Latest */)) && (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 2 /* Latest */))) { - // Found a real match. Keep searching. + // Found a real match. Keep searching. positions.push(position); } position = text.indexOf(symbolName, position + symbolNameLength + 1); @@ -44514,16 +46359,16 @@ var ts; if (node) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return node.getWidth() === searchSymbolName.length; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { // For string literals we have two additional chars for the quotes return node.getWidth() === searchSymbolName.length + 2; } break; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { return node.getWidth() === searchSymbolName.length; } @@ -44547,11 +46392,11 @@ var ts; cancellationToken.throwIfCancellationRequested(); var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); if (!isValidReferencePosition(referenceLocation, searchText)) { - // This wasn't the start of a token. Check to see if it might be a + // This wasn't the start of a token. Check to see if it might be a // match in a comment or string if that's what the caller is asking // for. - if ((findInStrings && isInString(position)) || - (findInComments && isInComment(position))) { + if ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && isInNonReferenceComment(sourceFile, position))) { // In the case where we're looking inside comments/strings, we don't have // an actual definition. So just use 'undefined' here. Features like // 'Rename' won't care (as they ignore the definitions), and features like @@ -44600,44 +46445,29 @@ var ts; } return result[index]; } - function isInString(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - return token && token.kind === 8 /* StringLiteral */ && position > token.getStart(); - } - function isInComment(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (token && position < token.getStart()) { - // First, we have to see if this position actually landed in a comment. - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - // Then we want to make sure that it wasn't in a "///<" directive comment - // We don't want to unintentionally update a file name. - return ts.forEach(commentRanges, function (c) { - if (c.pos < position && position < c.end) { - var commentText = sourceFile.text.substring(c.pos, c.end); - if (!tripleSlashDirectivePrefixRegex.test(commentText)) { - return true; - } - } - }); + function isInNonReferenceComment(sourceFile, position) { + return ts.isInCommentHelper(sourceFile, position, isNonReferenceComment); + function isNonReferenceComment(c) { + var commentText = sourceFile.text.substring(c.pos, c.end); + return !tripleSlashDirectivePrefixRegex.test(commentText); } - return false; } } function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, false); + var searchSpaceNode = ts.getSuperContainer(superKeyword, /*includeFunctions*/ false); if (!searchSpaceNode) { return undefined; } // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -44650,10 +46480,10 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 92 /* SuperKeyword */) { + if (!node || node.kind !== 93 /* SuperKeyword */) { return; } - var container = ts.getSuperContainer(node, false); + var container = ts.getSuperContainer(node, /*includeFunctions*/ false); // If we have a 'super' container, we must have an enclosing class. // Now make sure the owning class is the same as the search-space // and has the same static qualifier as the original 'super's owner. @@ -44665,31 +46495,31 @@ var ts; return [{ definition: definition, references: references }]; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. @@ -44698,7 +46528,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 245 /* SourceFile */) { + if (searchSpaceNode.kind === 246 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -44724,32 +46554,33 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 94 /* ThisKeyword */) { + if (!node || node.kind !== 95 /* ThisKeyword */) { return; } - var container = ts.getThisContainer(node, false); + var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 211 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 245 /* SourceFile */: - if (container.kind === 245 /* SourceFile */ && !ts.isExternalModule(container)) { + case 246 /* SourceFile */: + if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -44803,11 +46634,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 211 /* ClassDeclaration */) { + if (declaration.kind === 212 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 212 /* InterfaceDeclaration */) { + else if (declaration.kind === 213 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -44839,7 +46670,7 @@ var ts; return aliasedSymbol; } } - // If the reference location is in an object literal, try to get the contextual type for the + // 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)) { @@ -44854,7 +46685,7 @@ var ts; if (searchSymbols.indexOf(rootSymbol) >= 0) { return rootSymbol; } - // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // Finally, try all properties with the same name in any type the containing type extended or implemented, and // see if any is in the list if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { var result_3 = []; @@ -44930,7 +46761,7 @@ var ts; function getReferenceEntryFromNode(node) { var start = node.getStart(); var end = node.getEnd(); - if (node.kind === 8 /* StringLiteral */) { + if (node.kind === 9 /* StringLiteral */) { start += 1; end -= 1; } @@ -44942,17 +46773,17 @@ var ts; } /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node) { - if (node.kind === 66 /* Identifier */ && ts.isDeclarationName(node)) { + if (node.kind === 67 /* Identifier */ && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 177 /* PostfixUnaryExpression */ || parent.kind === 176 /* PrefixUnaryExpression */) { + if (parent.kind === 178 /* PostfixUnaryExpression */ || parent.kind === 177 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 178 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 179 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; - return 54 /* FirstAssignment */ <= operator && operator <= 65 /* LastAssignment */; + return 55 /* FirstAssignment */ <= operator && operator <= 66 /* LastAssignment */; } } return false; @@ -44984,34 +46815,34 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 135 /* Parameter */: - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: - case 244 /* EnumMember */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 241 /* CatchClause */: + case 136 /* Parameter */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: + case 245 /* EnumMember */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 242 /* CatchClause */: return 1 /* Value */; - case 134 /* TypeParameter */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 152 /* TypeLiteral */: + case 135 /* TypeParameter */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 153 /* TypeLiteral */: return 2 /* Type */; - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 215 /* ModuleDeclaration */: - if (node.name.kind === 8 /* StringLiteral */) { + case 216 /* ModuleDeclaration */: + if (node.name.kind === 9 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { @@ -45020,15 +46851,15 @@ var ts; else { return 4 /* Namespace */; } - case 222 /* NamedImports */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 219 /* ImportDeclaration */: - case 224 /* ExportAssignment */: - case 225 /* ExportDeclaration */: + case 223 /* NamedImports */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 220 /* ImportDeclaration */: + case 225 /* ExportAssignment */: + case 226 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 245 /* SourceFile */: + case 246 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -45038,8 +46869,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 148 /* TypeReference */ || - (node.parent.kind === 185 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 149 /* TypeReference */ || + (node.parent.kind === 186 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -45047,50 +46878,50 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 163 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 163 /* PropertyAccessExpression */) { + if (root.parent.kind === 164 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 164 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 185 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 240 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 186 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 241 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 211 /* ClassDeclaration */ && root.parent.parent.token === 103 /* ImplementsKeyword */) || - (decl.kind === 212 /* InterfaceDeclaration */ && root.parent.parent.token === 80 /* ExtendsKeyword */); + return (decl.kind === 212 /* ClassDeclaration */ && root.parent.parent.token === 104 /* ImplementsKeyword */) || + (decl.kind === 213 /* InterfaceDeclaration */ && root.parent.parent.token === 81 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 132 /* QualifiedName */) { - while (root.parent && root.parent.kind === 132 /* QualifiedName */) { + if (root.parent.kind === 133 /* QualifiedName */) { + while (root.parent && root.parent.kind === 133 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 148 /* TypeReference */ && !isLastClause; + return root.parent.kind === 149 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 132 /* QualifiedName */) { + while (node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 66 /* Identifier */); + ts.Debug.assert(node.kind === 67 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 132 /* QualifiedName */ && + if (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 218 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 219 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 224 /* ExportAssignment */) { + if (node.parent.kind === 225 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -45130,15 +46961,15 @@ var ts; return; } switch (node.kind) { - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: - case 8 /* StringLiteral */: - case 81 /* FalseKeyword */: - case 96 /* TrueKeyword */: - case 90 /* NullKeyword */: - case 92 /* SuperKeyword */: - case 94 /* ThisKeyword */: - case 66 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 9 /* StringLiteral */: + case 82 /* FalseKeyword */: + case 97 /* TrueKeyword */: + case 91 /* NullKeyword */: + case 93 /* SuperKeyword */: + case 95 /* ThisKeyword */: + case 67 /* Identifier */: break; // Cant create the text span default: @@ -45152,9 +46983,9 @@ var ts; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { // If this is name of a module declarations, check if this is right side of dotted module name - // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of + // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 215 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 216 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -45188,17 +47019,17 @@ var ts; // been canceled. That would be an enormous amount of chattyness, along with the all // the overhead of marshalling the data to/from the host. So instead we pick a few // reasonable node kinds to bother checking on. These node kinds represent high level - // constructs that we would expect to see commonly, but just at a far less frequent + // constructs that we would expect to see commonly, but just at a far less frequent // interval. // // For example, in checker.ts (around 750k) we only have around 600 of these constructs. // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -45252,7 +47083,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 215 /* ModuleDeclaration */ && + return declaration.kind === 216 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -45262,7 +47093,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(kind); - if (kind === 66 /* Identifier */ && !ts.nodeIsMissing(node)) { + if (kind === 67 /* Identifier */ && !ts.nodeIsMissing(node)) { var identifier = node; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run @@ -45323,8 +47154,8 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(2 /* Latest */, false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2 /* Latest */, false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(2 /* Latest */, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(2 /* Latest */, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; @@ -45355,13 +47186,13 @@ var ts; // Only bother with the trivia if it at least intersects the span of interest. if (ts.isComment(kind)) { classifyComment(token, kind, start, width); - // Classifying a comment might cause us to reuse the trivia scanner + // Classifying a comment might cause us to reuse the trivia scanner // (because of jsdoc comments). So after we classify the comment make // sure we set the scanner position back to where it needs to be. triviaScanner.setTextPos(end); continue; } - if (kind === 6 /* ConflictMarkerTrivia */) { + if (kind === 7 /* ConflictMarkerTrivia */) { var text = sourceFile.text; var ch = text.charCodeAt(start); // for the <<<<<<< and >>>>>>> markers, we just add them in as comments @@ -45399,7 +47230,7 @@ var ts; for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { var tag = _a[_i]; // As we walk through each tag, classify the portion of text from the end of - // the last tag (or the start of the entire doc comment) as 'comment'. + // the last tag (or the start of the entire doc comment) as 'comment'. if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } @@ -45407,16 +47238,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 264 /* JSDocParameterTag */: + case 265 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 267 /* JSDocTemplateTag */: + case 268 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 266 /* JSDocTypeTag */: + case 267 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 265 /* JSDocReturnTag */: + case 266 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -45451,7 +47282,7 @@ var ts; } } function classifyDisabledMergeCode(text, start, end) { - // Classify the line that the ======= marker is on as a comment. Then just lex + // Classify the line that the ======= marker is on as a comment. Then just lex // all further tokens and add them to the result. for (var i = start; i < end; i++) { if (ts.isLineBreak(text.charCodeAt(i))) { @@ -45487,7 +47318,7 @@ var ts; } } } - // for accurate classification, the actual token should be passed in. however, for + // for accurate classification, the actual token should be passed in. however, for // cases like 'disabled merge code' classification, we just get the token kind and // classify based on that instead. function classifyTokenType(tokenKind, token) { @@ -45496,7 +47327,7 @@ var ts; } // Special case < and > If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 24 /* LessThanToken */ || tokenKind === 26 /* GreaterThanToken */) { + if (tokenKind === 25 /* LessThanToken */ || tokenKind === 27 /* GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { @@ -45505,30 +47336,30 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 54 /* EqualsToken */) { + if (tokenKind === 55 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 208 /* VariableDeclaration */ || - token.parent.kind === 138 /* PropertyDeclaration */ || - token.parent.kind === 135 /* Parameter */) { + if (token.parent.kind === 209 /* VariableDeclaration */ || + token.parent.kind === 139 /* PropertyDeclaration */ || + token.parent.kind === 136 /* Parameter */) { return 5 /* operator */; } } - if (token.parent.kind === 178 /* BinaryExpression */ || - token.parent.kind === 176 /* PrefixUnaryExpression */ || - token.parent.kind === 177 /* PostfixUnaryExpression */ || - token.parent.kind === 179 /* ConditionalExpression */) { + if (token.parent.kind === 179 /* BinaryExpression */ || + token.parent.kind === 177 /* PrefixUnaryExpression */ || + token.parent.kind === 178 /* PostfixUnaryExpression */ || + token.parent.kind === 180 /* ConditionalExpression */) { return 5 /* operator */; } } return 10 /* punctuation */; } - else if (tokenKind === 7 /* NumericLiteral */) { + else if (tokenKind === 8 /* NumericLiteral */) { return 4 /* numericLiteral */; } - else if (tokenKind === 8 /* StringLiteral */) { + else if (tokenKind === 9 /* StringLiteral */) { return 6 /* stringLiteral */; } - else if (tokenKind === 9 /* RegularExpressionLiteral */) { + else if (tokenKind === 10 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. return 6 /* stringLiteral */; } @@ -45536,35 +47367,35 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 66 /* Identifier */) { + else if (tokenKind === 67 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 135 /* Parameter */: + case 136 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } @@ -45630,14 +47461,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 14 /* OpenBraceToken */: return 15 /* CloseBraceToken */; - case 16 /* OpenParenToken */: return 17 /* CloseParenToken */; - case 18 /* OpenBracketToken */: return 19 /* CloseBracketToken */; - case 24 /* LessThanToken */: return 26 /* GreaterThanToken */; - case 15 /* CloseBraceToken */: return 14 /* OpenBraceToken */; - case 17 /* CloseParenToken */: return 16 /* OpenParenToken */; - case 19 /* CloseBracketToken */: return 18 /* OpenBracketToken */; - case 26 /* GreaterThanToken */: return 24 /* LessThanToken */; + case 15 /* OpenBraceToken */: return 16 /* CloseBraceToken */; + case 17 /* OpenParenToken */: return 18 /* CloseParenToken */; + case 19 /* OpenBracketToken */: return 20 /* CloseBracketToken */; + case 25 /* LessThanToken */: return 27 /* GreaterThanToken */; + case 16 /* CloseBraceToken */: return 15 /* OpenBraceToken */; + case 18 /* CloseParenToken */: return 17 /* OpenParenToken */; + case 20 /* CloseBracketToken */: return 19 /* OpenBracketToken */; + case 27 /* GreaterThanToken */: return 25 /* LessThanToken */; } return undefined; } @@ -45672,12 +47503,73 @@ var ts; } return []; } + /** + * Checks if position points to a valid position to add JSDoc comments, and if so, + * returns the appropriate template. Otherwise returns an empty string. + * Valid positions are + * - outside of comments, statements, and expressions, and + * - preceding a function declaration. + * + * Hosts should ideally check that: + * - The line is all whitespace up to 'position' before performing the insertion. + * - If the keystroke sequence "/\*\*" induced the call, we also check that the next + * non-whitespace character is '*', which (approximately) indicates whether we added + * the second '*' to complete an existing (JSDoc) comment. + * @param fileName The file in which to perform the check. + * @param position The (character-indexed) position in the file where the check should + * be performed. + */ + function getDocCommentTemplateAtPosition(fileName, position) { + var start = new Date().getTime(); + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + // Check if in a context where we don't want to perform any insertion + if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { + return undefined; + } + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); + var tokenStart = tokenAtPos.getStart(); + if (!tokenAtPos || tokenStart < position) { + return undefined; + } + // TODO: add support for: + // - methods + // - constructors + // - class decls + var containingFunction = ts.getAncestor(tokenAtPos, 211 /* FunctionDeclaration */); + if (!containingFunction || containingFunction.getStart() < position) { + return undefined; + } + var parameters = containingFunction.parameters; + var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); + var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + // TODO: call a helper method instead once PR #4133 gets merged in. + var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; + var docParams = parameters.reduce(function (prev, cur, index) { + return prev + + indentationStr + " * @param " + (cur.name.kind === 67 /* Identifier */ ? cur.name.text : "param" + index) + newLine; + }, ""); + // A doc comment consists of the following + // * The opening comment line + // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) + // * the '@param'-tagged lines + // * TODO: other tags. + // * the closing comment line + // * if the caret was directly in front of the object, then we add an extra line and indentation. + var preamble = "/**" + newLine + + indentationStr + " * "; + var result = preamble + newLine + + docParams + + indentationStr + " */" + + (tokenStart === position ? newLine + indentationStr : ""); + return { newText: result, caretOffset: preamble.length }; + } function getTodoComments(fileName, descriptors) { - // Note: while getting todo comments seems like a syntactic operation, we actually + // Note: while getting todo comments seems like a syntactic operation, we actually // treat it as a semantic operation here. This is because we expect our host to call // this on every single file. If we treat this syntactically, then that will cause // us to populate and throw away the tree in our syntax tree cache for each file. By - // treating this as a semantic operation, we can access any tree without throwing + // treating this as a semantic operation, we can access any tree without throwing // anything away. synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -45701,7 +47593,7 @@ var ts; // 0) The full match for the entire regexp. // 1) The preamble to the message portion. // 2) The message portion. - // 3...N) The descriptor that was matched - by index. 'undefined' for each + // 3...N) The descriptor that was matched - by index. 'undefined' for each // descriptor that didn't match. an actual value if it did match. // // i.e. 'undefined' in position 3 above means TODO(jason) didn't match. @@ -45723,7 +47615,7 @@ var ts; } } ts.Debug.assert(descriptor !== undefined); - // We don't want to match something like 'TODOBY', so we make sure a non + // We don't want to match something like 'TODOBY', so we make sure a non // letter/digit follows the match. if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { continue; @@ -45768,10 +47660,10 @@ var ts; // (?:(TODO\(jason\))|(HACK)) // // Note that the outermost group is *not* a capture group, but the innermost groups - // *are* capture groups. By capturing the inner literals we can determine after + // *are* capture groups. By capturing the inner literals we can determine after // matching which descriptor we are dealing with. var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; - // After matching a descriptor literal, the following regexp matches the rest of the + // After matching a descriptor literal, the following regexp matches the rest of the // text up to the end of the line (or */). var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; var messageRemainder = /(?:.*?)/.source; @@ -45802,7 +47694,7 @@ var ts; var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); // Can only rename an identifier. - if (node && node.kind === 66 /* Identifier */) { + if (node && node.kind === 67 /* Identifier */) { var symbol = typeChecker.getSymbolAtLocation(node); // Only allow a symbol to be renamed if it actually has at least one declaration. if (symbol) { @@ -45882,6 +47774,7 @@ var ts; getFormattingEditsForRange: getFormattingEditsForRange, getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, getEmitOutput: getEmitOutput, getSourceFile: getSourceFile, getProgram: getProgram @@ -45902,17 +47795,17 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: nameTable[node.text] = node.text; break; - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: // We want to store any numbers/strings if they were a name that could be // related to a declaration. So, if we have 'import x = require("something")' // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 229 /* ExternalModuleReference */ || + node.parent.kind === 230 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -45925,29 +47818,29 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 164 /* ElementAccessExpression */ && + node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier function createClassifier() { - var scanner = ts.createScanner(2 /* Latest */, false); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); /// We do not have a full parser support to know when we should parse a regex or not /// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where - /// we have a series of divide operator. this list allows us to be more accurate by ruling out + /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = []; - noRegexTable[66 /* Identifier */] = true; - noRegexTable[8 /* StringLiteral */] = true; - noRegexTable[7 /* NumericLiteral */] = true; - noRegexTable[9 /* RegularExpressionLiteral */] = true; - noRegexTable[94 /* ThisKeyword */] = true; - noRegexTable[39 /* PlusPlusToken */] = true; - noRegexTable[40 /* MinusMinusToken */] = true; - noRegexTable[17 /* CloseParenToken */] = true; - noRegexTable[19 /* CloseBracketToken */] = true; - noRegexTable[15 /* CloseBraceToken */] = true; - noRegexTable[96 /* TrueKeyword */] = true; - noRegexTable[81 /* FalseKeyword */] = true; + noRegexTable[67 /* Identifier */] = true; + noRegexTable[9 /* StringLiteral */] = true; + noRegexTable[8 /* NumericLiteral */] = true; + noRegexTable[10 /* RegularExpressionLiteral */] = true; + noRegexTable[95 /* ThisKeyword */] = true; + noRegexTable[40 /* PlusPlusToken */] = true; + noRegexTable[41 /* MinusMinusToken */] = true; + noRegexTable[18 /* CloseParenToken */] = true; + noRegexTable[20 /* CloseBracketToken */] = true; + noRegexTable[16 /* CloseBraceToken */] = true; + noRegexTable[97 /* TrueKeyword */] = true; + noRegexTable[82 /* FalseKeyword */] = true; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -45972,11 +47865,11 @@ var ts; /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 120 /* GetKeyword */ || - keyword2 === 126 /* SetKeyword */ || - keyword2 === 118 /* ConstructorKeyword */ || - keyword2 === 110 /* StaticKeyword */) { - // Allow things like "public get", "public constructor" and "public static". + if (keyword2 === 121 /* GetKeyword */ || + keyword2 === 127 /* SetKeyword */ || + keyword2 === 119 /* ConstructorKeyword */ || + keyword2 === 111 /* StaticKeyword */) { + // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; } @@ -45994,7 +47887,7 @@ var ts; var lastEnd = 0; for (var i = 0, n = dense.length; i < n; i += 3) { var start = dense[i]; - var length_2 = dense[i + 1]; + var length_3 = dense[i + 1]; var type = dense[i + 2]; // Make a whitespace entry between the last item and this one. if (lastEnd >= 0) { @@ -46003,8 +47896,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); } } - entries.push({ length: length_2, classification: convertClassification(type) }); - lastEnd = start + length_2; + entries.push({ length: length_3, classification: convertClassification(type) }); + lastEnd = start + length_3; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -46074,7 +47967,7 @@ var ts; offset = 2; // fallthrough case 6 /* InTemplateSubstitutionPosition */: - templateStack.push(11 /* TemplateHead */); + templateStack.push(12 /* TemplateHead */); break; } scanner.setText(text); @@ -46093,83 +47986,83 @@ var ts; // token. So the classification will go back to being an identifier. The moment the user // types again, number will become a keyword, then an identifier, etc. etc. // - // To try to avoid this problem, we avoid classifying contextual keywords as keywords + // To try to avoid this problem, we avoid classifying contextual keywords as keywords // when the user is potentially typing something generic. We just can't do a good enough // job at the lexical level, and so well leave it up to the syntactic classifier to make // the determination. // - // In order to determine if the user is potentially typing something generic, we use a + // In order to determine if the user is potentially typing something generic, we use a // weak heuristic where we track < and > tokens. It's a weak heuristic, but should // work well enough in practice. var angleBracketStack = 0; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 37 /* SlashToken */ || token === 58 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 9 /* RegularExpressionLiteral */) { - token = 9 /* RegularExpressionLiteral */; + if ((token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 10 /* RegularExpressionLiteral */) { + token = 10 /* RegularExpressionLiteral */; } } - else if (lastNonTriviaToken === 20 /* DotToken */ && isKeyword(token)) { - token = 66 /* Identifier */; + else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { + token = 67 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - // We have two keywords in a row. Only treat the second as a keyword if + // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 66 /* Identifier */; + token = 67 /* Identifier */; } - else if (lastNonTriviaToken === 66 /* Identifier */ && - token === 24 /* LessThanToken */) { - // Could be the start of something generic. Keep track of that by bumping + else if (lastNonTriviaToken === 67 /* Identifier */ && + token === 25 /* LessThanToken */) { + // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } - else if (token === 26 /* GreaterThanToken */ && angleBracketStack > 0) { + else if (token === 27 /* GreaterThanToken */ && angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } - else if (token === 114 /* AnyKeyword */ || - token === 127 /* StringKeyword */ || - token === 125 /* NumberKeyword */ || - token === 117 /* BooleanKeyword */ || - token === 128 /* SymbolKeyword */) { + else if (token === 115 /* AnyKeyword */ || + token === 128 /* StringKeyword */ || + token === 126 /* NumberKeyword */ || + token === 118 /* BooleanKeyword */ || + token === 129 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - // If it looks like we're could be in something generic, don't classify this + // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 66 /* Identifier */; + token = 67 /* Identifier */; } } - else if (token === 11 /* TemplateHead */) { + else if (token === 12 /* TemplateHead */) { templateStack.push(token); } - else if (token === 14 /* OpenBraceToken */) { + else if (token === 15 /* OpenBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 15 /* CloseBraceToken */) { + else if (token === 16 /* CloseBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 11 /* TemplateHead */) { + if (lastTemplateStackToken === 12 /* TemplateHead */) { token = scanner.reScanTemplateToken(); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 13 /* TemplateTail */) { + if (token === 14 /* TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assert(token === 12 /* TemplateMiddle */, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 13 /* TemplateMiddle */, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 14 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 15 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -46184,7 +48077,7 @@ var ts; var end = scanner.getTextPos(); addResult(start, end, classFromKind(token)); if (end >= text.length) { - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // Check to see if we finished up on a multiline string literal. var tokenText = scanner.getTokenText(); if (scanner.isUnterminated()) { @@ -46210,10 +48103,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 13 /* TemplateTail */) { + if (token === 14 /* TemplateTail */) { result.endOfLineState = 5 /* InTemplateMiddleOrTail */; } - else if (token === 10 /* NoSubstitutionTemplateLiteral */) { + else if (token === 11 /* NoSubstitutionTemplateLiteral */) { result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; } else { @@ -46221,7 +48114,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 11 /* TemplateHead */) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12 /* TemplateHead */) { result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; } } @@ -46232,8 +48125,8 @@ var ts; return; } if (start === 0 && offset > 0) { - // We're classifying the first token, and this was a case where we prepended - // text. We should consider the start of this token to be at the start of + // We're classifying the first token, and this was a case where we prepended + // text. We should consider the start of this token to be at the start of // the original text. start += offset; } @@ -46251,42 +48144,42 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 41 /* LessThanLessThanToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: - case 88 /* InstanceOfKeyword */: - case 87 /* InKeyword */: - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: - case 44 /* AmpersandToken */: - case 46 /* CaretToken */: - case 45 /* BarToken */: - case 49 /* AmpersandAmpersandToken */: - case 50 /* BarBarToken */: - case 64 /* BarEqualsToken */: - case 63 /* AmpersandEqualsToken */: - case 65 /* CaretEqualsToken */: - case 60 /* LessThanLessThanEqualsToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 55 /* PlusEqualsToken */: - case 56 /* MinusEqualsToken */: - case 57 /* AsteriskEqualsToken */: - case 58 /* SlashEqualsToken */: - case 59 /* PercentEqualsToken */: - case 54 /* EqualsToken */: - case 23 /* CommaToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 42 /* LessThanLessThanToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: + case 89 /* InstanceOfKeyword */: + case 88 /* InKeyword */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: + case 45 /* AmpersandToken */: + case 47 /* CaretToken */: + case 46 /* BarToken */: + case 50 /* AmpersandAmpersandToken */: + case 51 /* BarBarToken */: + case 65 /* BarEqualsToken */: + case 64 /* AmpersandEqualsToken */: + case 66 /* CaretEqualsToken */: + case 61 /* LessThanLessThanEqualsToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 56 /* PlusEqualsToken */: + case 57 /* MinusEqualsToken */: + case 58 /* AsteriskEqualsToken */: + case 59 /* SlashEqualsToken */: + case 60 /* PercentEqualsToken */: + case 55 /* EqualsToken */: + case 24 /* CommaToken */: return true; default: return false; @@ -46294,19 +48187,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 67 /* FirstKeyword */ && token <= 131 /* LastKeyword */; + return token >= 68 /* FirstKeyword */ && token <= 132 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -46315,24 +48208,24 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 14 /* FirstPunctuation */ && token <= 65 /* LastPunctuation */) { + else if (token >= 15 /* FirstPunctuation */ && token <= 66 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return 4 /* numericLiteral */; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: return 6 /* stringLiteral */; - case 9 /* RegularExpressionLiteral */: + case 10 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; - case 6 /* ConflictMarkerTrivia */: + case 7 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: case 2 /* SingleLineCommentTrivia */: return 1 /* comment */; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 66 /* Identifier */: + case 67 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -46364,7 +48257,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 245 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 246 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = -1; proto.end = -1; @@ -46434,159 +48327,159 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ForStatement */) { + if (node.parent.kind === 197 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 178 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { + if (node.parent.kind === 179 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind === 171 /* ArrowFunction */ && node.parent.body === node) { + if (node.parent.kind === 172 /* ArrowFunction */ && node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); } } switch (node.kind) { - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 208 /* VariableDeclaration */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 209 /* VariableDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return spanInVariableDeclaration(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return spanInParameterDeclaration(node); - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 216 /* ModuleBlock */: + case 217 /* ModuleBlock */: return spanInBlock(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return spanInBlock(node.block); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 194 /* DoStatement */: + case 195 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 193 /* IfStatement */: + case 194 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return spanInForStatement(node); - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 206 /* TryStatement */: + case 207 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: // span on complete node return textSpan(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: return undefined; // Tokens: - case 22 /* SemicolonToken */: + case 23 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 23 /* CommaToken */: + case 24 /* CommaToken */: return spanInPreviousNode(node); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 15 /* CloseBraceToken */: + case 16 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return spanInOpenParenToken(node); - case 17 /* CloseParenToken */: + case 18 /* CloseParenToken */: return spanInCloseParenToken(node); - case 52 /* ColonToken */: + case 53 /* ColonToken */: return spanInColonToken(node); - case 26 /* GreaterThanToken */: - case 24 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 25 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 101 /* WhileKeyword */: + case 102 /* WhileKeyword */: return spanInWhileKeyword(node); - case 77 /* ElseKeyword */: - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 78 /* ElseKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 242 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 243 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 168 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 169 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -46599,12 +48492,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 197 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 198 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 198 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 190 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 196 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -46658,7 +48551,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 211 /* ClassDeclaration */ && functionDeclaration.kind !== 141 /* Constructor */); + (functionDeclaration.parent.kind === 212 /* ClassDeclaration */ && functionDeclaration.kind !== 142 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -46681,18 +48574,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 195 /* WhileStatement */: - case 193 /* IfStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 194 /* IfStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 196 /* ForStatement */: + case 197 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -46700,7 +48593,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 209 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -46720,13 +48613,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -46734,25 +48627,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 216 /* ModuleBlock */: + case 217 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 214 /* EnumDeclaration */: - case 211 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 241 /* CatchClause */: + case 242 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -46766,7 +48659,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -46776,17 +48669,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 195 /* WhileStatement */: - case 194 /* DoStatement */: - case 196 /* ForStatement */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 196 /* WhileStatement */: + case 195 /* DoStatement */: + case 197 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -46797,19 +48690,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 242 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 243 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 168 /* TypeAssertionExpression */) { + if (node.parent.kind === 169 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -46878,9 +48771,21 @@ var ts; })(); var LanguageServiceShimHostAdapter = (function () { function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; this.shimHost = shimHost; this.loggingEnabled = false; this.tracingEnabled = false; + // if shimHost is a COM object then property check will become method call with no arguments. + // 'in' does not have this effect. + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { + var result = ts.lookUp(resolutionsInFile, name); + return result ? { resolvedFileName: result } : undefined; + }); + }; + } } LanguageServiceShimHostAdapter.prototype.log = function (s) { if (this.loggingEnabled) { @@ -46988,10 +48893,26 @@ var ts; function CoreServicesShimHostAdapter(shimHost) { this.shimHost = shimHost; } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension) { - var encoded = this.shimHost.readDirectory(rootDir, extension); + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension, exclude) { + // Wrap the API changes for 1.5 release. This try/catch + // should be removed once TypeScript 1.5 has shipped. + // Also consider removing the optional designation for + // the exclude param at this time. + var encoded; + try { + encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); + } + catch (e) { + encoded = this.shimHost.readDirectory(rootDir, extension); + } return JSON.parse(encoded); }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; return CoreServicesShimHostAdapter; })(); ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; @@ -47098,7 +49019,7 @@ var ts; }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { - var newLine = this.getNewLine(); + var newLine = ts.getNewLineOrDefaultFromHost(this.host); return ts.realizeDiagnostics(diagnostics, newLine); }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { @@ -47131,9 +49052,6 @@ var ts; return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; - LanguageServiceShimObject.prototype.getNewLine = function () { - return this.host.getNewLine ? this.host.getNewLine() : "\r\n"; - }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { @@ -47270,7 +49188,10 @@ var ts; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { - return _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + // workaround for VS document higlighting issue - keep only items from the initial file + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); }); }; /// COMPLETION LISTS @@ -47318,6 +49239,10 @@ var ts; return edits; }); }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount) { @@ -47401,12 +49326,24 @@ var ts; CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + return { + resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); var convertResult = { referencedFiles: [], importedFiles: [], + ambientExternalModules: result.ambientExternalModules, isLibFile: result.isLibFile }; ts.forEach(result.referencedFiles, function (refFile) { @@ -47530,4 +49467,4 @@ var TypeScript; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); /* @internal */ -var toolsVersion = "1.5"; +var toolsVersion = "1.6"; diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 7b4eaea9e16..761ce39d418 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -23,6 +23,7 @@ declare namespace ts { contains(fileName: string): boolean; remove(fileName: string): void; forEachValue(f: (v: T) => void): void; + clear(): void; } interface TextRange { pos: number; @@ -35,293 +36,294 @@ declare namespace ts { MultiLineCommentTrivia = 3, NewLineTrivia = 4, WhitespaceTrivia = 5, - ConflictMarkerTrivia = 6, - NumericLiteral = 7, - StringLiteral = 8, - RegularExpressionLiteral = 9, - NoSubstitutionTemplateLiteral = 10, - TemplateHead = 11, - TemplateMiddle = 12, - TemplateTail = 13, - OpenBraceToken = 14, - CloseBraceToken = 15, - OpenParenToken = 16, - CloseParenToken = 17, - OpenBracketToken = 18, - CloseBracketToken = 19, - DotToken = 20, - DotDotDotToken = 21, - SemicolonToken = 22, - CommaToken = 23, - LessThanToken = 24, - LessThanSlashToken = 25, - GreaterThanToken = 26, - LessThanEqualsToken = 27, - GreaterThanEqualsToken = 28, - EqualsEqualsToken = 29, - ExclamationEqualsToken = 30, - EqualsEqualsEqualsToken = 31, - ExclamationEqualsEqualsToken = 32, - EqualsGreaterThanToken = 33, - PlusToken = 34, - MinusToken = 35, - AsteriskToken = 36, - SlashToken = 37, - PercentToken = 38, - PlusPlusToken = 39, - MinusMinusToken = 40, - LessThanLessThanToken = 41, - GreaterThanGreaterThanToken = 42, - GreaterThanGreaterThanGreaterThanToken = 43, - AmpersandToken = 44, - BarToken = 45, - CaretToken = 46, - ExclamationToken = 47, - TildeToken = 48, - AmpersandAmpersandToken = 49, - BarBarToken = 50, - QuestionToken = 51, - ColonToken = 52, - AtToken = 53, - EqualsToken = 54, - PlusEqualsToken = 55, - MinusEqualsToken = 56, - AsteriskEqualsToken = 57, - SlashEqualsToken = 58, - PercentEqualsToken = 59, - LessThanLessThanEqualsToken = 60, - GreaterThanGreaterThanEqualsToken = 61, - GreaterThanGreaterThanGreaterThanEqualsToken = 62, - AmpersandEqualsToken = 63, - BarEqualsToken = 64, - CaretEqualsToken = 65, - Identifier = 66, - BreakKeyword = 67, - CaseKeyword = 68, - CatchKeyword = 69, - ClassKeyword = 70, - ConstKeyword = 71, - ContinueKeyword = 72, - DebuggerKeyword = 73, - DefaultKeyword = 74, - DeleteKeyword = 75, - DoKeyword = 76, - ElseKeyword = 77, - EnumKeyword = 78, - ExportKeyword = 79, - ExtendsKeyword = 80, - FalseKeyword = 81, - FinallyKeyword = 82, - ForKeyword = 83, - FunctionKeyword = 84, - IfKeyword = 85, - ImportKeyword = 86, - InKeyword = 87, - InstanceOfKeyword = 88, - NewKeyword = 89, - NullKeyword = 90, - ReturnKeyword = 91, - SuperKeyword = 92, - SwitchKeyword = 93, - ThisKeyword = 94, - ThrowKeyword = 95, - TrueKeyword = 96, - TryKeyword = 97, - TypeOfKeyword = 98, - VarKeyword = 99, - VoidKeyword = 100, - WhileKeyword = 101, - WithKeyword = 102, - ImplementsKeyword = 103, - InterfaceKeyword = 104, - LetKeyword = 105, - PackageKeyword = 106, - PrivateKeyword = 107, - ProtectedKeyword = 108, - PublicKeyword = 109, - StaticKeyword = 110, - YieldKeyword = 111, - AbstractKeyword = 112, - AsKeyword = 113, - AnyKeyword = 114, - AsyncKeyword = 115, - AwaitKeyword = 116, - BooleanKeyword = 117, - ConstructorKeyword = 118, - DeclareKeyword = 119, - GetKeyword = 120, - IsKeyword = 121, - ModuleKeyword = 122, - NamespaceKeyword = 123, - RequireKeyword = 124, - NumberKeyword = 125, - SetKeyword = 126, - StringKeyword = 127, - SymbolKeyword = 128, - TypeKeyword = 129, - FromKeyword = 130, - OfKeyword = 131, - QualifiedName = 132, - ComputedPropertyName = 133, - TypeParameter = 134, - Parameter = 135, - Decorator = 136, - PropertySignature = 137, - PropertyDeclaration = 138, - MethodSignature = 139, - MethodDeclaration = 140, - Constructor = 141, - GetAccessor = 142, - SetAccessor = 143, - CallSignature = 144, - ConstructSignature = 145, - IndexSignature = 146, - TypePredicate = 147, - TypeReference = 148, - FunctionType = 149, - ConstructorType = 150, - TypeQuery = 151, - TypeLiteral = 152, - ArrayType = 153, - TupleType = 154, - UnionType = 155, - IntersectionType = 156, - ParenthesizedType = 157, - ObjectBindingPattern = 158, - ArrayBindingPattern = 159, - BindingElement = 160, - ArrayLiteralExpression = 161, - ObjectLiteralExpression = 162, - PropertyAccessExpression = 163, - ElementAccessExpression = 164, - CallExpression = 165, - NewExpression = 166, - TaggedTemplateExpression = 167, - TypeAssertionExpression = 168, - ParenthesizedExpression = 169, - FunctionExpression = 170, - ArrowFunction = 171, - DeleteExpression = 172, - TypeOfExpression = 173, - VoidExpression = 174, - AwaitExpression = 175, - PrefixUnaryExpression = 176, - PostfixUnaryExpression = 177, - BinaryExpression = 178, - ConditionalExpression = 179, - TemplateExpression = 180, - YieldExpression = 181, - SpreadElementExpression = 182, - ClassExpression = 183, - OmittedExpression = 184, - ExpressionWithTypeArguments = 185, - AsExpression = 186, - TemplateSpan = 187, - SemicolonClassElement = 188, - Block = 189, - VariableStatement = 190, - EmptyStatement = 191, - ExpressionStatement = 192, - IfStatement = 193, - DoStatement = 194, - WhileStatement = 195, - ForStatement = 196, - ForInStatement = 197, - ForOfStatement = 198, - ContinueStatement = 199, - BreakStatement = 200, - ReturnStatement = 201, - WithStatement = 202, - SwitchStatement = 203, - LabeledStatement = 204, - ThrowStatement = 205, - TryStatement = 206, - DebuggerStatement = 207, - VariableDeclaration = 208, - VariableDeclarationList = 209, - FunctionDeclaration = 210, - ClassDeclaration = 211, - InterfaceDeclaration = 212, - TypeAliasDeclaration = 213, - EnumDeclaration = 214, - ModuleDeclaration = 215, - ModuleBlock = 216, - CaseBlock = 217, - ImportEqualsDeclaration = 218, - ImportDeclaration = 219, - ImportClause = 220, - NamespaceImport = 221, - NamedImports = 222, - ImportSpecifier = 223, - ExportAssignment = 224, - ExportDeclaration = 225, - NamedExports = 226, - ExportSpecifier = 227, - MissingDeclaration = 228, - ExternalModuleReference = 229, - JsxElement = 230, - JsxSelfClosingElement = 231, - JsxOpeningElement = 232, - JsxText = 233, - JsxClosingElement = 234, - JsxAttribute = 235, - JsxSpreadAttribute = 236, - JsxExpression = 237, - CaseClause = 238, - DefaultClause = 239, - HeritageClause = 240, - CatchClause = 241, - PropertyAssignment = 242, - ShorthandPropertyAssignment = 243, - EnumMember = 244, - SourceFile = 245, - JSDocTypeExpression = 246, - JSDocAllType = 247, - JSDocUnknownType = 248, - JSDocArrayType = 249, - JSDocUnionType = 250, - JSDocTupleType = 251, - JSDocNullableType = 252, - JSDocNonNullableType = 253, - JSDocRecordType = 254, - JSDocRecordMember = 255, - JSDocTypeReference = 256, - JSDocOptionalType = 257, - JSDocFunctionType = 258, - JSDocVariadicType = 259, - JSDocConstructorType = 260, - JSDocThisType = 261, - JSDocComment = 262, - JSDocTag = 263, - JSDocParameterTag = 264, - JSDocReturnTag = 265, - JSDocTypeTag = 266, - JSDocTemplateTag = 267, - SyntaxList = 268, - Count = 269, - FirstAssignment = 54, - LastAssignment = 65, - FirstReservedWord = 67, - LastReservedWord = 102, - FirstKeyword = 67, - LastKeyword = 131, - FirstFutureReservedWord = 103, - LastFutureReservedWord = 111, - FirstTypeNode = 148, - LastTypeNode = 157, - FirstPunctuation = 14, - LastPunctuation = 65, + ShebangTrivia = 6, + ConflictMarkerTrivia = 7, + NumericLiteral = 8, + StringLiteral = 9, + RegularExpressionLiteral = 10, + NoSubstitutionTemplateLiteral = 11, + TemplateHead = 12, + TemplateMiddle = 13, + TemplateTail = 14, + OpenBraceToken = 15, + CloseBraceToken = 16, + OpenParenToken = 17, + CloseParenToken = 18, + OpenBracketToken = 19, + CloseBracketToken = 20, + DotToken = 21, + DotDotDotToken = 22, + SemicolonToken = 23, + CommaToken = 24, + LessThanToken = 25, + LessThanSlashToken = 26, + GreaterThanToken = 27, + LessThanEqualsToken = 28, + GreaterThanEqualsToken = 29, + EqualsEqualsToken = 30, + ExclamationEqualsToken = 31, + EqualsEqualsEqualsToken = 32, + ExclamationEqualsEqualsToken = 33, + EqualsGreaterThanToken = 34, + PlusToken = 35, + MinusToken = 36, + AsteriskToken = 37, + SlashToken = 38, + PercentToken = 39, + PlusPlusToken = 40, + MinusMinusToken = 41, + LessThanLessThanToken = 42, + GreaterThanGreaterThanToken = 43, + GreaterThanGreaterThanGreaterThanToken = 44, + AmpersandToken = 45, + BarToken = 46, + CaretToken = 47, + ExclamationToken = 48, + TildeToken = 49, + AmpersandAmpersandToken = 50, + BarBarToken = 51, + QuestionToken = 52, + ColonToken = 53, + AtToken = 54, + EqualsToken = 55, + PlusEqualsToken = 56, + MinusEqualsToken = 57, + AsteriskEqualsToken = 58, + SlashEqualsToken = 59, + PercentEqualsToken = 60, + LessThanLessThanEqualsToken = 61, + GreaterThanGreaterThanEqualsToken = 62, + GreaterThanGreaterThanGreaterThanEqualsToken = 63, + AmpersandEqualsToken = 64, + BarEqualsToken = 65, + CaretEqualsToken = 66, + Identifier = 67, + BreakKeyword = 68, + CaseKeyword = 69, + CatchKeyword = 70, + ClassKeyword = 71, + ConstKeyword = 72, + ContinueKeyword = 73, + DebuggerKeyword = 74, + DefaultKeyword = 75, + DeleteKeyword = 76, + DoKeyword = 77, + ElseKeyword = 78, + EnumKeyword = 79, + ExportKeyword = 80, + ExtendsKeyword = 81, + FalseKeyword = 82, + FinallyKeyword = 83, + ForKeyword = 84, + FunctionKeyword = 85, + IfKeyword = 86, + ImportKeyword = 87, + InKeyword = 88, + InstanceOfKeyword = 89, + NewKeyword = 90, + NullKeyword = 91, + ReturnKeyword = 92, + SuperKeyword = 93, + SwitchKeyword = 94, + ThisKeyword = 95, + ThrowKeyword = 96, + TrueKeyword = 97, + TryKeyword = 98, + TypeOfKeyword = 99, + VarKeyword = 100, + VoidKeyword = 101, + WhileKeyword = 102, + WithKeyword = 103, + ImplementsKeyword = 104, + InterfaceKeyword = 105, + LetKeyword = 106, + PackageKeyword = 107, + PrivateKeyword = 108, + ProtectedKeyword = 109, + PublicKeyword = 110, + StaticKeyword = 111, + YieldKeyword = 112, + AbstractKeyword = 113, + AsKeyword = 114, + AnyKeyword = 115, + AsyncKeyword = 116, + AwaitKeyword = 117, + BooleanKeyword = 118, + ConstructorKeyword = 119, + DeclareKeyword = 120, + GetKeyword = 121, + IsKeyword = 122, + ModuleKeyword = 123, + NamespaceKeyword = 124, + RequireKeyword = 125, + NumberKeyword = 126, + SetKeyword = 127, + StringKeyword = 128, + SymbolKeyword = 129, + TypeKeyword = 130, + FromKeyword = 131, + OfKeyword = 132, + QualifiedName = 133, + ComputedPropertyName = 134, + TypeParameter = 135, + Parameter = 136, + Decorator = 137, + PropertySignature = 138, + PropertyDeclaration = 139, + MethodSignature = 140, + MethodDeclaration = 141, + Constructor = 142, + GetAccessor = 143, + SetAccessor = 144, + CallSignature = 145, + ConstructSignature = 146, + IndexSignature = 147, + TypePredicate = 148, + TypeReference = 149, + FunctionType = 150, + ConstructorType = 151, + TypeQuery = 152, + TypeLiteral = 153, + ArrayType = 154, + TupleType = 155, + UnionType = 156, + IntersectionType = 157, + ParenthesizedType = 158, + ObjectBindingPattern = 159, + ArrayBindingPattern = 160, + BindingElement = 161, + ArrayLiteralExpression = 162, + ObjectLiteralExpression = 163, + PropertyAccessExpression = 164, + ElementAccessExpression = 165, + CallExpression = 166, + NewExpression = 167, + TaggedTemplateExpression = 168, + TypeAssertionExpression = 169, + ParenthesizedExpression = 170, + FunctionExpression = 171, + ArrowFunction = 172, + DeleteExpression = 173, + TypeOfExpression = 174, + VoidExpression = 175, + AwaitExpression = 176, + PrefixUnaryExpression = 177, + PostfixUnaryExpression = 178, + BinaryExpression = 179, + ConditionalExpression = 180, + TemplateExpression = 181, + YieldExpression = 182, + SpreadElementExpression = 183, + ClassExpression = 184, + OmittedExpression = 185, + ExpressionWithTypeArguments = 186, + AsExpression = 187, + TemplateSpan = 188, + SemicolonClassElement = 189, + Block = 190, + VariableStatement = 191, + EmptyStatement = 192, + ExpressionStatement = 193, + IfStatement = 194, + DoStatement = 195, + WhileStatement = 196, + ForStatement = 197, + ForInStatement = 198, + ForOfStatement = 199, + ContinueStatement = 200, + BreakStatement = 201, + ReturnStatement = 202, + WithStatement = 203, + SwitchStatement = 204, + LabeledStatement = 205, + ThrowStatement = 206, + TryStatement = 207, + DebuggerStatement = 208, + VariableDeclaration = 209, + VariableDeclarationList = 210, + FunctionDeclaration = 211, + ClassDeclaration = 212, + InterfaceDeclaration = 213, + TypeAliasDeclaration = 214, + EnumDeclaration = 215, + ModuleDeclaration = 216, + ModuleBlock = 217, + CaseBlock = 218, + ImportEqualsDeclaration = 219, + ImportDeclaration = 220, + ImportClause = 221, + NamespaceImport = 222, + NamedImports = 223, + ImportSpecifier = 224, + ExportAssignment = 225, + ExportDeclaration = 226, + NamedExports = 227, + ExportSpecifier = 228, + MissingDeclaration = 229, + ExternalModuleReference = 230, + JsxElement = 231, + JsxSelfClosingElement = 232, + JsxOpeningElement = 233, + JsxText = 234, + JsxClosingElement = 235, + JsxAttribute = 236, + JsxSpreadAttribute = 237, + JsxExpression = 238, + CaseClause = 239, + DefaultClause = 240, + HeritageClause = 241, + CatchClause = 242, + PropertyAssignment = 243, + ShorthandPropertyAssignment = 244, + EnumMember = 245, + SourceFile = 246, + JSDocTypeExpression = 247, + JSDocAllType = 248, + JSDocUnknownType = 249, + JSDocArrayType = 250, + JSDocUnionType = 251, + JSDocTupleType = 252, + JSDocNullableType = 253, + JSDocNonNullableType = 254, + JSDocRecordType = 255, + JSDocRecordMember = 256, + JSDocTypeReference = 257, + JSDocOptionalType = 258, + JSDocFunctionType = 259, + JSDocVariadicType = 260, + JSDocConstructorType = 261, + JSDocThisType = 262, + JSDocComment = 263, + JSDocTag = 264, + JSDocParameterTag = 265, + JSDocReturnTag = 266, + JSDocTypeTag = 267, + JSDocTemplateTag = 268, + SyntaxList = 269, + Count = 270, + FirstAssignment = 55, + LastAssignment = 66, + FirstReservedWord = 68, + LastReservedWord = 103, + FirstKeyword = 68, + LastKeyword = 132, + FirstFutureReservedWord = 104, + LastFutureReservedWord = 112, + FirstTypeNode = 149, + LastTypeNode = 158, + FirstPunctuation = 15, + LastPunctuation = 66, FirstToken = 0, - LastToken = 131, + LastToken = 132, FirstTriviaToken = 2, - LastTriviaToken = 6, - FirstLiteralToken = 7, - LastLiteralToken = 10, - FirstTemplateToken = 10, - LastTemplateToken = 13, - FirstBinaryOperator = 24, - LastBinaryOperator = 65, - FirstNode = 132, + LastTriviaToken = 7, + FirstLiteralToken = 8, + LastLiteralToken = 11, + FirstTemplateToken = 11, + LastTemplateToken = 14, + FirstBinaryOperator = 25, + LastBinaryOperator = 66, + FirstNode = 133, } const enum NodeFlags { Export = 1, @@ -452,9 +454,9 @@ declare namespace ts { * Several node kinds share function-like features such as a signature, * a name, and a body. These nodes should extend FunctionLikeDeclaration. * Examples: - * FunctionDeclaration - * MethodDeclaration - * AccessorDeclaration + * - FunctionDeclaration + * - MethodDeclaration + * - AccessorDeclaration */ interface FunctionLikeDeclaration extends SignatureDeclaration { _functionLikeDeclarationBrand: any; @@ -944,7 +946,7 @@ declare namespace ts { getSourceFile(fileName: string): SourceFile; getCurrentDirectory(): string; } - interface ParseConfigHost { + interface ParseConfigHost extends ModuleResolutionHost { readDirectory(rootDir: string, extension: string, exclude: string[]): string[]; } interface WriteFileCallback { @@ -958,6 +960,10 @@ declare namespace ts { throwIfCancellationRequested(): void; } interface Program extends ScriptReferenceHost { + /** + * Get a list of root file names that were passed to a 'createProgram' + */ + getRootFileNames(): string[]; /** * Get a list of files in the program */ @@ -1019,11 +1025,6 @@ declare namespace ts { emitSkipped: boolean; diagnostics: Diagnostic[]; } - interface TypeCheckerHost { - getCompilerOptions(): CompilerOptions; - getSourceFiles(): SourceFile[]; - getSourceFile(fileName: string): SourceFile; - } interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; getDeclaredTypeOfSymbol(symbol: Symbol): Type; @@ -1031,6 +1032,7 @@ declare namespace ts { getPropertyOfType(type: Type, propertyName: string): Symbol; getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; + getBaseTypes(type: InterfaceType): ObjectType[]; getReturnTypeOfSignature(signature: Signature): Type; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; @@ -1054,6 +1056,7 @@ declare namespace ts { getExportsOfModule(moduleSymbol: Symbol): Symbol[]; getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; + isOptionalParameter(node: ParameterDeclaration): boolean; } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1198,16 +1201,18 @@ declare namespace ts { Anonymous = 65536, Instantiated = 131072, ObjectLiteral = 524288, - ESSymbol = 4194304, + ESSymbol = 16777216, StringLike = 258, NumberLike = 132, ObjectType = 80896, UnionOrIntersection = 49152, StructuredType = 130048, } + type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { flags: TypeFlags; symbol?: Symbol; + pattern?: DestructuringPattern; } interface StringLiteralType extends Type { text: string; @@ -1218,8 +1223,6 @@ declare namespace ts { typeParameters: TypeParameter[]; outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; - resolvedBaseConstructorType?: Type; - resolvedBaseTypes: ObjectType[]; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -1236,7 +1239,6 @@ declare namespace ts { } interface TupleType extends ObjectType { elementTypes: Type[]; - baseArrayType: TypeReference; } interface UnionOrIntersectionType extends Type { types: Type[]; @@ -1292,6 +1294,10 @@ declare namespace ts { Error = 1, Message = 2, } + const enum ModuleResolutionKind { + Classic = 1, + NodeJs = 2, + } interface CompilerOptions { allowNonTsExtensions?: boolean; charset?: string; @@ -1299,6 +1305,7 @@ declare namespace ts { diagnostics?: boolean; emitBOM?: boolean; help?: boolean; + init?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; jsx?: JsxEmit; @@ -1315,6 +1322,7 @@ declare namespace ts { noLib?: boolean; noResolve?: boolean; out?: string; + outFile?: string; outDir?: string; preserveConstEnums?: boolean; project?: string; @@ -1322,6 +1330,7 @@ declare namespace ts { rootDir?: string; sourceMap?: boolean; sourceRoot?: string; + suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; version?: boolean; @@ -1330,6 +1339,7 @@ declare namespace ts { experimentalDecorators?: boolean; experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; + moduleResolution?: ModuleResolutionKind; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1367,14 +1377,28 @@ declare namespace ts { fileNames: string[]; errors: Diagnostic[]; } - interface CompilerHost { + interface ModuleResolutionHost { + fileExists(fileName: string): boolean; + readFile(fileName: string): string; + } + interface ResolvedModule { + resolvedFileName: string; + isExternalLibraryImport?: boolean; + } + interface ResolvedModuleWithFailedLookupLocations { + resolvedModule: ResolvedModule; + failedLookupLocations: string[]; + } + interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getCancellationToken?(): CancellationToken; getDefaultLibFileName(options: CompilerOptions): string; writeFile: WriteFileCallback; getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; + resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; } interface TextSpan { start: number; @@ -1448,9 +1472,11 @@ declare namespace ts { function couldStartTrivia(text: string, pos: number): boolean; function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + /** Optionally, get the shebang */ + function getShebang(text: string): string; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; - function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant: ts.LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -1490,21 +1516,24 @@ declare namespace ts { function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } declare namespace ts { - /** The version of the TypeScript compiler release */ const version: string; function findConfigFile(searchPath: string): string; + function resolveTripleslashReference(moduleName: string, containingFile: string): string; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; - function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; + function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; } declare namespace ts { - function parseCommandLine(commandLine: string[]): ParsedCommandLine; + function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine; /** * Read tsconfig.json file * @param fileName The path to the config file */ - function readConfigFile(fileName: string): { + function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; error?: Diagnostic; }; @@ -1560,6 +1589,7 @@ declare namespace ts { getConstructSignatures(): Signature[]; getStringIndexType(): Type; getNumberIndexType(): Type; + getBaseTypes(): ObjectType[]; } interface Signature { getDeclaration(): SignatureDeclaration; @@ -1601,6 +1631,7 @@ declare namespace ts { interface PreProcessedFileInfo { referencedFiles: FileReference[]; importedFiles: FileReference[]; + ambientExternalModules: string[]; isLibFile: boolean; } interface HostCancellationToken { @@ -1621,6 +1652,7 @@ declare namespace ts { trace?(s: string): void; error?(s: string): void; useCaseSensitiveFileNames?(): boolean; + resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; } interface LanguageService { cleanupSemanticCache(): void; @@ -1661,6 +1693,7 @@ declare namespace ts { getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[]; getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; + getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; getEmitOutput(fileName: string): EmitOutput; getProgram(): Program; getSourceFile(fileName: string): SourceFile; @@ -1697,6 +1730,11 @@ declare namespace ts { span: TextSpan; newText: string; } + interface TextInsertion { + newText: string; + /** The position in newText the caret should point to after the insertion. */ + caretOffset: number; + } interface RenameLocation { textSpan: TextSpan; fileName: string; @@ -1717,6 +1755,7 @@ declare namespace ts { const writtenReference: string; } interface HighlightSpan { + fileName?: string; textSpan: TextSpan; kind: string; } @@ -1744,6 +1783,7 @@ declare namespace ts { InsertSpaceAfterKeywordsInControlFlowStatements: boolean; InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; [s: string]: boolean | number | string; @@ -1986,6 +2026,7 @@ declare namespace ts { * @param compilationSettings The compilation settings used to acquire the file */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + reportStats(): string; } module ScriptElementKind { const unknown: string; @@ -2072,10 +2113,24 @@ declare namespace ts { } function displayPartsToString(displayParts: SymbolDisplayPart[]): string; function getDefaultCompilerOptions(): CompilerOptions; + interface TranspileOptions { + compilerOptions?: CompilerOptions; + fileName?: string; + reportDiagnostics?: boolean; + moduleName?: string; + renamedDependencies?: Map; + } + interface TranspileOutput { + outputText: string; + diagnostics?: Diagnostic[]; + sourceMapText?: string; + } + function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 6035d71fa2b..a1f9651570e 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -16,6 +16,7 @@ and limitations under the License. var ts; (function (ts) { // token > SyntaxKind.Identifer => token is a keyword + // Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync (function (SyntaxKind) { SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; @@ -23,324 +24,326 @@ var ts; SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + // We detect and preserve #! on the first line + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; // We detect and provide better error recovery when we encounter a git merge marker. This // allows us to edit files with git-conflict markers in them in a much more pleasant manner. - SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 6] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; // Literals - SyntaxKind[SyntaxKind["NumericLiteral"] = 7] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 8] = "StringLiteral"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 9] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 10] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 11] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 11] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 12] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 13] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 12] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 13] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 14] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 14] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 15] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 16] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 17] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 18] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 19] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 20] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 21] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 22] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 23] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 24] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 25] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 26] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 27] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 28] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 29] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 30] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 31] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 32] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 33] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 34] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 35] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 36] = "AsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 37] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 38] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 39] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 40] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 41] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 42] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 44] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 45] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 46] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 47] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 48] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 49] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 50] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 51] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 52] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 53] = "AtToken"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 15] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 16] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 17] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 18] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 19] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 20] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 21] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 22] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 23] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 24] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 25] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 26] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 27] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 28] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 29] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 30] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 31] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 32] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 33] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 34] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 35] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 36] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 37] = "AsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 38] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 39] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 40] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 41] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 42] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 45] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 46] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 47] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 48] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 49] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 50] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 51] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 52] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 53] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 54] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 54] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 55] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 56] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 57] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 58] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 59] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 60] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 61] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 63] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 64] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 65] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 55] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 56] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 57] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 58] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 59] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 60] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 61] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 63] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 64] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 65] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 66] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 66] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 67] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 67] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 68] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 69] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 70] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 71] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 72] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 73] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 74] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 75] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 76] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 77] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 78] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 79] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 80] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 81] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 82] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 83] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 84] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 85] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 86] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 87] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 88] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 89] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 90] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 91] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 92] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 93] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 94] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 95] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 96] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 97] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 98] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 99] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 100] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 101] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 102] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 68] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 69] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 70] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 71] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 72] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 73] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 74] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 75] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 76] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 77] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 78] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 79] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 80] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 81] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 82] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 83] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 84] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 85] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 86] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 87] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 88] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 89] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 90] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 91] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 92] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 93] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 94] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 95] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 96] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 97] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 98] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 99] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 100] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 101] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 102] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 103] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 103] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 104] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 105] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 106] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 107] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 108] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 109] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 110] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 111] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 104] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 105] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 106] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 107] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 108] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 109] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 110] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 111] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 112] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 112] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 113] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 114] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 115] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 116] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 117] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 118] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 119] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 120] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 121] = "IsKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 122] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 123] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 124] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 125] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 126] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 127] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 128] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 129] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 130] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 131] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 113] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 114] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 115] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 116] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 117] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 118] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 119] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 120] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 121] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 122] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 123] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 124] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 125] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 126] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 127] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 128] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 129] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 130] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 131] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 132] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 132] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 133] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 133] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 134] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 134] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 135] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 136] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 135] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 136] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 137] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 137] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 138] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 139] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 140] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 141] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 142] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 143] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 144] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 145] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 146] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 138] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 139] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 140] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 141] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 142] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 143] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 144] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 145] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 146] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 147] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 147] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 148] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 149] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 150] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 151] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 152] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 153] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 154] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 155] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 156] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 157] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 148] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 149] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 150] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 151] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 152] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 153] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 154] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 155] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 156] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 157] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 158] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 158] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 159] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 160] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 159] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 160] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 161] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 161] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 162] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 163] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 164] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 165] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 166] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 167] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 168] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 169] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 170] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 171] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 172] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 173] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 174] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 175] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 176] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 177] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 178] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 179] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 180] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 181] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 182] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 183] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 184] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 185] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 186] = "AsExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 162] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 163] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 164] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 165] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 166] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 167] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 168] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 169] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 170] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 171] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 172] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 173] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 174] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 175] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 176] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 177] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 178] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 179] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 180] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 181] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 182] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 183] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 184] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 185] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 186] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 187] = "AsExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 187] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 188] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 188] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 189] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 189] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 190] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 191] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 192] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 193] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 194] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 195] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 196] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 197] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 198] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 199] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 200] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 201] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 202] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 203] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 204] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 205] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 206] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 207] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 208] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 209] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 210] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 211] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 212] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 213] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 214] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 215] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 216] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 217] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 218] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 219] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 220] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 221] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 222] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 223] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 224] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 225] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 226] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 227] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 228] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 190] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 191] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 192] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 193] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 194] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 195] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 196] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 197] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 198] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 199] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 200] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 201] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 202] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 203] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 204] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 205] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 206] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 207] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 208] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 209] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 210] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 211] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 212] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 213] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 214] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 215] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 216] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 217] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 218] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 219] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 220] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 221] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 222] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 223] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 224] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 225] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 226] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 227] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 228] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 229] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 229] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 230] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 230] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 231] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 232] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 233] = "JsxText"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 234] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 235] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 236] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 237] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 231] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 232] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 233] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 234] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 235] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 236] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 237] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 238] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 238] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 239] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 240] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 241] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 239] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 240] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 241] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 242] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 242] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 243] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 243] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 244] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 244] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 245] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 245] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 246] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 246] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 247] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 247] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 248] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 248] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 249] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 250] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 251] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 252] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 253] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 254] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 255] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 256] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 257] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 258] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 259] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 260] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 261] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 262] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 263] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 264] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 265] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 266] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 267] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 249] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 250] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 251] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 252] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 253] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 254] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 255] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 256] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 257] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 258] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 259] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 260] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 261] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 262] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 263] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 264] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 265] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 266] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 267] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 268] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 268] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 269] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 269] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 270] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 54] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 65] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 67] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 102] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 67] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 131] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 103] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 111] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 148] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 157] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 65] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 55] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 66] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 68] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 103] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 68] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 132] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 104] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 112] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 149] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 158] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 66] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 131] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 132] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; - SyntaxKind[SyntaxKind["LastTriviaToken"] = 6] = "LastTriviaToken"; - SyntaxKind[SyntaxKind["FirstLiteralToken"] = 7] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 10] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 10] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 13] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 24] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 65] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 132] = "FirstNode"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 11] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 11] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 66] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 133] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -602,21 +605,27 @@ var ts; TypeFlags[TypeFlags["FromSignature"] = 262144] = "FromSignature"; TypeFlags[TypeFlags["ObjectLiteral"] = 524288] = "ObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 1048576] = "ContainsUndefinedOrNull"; + TypeFlags[TypeFlags["FreshObjectLiteral"] = 1048576] = "FreshObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 2097152] = "ContainsObjectLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 4194304] = "ESSymbol"; + TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 2097152] = "ContainsUndefinedOrNull"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 4194431] = "Intrinsic"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 4194814] = "Primitive"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["ESSymbol"] = 16777216] = "ESSymbol"; + /* @internal */ + TypeFlags[TypeFlags["Intrinsic"] = 16777343] = "Intrinsic"; + /* @internal */ + TypeFlags[TypeFlags["Primitive"] = 16777726] = "Primitive"; TypeFlags[TypeFlags["StringLike"] = 258] = "StringLike"; TypeFlags[TypeFlags["NumberLike"] = 132] = "NumberLike"; TypeFlags[TypeFlags["ObjectType"] = 80896] = "ObjectType"; TypeFlags[TypeFlags["UnionOrIntersection"] = 49152] = "UnionOrIntersection"; TypeFlags[TypeFlags["StructuredType"] = 130048] = "StructuredType"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 3145728] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; + /* @internal */ + TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; })(ts.TypeFlags || (ts.TypeFlags = {})); var TypeFlags = ts.TypeFlags; (function (SignatureKind) { @@ -635,6 +644,11 @@ var ts; DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); var DiagnosticCategory = ts.DiagnosticCategory; + (function (ModuleResolutionKind) { + ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; + ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; + })(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); + var ModuleResolutionKind = ts.ModuleResolutionKind; (function (ModuleKind) { ModuleKind[ModuleKind["None"] = 0] = "None"; ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; @@ -822,6 +836,7 @@ var ts; set: set, contains: contains, remove: remove, + clear: clear, forEachValue: forEachValueInMap }; function set(fileName, value) { @@ -843,6 +858,9 @@ var ts; function normalizeKey(key) { return getCanonicalFileName(normalizeSlashes(key)); } + function clear() { + files = {}; + } } ts.createFileMap = createFileMap; (function (Comparison) { @@ -990,6 +1008,13 @@ var ts; return array[array.length - 1]; } ts.lastOrUndefined = lastOrUndefined; + /** + * Performs a binary search, finding the index at which 'value' occurs in 'array'. + * If no such index is found, returns the 2's-complement of first index at which + * number[index] exceeds number. + * @param array A sorted array whose first element must be no larger than number + * @param number The value to be searched for in the array. + */ function binarySearch(array, value) { var low = 0; var high = array.length - 1; @@ -1293,7 +1318,7 @@ var ts; if (path.lastIndexOf("file:///", 0) === 0) { return "file:///".length; } - var idx = path.indexOf('://'); + var idx = path.indexOf("://"); if (idx !== -1) { return idx + "://".length; } @@ -1470,7 +1495,7 @@ var ts; /** * List of supported extensions in order of file resolution precedence. */ - ts.supportedExtensions = [".tsx", ".ts", ".d.ts"]; + ts.supportedExtensions = [".ts", ".tsx", ".d.ts"]; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { @@ -1699,7 +1724,7 @@ var ts; function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); - var _os = require('os'); + var _os = require("os"); var platform = _os.platform(); // win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; @@ -1734,7 +1759,7 @@ var ts; function writeFile(fileName, data, writeByteOrderMark) { // If a BOM is required, emit one if (writeByteOrderMark) { - data = '\uFEFF' + data; + data = "\uFEFF" + data; } _fs.writeFileSync(fileName, data, "utf8"); } @@ -1775,7 +1800,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, 'utf8'); + var buffer = new Buffer(s, "utf8"); var offset = 0; var toWrite = buffer.length; var written = 0; @@ -1799,7 +1824,6 @@ var ts; } callback(fileName); } - ; }, resolvePath: function (path) { return _path.resolve(path); @@ -1836,7 +1860,9 @@ var ts; if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { return getWScriptSystem(); } - else if (typeof module !== "undefined" && module.exports) { + else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { + // process and process.nextTick checks if current environment is node-like + // process.browser check excludes webpack and browserify return getNodeSystem(); } else { @@ -2091,7 +2117,7 @@ var ts; Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." }, @@ -2101,6 +2127,7 @@ var ts; Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: ts.DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, @@ -2140,7 +2167,7 @@ var ts; Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: ts.DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, Duplicate_function_implementation: { code: 2393, category: ts.DiagnosticCategory.Error, key: "Duplicate function implementation." }, Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: ts.DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: ts.DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: ts.DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: ts.DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, @@ -2261,6 +2288,7 @@ var ts; The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, + Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." }, JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2271,6 +2299,12 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, + Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, + Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, + Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, + Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." }, + Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2350,20 +2384,12 @@ var ts; Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: ts.DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." }, - Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: ts.DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, - Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: ts.DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, - Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: ts.DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, - Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: ts.DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, - Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: ts.DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, - Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: ts.DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, + Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." }, + Option_0_cannot_be_specified_with_option_1: { code: 5053, category: ts.DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." }, + A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: ts.DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, @@ -2412,13 +2438,17 @@ var ts; Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: ts.DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, + Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)." }, + Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." }, + Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." }, + Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -2459,131 +2489,137 @@ var ts; JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." } + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, + A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" } }; })(ts || (ts = {})); /// /// var ts; (function (ts) { + /* @internal */ + function tokenIsIdentifierOrKeyword(token) { + return token >= 67 /* Identifier */; + } + ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = { - "abstract": 112 /* AbstractKeyword */, - "any": 114 /* AnyKeyword */, - "as": 113 /* AsKeyword */, - "boolean": 117 /* BooleanKeyword */, - "break": 67 /* BreakKeyword */, - "case": 68 /* CaseKeyword */, - "catch": 69 /* CatchKeyword */, - "class": 70 /* ClassKeyword */, - "continue": 72 /* ContinueKeyword */, - "const": 71 /* ConstKeyword */, - "constructor": 118 /* ConstructorKeyword */, - "debugger": 73 /* DebuggerKeyword */, - "declare": 119 /* DeclareKeyword */, - "default": 74 /* DefaultKeyword */, - "delete": 75 /* DeleteKeyword */, - "do": 76 /* DoKeyword */, - "else": 77 /* ElseKeyword */, - "enum": 78 /* EnumKeyword */, - "export": 79 /* ExportKeyword */, - "extends": 80 /* ExtendsKeyword */, - "false": 81 /* FalseKeyword */, - "finally": 82 /* FinallyKeyword */, - "for": 83 /* ForKeyword */, - "from": 130 /* FromKeyword */, - "function": 84 /* FunctionKeyword */, - "get": 120 /* GetKeyword */, - "if": 85 /* IfKeyword */, - "implements": 103 /* ImplementsKeyword */, - "import": 86 /* ImportKeyword */, - "in": 87 /* InKeyword */, - "instanceof": 88 /* InstanceOfKeyword */, - "interface": 104 /* InterfaceKeyword */, - "is": 121 /* IsKeyword */, - "let": 105 /* LetKeyword */, - "module": 122 /* ModuleKeyword */, - "namespace": 123 /* NamespaceKeyword */, - "new": 89 /* NewKeyword */, - "null": 90 /* NullKeyword */, - "number": 125 /* NumberKeyword */, - "package": 106 /* PackageKeyword */, - "private": 107 /* PrivateKeyword */, - "protected": 108 /* ProtectedKeyword */, - "public": 109 /* PublicKeyword */, - "require": 124 /* RequireKeyword */, - "return": 91 /* ReturnKeyword */, - "set": 126 /* SetKeyword */, - "static": 110 /* StaticKeyword */, - "string": 127 /* StringKeyword */, - "super": 92 /* SuperKeyword */, - "switch": 93 /* SwitchKeyword */, - "symbol": 128 /* SymbolKeyword */, - "this": 94 /* ThisKeyword */, - "throw": 95 /* ThrowKeyword */, - "true": 96 /* TrueKeyword */, - "try": 97 /* TryKeyword */, - "type": 129 /* TypeKeyword */, - "typeof": 98 /* TypeOfKeyword */, - "var": 99 /* VarKeyword */, - "void": 100 /* VoidKeyword */, - "while": 101 /* WhileKeyword */, - "with": 102 /* WithKeyword */, - "yield": 111 /* YieldKeyword */, - "async": 115 /* AsyncKeyword */, - "await": 116 /* AwaitKeyword */, - "of": 131 /* OfKeyword */, - "{": 14 /* OpenBraceToken */, - "}": 15 /* CloseBraceToken */, - "(": 16 /* OpenParenToken */, - ")": 17 /* CloseParenToken */, - "[": 18 /* OpenBracketToken */, - "]": 19 /* CloseBracketToken */, - ".": 20 /* DotToken */, - "...": 21 /* DotDotDotToken */, - ";": 22 /* SemicolonToken */, - ",": 23 /* CommaToken */, - "<": 24 /* LessThanToken */, - ">": 26 /* GreaterThanToken */, - "<=": 27 /* LessThanEqualsToken */, - ">=": 28 /* GreaterThanEqualsToken */, - "==": 29 /* EqualsEqualsToken */, - "!=": 30 /* ExclamationEqualsToken */, - "===": 31 /* EqualsEqualsEqualsToken */, - "!==": 32 /* ExclamationEqualsEqualsToken */, - "=>": 33 /* EqualsGreaterThanToken */, - "+": 34 /* PlusToken */, - "-": 35 /* MinusToken */, - "*": 36 /* AsteriskToken */, - "/": 37 /* SlashToken */, - "%": 38 /* PercentToken */, - "++": 39 /* PlusPlusToken */, - "--": 40 /* MinusMinusToken */, - "<<": 41 /* LessThanLessThanToken */, - ">": 42 /* GreaterThanGreaterThanToken */, - ">>>": 43 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 44 /* AmpersandToken */, - "|": 45 /* BarToken */, - "^": 46 /* CaretToken */, - "!": 47 /* ExclamationToken */, - "~": 48 /* TildeToken */, - "&&": 49 /* AmpersandAmpersandToken */, - "||": 50 /* BarBarToken */, - "?": 51 /* QuestionToken */, - ":": 52 /* ColonToken */, - "=": 54 /* EqualsToken */, - "+=": 55 /* PlusEqualsToken */, - "-=": 56 /* MinusEqualsToken */, - "*=": 57 /* AsteriskEqualsToken */, - "/=": 58 /* SlashEqualsToken */, - "%=": 59 /* PercentEqualsToken */, - "<<=": 60 /* LessThanLessThanEqualsToken */, - ">>=": 61 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 63 /* AmpersandEqualsToken */, - "|=": 64 /* BarEqualsToken */, - "^=": 65 /* CaretEqualsToken */, - "@": 53 /* AtToken */ + "abstract": 113 /* AbstractKeyword */, + "any": 115 /* AnyKeyword */, + "as": 114 /* AsKeyword */, + "boolean": 118 /* BooleanKeyword */, + "break": 68 /* BreakKeyword */, + "case": 69 /* CaseKeyword */, + "catch": 70 /* CatchKeyword */, + "class": 71 /* ClassKeyword */, + "continue": 73 /* ContinueKeyword */, + "const": 72 /* ConstKeyword */, + "constructor": 119 /* ConstructorKeyword */, + "debugger": 74 /* DebuggerKeyword */, + "declare": 120 /* DeclareKeyword */, + "default": 75 /* DefaultKeyword */, + "delete": 76 /* DeleteKeyword */, + "do": 77 /* DoKeyword */, + "else": 78 /* ElseKeyword */, + "enum": 79 /* EnumKeyword */, + "export": 80 /* ExportKeyword */, + "extends": 81 /* ExtendsKeyword */, + "false": 82 /* FalseKeyword */, + "finally": 83 /* FinallyKeyword */, + "for": 84 /* ForKeyword */, + "from": 131 /* FromKeyword */, + "function": 85 /* FunctionKeyword */, + "get": 121 /* GetKeyword */, + "if": 86 /* IfKeyword */, + "implements": 104 /* ImplementsKeyword */, + "import": 87 /* ImportKeyword */, + "in": 88 /* InKeyword */, + "instanceof": 89 /* InstanceOfKeyword */, + "interface": 105 /* InterfaceKeyword */, + "is": 122 /* IsKeyword */, + "let": 106 /* LetKeyword */, + "module": 123 /* ModuleKeyword */, + "namespace": 124 /* NamespaceKeyword */, + "new": 90 /* NewKeyword */, + "null": 91 /* NullKeyword */, + "number": 126 /* NumberKeyword */, + "package": 107 /* PackageKeyword */, + "private": 108 /* PrivateKeyword */, + "protected": 109 /* ProtectedKeyword */, + "public": 110 /* PublicKeyword */, + "require": 125 /* RequireKeyword */, + "return": 92 /* ReturnKeyword */, + "set": 127 /* SetKeyword */, + "static": 111 /* StaticKeyword */, + "string": 128 /* StringKeyword */, + "super": 93 /* SuperKeyword */, + "switch": 94 /* SwitchKeyword */, + "symbol": 129 /* SymbolKeyword */, + "this": 95 /* ThisKeyword */, + "throw": 96 /* ThrowKeyword */, + "true": 97 /* TrueKeyword */, + "try": 98 /* TryKeyword */, + "type": 130 /* TypeKeyword */, + "typeof": 99 /* TypeOfKeyword */, + "var": 100 /* VarKeyword */, + "void": 101 /* VoidKeyword */, + "while": 102 /* WhileKeyword */, + "with": 103 /* WithKeyword */, + "yield": 112 /* YieldKeyword */, + "async": 116 /* AsyncKeyword */, + "await": 117 /* AwaitKeyword */, + "of": 132 /* OfKeyword */, + "{": 15 /* OpenBraceToken */, + "}": 16 /* CloseBraceToken */, + "(": 17 /* OpenParenToken */, + ")": 18 /* CloseParenToken */, + "[": 19 /* OpenBracketToken */, + "]": 20 /* CloseBracketToken */, + ".": 21 /* DotToken */, + "...": 22 /* DotDotDotToken */, + ";": 23 /* SemicolonToken */, + ",": 24 /* CommaToken */, + "<": 25 /* LessThanToken */, + ">": 27 /* GreaterThanToken */, + "<=": 28 /* LessThanEqualsToken */, + ">=": 29 /* GreaterThanEqualsToken */, + "==": 30 /* EqualsEqualsToken */, + "!=": 31 /* ExclamationEqualsToken */, + "===": 32 /* EqualsEqualsEqualsToken */, + "!==": 33 /* ExclamationEqualsEqualsToken */, + "=>": 34 /* EqualsGreaterThanToken */, + "+": 35 /* PlusToken */, + "-": 36 /* MinusToken */, + "*": 37 /* AsteriskToken */, + "/": 38 /* SlashToken */, + "%": 39 /* PercentToken */, + "++": 40 /* PlusPlusToken */, + "--": 41 /* MinusMinusToken */, + "<<": 42 /* LessThanLessThanToken */, + ">": 43 /* GreaterThanGreaterThanToken */, + ">>>": 44 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 45 /* AmpersandToken */, + "|": 46 /* BarToken */, + "^": 47 /* CaretToken */, + "!": 48 /* ExclamationToken */, + "~": 49 /* TildeToken */, + "&&": 50 /* AmpersandAmpersandToken */, + "||": 51 /* BarBarToken */, + "?": 52 /* QuestionToken */, + ":": 53 /* ColonToken */, + "=": 55 /* EqualsToken */, + "+=": 56 /* PlusEqualsToken */, + "-=": 57 /* MinusEqualsToken */, + "*=": 58 /* AsteriskEqualsToken */, + "/=": 59 /* SlashEqualsToken */, + "%=": 60 /* PercentEqualsToken */, + "<<=": 61 /* LessThanLessThanEqualsToken */, + ">>=": 62 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 64 /* AmpersandEqualsToken */, + "|=": 65 /* BarEqualsToken */, + "^=": 66 /* CaretEqualsToken */, + "@": 54 /* AtToken */ }; /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -2730,14 +2766,21 @@ var ts; } ts.getLineStarts = getLineStarts; /* @internal */ + /** + * We assume the first line starts at position 0 and 'position' is non-negative. + */ function computeLineAndCharacterOfPosition(lineStarts, position) { var lineNumber = ts.binarySearch(lineStarts, position); if (lineNumber < 0) { // If the actual position was not found, - // the binary search returns the negative value of the next line start + // the binary search returns the 2's-complement of the next line start // e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 - // then the search will return -2 + // then the search will return -2. + // + // We want the index of the previous line start, so we subtract 1. + // Review 2's-complement if this is confusing. lineNumber = ~lineNumber - 1; + ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); } return { line: lineNumber, @@ -2809,6 +2852,9 @@ var ts; case 62 /* greaterThan */: // Starts of conflict marker trivia return true; + case 35 /* hash */: + // Only if its the beginning can we have #! trivia + return pos === 0; default: return ch > 127 /* maxAsciiCharacter */; } @@ -2867,6 +2913,12 @@ var ts; continue; } break; + case 35 /* hash */: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; default: if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { pos++; @@ -2923,13 +2975,28 @@ var ts; } return pos; } - // Extract comments from the given source text starting at the given position. If trailing is - // false, whitespace is skipped until the first line break and comments between that location - // and the next token are returned.If trailing is true, comments occurring between the given - // position and the next line break are returned.The return value is an array containing a - // TextRange for each comment. Single-line comment ranges include the beginning '//' characters - // but not the ending line break. Multi - line comment ranges include the beginning '/* and - // ending '*/' characters.The return value is undefined if no comments were found. + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + // Shebangs check must only be done at the start of the file + ts.Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); + } + function scanShebangTrivia(text, pos) { + var shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; + } + /** + * Extract comments from text prefixing the token closest following `pos`. + * The return value is an array containing a TextRange for each comment. + * Single-line comment ranges include the beginning '//' characters but not the ending line break. + * Multi - line comment ranges include the beginning '/* and ending '/' characters. + * The return value is undefined if no comments were found. + * @param trailing + * If false, whitespace is skipped until the first line break and comments between that location + * and the next token are returned. + * If true, comments occurring between the given position and the next line break are returned. + */ function getCommentRanges(text, pos, trailing) { var result; var collecting = trailing || pos === 0; @@ -3004,13 +3071,20 @@ var ts; } } function getLeadingCommentRanges(text, pos) { - return getCommentRanges(text, pos, false); + return getCommentRanges(text, pos, /*trailing*/ false); } ts.getLeadingCommentRanges = getLeadingCommentRanges; function getTrailingCommentRanges(text, pos) { - return getCommentRanges(text, pos, true); + return getCommentRanges(text, pos, /*trailing*/ true); } ts.getTrailingCommentRanges = getTrailingCommentRanges; + /** Optionally, get the shebang */ + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch === 36 /* $ */ || ch === 95 /* _ */ || @@ -3023,7 +3097,6 @@ var ts; ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; - /* @internal */ // Creates a scanner over a (possibly unspecified) range of a piece of text. function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } @@ -3050,8 +3123,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 66 /* Identifier */ || token > 102 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 67 /* FirstReservedWord */ && token <= 102 /* LastReservedWord */; }, + isIdentifier: function () { return token === 67 /* Identifier */ || token > 103 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 68 /* FirstReservedWord */ && token <= 103 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -3121,14 +3194,14 @@ var ts; * returning -1 if the given number is unavailable. */ function scanExactNumberOfHexDigits(count) { - return scanHexDigits(count, false); + return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false); } /** * Scans as many hexadecimal digits as are available in the text, * returning -1 if the given number of digits was unavailable. */ function scanMinimumNumberOfHexDigits(count) { - return scanHexDigits(count, true); + return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ true); } function scanHexDigits(minCount, scanAsManyAsPossible) { var digits = 0; @@ -3203,7 +3276,7 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 10 /* NoSubstitutionTemplateLiteral */ : 13 /* TemplateTail */; + resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -3211,14 +3284,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 10 /* NoSubstitutionTemplateLiteral */ : 13 /* TemplateTail */; + resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 11 /* TemplateHead */ : 12 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 12 /* TemplateHead */ : 13 /* TemplateMiddle */; break; } // Escape character @@ -3280,10 +3353,10 @@ var ts; return scanExtendedUnicodeEscape(); } // '\uDDDD' - return scanHexadecimalEscape(4); + return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: // '\xDD' - return scanHexadecimalEscape(2); + return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". case 13 /* carriageReturn */: @@ -3395,7 +3468,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 66 /* Identifier */; + return token = 67 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -3430,6 +3503,16 @@ var ts; return token = 1 /* EndOfFileToken */; } var ch = text.charCodeAt(pos); + // Special handling for shebang + if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6 /* ShebangTrivia */; + } + } switch (ch) { case 10 /* lineFeed */: case 13 /* carriageReturn */: @@ -3465,66 +3548,66 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 32 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 33 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 30 /* ExclamationEqualsToken */; + return pos += 2, token = 31 /* ExclamationEqualsToken */; } - return pos++, token = 47 /* ExclamationToken */; + return pos++, token = 48 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); - return token = 8 /* StringLiteral */; + return token = 9 /* StringLiteral */; case 96 /* backtick */: return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* PercentEqualsToken */; + return pos += 2, token = 60 /* PercentEqualsToken */; } - return pos++, token = 38 /* PercentToken */; + return pos++, token = 39 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 49 /* AmpersandAmpersandToken */; + return pos += 2, token = 50 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* AmpersandEqualsToken */; + return pos += 2, token = 64 /* AmpersandEqualsToken */; } - return pos++, token = 44 /* AmpersandToken */; + return pos++, token = 45 /* AmpersandToken */; case 40 /* openParen */: - return pos++, token = 16 /* OpenParenToken */; + return pos++, token = 17 /* OpenParenToken */; case 41 /* closeParen */: - return pos++, token = 17 /* CloseParenToken */; + return pos++, token = 18 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* AsteriskEqualsToken */; + return pos += 2, token = 58 /* AsteriskEqualsToken */; } - return pos++, token = 36 /* AsteriskToken */; + return pos++, token = 37 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 39 /* PlusPlusToken */; + return pos += 2, token = 40 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 55 /* PlusEqualsToken */; + return pos += 2, token = 56 /* PlusEqualsToken */; } - return pos++, token = 34 /* PlusToken */; + return pos++, token = 35 /* PlusToken */; case 44 /* comma */: - return pos++, token = 23 /* CommaToken */; + return pos++, token = 24 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 40 /* MinusMinusToken */; + return pos += 2, token = 41 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* MinusEqualsToken */; + return pos += 2, token = 57 /* MinusEqualsToken */; } - return pos++, token = 35 /* MinusToken */; + return pos++, token = 36 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 21 /* DotDotDotToken */; + return pos += 3, token = 22 /* DotDotDotToken */; } - return pos++, token = 20 /* DotToken */; + return pos++, token = 21 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -3570,9 +3653,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* SlashEqualsToken */; + return pos += 2, token = 59 /* SlashEqualsToken */; } - return pos++, token = 37 /* SlashToken */; + return pos++, token = 38 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -3582,32 +3665,32 @@ var ts; value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { pos += 2; - var value = scanBinaryOrOctalDigits(2); + var value = scanBinaryOrOctalDigits(/* base */ 2); if (value < 0) { error(ts.Diagnostics.Binary_digit_expected); value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { pos += 2; - var value = scanBinaryOrOctalDigits(8); + var value = scanBinaryOrOctalDigits(/* base */ 8); if (value < 0) { error(ts.Diagnostics.Octal_digit_expected); value = 0; } tokenValue = "" + value; - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being @@ -3622,11 +3705,11 @@ var ts; case 56 /* _8 */: case 57 /* _9 */: tokenValue = "" + scanNumber(); - return token = 7 /* NumericLiteral */; + return token = 8 /* NumericLiteral */; case 58 /* colon */: - return pos++, token = 52 /* ColonToken */; + return pos++, token = 53 /* ColonToken */; case 59 /* semicolon */: - return pos++, token = 22 /* SemicolonToken */; + return pos++, token = 23 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3634,22 +3717,22 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 60 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 61 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 41 /* LessThanLessThanToken */; + return pos += 2, token = 42 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 27 /* LessThanEqualsToken */; + return pos += 2, token = 28 /* LessThanEqualsToken */; } if (text.charCodeAt(pos + 1) === 47 /* slash */ && languageVariant === 1 /* JSX */) { - return pos += 2, token = 25 /* LessThanSlashToken */; + return pos += 2, token = 26 /* LessThanSlashToken */; } - return pos++, token = 24 /* LessThanToken */; + return pos++, token = 25 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3657,19 +3740,19 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 31 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 32 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 29 /* EqualsEqualsToken */; + return pos += 2, token = 30 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 33 /* EqualsGreaterThanToken */; + return pos += 2, token = 34 /* EqualsGreaterThanToken */; } - return pos++, token = 54 /* EqualsToken */; + return pos++, token = 55 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3677,37 +3760,37 @@ var ts; continue; } else { - return token = 6 /* ConflictMarkerTrivia */; + return token = 7 /* ConflictMarkerTrivia */; } } - return pos++, token = 26 /* GreaterThanToken */; + return pos++, token = 27 /* GreaterThanToken */; case 63 /* question */: - return pos++, token = 51 /* QuestionToken */; + return pos++, token = 52 /* QuestionToken */; case 91 /* openBracket */: - return pos++, token = 18 /* OpenBracketToken */; + return pos++, token = 19 /* OpenBracketToken */; case 93 /* closeBracket */: - return pos++, token = 19 /* CloseBracketToken */; + return pos++, token = 20 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* CaretEqualsToken */; + return pos += 2, token = 66 /* CaretEqualsToken */; } - return pos++, token = 46 /* CaretToken */; + return pos++, token = 47 /* CaretToken */; case 123 /* openBrace */: - return pos++, token = 14 /* OpenBraceToken */; + return pos++, token = 15 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 50 /* BarBarToken */; + return pos += 2, token = 51 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* BarEqualsToken */; + return pos += 2, token = 65 /* BarEqualsToken */; } - return pos++, token = 45 /* BarToken */; + return pos++, token = 46 /* BarToken */; case 125 /* closeBrace */: - return pos++, token = 15 /* CloseBraceToken */; + return pos++, token = 16 /* CloseBraceToken */; case 126 /* tilde */: - return pos++, token = 48 /* TildeToken */; + return pos++, token = 49 /* TildeToken */; case 64 /* at */: - return pos++, token = 53 /* AtToken */; + return pos++, token = 54 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -3743,27 +3826,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 26 /* GreaterThanToken */) { + if (token === 27 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 43 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 44 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 62 /* GreaterThanGreaterThanEqualsToken */; } - return pos++, token = 42 /* GreaterThanGreaterThanToken */; + return pos++, token = 43 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { - return pos++, token = 28 /* GreaterThanEqualsToken */; + return pos++, token = 29 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 37 /* SlashToken */ || token === 58 /* SlashEqualsToken */) { + if (token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -3808,7 +3891,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 9 /* RegularExpressionLiteral */; + token = 10 /* RegularExpressionLiteral */; } return token; } @@ -3816,7 +3899,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 15 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 16 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -3833,14 +3916,14 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 25 /* LessThanSlashToken */; + return token = 26 /* LessThanSlashToken */; } pos++; - return token = 24 /* LessThanToken */; + return token = 25 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 14 /* OpenBraceToken */; + return token = 15 /* OpenBraceToken */; } while (pos < end) { pos++; @@ -3849,12 +3932,12 @@ var ts; break; } } - return token = 233 /* JsxText */; + return token = 234 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes function scanJsxIdentifier() { - if (token === 66 /* Identifier */) { + if (tokenIsIdentifierOrKeyword(token)) { var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); @@ -3890,10 +3973,10 @@ var ts; return result; } function lookAhead(callback) { - return speculationHelper(callback, true); + return speculationHelper(callback, /*isLookahead:*/ true); } function tryScan(callback) { - return speculationHelper(callback, false); + return speculationHelper(callback, /*isLookahead:*/ false); } function setText(newText, start, length) { text = newText || ""; @@ -3937,16 +4020,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 212 /* InterfaceDeclaration */ || node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 214 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 216 /* ModuleBlock */) { + else if (node.kind === 217 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3965,7 +4048,7 @@ var ts; }); return state; } - else if (node.kind === 215 /* ModuleDeclaration */) { + else if (node.kind === 216 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -4043,10 +4126,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 215 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { - return '"' + node.name.text + '"'; + if (node.kind === 216 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + return "\"" + node.name.text + "\""; } - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -4054,22 +4137,22 @@ var ts; return node.name.text; } switch (node.kind) { - case 141 /* Constructor */: + case 142 /* Constructor */: return "__constructor"; - case 149 /* FunctionType */: - case 144 /* CallSignature */: + case 150 /* FunctionType */: + case 145 /* CallSignature */: return "__call"; - case 150 /* ConstructorType */: - case 145 /* ConstructSignature */: + case 151 /* ConstructorType */: + case 146 /* ConstructSignature */: return "__new"; - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return "__index"; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return "__export"; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 210 /* FunctionDeclaration */: - case 211 /* ClassDeclaration */: + case 211 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: return node.flags & 1024 /* Default */ ? "default" : undefined; } } @@ -4140,7 +4223,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 227 /* ExportSpecifier */ || (node.kind === 218 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 228 /* ExportSpecifier */ || (node.kind === 219 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -4221,37 +4304,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 152 /* TypeLiteral */: - case 162 /* ObjectLiteralExpression */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 153 /* TypeLiteral */: + case 163 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 210 /* FunctionDeclaration */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 215 /* ModuleDeclaration */: - case 245 /* SourceFile */: - case 213 /* TypeAliasDeclaration */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 216 /* ModuleDeclaration */: + case 246 /* SourceFile */: + case 214 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 241 /* CatchClause */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 217 /* CaseBlock */: + case 242 /* CatchClause */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 218 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 189 /* Block */: + case 190 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -4288,38 +4371,38 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 152 /* TypeLiteral */: - case 162 /* ObjectLiteralExpression */: - case 212 /* InterfaceDeclaration */: + case 153 /* TypeLiteral */: + case 163 /* ObjectLiteralExpression */: + case 213 /* InterfaceDeclaration */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 213 /* TypeAliasDeclaration */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 214 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -4349,11 +4432,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 245 /* SourceFile */ ? node : node.body; - if (body.kind === 245 /* SourceFile */ || body.kind === 216 /* ModuleBlock */) { + var body = node.kind === 246 /* SourceFile */ ? node : node.body; + if (body.kind === 246 /* SourceFile */ || body.kind === 217 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 225 /* ExportDeclaration */ || stat.kind === 224 /* ExportAssignment */) { + if (stat.kind === 226 /* ExportDeclaration */ || stat.kind === 225 /* ExportAssignment */) { return true; } } @@ -4372,7 +4455,7 @@ var ts; } function bindModuleDeclaration(node) { setExportContextFlag(node); - if (node.name.kind === 8 /* StringLiteral */) { + if (node.name.kind === 9 /* StringLiteral */) { declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); } else { @@ -4382,14 +4465,21 @@ var ts; } else { declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */); - var currentModuleIsConstEnumOnly = state === 2 /* ConstEnumOnly */; - if (node.symbol.constEnumOnlyModule === undefined) { - // non-merged case - use the current state - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + if (node.symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */)) { + // if module was already merged with some function, class or non-const enum + // treat is a non-const-enum-only + node.symbol.constEnumOnlyModule = false; } else { - // merged case: module is const enum only if all its pieces are non-instantiated or const enum - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + var currentModuleIsConstEnumOnly = state === 2 /* ConstEnumOnly */; + if (node.symbol.constEnumOnlyModule === undefined) { + // non-merged case - use the current state + node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; + } + else { + // merged case: module is const enum only if all its pieces are non-instantiated or const enum + node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; + } } } } @@ -4418,7 +4508,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 66 /* Identifier */) { + if (prop.name.kind !== 67 /* Identifier */) { continue; } var identifier = prop.name; @@ -4430,7 +4520,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 242 /* PropertyAssignment */ || prop.kind === 243 /* ShorthandPropertyAssignment */ || prop.kind === 140 /* MethodDeclaration */ + var currentKind = prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */ || prop.kind === 141 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -4452,10 +4542,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -4476,8 +4566,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 103 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 111 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 104 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 112 /* LastFutureReservedWord */ && !ts.isIdentifierName(node)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { @@ -4512,7 +4602,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 66 /* Identifier */) { + if (inStrictMode && node.expression.kind === 67 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -4520,11 +4610,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 66 /* Identifier */) { + if (name && name.kind === 67 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -4568,7 +4658,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 39 /* PlusPlusToken */ || node.operator === 40 /* MinusMinusToken */) { + if (node.operator === 40 /* PlusPlusToken */ || node.operator === 41 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -4612,17 +4702,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 245 /* SourceFile */: - case 216 /* ModuleBlock */: + case 246 /* SourceFile */: + case 217 /* ModuleBlock */: updateStrictModeStatementList(node.statements); return; - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return; @@ -4645,103 +4735,103 @@ var ts; var nodeText = ts.getTextOfNodeFromSourceText(file.text, node.expression); // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the // string to contain unicode escapes (as per ES5). - return nodeText === '"use strict"' || nodeText === "'use strict'"; + return nodeText === "\"use strict\"" || nodeText === "'use strict'"; } function bindWorker(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return checkStrictModeIdentifier(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return checkStrictModeBinaryExpression(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return checkStrictModeCatchClause(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return checkStrictModeWithStatement(node); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 135 /* Parameter */: + case 136 /* Parameter */: return bindParameter(node); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 141 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); - case 142 /* GetAccessor */: + case 142 /* Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); + case 143 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: checkStrictModeFunctionName(node); var bindingName = node.name ? node.name.text : "__function"; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); - case 183 /* ClassExpression */: - case 211 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return bindModuleDeclaration(node); - case 218 /* ImportEqualsDeclaration */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return bindImportClause(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return bindExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return bindExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return bindSourceFileIfExternalModule(); } } function bindSourceFileIfExternalModule() { setExportContextFlag(file); if (ts.isExternalModule(file)) { - bindAnonymousDeclaration(file, 512 /* ValueModule */, '"' + ts.removeFileExtension(file.fileName) + '"'); + bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); } } function bindExportAssignment(node) { @@ -4749,7 +4839,7 @@ var ts; // Export assignment in some sort of block construct bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); } - else if (node.expression.kind === 66 /* Identifier */) { + else if (node.expression.kind === 67 /* Identifier */) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); } @@ -4774,12 +4864,16 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { var bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + // Add name of class expression into the map for semantic classifier + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } } var symbol = node.symbol; // TypeScript 1.0 spec (April 2014): 8.4 @@ -4846,7 +4940,7 @@ var ts; // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 141 /* Constructor */ && + node.parent.kind === 142 /* Constructor */ && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); @@ -4860,6 +4954,7 @@ var ts; } })(ts || (ts = {})); /// +/// /* @internal */ var ts; (function (ts) { @@ -4912,6 +5007,37 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(arr1, arr2, comparer) { + if (!arr1 || !arr2) { + return arr1 === arr2; + } + if (arr1.length !== arr2.length) { + return false; + } + for (var i = 0; i < arr1.length; ++i) { + var equals = comparer ? comparer(arr1[i], arr2[i]) : arr1[i] === arr2[i]; + if (!equals) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModule(sourceFile, moduleNameText) { + return sourceFile.resolvedModules && ts.hasProperty(sourceFile.resolvedModules, moduleNameText); + } + ts.hasResolvedModule = hasResolvedModule; + function getResolvedModule(sourceFile, moduleNameText) { + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModule = getResolvedModule; + function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = {}; + } + sourceFile.resolvedModules[moduleNameText] = resolvedModule; + } + ts.setResolvedModule = setResolvedModule; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); @@ -4936,7 +5062,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 245 /* SourceFile */) { + while (node && node.kind !== 246 /* SourceFile */) { node = node.parent; } return node; @@ -4958,16 +5084,16 @@ var ts; return node.pos; } ts.getStartPosOfNode = getStartPosOfNode; - // Returns true if this node is missing from the actual source code. 'missing' is different - // from 'undefined/defined'. When a node is undefined (which can happen for optional nodes - // in the tree), it is definitel missing. HOwever, a node may be defined, but still be + // Returns true if this node is missing from the actual source code. A 'missing' node is different + // from 'undefined/defined'. When a node is undefined (which can happen for optional nodes + // in the tree), it is definitely missing. However, a node may be defined, but still be // missing. This happens whenever the parser knows it needs to parse something, but can't - // get anything in the source code that it expects at that location. For example: + // get anything in the source code that it expects at that location. For example: // // let a: ; // // Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source - // code). So the parser will attempt to parse out a type, and will create an actual node. + // code). So the parser will attempt to parse out a type, and will create an actual node. // However, this node will be 'missing' in the sense that no actual source-code/tokens are // contained within it. function nodeIsMissing(node) { @@ -5031,7 +5157,7 @@ var ts; // Make an identifier from an external module name by extracting the string after the last "/" and replacing // all non-alphanumeric characters with underscores function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/\W/g, "_"); + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { @@ -5048,15 +5174,15 @@ var ts; return current; } switch (current.kind) { - case 245 /* SourceFile */: - case 217 /* CaseBlock */: - case 241 /* CatchClause */: - case 215 /* ModuleDeclaration */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 246 /* SourceFile */: + case 218 /* CaseBlock */: + case 242 /* CatchClause */: + case 216 /* ModuleDeclaration */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return current; - case 189 /* Block */: + case 190 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -5069,9 +5195,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 208 /* VariableDeclaration */ && + declaration.kind === 209 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 241 /* CatchClause */; + declaration.parent.kind === 242 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -5101,7 +5227,7 @@ var ts; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); + var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); scanner.scan(); var start = scanner.getTokenPos(); return ts.createTextSpanFromBounds(start, scanner.getTextPos()); @@ -5110,8 +5236,8 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 245 /* SourceFile */: - var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); + case 246 /* SourceFile */: + var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file return ts.createTextSpan(0, 0); @@ -5119,16 +5245,16 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: errorNode = node.name; break; } @@ -5152,11 +5278,11 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 214 /* EnumDeclaration */ && isConst(node); + return node.kind === 215 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 160 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 161 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; @@ -5171,14 +5297,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 208 /* VariableDeclaration */) { + if (node.kind === 209 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 209 /* VariableDeclarationList */) { + if (node && node.kind === 210 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 190 /* VariableStatement */) { + if (node && node.kind === 191 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -5193,25 +5319,18 @@ var ts; } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 192 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; + return node.kind === 193 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - // If parameter/type parameter, the prev token trailing comments are part of this node too - if (node.kind === 135 /* Parameter */ || node.kind === 134 /* TypeParameter */) { - // e.g. (/** blah */ a, /** blah */ b); - // e.g.: ( - // /** blah */ a, - // /** blah */ b); - return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); - } - else { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); + var commentRanges = (node.kind === 136 /* Parameter */ || node.kind === 135 /* TypeParameter */) ? + ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); + return ts.filter(commentRanges, isJsDocComment); function isJsDocComment(comment) { // True if the comment starts with '/**' but not if it is '/**/' return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && @@ -5221,41 +5340,42 @@ var ts; } ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (148 /* FirstTypeNode */ <= node.kind && node.kind <= 157 /* LastTypeNode */) { + if (149 /* FirstTypeNode */ <= node.kind && node.kind <= 158 /* LastTypeNode */) { return true; } switch (node.kind) { - case 114 /* AnyKeyword */: - case 125 /* NumberKeyword */: - case 127 /* StringKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: + case 115 /* AnyKeyword */: + case 126 /* NumberKeyword */: + case 128 /* StringKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: return true; - case 100 /* VoidKeyword */: - return node.parent.kind !== 174 /* VoidExpression */; - case 8 /* StringLiteral */: + case 101 /* VoidKeyword */: + return node.parent.kind !== 175 /* VoidExpression */; + case 9 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 135 /* Parameter */; - case 185 /* ExpressionWithTypeArguments */: + return node.parent.kind === 136 /* Parameter */; + case 186 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 66 /* Identifier */: + case 67 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // fall through - case 132 /* QualifiedName */: - case 163 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 164 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */ || node.kind === 163 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 151 /* TypeQuery */) { + if (parent_1.kind === 152 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -5264,38 +5384,38 @@ var ts; // // Calling isTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (148 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 157 /* LastTypeNode */) { + if (149 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 158 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return node === parent_1.constraint; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 135 /* Parameter */: - case 208 /* VariableDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 136 /* Parameter */: + case 209 /* VariableDeclaration */: return node === parent_1.type; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 141 /* Constructor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 142 /* Constructor */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return node === parent_1.type; - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return node === parent_1.type; - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return node === parent_1.type; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -5309,23 +5429,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return visitor(node); - case 217 /* CaseBlock */: - case 189 /* Block */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: + case 218 /* CaseBlock */: + case 190 /* Block */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -5335,18 +5455,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -5354,7 +5474,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 133 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 134 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(name_5.expression); @@ -5373,14 +5493,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 160 /* BindingElement */: - case 244 /* EnumMember */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 243 /* ShorthandPropertyAssignment */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 245 /* EnumMember */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 244 /* ShorthandPropertyAssignment */: + case 209 /* VariableDeclaration */: return true; } } @@ -5388,41 +5508,55 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 142 /* GetAccessor */ || node.kind === 143 /* SetAccessor */); + return node && (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 211 /* ClassDeclaration */ || node.kind === 183 /* ClassExpression */); + return node && (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 141 /* Constructor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 142 /* Constructor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return true; } } return false; } ts.isFunctionLike = isFunctionLike; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isFunctionBlock(node) { - return node && node.kind === 189 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 190 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 140 /* MethodDeclaration */ && node.parent.kind === 162 /* ObjectLiteralExpression */; + return node && node.kind === 141 /* MethodDeclaration */ && node.parent.kind === 163 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -5450,7 +5584,7 @@ var ts; return undefined; } switch (node.kind) { - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -5465,9 +5599,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 135 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5478,23 +5612,23 @@ var ts; node = node.parent; } break; - case 171 /* ArrowFunction */: + case 172 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 215 /* ModuleDeclaration */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 214 /* EnumDeclaration */: - case 245 /* SourceFile */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 216 /* ModuleDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 215 /* EnumDeclaration */: + case 246 /* SourceFile */: return node; } } @@ -5506,7 +5640,7 @@ var ts; if (!node) return node; switch (node.kind) { - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container @@ -5521,9 +5655,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 135 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 136 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5534,19 +5668,19 @@ var ts; node = node.parent; } break; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return node; } } @@ -5555,12 +5689,12 @@ var ts; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 148 /* TypeReference */: + case 149 /* TypeReference */: return node.typeName; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return node.expression; - case 66 /* Identifier */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 133 /* QualifiedName */: return node; } } @@ -5568,7 +5702,7 @@ var ts; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -5577,44 +5711,44 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: // classes are valid targets return true; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 211 /* ClassDeclaration */; - case 135 /* Parameter */: + return node.parent.kind === 212 /* ClassDeclaration */; + case 136 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return node.parent.body && node.parent.parent.kind === 211 /* ClassDeclaration */; - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 140 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 212 /* ClassDeclaration */; + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 141 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 211 /* ClassDeclaration */; + return node.body && node.parent.kind === 212 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: if (node.decorators) { return true; } return false; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -5625,10 +5759,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -5640,93 +5774,94 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: - case 9 /* RegularExpressionLiteral */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 167 /* TaggedTemplateExpression */: - case 186 /* AsExpression */: - case 168 /* TypeAssertionExpression */: - case 169 /* ParenthesizedExpression */: - case 170 /* FunctionExpression */: - case 183 /* ClassExpression */: - case 171 /* ArrowFunction */: - case 174 /* VoidExpression */: - case 172 /* DeleteExpression */: - case 173 /* TypeOfExpression */: - case 176 /* PrefixUnaryExpression */: - case 177 /* PostfixUnaryExpression */: - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 180 /* TemplateExpression */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 184 /* OmittedExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 181 /* YieldExpression */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: + case 10 /* RegularExpressionLiteral */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 168 /* TaggedTemplateExpression */: + case 187 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 170 /* ParenthesizedExpression */: + case 171 /* FunctionExpression */: + case 184 /* ClassExpression */: + case 172 /* ArrowFunction */: + case 175 /* VoidExpression */: + case 173 /* DeleteExpression */: + case 174 /* TypeOfExpression */: + case 177 /* PrefixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 181 /* TemplateExpression */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 185 /* OmittedExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 182 /* YieldExpression */: return true; - case 132 /* QualifiedName */: - while (node.parent.kind === 132 /* QualifiedName */) { + case 133 /* QualifiedName */: + while (node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 151 /* TypeQuery */; - case 66 /* Identifier */: - if (node.parent.kind === 151 /* TypeQuery */) { + return node.parent.kind === 152 /* TypeQuery */; + case 67 /* Identifier */: + if (node.parent.kind === 152 /* TypeQuery */) { return true; } // fall through - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: var parent_2 = node.parent; switch (parent_2.kind) { - case 208 /* VariableDeclaration */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 244 /* EnumMember */: - case 242 /* PropertyAssignment */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 245 /* EnumMember */: + case 243 /* PropertyAssignment */: + case 161 /* BindingElement */: return parent_2.initializer === node; - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 201 /* ReturnStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 205 /* ThrowStatement */: - case 203 /* SwitchStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 202 /* ReturnStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 206 /* ThrowStatement */: + case 204 /* SwitchStatement */: return parent_2.expression === node; - case 196 /* ForStatement */: + case 197 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 209 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 210 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 209 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 210 /* VariableDeclarationList */) || forInStatement.expression === node; - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return node === parent_2.expression; - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return node === parent_2.expression; - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return node === parent_2.expression; - case 136 /* Decorator */: + case 137 /* Decorator */: + case 238 /* JsxExpression */: return true; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5744,7 +5879,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 229 /* ExternalModuleReference */; + return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5753,20 +5888,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 229 /* ExternalModuleReference */; + return node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 230 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 219 /* ImportDeclaration */) { + if (node.kind === 220 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 229 /* ExternalModuleReference */) { + if (reference.kind === 230 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 225 /* ExportDeclaration */) { + if (node.kind === 226 /* ExportDeclaration */) { return node.moduleSpecifier; } } @@ -5774,15 +5909,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 135 /* Parameter */: - return node.questionToken !== undefined; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - return node.questionToken !== undefined; - case 243 /* ShorthandPropertyAssignment */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 136 /* Parameter */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 244 /* ShorthandPropertyAssignment */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5790,9 +5923,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 258 /* JSDocFunctionType */ && + return node.kind === 259 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 260 /* JSDocConstructorType */; + node.parameters[0].type.kind === 261 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5806,26 +5939,26 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 266 /* JSDocTypeTag */); + return getJSDocTag(node, 267 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 265 /* JSDocReturnTag */); + return getJSDocTag(node, 266 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 267 /* JSDocTemplateTag */); + return getJSDocTag(node, 268 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 66 /* Identifier */) { + if (parameter.name && parameter.name.kind === 67 /* Identifier */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 264 /* JSDocParameterTag */) { + if (t.kind === 265 /* JSDocParameterTag */) { var parameterTag = t; var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; if (name_6.text === parameterName) { @@ -5844,12 +5977,12 @@ var ts; function isRestParameter(node) { if (node) { if (node.parserContextFlags & 32 /* JavaScriptFile */) { - if (node.type && node.type.kind === 259 /* JSDocVariadicType */) { + if (node.type && node.type.kind === 260 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 259 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 260 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -5858,19 +5991,19 @@ var ts; } ts.isRestParameter = isRestParameter; function isLiteralKind(kind) { - return 7 /* FirstLiteralToken */ <= kind && kind <= 10 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 11 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 8 /* StringLiteral */ || kind === 10 /* NoSubstitutionTemplateLiteral */; + return kind === 9 /* StringLiteral */ || kind === 11 /* NoSubstitutionTemplateLiteral */; } ts.isTextualLiteralKind = isTextualLiteralKind; function isTemplateLiteralKind(kind) { - return 10 /* FirstTemplateToken */ <= kind && kind <= 13 /* LastTemplateToken */; + return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 159 /* ArrayBindingPattern */ || node.kind === 158 /* ObjectBindingPattern */); + return !!node && (node.kind === 160 /* ArrayBindingPattern */ || node.kind === 159 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { @@ -5885,34 +6018,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 171 /* ArrowFunction */: - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 141 /* Constructor */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 227 /* ExportSpecifier */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 142 /* GetAccessor */: - case 220 /* ImportClause */: - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 212 /* InterfaceDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 215 /* ModuleDeclaration */: - case 221 /* NamespaceImport */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 143 /* SetAccessor */: - case 243 /* ShorthandPropertyAssignment */: - case 213 /* TypeAliasDeclaration */: - case 134 /* TypeParameter */: - case 208 /* VariableDeclaration */: + case 172 /* ArrowFunction */: + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 142 /* Constructor */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 228 /* ExportSpecifier */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 143 /* GetAccessor */: + case 221 /* ImportClause */: + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 213 /* InterfaceDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 216 /* ModuleDeclaration */: + case 222 /* NamespaceImport */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 144 /* SetAccessor */: + case 244 /* ShorthandPropertyAssignment */: + case 214 /* TypeAliasDeclaration */: + case 135 /* TypeParameter */: + case 209 /* VariableDeclaration */: return true; } return false; @@ -5920,25 +6053,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: - case 207 /* DebuggerStatement */: - case 194 /* DoStatement */: - case 192 /* ExpressionStatement */: - case 191 /* EmptyStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 193 /* IfStatement */: - case 204 /* LabeledStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 95 /* ThrowKeyword */: - case 206 /* TryStatement */: - case 190 /* VariableStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 224 /* ExportAssignment */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 208 /* DebuggerStatement */: + case 195 /* DoStatement */: + case 193 /* ExpressionStatement */: + case 192 /* EmptyStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 194 /* IfStatement */: + case 205 /* LabeledStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 96 /* ThrowKeyword */: + case 207 /* TryStatement */: + case 191 /* VariableStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 225 /* ExportAssignment */: return true; default: return false; @@ -5947,13 +6080,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 141 /* Constructor */: - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: + case 142 /* Constructor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: return true; default: return false; @@ -5962,11 +6095,11 @@ var ts; ts.isClassElement = isClassElement; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 66 /* Identifier */ && name.kind !== 8 /* StringLiteral */ && name.kind !== 7 /* NumericLiteral */) { + if (name.kind !== 67 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 223 /* ImportSpecifier */ || parent.kind === 227 /* ExportSpecifier */) { + if (parent.kind === 224 /* ImportSpecifier */ || parent.kind === 228 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5981,31 +6114,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 244 /* EnumMember */: - case 242 /* PropertyAssignment */: - case 163 /* PropertyAccessExpression */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 245 /* EnumMember */: + case 243 /* PropertyAssignment */: + case 164 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 132 /* QualifiedName */) { + while (parent.kind === 133 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 151 /* TypeQuery */; + return parent.kind === 152 /* TypeQuery */; } return false; - case 160 /* BindingElement */: - case 223 /* ImportSpecifier */: + case 161 /* BindingElement */: + case 224 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 227 /* ExportSpecifier */: + case 228 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -6021,26 +6154,26 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 218 /* ImportEqualsDeclaration */ || - node.kind === 220 /* ImportClause */ && !!node.name || - node.kind === 221 /* NamespaceImport */ || - node.kind === 223 /* ImportSpecifier */ || - node.kind === 227 /* ExportSpecifier */ || - node.kind === 224 /* ExportAssignment */ && node.expression.kind === 66 /* Identifier */; + return node.kind === 219 /* ImportEqualsDeclaration */ || + node.kind === 221 /* ImportClause */ && !!node.name || + node.kind === 222 /* NamespaceImport */ || + node.kind === 224 /* ImportSpecifier */ || + node.kind === 228 /* ExportSpecifier */ || + node.kind === 225 /* ExportAssignment */ && node.expression.kind === 67 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 103 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 104 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 80 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 81 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -6109,11 +6242,11 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 67 /* FirstKeyword */ <= token && token <= 131 /* LastKeyword */; + return 68 /* FirstKeyword */ <= token && token <= 132 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 6 /* LastTriviaToken */; + return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { @@ -6129,7 +6262,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 133 /* ComputedPropertyName */ && + declaration.name.kind === 134 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -6139,14 +6272,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 163 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return node.kind === 164 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 66 /* Identifier */ || name.kind === 8 /* StringLiteral */ || name.kind === 7 /* NumericLiteral */) { + if (name.kind === 67 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return name.text; } - if (name.kind === 133 /* ComputedPropertyName */) { + if (name.kind === 134 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6164,21 +6297,21 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 66 /* Identifier */ && node.text === "Symbol"; + return node.kind === 67 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 112 /* AbstractKeyword */: - case 115 /* AsyncKeyword */: - case 71 /* ConstKeyword */: - case 119 /* DeclareKeyword */: - case 74 /* DefaultKeyword */: - case 79 /* ExportKeyword */: - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 113 /* AbstractKeyword */: + case 116 /* AsyncKeyword */: + case 72 /* ConstKeyword */: + case 120 /* DeclareKeyword */: + case 75 /* DefaultKeyword */: + case 80 /* ExportKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: return true; } return false; @@ -6186,20 +6319,36 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 135 /* Parameter */; + return root.kind === 136 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 160 /* BindingElement */) { + while (node.kind === 161 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 215 /* ModuleDeclaration */ || n.kind === 245 /* SourceFile */; + return isFunctionLike(n) || n.kind === 216 /* ModuleDeclaration */ || n.kind === 246 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function cloneEntityName(node) { + if (node.kind === 67 /* Identifier */) { + var clone_1 = createSynthesizedNode(67 /* Identifier */); + clone_1.text = node.text; + return clone_1; + } + else { + var clone_2 = createSynthesizedNode(133 /* QualifiedName */); + clone_2.left = cloneEntityName(node.left); + clone_2.left.parent = clone_2; + clone_2.right = cloneEntityName(node.right); + clone_2.right.parent = clone_2; + return clone_2; + } + } + ts.cloneEntityName = cloneEntityName; function nodeIsSynthesized(node) { return node.pos === -1; } @@ -6226,11 +6375,21 @@ var ts; add: add, getGlobalDiagnostics: getGlobalDiagnostics, getDiagnostics: getDiagnostics, - getModificationCount: getModificationCount + getModificationCount: getModificationCount, + reattachFileDiagnostics: reattachFileDiagnostics }; function getModificationCount() { return modificationCount; } + function reattachFileDiagnostics(newFile) { + if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { + return; + } + for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { + var diagnostic = _a[_i]; + diagnostic.file = newFile; + } + } function add(diagnostic) { var diagnostics; if (diagnostic.file) { @@ -6436,7 +6595,7 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 141 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 142 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -6448,7 +6607,7 @@ var ts; ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { // 1. in-browser single file compilation scenario // 2. non .js file return compilerOptions.isolatedModules || !ts.fileExtensionIs(sourceFile.fileName, ".js"); @@ -6465,10 +6624,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 142 /* GetAccessor */) { + if (accessor.kind === 143 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 143 /* SetAccessor */) { + else if (accessor.kind === 144 /* SetAccessor */) { setAccessor = accessor; } else { @@ -6477,7 +6636,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 142 /* GetAccessor */ || member.kind === 143 /* SetAccessor */) + if ((member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6488,10 +6647,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 142 /* GetAccessor */ && !getAccessor) { + if (member.kind === 143 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 143 /* SetAccessor */ && !setAccessor) { + if (member.kind === 144 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6593,7 +6752,7 @@ var ts; } function writeTrimmedCurrentLine(pos, nextLineStart) { var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ""); if (currentLineText) { // trimmed forward and ending spaces text writer.write(currentLineText); @@ -6624,16 +6783,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 110 /* StaticKeyword */: return 128 /* Static */; - case 109 /* PublicKeyword */: return 16 /* Public */; - case 108 /* ProtectedKeyword */: return 64 /* Protected */; - case 107 /* PrivateKeyword */: return 32 /* Private */; - case 112 /* AbstractKeyword */: return 256 /* Abstract */; - case 79 /* ExportKeyword */: return 1 /* Export */; - case 119 /* DeclareKeyword */: return 2 /* Ambient */; - case 71 /* ConstKeyword */: return 32768 /* Const */; - case 74 /* DefaultKeyword */: return 1024 /* Default */; - case 115 /* AsyncKeyword */: return 512 /* Async */; + case 111 /* StaticKeyword */: return 128 /* Static */; + case 110 /* PublicKeyword */: return 16 /* Public */; + case 109 /* ProtectedKeyword */: return 64 /* Protected */; + case 108 /* PrivateKeyword */: return 32 /* Private */; + case 113 /* AbstractKeyword */: return 256 /* Abstract */; + case 80 /* ExportKeyword */: return 1 /* Export */; + case 120 /* DeclareKeyword */: return 2 /* Ambient */; + case 72 /* ConstKeyword */: return 32768 /* Const */; + case 75 /* DefaultKeyword */: return 1024 /* Default */; + case 116 /* AsyncKeyword */: return 512 /* Async */; } return 0; } @@ -6641,29 +6800,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 166 /* NewExpression */: - case 165 /* CallExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 167 /* TaggedTemplateExpression */: - case 161 /* ArrayLiteralExpression */: - case 169 /* ParenthesizedExpression */: - case 162 /* ObjectLiteralExpression */: - case 183 /* ClassExpression */: - case 170 /* FunctionExpression */: - case 66 /* Identifier */: - case 9 /* RegularExpressionLiteral */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 180 /* TemplateExpression */: - case 81 /* FalseKeyword */: - case 90 /* NullKeyword */: - case 94 /* ThisKeyword */: - case 96 /* TrueKeyword */: - case 92 /* SuperKeyword */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 167 /* NewExpression */: + case 166 /* CallExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 168 /* TaggedTemplateExpression */: + case 162 /* ArrayLiteralExpression */: + case 170 /* ParenthesizedExpression */: + case 163 /* ObjectLiteralExpression */: + case 184 /* ClassExpression */: + case 171 /* FunctionExpression */: + case 67 /* Identifier */: + case 10 /* RegularExpressionLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 181 /* TemplateExpression */: + case 82 /* FalseKeyword */: + case 91 /* NullKeyword */: + case 95 /* ThisKeyword */: + case 97 /* TrueKeyword */: + case 93 /* SuperKeyword */: return true; } } @@ -6671,12 +6830,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 54 /* FirstAssignment */ && token <= 65 /* LastAssignment */; + return token >= 55 /* FirstAssignment */ && token <= 66 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 185 /* ExpressionWithTypeArguments */ && - node.parent.token === 80 /* ExtendsKeyword */ && + return node.kind === 186 /* ExpressionWithTypeArguments */ && + node.parent.token === 81 /* ExtendsKeyword */ && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -6687,10 +6846,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 66 /* Identifier */) { + if (node.kind === 67 /* Identifier */) { return true; } - else if (node.kind === 163 /* PropertyAccessExpression */) { + else if (node.kind === 164 /* PropertyAccessExpression */) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -6698,10 +6857,21 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 163 /* ObjectLiteralExpression */) { + return expression.properties.length === 0; + } + if (kind === 162 /* ArrayLiteralExpression */) { + return expression.elements.length === 0; + } + return false; + } + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -7004,13 +7174,13 @@ var ts; oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN); } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 134 /* TypeParameter */) { + if (d && d.kind === 135 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 212 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 213 /* InterfaceDeclaration */) { return current; } } @@ -7022,7 +7192,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(269 /* Count */); + var nodeConstructors = new Array(270 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -7067,20 +7237,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -7089,24 +7259,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -7117,290 +7287,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 154 /* TupleType */: + case 155 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 155 /* UnionType */: - case 156 /* IntersectionType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 186 /* AsExpression */: + case 187 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 209 /* VariableDeclarationList */: + case 210 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 197 /* ForInStatement */: + case 198 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 198 /* ForOfStatement */: + case 199 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return visitNode(cbNode, node.label); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 238 /* CaseClause */: + case 239 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 239 /* DefaultClause */: + case 240 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 136 /* Decorator */: + case 137 /* Decorator */: return visitNode(cbNode, node.expression); - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 221 /* NamespaceImport */: + case 222 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 222 /* NamedImports */: - case 226 /* NamedExports */: + case 223 /* NamedImports */: + case 227 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 240 /* HeritageClause */: + case 241 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 229 /* ExternalModuleReference */: + case 230 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 228 /* MissingDeclaration */: + case 229 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 230 /* JsxElement */: + case 231 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 231 /* JsxSelfClosingElement */: - case 232 /* JsxOpeningElement */: + case 232 /* JsxSelfClosingElement */: + case 233 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 235 /* JsxAttribute */: + case 236 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 236 /* JsxSpreadAttribute */: + case 237 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 234 /* JsxClosingElement */: + case 235 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 246 /* JSDocTypeExpression */: + case 247 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 250 /* JSDocUnionType */: + case 251 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 251 /* JSDocTupleType */: + case 252 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 249 /* JSDocArrayType */: + case 250 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 253 /* JSDocNonNullableType */: + case 254 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 252 /* JSDocNullableType */: + case 253 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 254 /* JSDocRecordType */: + case 255 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 256 /* JSDocTypeReference */: + case 257 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 257 /* JSDocOptionalType */: + case 258 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 258 /* JSDocFunctionType */: + case 259 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 259 /* JSDocVariadicType */: + case 260 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 260 /* JSDocConstructorType */: + case 261 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 261 /* JSDocThisType */: + case 262 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 255 /* JSDocRecordMember */: + case 256 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 262 /* JSDocComment */: + case 263 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 264 /* JSDocParameterTag */: + case 265 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 265 /* JSDocReturnTag */: + case 266 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 266 /* JSDocTypeTag */: + case 267 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 267 /* JSDocTemplateTag */: + case 268 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -7408,7 +7578,7 @@ var ts; function createSourceFile(fileName, sourceText, languageVersion, setParentNodes) { if (setParentNodes === void 0) { setParentNodes = false; } var start = new Date().getTime(); - var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes); + var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes); ts.parseTime += new Date().getTime() - start; return result; } @@ -7444,7 +7614,7 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(2 /* Latest */, true); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); var disallowInAndDecoratorContext = 1 /* DisallowIn */ | 4 /* Decorator */; var sourceFile; var parseDiagnostics; @@ -7595,9 +7765,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 190 /* VariableStatement */: - case 210 /* FunctionDeclaration */: - case 135 /* Parameter */: + case 191 /* VariableStatement */: + case 211 /* FunctionDeclaration */: + case 136 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7638,7 +7808,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(245 /* SourceFile */, 0); + var sourceFile = createNode(246 /* SourceFile */, /*pos*/ 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; @@ -7792,6 +7962,9 @@ var ts; function scanJsxIdentifier() { return token = scanner.scanJsxIdentifier(); } + function scanJsxText() { + return token = scanner.scanJsxToken(); + } function speculationHelper(callback, isLookAhead) { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). @@ -7823,35 +7996,38 @@ var ts; // was in immediately prior to invoking the callback. The result of invoking the callback // is returned from this function. function lookAhead(callback) { - return speculationHelper(callback, true); + return speculationHelper(callback, /*isLookAhead*/ true); } // Invokes the provided callback. If the callback returns something falsy, then it restores // the parser to the state it was in immediately prior to invoking the callback. If the // callback returns something truthy, then the parser state is not rolled back. The result // of invoking the callback is returned from this function. function tryParse(callback) { - return speculationHelper(callback, false); + return speculationHelper(callback, /*isLookAhead*/ false); } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token === 111 /* YieldKeyword */ && inYieldContext()) { + if (token === 112 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token === 116 /* AwaitKeyword */ && inAwaitContext()) { + if (token === 117 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token > 102 /* LastReservedWord */; + return token > 103 /* LastReservedWord */; } - function parseExpected(kind, diagnosticMessage) { + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } if (token === kind) { - nextToken(); + if (shouldAdvance) { + nextToken(); + } return true; } // Report specific message if provided with one. Otherwise, report generic fallback message. @@ -7887,22 +8063,22 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token === 22 /* SemicolonToken */) { + if (token === 23 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token === 15 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token === 16 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token === 22 /* SemicolonToken */) { + if (token === 23 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(22 /* SemicolonToken */); + return parseExpected(23 /* SemicolonToken */); } } function createNode(kind, pos) { @@ -7950,75 +8126,75 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(66 /* Identifier */); + var node = createNode(67 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token !== 66 /* Identifier */) { + if (token !== 67 /* Identifier */) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(66 /* Identifier */, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); } function parseIdentifierName() { - return createIdentifier(isIdentifierOrKeyword()); + return createIdentifier(ts.tokenIsIdentifierOrKeyword(token)); } function isLiteralPropertyName() { - return isIdentifierOrKeyword() || - token === 8 /* StringLiteral */ || - token === 7 /* NumericLiteral */; + return ts.tokenIsIdentifierOrKeyword(token) || + token === 9 /* StringLiteral */ || + token === 8 /* NumericLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */) { - return parseLiteralNode(true); + if (token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */) { + return parseLiteralNode(/*internName*/ true); } - if (allowComputedPropertyNames && token === 18 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token === 19 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); } function parsePropertyName() { - return parsePropertyNameWorker(true); + return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ true); } function parseSimplePropertyName() { - return parsePropertyNameWorker(false); + return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ false); } function isSimplePropertyName() { - return token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */ || isIdentifierOrKeyword(); + return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || ts.tokenIsIdentifierOrKeyword(token); } function parseComputedPropertyName() { // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(133 /* ComputedPropertyName */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(134 /* ComputedPropertyName */); + parseExpected(19 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 71 /* ConstKeyword */) { + if (token === 72 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 78 /* EnumKeyword */; + return nextToken() === 79 /* EnumKeyword */; } - if (token === 79 /* ExportKeyword */) { + if (token === 80 /* ExportKeyword */) { nextToken(); - if (token === 74 /* DefaultKeyword */) { + if (token === 75 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunction); } - return token !== 36 /* AsteriskToken */ && token !== 14 /* OpenBraceToken */ && canFollowModifier(); + return token !== 37 /* AsteriskToken */ && token !== 15 /* OpenBraceToken */ && canFollowModifier(); } - if (token === 74 /* DefaultKeyword */) { + if (token === 75 /* DefaultKeyword */) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -8028,14 +8204,14 @@ var ts; return ts.isModifier(token) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token === 18 /* OpenBracketToken */ - || token === 14 /* OpenBraceToken */ - || token === 36 /* AsteriskToken */ + return token === 19 /* OpenBracketToken */ + || token === 15 /* OpenBraceToken */ + || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); } function nextTokenIsClassOrFunction() { nextToken(); - return token === 70 /* ClassKeyword */ || token === 84 /* FunctionKeyword */; + return token === 71 /* ClassKeyword */ || token === 85 /* FunctionKeyword */; } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -8053,9 +8229,9 @@ var ts; // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token === 22 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token === 23 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token === 68 /* CaseKeyword */ || token === 74 /* DefaultKeyword */; + return token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; case 4 /* TypeMembers */: return isStartOfTypeMember(); case 5 /* ClassMembers */: @@ -8063,19 +8239,19 @@ var ts; // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token === 22 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token === 23 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token === 18 /* OpenBracketToken */ || isLiteralPropertyName(); + return token === 19 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: - return token === 18 /* OpenBracketToken */ || token === 36 /* AsteriskToken */ || isLiteralPropertyName(); + return token === 19 /* OpenBracketToken */ || token === 37 /* AsteriskToken */ || isLiteralPropertyName(); case 9 /* ObjectBindingElements */: return isLiteralPropertyName(); case 7 /* HeritageClauseElement */: // If we see { } then only consume it as an expression if it is followed by , or { // That way we won't consume the body of a class in its heritage clause. - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -8090,23 +8266,23 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isIdentifierOrPattern(); case 17 /* TypeParameters */: return isIdentifier(); case 11 /* ArgumentExpressions */: case 15 /* ArrayLiteralMembers */: - return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isStartOfExpression(); + return token === 24 /* CommaToken */ || token === 22 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(); case 18 /* TypeArguments */: case 19 /* TupleElementTypes */: - return token === 23 /* CommaToken */ || isStartOfType(); + return token === 24 /* CommaToken */ || isStartOfType(); case 20 /* HeritageClauses */: return isHeritageClause(); case 21 /* ImportOrExportSpecifiers */: - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); case 13 /* JsxAttributes */: - return isIdentifierOrKeyword() || token === 14 /* OpenBraceToken */; + return ts.tokenIsIdentifierOrKeyword(token) || token === 15 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; case 22 /* JSDocFunctionParameters */: @@ -8119,8 +8295,8 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token === 14 /* OpenBraceToken */); - if (nextToken() === 15 /* CloseBraceToken */) { + ts.Debug.assert(token === 15 /* OpenBraceToken */); + if (nextToken() === 16 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -8129,7 +8305,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 23 /* CommaToken */ || next === 14 /* OpenBraceToken */ || next === 80 /* ExtendsKeyword */ || next === 103 /* ImplementsKeyword */; + return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 81 /* ExtendsKeyword */ || next === 104 /* ImplementsKeyword */; } return true; } @@ -8139,11 +8315,11 @@ var ts; } function nextTokenIsIdentifierOrKeyword() { nextToken(); - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 103 /* ImplementsKeyword */ || - token === 80 /* ExtendsKeyword */) { + if (token === 104 /* ImplementsKeyword */ || + token === 81 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -8167,43 +8343,43 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 21 /* ImportOrExportSpecifiers */: - return token === 15 /* CloseBraceToken */; + return token === 16 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token === 15 /* CloseBraceToken */ || token === 68 /* CaseKeyword */ || token === 74 /* DefaultKeyword */; + return token === 16 /* CloseBraceToken */ || token === 69 /* CaseKeyword */ || token === 75 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token === 14 /* OpenBraceToken */ || token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 17 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token === 26 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */ || token === 15 /* OpenBraceToken */ || token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token === 17 /* CloseParenToken */ || token === 22 /* SemicolonToken */; + return token === 18 /* CloseParenToken */ || token === 23 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 19 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token === 19 /* CloseBracketToken */; + return token === 20 /* CloseBracketToken */; case 16 /* Parameters */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token === 17 /* CloseParenToken */ || token === 19 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token === 18 /* CloseParenToken */ || token === 20 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 18 /* TypeArguments */: // Tokens other than '>' are here for better error recovery - return token === 26 /* GreaterThanToken */ || token === 16 /* OpenParenToken */; + return token === 27 /* GreaterThanToken */ || token === 17 /* OpenParenToken */; case 20 /* HeritageClauses */: - return token === 14 /* OpenBraceToken */ || token === 15 /* CloseBraceToken */; + return token === 15 /* OpenBraceToken */ || token === 16 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token === 26 /* GreaterThanToken */ || token === 37 /* SlashToken */; + return token === 27 /* GreaterThanToken */ || token === 38 /* SlashToken */; case 14 /* JsxChildren */: - return token === 24 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); case 22 /* JSDocFunctionParameters */: - return token === 17 /* CloseParenToken */ || token === 52 /* ColonToken */ || token === 15 /* CloseBraceToken */; + return token === 18 /* CloseParenToken */ || token === 53 /* ColonToken */ || token === 16 /* CloseBraceToken */; case 23 /* JSDocTypeArguments */: - return token === 26 /* GreaterThanToken */ || token === 15 /* CloseBraceToken */; + return token === 27 /* GreaterThanToken */ || token === 16 /* CloseBraceToken */; case 25 /* JSDocTupleTypes */: - return token === 19 /* CloseBracketToken */ || token === 15 /* CloseBraceToken */; + return token === 20 /* CloseBracketToken */ || token === 16 /* CloseBraceToken */; case 24 /* JSDocRecordMembers */: - return token === 15 /* CloseBraceToken */; + return token === 16 /* CloseBraceToken */; } } function isVariableDeclaratorListTerminator() { @@ -8221,7 +8397,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -8231,7 +8407,7 @@ var ts; function isInSomeParsingContext() { for (var kind = 0; kind < 26 /* Count */; kind++) { if (parsingContext & (1 << kind)) { - if (isListElement(kind, true) || isListTerminator(kind)) { + if (isListElement(kind, /* inErrorRecovery */ true) || isListTerminator(kind)) { return true; } } @@ -8245,7 +8421,7 @@ var ts; var result = []; result.pos = getNodePos(); while (!isListTerminator(kind)) { - if (isListElement(kind, false)) { + if (isListElement(kind, /* inErrorRecovery */ false)) { var element = parseListElement(kind, parseElement); result.push(element); continue; @@ -8385,20 +8561,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 141 /* Constructor */: - case 146 /* IndexSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 138 /* PropertyDeclaration */: - case 188 /* SemicolonClassElement */: + case 142 /* Constructor */: + case 147 /* IndexSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 189 /* SemicolonClassElement */: return true; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 66 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 118 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 67 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 119 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -8407,8 +8583,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: return true; } } @@ -8417,58 +8593,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 190 /* VariableStatement */: - case 189 /* Block */: - case 193 /* IfStatement */: - case 192 /* ExpressionStatement */: - case 205 /* ThrowStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 191 /* EmptyStatement */: - case 206 /* TryStatement */: - case 204 /* LabeledStatement */: - case 194 /* DoStatement */: - case 207 /* DebuggerStatement */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 225 /* ExportDeclaration */: - case 224 /* ExportAssignment */: - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 213 /* TypeAliasDeclaration */: + case 211 /* FunctionDeclaration */: + case 191 /* VariableStatement */: + case 190 /* Block */: + case 194 /* IfStatement */: + case 193 /* ExpressionStatement */: + case 206 /* ThrowStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 192 /* EmptyStatement */: + case 207 /* TryStatement */: + case 205 /* LabeledStatement */: + case 195 /* DoStatement */: + case 208 /* DebuggerStatement */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + case 225 /* ExportAssignment */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 214 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 244 /* EnumMember */; + return node.kind === 245 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 145 /* ConstructSignature */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: - case 137 /* PropertySignature */: - case 144 /* CallSignature */: + case 146 /* ConstructSignature */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: + case 138 /* PropertySignature */: + case 145 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 208 /* VariableDeclaration */) { + if (node.kind !== 209 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -8489,7 +8665,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 135 /* Parameter */) { + if (node.kind !== 136 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -8544,10 +8720,10 @@ var ts; result.pos = getNodePos(); var commaStart = -1; // Meaning the previous token was not a comma while (true) { - if (isListElement(kind, false)) { + if (isListElement(kind, /* inErrorRecovery */ false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(23 /* CommaToken */)) { + if (parseOptional(24 /* CommaToken */)) { continue; } commaStart = -1; // Back to the state where the last token was not a comma @@ -8556,13 +8732,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(23 /* CommaToken */); + parseExpected(24 /* CommaToken */); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimeter && token === 22 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimeter && token === 23 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -8605,8 +8781,8 @@ var ts; // The allowReservedWords parameter controls whether reserved words are permitted after the first dot function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(20 /* DotToken */)) { - var node = createNode(132 /* QualifiedName */, entity.pos); + while (parseOptional(21 /* DotToken */)) { + var node = createNode(133 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -8633,40 +8809,40 @@ var ts; // the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword". // In the first case though, ASI will not take effect because there is not a // line terminator after the identifier or keyword. - if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { + if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(66 /* Identifier */, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(67 /* Identifier */, /*reportAtCurrentToken*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(180 /* TemplateExpression */); + var template = createNode(181 /* TemplateExpression */); template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 11 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; templateSpans.pos = getNodePos(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 12 /* TemplateMiddle */); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 13 /* TemplateMiddle */); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(187 /* TemplateSpan */); + var span = createNode(188 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseLiteralNode(); } else { - literal = parseExpectedToken(13 /* TemplateTail */, false, ts.Diagnostics._0_expected, ts.tokenToString(15 /* CloseBraceToken */)); + literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -8690,7 +8866,7 @@ var ts; // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - if (node.kind === 7 /* NumericLiteral */ + if (node.kind === 8 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { node.flags |= 65536 /* OctalLiteral */; @@ -8699,31 +8875,31 @@ var ts; } // TYPES function parseTypeReferenceOrTypePredicate() { - var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 66 /* Identifier */ && token === 121 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); + if (typeName.kind === 67 /* Identifier */ && token === 122 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(147 /* TypePredicate */, typeName.pos); + var node_1 = createNode(148 /* TypePredicate */, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(148 /* TypeReference */, typeName.pos); + var node = createNode(149 /* TypeReference */, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && token === 25 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(151 /* TypeQuery */); - parseExpected(98 /* TypeOfKeyword */); - node.exprName = parseEntityName(true); + var node = createNode(152 /* TypeQuery */); + parseExpected(99 /* TypeOfKeyword */); + node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(134 /* TypeParameter */); + var node = createNode(135 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(80 /* ExtendsKeyword */)) { + if (parseOptional(81 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -8745,20 +8921,20 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token === 24 /* LessThanToken */) { - return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (token === 25 /* LessThanToken */) { + return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(52 /* ColonToken */)) { - return token === 8 /* StringLiteral */ - ? parseLiteralNode(true) + if (parseOptional(53 /* ColonToken */)) { + return token === 9 /* StringLiteral */ + ? parseLiteralNode(/*internName*/ true) : parseType(); } return undefined; } function isStartOfParameter() { - return token === 21 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 53 /* AtToken */; + return token === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 54 /* AtToken */; } function setModifiers(node, modifiers) { if (modifiers) { @@ -8767,10 +8943,10 @@ var ts; } } function parseParameter() { - var node = createNode(135 /* Parameter */); + var node = createNode(136 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -8785,9 +8961,9 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(51 /* QuestionToken */); + node.questionToken = parseOptionalToken(52 /* QuestionToken */); node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(true); + node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not // a grammar error because the grammar allows arbitrary call signatures in // an ambient context. @@ -8802,10 +8978,10 @@ var ts; return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); } function parseParameterInitializer() { - return parseInitializer(true); + return parseInitializer(/*inParameter*/ true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 33 /* EqualsGreaterThanToken */; + var returnTokenRequired = returnToken === 34 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -8830,7 +9006,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (parseExpected(16 /* OpenParenToken */)) { + if (parseExpected(17 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -8838,7 +9014,7 @@ var ts; var result = parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(17 /* CloseParenToken */) && requireCompleteParameterList) { + if (!parseExpected(18 /* CloseParenToken */) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return // undefined here. return undefined; @@ -8853,7 +9029,7 @@ var ts; function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(23 /* CommaToken */)) { + if (parseOptional(24 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -8861,15 +9037,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 145 /* ConstructSignature */) { - parseExpected(89 /* NewKeyword */); + if (kind === 146 /* ConstructSignature */) { + parseExpected(90 /* NewKeyword */); } - fillSignature(52 /* ColonToken */, false, false, false, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return finishNode(node); } function isIndexSignature() { - if (token !== 18 /* OpenBracketToken */) { + if (token !== 19 /* OpenBracketToken */) { return false; } return lookAhead(isUnambiguouslyIndexSignature); @@ -8892,7 +9068,7 @@ var ts; // [] // nextToken(); - if (token === 21 /* DotDotDotToken */ || token === 19 /* CloseBracketToken */) { + if (token === 22 /* DotDotDotToken */ || token === 20 /* CloseBracketToken */) { return true; } if (ts.isModifier(token)) { @@ -8911,24 +9087,24 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token === 52 /* ColonToken */ || token === 23 /* CommaToken */) { + if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token !== 51 /* QuestionToken */) { + if (token !== 52 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token === 52 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; + return token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || token === 20 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(146 /* IndexSignature */, fullStart); + var node = createNode(147 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -8936,19 +9112,19 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { - var method = createNode(139 /* MethodSignature */, fullStart); + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { + var method = createNode(140 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(52 /* ColonToken */, false, false, false, method); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(137 /* PropertySignature */, fullStart); + var property = createNode(138 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -8958,9 +9134,9 @@ var ts; } function isStartOfTypeMember() { switch (token) { - case 16 /* OpenParenToken */: - case 24 /* LessThanToken */: - case 18 /* OpenBracketToken */: + case 17 /* OpenParenToken */: + case 25 /* LessThanToken */: + case 19 /* OpenBracketToken */: return true; default: if (ts.isModifier(token)) { @@ -8980,29 +9156,29 @@ var ts; } function isTypeMemberWithLiteralPropertyName() { nextToken(); - return token === 16 /* OpenParenToken */ || - token === 24 /* LessThanToken */ || - token === 51 /* QuestionToken */ || - token === 52 /* ColonToken */ || + return token === 17 /* OpenParenToken */ || + token === 25 /* LessThanToken */ || + token === 52 /* QuestionToken */ || + token === 53 /* ColonToken */ || canParseSemicolon(); } function parseTypeMember() { switch (token) { - case 16 /* OpenParenToken */: - case 24 /* LessThanToken */: - return parseSignatureMember(144 /* CallSignature */); - case 18 /* OpenBracketToken */: + case 17 /* OpenParenToken */: + case 25 /* LessThanToken */: + return parseSignatureMember(145 /* CallSignature */); + case 19 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() - ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) + ? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined) : parsePropertyOrMethodSignature(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(145 /* ConstructSignature */); + return parseSignatureMember(146 /* ConstructSignature */); } // fall through. - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: return parsePropertyOrMethodSignature(); default: // Index declaration as allowed as a type member. But as per the grammar, @@ -9017,7 +9193,7 @@ var ts; return result; } } - if (isIdentifierOrKeyword()) { + if (ts.tokenIsIdentifierOrKeyword(token)) { return parsePropertyOrMethodSignature(); } } @@ -9032,18 +9208,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */; + return token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(152 /* TypeLiteral */); + var node = createNode(153 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(14 /* OpenBraceToken */)) { + if (parseExpected(15 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { members = createMissingList(); @@ -9051,48 +9227,48 @@ var ts; return members; } function parseTupleType() { - var node = createNode(154 /* TupleType */); - node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + var node = createNode(155 /* TupleType */); + node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(157 /* ParenthesizedType */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(158 /* ParenthesizedType */); + parseExpected(17 /* OpenParenToken */); node.type = parseType(); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 150 /* ConstructorType */) { - parseExpected(89 /* NewKeyword */); + if (kind === 151 /* ConstructorType */) { + parseExpected(90 /* NewKeyword */); } - fillSignature(33 /* EqualsGreaterThanToken */, false, false, false, node); + fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token === 20 /* DotToken */ ? undefined : node; + return token === 21 /* DotToken */ ? undefined : node; } function parseNonArrayType() { switch (token) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return parseTokenNode(); - case 98 /* TypeOfKeyword */: + case 99 /* TypeOfKeyword */: return parseTypeQuery(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseTypeLiteral(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseTupleType(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseParenthesizedType(); default: return parseTypeReferenceOrTypePredicate(); @@ -9100,19 +9276,19 @@ var ts; } function isStartOfType() { switch (token) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: - case 98 /* TypeOfKeyword */: - case 14 /* OpenBraceToken */: - case 18 /* OpenBracketToken */: - case 24 /* LessThanToken */: - case 89 /* NewKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: + case 99 /* TypeOfKeyword */: + case 15 /* OpenBraceToken */: + case 19 /* OpenBracketToken */: + case 25 /* LessThanToken */: + case 90 /* NewKeyword */: return true; - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -9122,13 +9298,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token === 17 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + return token === 18 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(18 /* OpenBracketToken */)) { - parseExpected(19 /* CloseBracketToken */); - var node = createNode(153 /* ArrayType */, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { + parseExpected(20 /* CloseBracketToken */); + var node = createNode(154 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -9150,28 +9326,28 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(156 /* IntersectionType */, parseArrayTypeOrHigher, 44 /* AmpersandToken */); + return parseUnionOrIntersectionType(157 /* IntersectionType */, parseArrayTypeOrHigher, 45 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(155 /* UnionType */, parseIntersectionTypeOrHigher, 45 /* BarToken */); + return parseUnionOrIntersectionType(156 /* UnionType */, parseIntersectionTypeOrHigher, 46 /* BarToken */); } function isStartOfFunctionType() { - if (token === 24 /* LessThanToken */) { + if (token === 25 /* LessThanToken */) { return true; } - return token === 16 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token === 17 /* CloseParenToken */ || token === 21 /* DotDotDotToken */) { + if (token === 18 /* CloseParenToken */ || token === 22 /* DotDotDotToken */) { // ( ) // ( ... return true; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 52 /* ColonToken */ || token === 23 /* CommaToken */ || - token === 51 /* QuestionToken */ || token === 54 /* EqualsToken */ || + if (token === 53 /* ColonToken */ || token === 24 /* CommaToken */ || + token === 52 /* QuestionToken */ || token === 55 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { // ( id : // ( id , @@ -9180,9 +9356,9 @@ var ts; // ( modifier id return true; } - if (token === 17 /* CloseParenToken */) { + if (token === 18 /* CloseParenToken */) { nextToken(); - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { // ( id ) => return true; } @@ -9197,37 +9373,37 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(149 /* FunctionType */); + return parseFunctionOrConstructorType(150 /* FunctionType */); } - if (token === 89 /* NewKeyword */) { - return parseFunctionOrConstructorType(150 /* ConstructorType */); + if (token === 90 /* NewKeyword */) { + return parseFunctionOrConstructorType(151 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(52 /* ColonToken */) ? parseType() : undefined; + return parseOptional(53 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token) { - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 11 /* TemplateHead */: - case 16 /* OpenParenToken */: - case 18 /* OpenBracketToken */: - case 14 /* OpenBraceToken */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 89 /* NewKeyword */: - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - case 66 /* Identifier */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* TemplateHead */: + case 17 /* OpenParenToken */: + case 19 /* OpenBracketToken */: + case 15 /* OpenBraceToken */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 90 /* NewKeyword */: + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + case 67 /* Identifier */: return true; default: return isIdentifier(); @@ -9238,18 +9414,18 @@ var ts; return true; } switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 75 /* DeleteKeyword */: - case 98 /* TypeOfKeyword */: - case 100 /* VoidKeyword */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: - case 24 /* LessThanToken */: - case 116 /* AwaitKeyword */: - case 111 /* YieldKeyword */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 76 /* DeleteKeyword */: + case 99 /* TypeOfKeyword */: + case 101 /* VoidKeyword */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: + case 25 /* LessThanToken */: + case 117 /* AwaitKeyword */: + case 112 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -9267,10 +9443,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token !== 14 /* OpenBraceToken */ && - token !== 84 /* FunctionKeyword */ && - token !== 70 /* ClassKeyword */ && - token !== 53 /* AtToken */ && + return token !== 15 /* OpenBraceToken */ && + token !== 85 /* FunctionKeyword */ && + token !== 71 /* ClassKeyword */ && + token !== 54 /* AtToken */ && isStartOfExpression(); } function allowInAndParseExpression() { @@ -9287,7 +9463,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(23 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(24 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -9296,7 +9472,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 54 /* EqualsToken */) { + if (token !== 55 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. @@ -9305,7 +9481,7 @@ var ts; // it's more likely that a { would be a allowed (as an object literal). While this // is also allowed for parameters, the risk is that we consume the { as an object // literal when it really will be for the block following the parameter. - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14 /* OpenBraceToken */) || !isStartOfExpression()) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 15 /* OpenBraceToken */) || !isStartOfExpression()) { // preceding line break, open brace in a parameter (likely a function body) or current token is not an expression - // do not try to parse initializer return undefined; @@ -9313,7 +9489,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -9347,11 +9523,11 @@ var ts; // Otherwise, we try to parse out the conditional expression bit. We want to allow any // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. - var expr = parseBinaryExpressionOrHigher(0); + var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 66 /* Identifier */ && token === 33 /* EqualsGreaterThanToken */) { + if (expr.kind === 67 /* Identifier */ && token === 34 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -9367,7 +9543,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 111 /* YieldKeyword */) { + if (token === 112 /* YieldKeyword */) { // If we have a 'yield' keyword, and htis is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -9396,15 +9572,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(181 /* YieldExpression */); + var node = createNode(182 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token === 36 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + (token === 37 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9415,16 +9591,16 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 33 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(171 /* ArrowFunction */, identifier.pos); - var parameter = createNode(135 /* Parameter */, identifier.pos); + ts.Debug.assert(token === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(172 /* ArrowFunction */, identifier.pos); + var parameter = createNode(136 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(33 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(false); + node.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); + node.body = parseArrowFunctionExpressionBody(/*isAsync*/ false); return finishNode(node); } function tryParseParenthesizedArrowFunctionExpression() { @@ -9438,7 +9614,7 @@ var ts; // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. var arrowFunction = triState === 1 /* True */ - ? parseParenthesizedArrowFunctionExpressionHead(true) + ? parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ true) : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); if (!arrowFunction) { // Didn't appear to actually be a parenthesized arrow function. Just bail out. @@ -9448,8 +9624,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(33 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 33 /* EqualsGreaterThanToken */ || lastToken === 14 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 34 /* EqualsGreaterThanToken */ || lastToken === 15 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -9459,10 +9635,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */ || token === 115 /* AsyncKeyword */) { + if (token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */ || token === 116 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 33 /* EqualsGreaterThanToken */) { + if (token === 34 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -9472,28 +9648,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token === 115 /* AsyncKeyword */) { + if (token === 116 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token !== 16 /* OpenParenToken */ && token !== 24 /* LessThanToken */) { + if (token !== 17 /* OpenParenToken */ && token !== 25 /* LessThanToken */) { return 0 /* False */; } } var first = token; var second = nextToken(); - if (first === 16 /* OpenParenToken */) { - if (second === 17 /* CloseParenToken */) { + if (first === 17 /* OpenParenToken */) { + if (second === 18 /* CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 33 /* EqualsGreaterThanToken */: - case 52 /* ColonToken */: - case 14 /* OpenBraceToken */: + case 34 /* EqualsGreaterThanToken */: + case 53 /* ColonToken */: + case 15 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -9505,12 +9681,12 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 18 /* OpenBracketToken */ || second === 14 /* OpenBraceToken */) { + if (second === 19 /* OpenBracketToken */ || second === 15 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 21 /* DotDotDotToken */) { + if (second === 22 /* DotDotDotToken */) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, @@ -9523,7 +9699,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 52 /* ColonToken */) { + if (nextToken() === 53 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -9531,7 +9707,7 @@ var ts; return 2 /* Unknown */; } else { - ts.Debug.assert(first === 24 /* LessThanToken */); + ts.Debug.assert(first === 25 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -9541,17 +9717,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 80 /* ExtendsKeyword */) { + if (third === 81 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 54 /* EqualsToken */: - case 26 /* GreaterThanToken */: + case 55 /* EqualsToken */: + case 27 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 23 /* CommaToken */) { + else if (third === 24 /* CommaToken */) { return true; } return false; @@ -9566,10 +9742,10 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(false); + return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(171 /* ArrowFunction */); + var node = createNode(172 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); var isAsync = !!(node.flags & 512 /* Async */); // Arrow functions are never generators. @@ -9579,7 +9755,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(52 /* ColonToken */, false, isAsync, !allowAmbiguity, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { return undefined; @@ -9592,19 +9768,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token !== 33 /* EqualsGreaterThanToken */ && token !== 14 /* OpenBraceToken */) { + if (!allowAmbiguity && token !== 34 /* EqualsGreaterThanToken */ && token !== 15 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token === 14 /* OpenBraceToken */) { - return parseFunctionBlock(false, isAsync, false); + if (token === 15 /* OpenBraceToken */) { + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } - if (token !== 22 /* SemicolonToken */ && - token !== 84 /* FunctionKeyword */ && - token !== 70 /* ClassKeyword */ && + if (token !== 23 /* SemicolonToken */ && + token !== 85 /* FunctionKeyword */ && + token !== 71 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -9621,7 +9797,7 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. - return parseFunctionBlock(false, isAsync, true); + return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ true); } return isAsync ? doInAwaitContext(parseAssignmentExpressionOrHigher) @@ -9629,17 +9805,17 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(51 /* QuestionToken */); + var questionToken = parseOptionalToken(52 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(179 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(180 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(52 /* ColonToken */, false, ts.Diagnostics._0_expected, ts.tokenToString(52 /* ColonToken */)); + node.colonToken = parseExpectedToken(53 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(53 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9648,7 +9824,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 87 /* InKeyword */ || t === 131 /* OfKeyword */; + return t === 88 /* InKeyword */ || t === 132 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9660,10 +9836,10 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 87 /* InKeyword */ && inDisallowInContext()) { + if (token === 88 /* InKeyword */ && inDisallowInContext()) { break; } - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -9684,46 +9860,46 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 87 /* InKeyword */) { + if (inDisallowInContext() && token === 88 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 50 /* BarBarToken */: + case 51 /* BarBarToken */: return 1; - case 49 /* AmpersandAmpersandToken */: + case 50 /* AmpersandAmpersandToken */: return 2; - case 45 /* BarToken */: + case 46 /* BarToken */: return 3; - case 46 /* CaretToken */: + case 47 /* CaretToken */: return 4; - case 44 /* AmpersandToken */: + case 45 /* AmpersandToken */: return 5; - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: return 6; - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: - case 88 /* InstanceOfKeyword */: - case 87 /* InKeyword */: - case 113 /* AsKeyword */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: + case 89 /* InstanceOfKeyword */: + case 88 /* InKeyword */: + case 114 /* AsKeyword */: return 7; - case 41 /* LessThanLessThanToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: + case 42 /* LessThanLessThanToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 34 /* PlusToken */: - case 35 /* MinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: return 9; - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: return 10; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -9731,45 +9907,45 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(178 /* BinaryExpression */, left.pos); + var node = createNode(179 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(186 /* AsExpression */, left.pos); + var node = createNode(187 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(176 /* PrefixUnaryExpression */); + var node = createNode(177 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(172 /* DeleteExpression */); + var node = createNode(173 /* DeleteExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(173 /* TypeOfExpression */); + var node = createNode(174 /* TypeOfExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(174 /* VoidExpression */); + var node = createNode(175 /* VoidExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function isAwaitExpression() { - if (token === 116 /* AwaitKeyword */) { + if (token === 117 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -9779,7 +9955,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(175 /* AwaitExpression */); + var node = createNode(176 /* AwaitExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); @@ -9789,25 +9965,25 @@ var ts; return parseAwaitExpression(); } switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: return parsePrefixUnaryExpression(); - case 75 /* DeleteKeyword */: + case 76 /* DeleteKeyword */: return parseDeleteExpression(); - case 98 /* TypeOfKeyword */: + case 99 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return parseVoidExpression(); - case 24 /* LessThanToken */: + case 25 /* LessThanToken */: if (sourceFile.languageVariant !== 1 /* JSX */) { return parseTypeAssertion(); } if (lookAhead(nextTokenIsIdentifierOrKeyword)) { - return parseJsxElementOrSelfClosingElement(); + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); } // Fall through default: @@ -9817,8 +9993,8 @@ var ts; function parsePostfixExpressionOrHigher() { var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 39 /* PlusPlusToken */ || token === 40 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(177 /* PostfixUnaryExpression */, expression.pos); + if ((token === 40 /* PlusPlusToken */ || token === 41 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(178 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -9857,7 +10033,7 @@ var ts; // the last two CallExpression productions. Or we have a MemberExpression which either // completes the LeftHandSideExpression, or starts the beginning of the first four // CallExpression productions. - var expression = token === 92 /* SuperKeyword */ + var expression = token === 93 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -9917,47 +10093,47 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token === 16 /* OpenParenToken */ || token === 20 /* DotToken */) { + if (token === 17 /* OpenParenToken */ || token === 21 /* DotToken */ || token === 19 /* OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(163 /* PropertyAccessExpression */, expression.pos); + var node = createNode(164 /* PropertyAccessExpression */, expression.pos); node.expression = expression; - node.dotToken = parseExpectedToken(20 /* DotToken */, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); - node.name = parseRightSideOfDot(true); + node.dotToken = parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } - function parseJsxElementOrSelfClosingElement() { - var opening = parseJsxOpeningOrSelfClosingElement(); - if (opening.kind === 232 /* JsxOpeningElement */) { - var node = createNode(230 /* JsxElement */, opening.pos); + function parseJsxElementOrSelfClosingElement(inExpressionContext) { + var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); + if (opening.kind === 233 /* JsxOpeningElement */) { + var node = createNode(231 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); - node.closingElement = parseJsxClosingElement(); + node.closingElement = parseJsxClosingElement(inExpressionContext); return finishNode(node); } else { - ts.Debug.assert(opening.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 232 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements return opening; } } function parseJsxText() { - var node = createNode(233 /* JsxText */, scanner.getStartPos()); + var node = createNode(234 /* JsxText */, scanner.getStartPos()); token = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token) { - case 233 /* JsxText */: + case 234 /* JsxText */: return parseJsxText(); - case 14 /* OpenBraceToken */: - return parseJsxExpression(); - case 24 /* LessThanToken */: - return parseJsxElementOrSelfClosingElement(); + case 15 /* OpenBraceToken */: + return parseJsxExpression(/*inExpressionContext*/ false); + case 25 /* LessThanToken */: + return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); } - ts.Debug.fail('Unknown JSX child kind ' + token); + ts.Debug.fail("Unknown JSX child kind " + token); } function parseJsxChildren(openingTagName) { var result = []; @@ -9966,7 +10142,7 @@ var ts; parsingContext |= 1 << 14 /* JsxChildren */; while (true) { token = scanner.reScanJsxToken(); - if (token === 25 /* LessThanSlashToken */) { + if (token === 26 /* LessThanSlashToken */) { break; } else if (token === 1 /* EndOfFileToken */) { @@ -9979,19 +10155,29 @@ var ts; parsingContext = saveParsingContext; return result; } - function parseJsxOpeningOrSelfClosingElement() { + function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(24 /* LessThanToken */); + parseExpected(25 /* LessThanToken */); var tagName = parseJsxElementName(); var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); var node; - if (parseOptional(26 /* GreaterThanToken */)) { - node = createNode(232 /* JsxOpeningElement */, fullStart); + if (token === 27 /* GreaterThanToken */) { + // Closing tag, so scan the immediately-following text with the JSX scanning instead + // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate + // scanning errors + node = createNode(233 /* JsxOpeningElement */, fullStart); + scanJsxText(); } else { - parseExpected(37 /* SlashToken */); - parseExpected(26 /* GreaterThanToken */); - node = createNode(231 /* JsxSelfClosingElement */, fullStart); + parseExpected(38 /* SlashToken */); + if (inExpressionContext) { + parseExpected(27 /* GreaterThanToken */); + } + else { + parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } + node = createNode(232 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -10000,98 +10186,110 @@ var ts; function parseJsxElementName() { scanJsxIdentifier(); var elementName = parseIdentifierName(); - while (parseOptional(20 /* DotToken */)) { + while (parseOptional(21 /* DotToken */)) { scanJsxIdentifier(); - var node = createNode(132 /* QualifiedName */, elementName.pos); + var node = createNode(133 /* QualifiedName */, elementName.pos); node.left = elementName; node.right = parseIdentifierName(); elementName = finishNode(node); } return elementName; } - function parseJsxExpression() { - var node = createNode(237 /* JsxExpression */); - parseExpected(14 /* OpenBraceToken */); - if (token !== 15 /* CloseBraceToken */) { + function parseJsxExpression(inExpressionContext) { + var node = createNode(238 /* JsxExpression */); + parseExpected(15 /* OpenBraceToken */); + if (token !== 16 /* CloseBraceToken */) { node.expression = parseExpression(); } - parseExpected(15 /* CloseBraceToken */); + if (inExpressionContext) { + parseExpected(16 /* CloseBraceToken */); + } + else { + parseExpected(16 /* CloseBraceToken */, /*message*/ undefined, /*advance*/ false); + scanJsxText(); + } return finishNode(node); } function parseJsxAttribute() { - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(235 /* JsxAttribute */); + var node = createNode(236 /* JsxAttribute */); node.name = parseIdentifierName(); - if (parseOptional(54 /* EqualsToken */)) { + if (parseOptional(55 /* EqualsToken */)) { switch (token) { - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: node.initializer = parseLiteralNode(); break; default: - node.initializer = parseJsxExpression(); + node.initializer = parseJsxExpression(/*inExpressionContext*/ true); break; } } return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(236 /* JsxSpreadAttribute */); - parseExpected(14 /* OpenBraceToken */); - parseExpected(21 /* DotDotDotToken */); + var node = createNode(237 /* JsxSpreadAttribute */); + parseExpected(15 /* OpenBraceToken */); + parseExpected(22 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } - function parseJsxClosingElement() { - var node = createNode(234 /* JsxClosingElement */); - parseExpected(25 /* LessThanSlashToken */); + function parseJsxClosingElement(inExpressionContext) { + var node = createNode(235 /* JsxClosingElement */); + parseExpected(26 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); - parseExpected(26 /* GreaterThanToken */); + if (inExpressionContext) { + parseExpected(27 /* GreaterThanToken */); + } + else { + parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*advance*/ false); + scanJsxText(); + } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(168 /* TypeAssertionExpression */); - parseExpected(24 /* LessThanToken */); + var node = createNode(169 /* TypeAssertionExpression */); + parseExpected(25 /* LessThanToken */); node.type = parseType(); - parseExpected(26 /* GreaterThanToken */); + parseExpected(27 /* GreaterThanToken */); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(20 /* DotToken */); + var dotToken = parseOptionalToken(21 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(163 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(164 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; - propertyAccess.name = parseRightSideOfDot(true); + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(18 /* OpenBracketToken */)) { - var indexedAccess = createNode(164 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { + var indexedAccess = createNode(165 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. - if (token !== 19 /* CloseBracketToken */) { + if (token !== 20 /* CloseBracketToken */) { indexedAccess.argumentExpression = allowInAnd(parseExpression); - if (indexedAccess.argumentExpression.kind === 8 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 7 /* NumericLiteral */) { + if (indexedAccess.argumentExpression.kind === 9 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 8 /* NumericLiteral */) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } - if (token === 10 /* NoSubstitutionTemplateLiteral */ || token === 11 /* TemplateHead */) { - var tagExpression = createNode(167 /* TaggedTemplateExpression */, expression.pos); + if (token === 11 /* NoSubstitutionTemplateLiteral */ || token === 12 /* TemplateHead */) { + var tagExpression = createNode(168 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; - tagExpression.template = token === 10 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token === 11 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -10103,7 +10301,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token === 24 /* LessThanToken */) { + if (token === 25 /* LessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the @@ -10112,15 +10310,15 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(165 /* CallExpression */, expression.pos); + var callExpr = createNode(166 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token === 16 /* OpenParenToken */) { - var callExpr = createNode(165 /* CallExpression */, expression.pos); + else if (token === 17 /* OpenParenToken */) { + var callExpr = createNode(166 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -10130,17 +10328,17 @@ var ts; } } function parseArgumentList() { - parseExpected(16 /* OpenParenToken */); + parseExpected(17 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(24 /* LessThanToken */)) { + if (!parseOptional(25 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); - if (!parseExpected(26 /* GreaterThanToken */)) { + if (!parseExpected(27 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; } @@ -10152,32 +10350,32 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token) { - case 16 /* OpenParenToken */: // foo( + case 17 /* OpenParenToken */: // foo( // this case are the only case where this token can legally follow a type argument // list. So we definitely want to treat this as a type arg list. - case 20 /* DotToken */: // foo. - case 17 /* CloseParenToken */: // foo) - case 19 /* CloseBracketToken */: // foo] - case 52 /* ColonToken */: // foo: - case 22 /* SemicolonToken */: // foo; - case 51 /* QuestionToken */: // foo? - case 29 /* EqualsEqualsToken */: // foo == - case 31 /* EqualsEqualsEqualsToken */: // foo === - case 30 /* ExclamationEqualsToken */: // foo != - case 32 /* ExclamationEqualsEqualsToken */: // foo !== - case 49 /* AmpersandAmpersandToken */: // foo && - case 50 /* BarBarToken */: // foo || - case 46 /* CaretToken */: // foo ^ - case 44 /* AmpersandToken */: // foo & - case 45 /* BarToken */: // foo | - case 15 /* CloseBraceToken */: // foo } + case 21 /* DotToken */: // foo. + case 18 /* CloseParenToken */: // foo) + case 20 /* CloseBracketToken */: // foo] + case 53 /* ColonToken */: // foo: + case 23 /* SemicolonToken */: // foo; + case 52 /* QuestionToken */: // foo? + case 30 /* EqualsEqualsToken */: // foo == + case 32 /* EqualsEqualsEqualsToken */: // foo === + case 31 /* ExclamationEqualsToken */: // foo != + case 33 /* ExclamationEqualsEqualsToken */: // foo !== + case 50 /* AmpersandAmpersandToken */: // foo && + case 51 /* BarBarToken */: // foo || + case 47 /* CaretToken */: // foo ^ + case 45 /* AmpersandToken */: // foo & + case 46 /* BarToken */: // foo | + case 16 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. return true; - case 23 /* CommaToken */: // foo, - case 14 /* OpenBraceToken */: // foo { + case 24 /* CommaToken */: // foo, + case 15 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -10188,23 +10386,23 @@ var ts; } function parsePrimaryExpression() { switch (token) { - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: - case 90 /* NullKeyword */: - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: + case 91 /* NullKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: return parseTokenNode(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseParenthesizedExpression(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 115 /* AsyncKeyword */: + case 116 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -10212,59 +10410,59 @@ var ts; break; } return parseFunctionExpression(); - case 70 /* ClassKeyword */: + case 71 /* ClassKeyword */: return parseClassExpression(); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseFunctionExpression(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: return parseNewExpression(); - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - if (reScanSlashToken() === 9 /* RegularExpressionLiteral */) { + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 11 /* TemplateHead */: + case 12 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(169 /* ParenthesizedExpression */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(170 /* ParenthesizedExpression */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(182 /* SpreadElementExpression */); - parseExpected(21 /* DotDotDotToken */); + var node = createNode(183 /* SpreadElementExpression */); + parseExpected(22 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token === 21 /* DotDotDotToken */ ? parseSpreadElement() : - token === 23 /* CommaToken */ ? createNode(184 /* OmittedExpression */) : + return token === 22 /* DotDotDotToken */ ? parseSpreadElement() : + token === 24 /* CommaToken */ ? createNode(185 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(161 /* ArrayLiteralExpression */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(162 /* ArrayLiteralExpression */); + parseExpected(19 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 2048 /* MultiLine */; node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(120 /* GetKeyword */)) { - return parseAccessorDeclaration(142 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(121 /* GetKeyword */)) { + return parseAccessorDeclaration(143 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(126 /* SetKeyword */)) { - return parseAccessorDeclaration(143 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(127 /* SetKeyword */)) { + return parseAccessorDeclaration(144 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -10276,39 +10474,39 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } // Parse to check if it is short-hand property assignment or normal property assignment - if ((token === 23 /* CommaToken */ || token === 15 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(243 /* ShorthandPropertyAssignment */, fullStart); + if ((token === 24 /* CommaToken */ || token === 16 /* CloseBraceToken */) && tokenIsIdentifier) { + var shorthandDeclaration = createNode(244 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(242 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(243 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(162 /* ObjectLiteralExpression */); - parseExpected(14 /* OpenBraceToken */); + var node = createNode(163 /* ObjectLiteralExpression */); + parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 2048 /* MultiLine */; } - node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, true); - parseExpected(15 /* CloseBraceToken */); + node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -10321,10 +10519,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(170 /* FunctionExpression */); + var node = createNode(171 /* FunctionExpression */); setModifiers(node, parseModifiers()); - parseExpected(84 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + parseExpected(85 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); node.name = @@ -10332,8 +10530,8 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, node); - node.body = parseFunctionBlock(isGenerator, isAsync, false); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -10343,21 +10541,21 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(166 /* NewExpression */); - parseExpected(89 /* NewKeyword */); + var node = createNode(167 /* NewExpression */); + parseExpected(90 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 16 /* OpenParenToken */) { + if (node.typeArguments || token === 17 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(189 /* Block */); - if (parseExpected(14 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(190 /* Block */); + if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -10384,84 +10582,84 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(191 /* EmptyStatement */); - parseExpected(22 /* SemicolonToken */); + var node = createNode(192 /* EmptyStatement */); + parseExpected(23 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(193 /* IfStatement */); - parseExpected(85 /* IfKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(194 /* IfStatement */); + parseExpected(86 /* IfKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(77 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(78 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(194 /* DoStatement */); - parseExpected(76 /* DoKeyword */); + var node = createNode(195 /* DoStatement */); + parseExpected(77 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(101 /* WhileKeyword */); - parseExpected(16 /* OpenParenToken */); + parseExpected(102 /* WhileKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(22 /* SemicolonToken */); + parseOptional(23 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(195 /* WhileStatement */); - parseExpected(101 /* WhileKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(196 /* WhileStatement */); + parseExpected(102 /* WhileKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(83 /* ForKeyword */); - parseExpected(16 /* OpenParenToken */); + parseExpected(84 /* ForKeyword */); + parseExpected(17 /* OpenParenToken */); var initializer = undefined; - if (token !== 22 /* SemicolonToken */) { - if (token === 99 /* VarKeyword */ || token === 105 /* LetKeyword */ || token === 71 /* ConstKeyword */) { - initializer = parseVariableDeclarationList(true); + if (token !== 23 /* SemicolonToken */) { + if (token === 100 /* VarKeyword */ || token === 106 /* LetKeyword */ || token === 72 /* ConstKeyword */) { + initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { initializer = disallowInAnd(parseExpression); } } var forOrForInOrForOfStatement; - if (parseOptional(87 /* InKeyword */)) { - var forInStatement = createNode(197 /* ForInStatement */, pos); + if (parseOptional(88 /* InKeyword */)) { + var forInStatement = createNode(198 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(131 /* OfKeyword */)) { - var forOfStatement = createNode(198 /* ForOfStatement */, pos); + else if (parseOptional(132 /* OfKeyword */)) { + var forOfStatement = createNode(199 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(196 /* ForStatement */, pos); + var forStatement = createNode(197 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(22 /* SemicolonToken */); - if (token !== 22 /* SemicolonToken */ && token !== 17 /* CloseParenToken */) { + parseExpected(23 /* SemicolonToken */); + if (token !== 23 /* SemicolonToken */ && token !== 18 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(22 /* SemicolonToken */); - if (token !== 17 /* CloseParenToken */) { + parseExpected(23 /* SemicolonToken */); + if (token !== 18 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -10469,7 +10667,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 200 /* BreakStatement */ ? 67 /* BreakKeyword */ : 72 /* ContinueKeyword */); + parseExpected(kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -10477,8 +10675,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(201 /* ReturnStatement */); - parseExpected(91 /* ReturnKeyword */); + var node = createNode(202 /* ReturnStatement */); + parseExpected(92 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -10486,42 +10684,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(202 /* WithStatement */); - parseExpected(102 /* WithKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(203 /* WithStatement */); + parseExpected(103 /* WithKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(238 /* CaseClause */); - parseExpected(68 /* CaseKeyword */); + var node = createNode(239 /* CaseClause */); + parseExpected(69 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(239 /* DefaultClause */); - parseExpected(74 /* DefaultKeyword */); - parseExpected(52 /* ColonToken */); + var node = createNode(240 /* DefaultClause */); + parseExpected(75 /* DefaultKeyword */); + parseExpected(53 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 68 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token === 69 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(203 /* SwitchStatement */); - parseExpected(93 /* SwitchKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(204 /* SwitchStatement */); + parseExpected(94 /* SwitchKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(17 /* CloseParenToken */); - var caseBlock = createNode(217 /* CaseBlock */, scanner.getStartPos()); - parseExpected(14 /* OpenBraceToken */); + parseExpected(18 /* CloseParenToken */); + var caseBlock = createNode(218 /* CaseBlock */, scanner.getStartPos()); + parseExpected(15 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -10533,39 +10731,39 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(205 /* ThrowStatement */); - parseExpected(95 /* ThrowKeyword */); + var node = createNode(206 /* ThrowStatement */); + parseExpected(96 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(206 /* TryStatement */); - parseExpected(97 /* TryKeyword */); - node.tryBlock = parseBlock(false); - node.catchClause = token === 69 /* CatchKeyword */ ? parseCatchClause() : undefined; + var node = createNode(207 /* TryStatement */); + parseExpected(98 /* TryKeyword */); + node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); + node.catchClause = token === 70 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token === 82 /* FinallyKeyword */) { - parseExpected(82 /* FinallyKeyword */); - node.finallyBlock = parseBlock(false); + if (!node.catchClause || token === 83 /* FinallyKeyword */) { + parseExpected(83 /* FinallyKeyword */); + node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(241 /* CatchClause */); - parseExpected(69 /* CatchKeyword */); - if (parseExpected(16 /* OpenParenToken */)) { + var result = createNode(242 /* CatchClause */); + parseExpected(70 /* CatchKeyword */); + if (parseExpected(17 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(17 /* CloseParenToken */); - result.block = parseBlock(false); + parseExpected(18 /* CloseParenToken */); + result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(207 /* DebuggerStatement */); - parseExpected(73 /* DebuggerKeyword */); + var node = createNode(208 /* DebuggerStatement */); + parseExpected(74 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -10575,43 +10773,40 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 66 /* Identifier */ && parseOptional(52 /* ColonToken */)) { - var labeledStatement = createNode(204 /* LabeledStatement */, fullStart); + if (expression.kind === 67 /* Identifier */ && parseOptional(53 /* ColonToken */)) { + var labeledStatement = createNode(205 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(192 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(193 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } - function isIdentifierOrKeyword() { - return token >= 66 /* Identifier */; - } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); - return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); + return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token === 84 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token === 85 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); - return (isIdentifierOrKeyword() || token === 7 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token) || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token) { - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -10634,36 +10829,36 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 104 /* InterfaceKeyword */: - case 129 /* TypeKeyword */: + case 105 /* InterfaceKeyword */: + case 130 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115 /* AsyncKeyword */: - case 119 /* DeclareKeyword */: + case 116 /* AsyncKeyword */: + case 120 /* DeclareKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 86 /* ImportKeyword */: + case 87 /* ImportKeyword */: nextToken(); - return token === 8 /* StringLiteral */ || token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || isIdentifierOrKeyword(); - case 79 /* ExportKeyword */: + return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token); + case 80 /* ExportKeyword */: nextToken(); - if (token === 54 /* EqualsToken */ || token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || token === 74 /* DefaultKeyword */) { + if (token === 55 /* EqualsToken */ || token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */ || token === 75 /* DefaultKeyword */) { return true; } continue; - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: - case 112 /* AbstractKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: + case 113 /* AbstractKeyword */: nextToken(); continue; default: @@ -10676,47 +10871,47 @@ var ts; } function isStartOfStatement() { switch (token) { - case 53 /* AtToken */: - case 22 /* SemicolonToken */: - case 14 /* OpenBraceToken */: - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 84 /* FunctionKeyword */: - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: - case 85 /* IfKeyword */: - case 76 /* DoKeyword */: - case 101 /* WhileKeyword */: - case 83 /* ForKeyword */: - case 72 /* ContinueKeyword */: - case 67 /* BreakKeyword */: - case 91 /* ReturnKeyword */: - case 102 /* WithKeyword */: - case 93 /* SwitchKeyword */: - case 95 /* ThrowKeyword */: - case 97 /* TryKeyword */: - case 73 /* DebuggerKeyword */: + case 54 /* AtToken */: + case 23 /* SemicolonToken */: + case 15 /* OpenBraceToken */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 85 /* FunctionKeyword */: + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: + case 86 /* IfKeyword */: + case 77 /* DoKeyword */: + case 102 /* WhileKeyword */: + case 84 /* ForKeyword */: + case 73 /* ContinueKeyword */: + case 68 /* BreakKeyword */: + case 92 /* ReturnKeyword */: + case 103 /* WithKeyword */: + case 94 /* SwitchKeyword */: + case 96 /* ThrowKeyword */: + case 98 /* TryKeyword */: + case 74 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return true; - case 71 /* ConstKeyword */: - case 79 /* ExportKeyword */: - case 86 /* ImportKeyword */: + case 72 /* ConstKeyword */: + case 80 /* ExportKeyword */: + case 87 /* ImportKeyword */: return isStartOfDeclaration(); - case 115 /* AsyncKeyword */: - case 119 /* DeclareKeyword */: - case 104 /* InterfaceKeyword */: - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: - case 129 /* TypeKeyword */: + case 116 /* AsyncKeyword */: + case 120 /* DeclareKeyword */: + case 105 /* InterfaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: + case 130 /* TypeKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -10726,7 +10921,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */; + return isIdentifier() || token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -10735,65 +10930,65 @@ var ts; } function parseStatement() { switch (token) { - case 22 /* SemicolonToken */: + case 23 /* SemicolonToken */: return parseEmptyStatement(); - case 14 /* OpenBraceToken */: - return parseBlock(false); - case 99 /* VarKeyword */: - return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 105 /* LetKeyword */: + case 15 /* OpenBraceToken */: + return parseBlock(/*ignoreMissingOpenBrace*/ false); + case 100 /* VarKeyword */: + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 106 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(scanner.getStartPos(), undefined, undefined); + return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 84 /* FunctionKeyword */: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 70 /* ClassKeyword */: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 85 /* IfKeyword */: + case 85 /* FunctionKeyword */: + return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 71 /* ClassKeyword */: + return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + case 86 /* IfKeyword */: return parseIfStatement(); - case 76 /* DoKeyword */: + case 77 /* DoKeyword */: return parseDoStatement(); - case 101 /* WhileKeyword */: + case 102 /* WhileKeyword */: return parseWhileStatement(); - case 83 /* ForKeyword */: + case 84 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 72 /* ContinueKeyword */: - return parseBreakOrContinueStatement(199 /* ContinueStatement */); - case 67 /* BreakKeyword */: - return parseBreakOrContinueStatement(200 /* BreakStatement */); - case 91 /* ReturnKeyword */: + case 73 /* ContinueKeyword */: + return parseBreakOrContinueStatement(200 /* ContinueStatement */); + case 68 /* BreakKeyword */: + return parseBreakOrContinueStatement(201 /* BreakStatement */); + case 92 /* ReturnKeyword */: return parseReturnStatement(); - case 102 /* WithKeyword */: + case 103 /* WithKeyword */: return parseWithStatement(); - case 93 /* SwitchKeyword */: + case 94 /* SwitchKeyword */: return parseSwitchStatement(); - case 95 /* ThrowKeyword */: + case 96 /* ThrowKeyword */: return parseThrowStatement(); - case 97 /* TryKeyword */: + case 98 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return parseTryStatement(); - case 73 /* DebuggerKeyword */: + case 74 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 53 /* AtToken */: + case 54 /* AtToken */: return parseDeclaration(); - case 115 /* AsyncKeyword */: - case 104 /* InterfaceKeyword */: - case 129 /* TypeKeyword */: - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: - case 119 /* DeclareKeyword */: - case 71 /* ConstKeyword */: - case 78 /* EnumKeyword */: - case 79 /* ExportKeyword */: - case 86 /* ImportKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 109 /* PublicKeyword */: - case 112 /* AbstractKeyword */: - case 110 /* StaticKeyword */: + case 116 /* AsyncKeyword */: + case 105 /* InterfaceKeyword */: + case 130 /* TypeKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: + case 120 /* DeclareKeyword */: + case 72 /* ConstKeyword */: + case 79 /* EnumKeyword */: + case 80 /* ExportKeyword */: + case 87 /* ImportKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 110 /* PublicKeyword */: + case 113 /* AbstractKeyword */: + case 111 /* StaticKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -10806,35 +11001,35 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 99 /* VarKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 70 /* ClassKeyword */: + case 71 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 104 /* InterfaceKeyword */: + case 105 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 129 /* TypeKeyword */: + case 130 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 78 /* EnumKeyword */: + case 79 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 122 /* ModuleKeyword */: - case 123 /* NamespaceKeyword */: + case 123 /* ModuleKeyword */: + case 124 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 86 /* ImportKeyword */: + case 87 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: nextToken(); - return token === 74 /* DefaultKeyword */ || token === 54 /* EqualsToken */ ? + return token === 75 /* DefaultKeyword */ || token === 55 /* EqualsToken */ ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(228 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(229 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -10844,86 +11039,86 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 9 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token !== 14 /* OpenBraceToken */ && canParseSemicolon()) { + if (token !== 15 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } - return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); + return parseFunctionBlock(isGenerator, isAsync, /*ignoreMissingOpenBrace*/ false, diagnosticMessage); } // DECLARATIONS function parseArrayBindingElement() { - if (token === 23 /* CommaToken */) { - return createNode(184 /* OmittedExpression */); + if (token === 24 /* CommaToken */) { + return createNode(185 /* OmittedExpression */); } - var node = createNode(160 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); + var node = createNode(161 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(160 /* BindingElement */); + var node = createNode(161 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 52 /* ColonToken */) { + if (tokenIsIdentifier && token !== 53 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(158 /* ObjectBindingPattern */); - parseExpected(14 /* OpenBraceToken */); + var node = createNode(159 /* ObjectBindingPattern */); + parseExpected(15 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(159 /* ArrayBindingPattern */); - parseExpected(18 /* OpenBracketToken */); + var node = createNode(160 /* ArrayBindingPattern */); + parseExpected(19 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */ || isIdentifier(); + return token === 15 /* OpenBraceToken */ || token === 19 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token === 18 /* OpenBracketToken */) { + if (token === 19 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(208 /* VariableDeclaration */); + var node = createNode(209 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { - node.initializer = parseInitializer(false); + node.initializer = parseInitializer(/*inParameter*/ false); } return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(209 /* VariableDeclarationList */); + var node = createNode(210 /* VariableDeclarationList */); switch (token) { - case 99 /* VarKeyword */: + case 100 /* VarKeyword */: break; - case 105 /* LetKeyword */: + case 106 /* LetKeyword */: node.flags |= 16384 /* Let */; break; - case 71 /* ConstKeyword */: + case 72 /* ConstKeyword */: node.flags |= 32768 /* Const */; break; default: @@ -10939,7 +11134,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token === 131 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 132 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -10951,40 +11146,40 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 17 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(190 /* VariableStatement */, fullStart); + var node = createNode(191 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.declarationList = parseVariableDeclarationList(false); + node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(210 /* FunctionDeclaration */, fullStart); + var node = createNode(211 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(84 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + parseExpected(85 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = !!(node.flags & 512 /* Async */); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, node); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(141 /* Constructor */, pos); + var node = createNode(142 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(118 /* ConstructorKeyword */); - fillSignature(52 /* ColonToken */, false, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); + parseExpected(119 /* ConstructorKeyword */); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(140 /* MethodDeclaration */, fullStart); + var method = createNode(141 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; @@ -10992,12 +11187,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = !!(method.flags & 512 /* Async */); - fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, method); + fillSignature(53 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(138 /* PropertyDeclaration */, fullStart); + var property = createNode(139 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -11019,12 +11214,12 @@ var ts; return finishNode(property); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(51 /* QuestionToken */); - if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + var questionToken = parseOptionalToken(52 /* QuestionToken */); + if (asteriskToken || token === 17 /* OpenParenToken */ || token === 25 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -11032,23 +11227,23 @@ var ts; } } function parseNonParameterInitializer() { - return parseInitializer(false); + return parseInitializer(/*inParameter*/ false); } function parseAccessorDeclaration(kind, fullStart, decorators, modifiers) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(52 /* ColonToken */, false, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, false); + fillSignature(53 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 110 /* StaticKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 111 /* StaticKeyword */: return true; default: return false; @@ -11056,7 +11251,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 53 /* AtToken */) { + if (token === 54 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -11073,7 +11268,7 @@ var ts; } nextToken(); } - if (token === 36 /* AsteriskToken */) { + if (token === 37 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -11083,23 +11278,23 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token === 18 /* OpenBracketToken */) { + if (token === 19 /* OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 126 /* SetKeyword */ || idToken === 120 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 127 /* SetKeyword */ || idToken === 121 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token) { - case 16 /* OpenParenToken */: // Method declaration - case 24 /* LessThanToken */: // Generic Method declaration - case 52 /* ColonToken */: // Type Annotation for declaration - case 54 /* EqualsToken */: // Initializer for declaration - case 51 /* QuestionToken */: + case 17 /* OpenParenToken */: // Method declaration + case 25 /* LessThanToken */: // Generic Method declaration + case 53 /* ColonToken */: // Type Annotation for declaration + case 55 /* EqualsToken */: // Initializer for declaration + case 52 /* QuestionToken */: return true; default: // Covers @@ -11116,14 +11311,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(53 /* AtToken */)) { + if (!parseOptional(54 /* AtToken */)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(136 /* Decorator */, decoratorStart); + var decorator = createNode(137 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -11157,7 +11352,7 @@ var ts; function parseModifiersForArrowFunction() { var flags = 0; var modifiers; - if (token === 115 /* AsyncKeyword */) { + if (token === 116 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token; nextToken(); @@ -11171,8 +11366,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token === 22 /* SemicolonToken */) { - var result = createNode(188 /* SemicolonClassElement */); + if (token === 23 /* SemicolonToken */) { + var result = createNode(189 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -11183,7 +11378,7 @@ var ts; if (accessor) { return accessor; } - if (token === 118 /* ConstructorKeyword */) { + if (token === 119 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -11191,17 +11386,17 @@ var ts; } // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name - if (isIdentifierOrKeyword() || - token === 8 /* StringLiteral */ || - token === 7 /* NumericLiteral */ || - token === 36 /* AsteriskToken */ || - token === 18 /* OpenBracketToken */) { + if (ts.tokenIsIdentifierOrKeyword(token) || + token === 9 /* StringLiteral */ || + token === 8 /* NumericLiteral */ || + token === 37 /* AsteriskToken */ || + token === 19 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_7 = createMissingNode(66 /* Identifier */, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); + var name_7 = createMissingNode(67 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. ts.Debug.fail("Should not have attempted to parse class member declaration."); @@ -11210,24 +11405,24 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 183 /* ClassExpression */); + /*modifiers*/ undefined, 184 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 211 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 212 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(70 /* ClassKeyword */); + parseExpected(71 /* ClassKeyword */); node.name = parseOptionalIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(14 /* OpenBraceToken */)) { + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); + if (parseExpected(15 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -11246,8 +11441,8 @@ var ts; return parseList(20 /* HeritageClauses */, parseHeritageClause); } function parseHeritageClause() { - if (token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */) { - var node = createNode(240 /* HeritageClause */); + if (token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */) { + var node = createNode(241 /* HeritageClause */); node.token = token; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -11256,38 +11451,38 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(185 /* ExpressionWithTypeArguments */); + var node = createNode(186 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 24 /* LessThanToken */, 26 /* GreaterThanToken */); + if (token === 25 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); } return finishNode(node); } function isHeritageClause() { - return token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; + return token === 81 /* ExtendsKeyword */ || token === 104 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(212 /* InterfaceDeclaration */, fullStart); + var node = createNode(213 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(104 /* InterfaceKeyword */); + parseExpected(105 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(false); + node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(213 /* TypeAliasDeclaration */, fullStart); + var node = createNode(214 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(129 /* TypeKeyword */); + parseExpected(130 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -11297,20 +11492,20 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(244 /* EnumMember */, scanner.getStartPos()); + var node = createNode(245 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(214 /* EnumDeclaration */, fullStart); + var node = createNode(215 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(78 /* EnumKeyword */); + parseExpected(79 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(14 /* OpenBraceToken */)) { + if (parseExpected(15 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -11318,10 +11513,10 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(216 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(14 /* OpenBraceToken */)) { + var node = createNode(217 /* ModuleBlock */, scanner.getStartPos()); + if (parseExpected(15 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -11329,84 +11524,87 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(215 /* ModuleDeclaration */, fullStart); + var node = createNode(216 /* ModuleDeclaration */, fullStart); + // If we are parsing a dotted namespace name, we want to + // propagate the 'Namespace' flag across the names if set. + var namespaceFlag = flags & 131072 /* Namespace */; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(20 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 /* Export */) + node.body = parseOptional(21 /* DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag) : parseModuleBlock(); return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(215 /* ModuleDeclaration */, fullStart); + var node = createNode(216 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.name = parseLiteralNode(true); + node.name = parseLiteralNode(/*internName*/ true); node.body = parseModuleBlock(); return finishNode(node); } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(123 /* NamespaceKeyword */)) { + if (parseOptional(124 /* NamespaceKeyword */)) { flags |= 131072 /* Namespace */; } else { - parseExpected(122 /* ModuleKeyword */); - if (token === 8 /* StringLiteral */) { + parseExpected(123 /* ModuleKeyword */); + if (token === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 124 /* RequireKeyword */ && + return token === 125 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 16 /* OpenParenToken */; + return nextToken() === 17 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 37 /* SlashToken */; + return nextToken() === 38 /* SlashToken */; } function nextTokenIsCommaOrFromKeyword() { nextToken(); - return token === 23 /* CommaToken */ || - token === 130 /* FromKeyword */; + return token === 24 /* CommaToken */ || + token === 131 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(86 /* ImportKeyword */); + parseExpected(87 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 /* CommaToken */ && token !== 130 /* FromKeyword */) { + if (token !== 24 /* CommaToken */ && token !== 131 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(218 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(219 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(54 /* EqualsToken */); + parseExpected(55 /* EqualsToken */); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } // Import statement - var importDeclaration = createNode(219 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(220 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || - token === 36 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */) { + token === 37 /* AsteriskToken */ || + token === 15 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(130 /* FromKeyword */); + parseExpected(131 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -11419,7 +11617,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(220 /* ImportClause */, fullStart); + var importClause = createNode(221 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -11428,22 +11626,22 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(23 /* CommaToken */)) { - importClause.namedBindings = token === 36 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(222 /* NamedImports */); + parseOptional(24 /* CommaToken */)) { + importClause.namedBindings = token === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(223 /* NamedImports */); } return finishNode(importClause); } function parseModuleReference() { return isExternalModuleReference() ? parseExternalModuleReference() - : parseEntityName(false); + : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(229 /* ExternalModuleReference */); - parseExpected(124 /* RequireKeyword */); - parseExpected(16 /* OpenParenToken */); + var node = createNode(230 /* ExternalModuleReference */); + parseExpected(125 /* RequireKeyword */); + parseExpected(17 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { @@ -11453,7 +11651,7 @@ var ts; var result = parseExpression(); // Ensure the string being required is in our 'identifier' table. This will ensure // that features like 'find refs' will look inside this file when search for its name. - if (result.kind === 8 /* StringLiteral */) { + if (result.kind === 9 /* StringLiteral */) { internIdentifier(result.text); } return result; @@ -11461,9 +11659,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(221 /* NamespaceImport */); - parseExpected(36 /* AsteriskToken */); - parseExpected(113 /* AsKeyword */); + var namespaceImport = createNode(222 /* NamespaceImport */); + parseExpected(37 /* AsteriskToken */); + parseExpected(114 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -11476,14 +11674,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 222 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 223 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(227 /* ExportSpecifier */); + return parseImportOrExportSpecifier(228 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(223 /* ImportSpecifier */); + return parseImportOrExportSpecifier(224 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -11497,9 +11695,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(113 /* AsKeyword */); + parseExpected(114 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -11508,27 +11706,27 @@ var ts; else { node.name = identifierName; } - if (kind === 223 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 224 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225 /* ExportDeclaration */, fullStart); + var node = createNode(226 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(36 /* AsteriskToken */)) { - parseExpected(130 /* FromKeyword */); + if (parseOptional(37 /* AsteriskToken */)) { + parseExpected(131 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(226 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(227 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token === 130 /* FromKeyword */ || (token === 8 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(130 /* FromKeyword */); + if (token === 131 /* FromKeyword */ || (token === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(131 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -11536,21 +11734,21 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(224 /* ExportAssignment */, fullStart); + var node = createNode(225 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(54 /* EqualsToken */)) { + if (parseOptional(55 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(74 /* DefaultKeyword */); + parseExpected(75 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); return finishNode(node); } function processReferenceComments(sourceFile) { - var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, 0 /* Standard */, sourceText); + var triviaScanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, 0 /* Standard */, sourceText); var referencedFiles = []; var amdDependencies = []; var amdModuleName; @@ -11609,10 +11807,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 229 /* ExternalModuleReference */ - || node.kind === 219 /* ImportDeclaration */ - || node.kind === 224 /* ExportAssignment */ - || node.kind === 225 /* ExportDeclaration */ + || node.kind === 219 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 230 /* ExternalModuleReference */ + || node.kind === 220 /* ImportDeclaration */ + || node.kind === 225 /* ExportAssignment */ + || node.kind === 226 /* ExportDeclaration */ ? node : undefined; }); @@ -11657,23 +11855,23 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token) { - case 36 /* AsteriskToken */: - case 51 /* QuestionToken */: - case 16 /* OpenParenToken */: - case 18 /* OpenBracketToken */: - case 47 /* ExclamationToken */: - case 14 /* OpenBraceToken */: - case 84 /* FunctionKeyword */: - case 21 /* DotDotDotToken */: - case 89 /* NewKeyword */: - case 94 /* ThisKeyword */: + case 37 /* AsteriskToken */: + case 52 /* QuestionToken */: + case 17 /* OpenParenToken */: + case 19 /* OpenBracketToken */: + case 48 /* ExclamationToken */: + case 15 /* OpenBraceToken */: + case 85 /* FunctionKeyword */: + case 22 /* DotDotDotToken */: + case 90 /* NewKeyword */: + case 95 /* ThisKeyword */: return true; } - return isIdentifierOrKeyword(); + return ts.tokenIsIdentifierOrKeyword(token); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, undefined); + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); var jsDocTypeExpression = parseJSDocTypeExpression(start, length); var diagnostics = parseDiagnostics; clearState(); @@ -11687,23 +11885,23 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(246 /* JSDocTypeExpression */); - parseExpected(14 /* OpenBraceToken */); + var result = createNode(247 /* JSDocTypeExpression */); + parseExpected(15 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 45 /* BarToken */) { - var unionType = createNode(250 /* JSDocUnionType */, type.pos); + if (token === 46 /* BarToken */) { + var unionType = createNode(251 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 54 /* EqualsToken */) { - var optionalType = createNode(257 /* JSDocOptionalType */, type.pos); + if (token === 55 /* EqualsToken */) { + var optionalType = createNode(258 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -11713,21 +11911,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token === 18 /* OpenBracketToken */) { - var arrayType = createNode(249 /* JSDocArrayType */, type.pos); + if (token === 19 /* OpenBracketToken */) { + var arrayType = createNode(250 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token === 51 /* QuestionToken */) { - var nullableType = createNode(252 /* JSDocNullableType */, type.pos); + else if (token === 52 /* QuestionToken */) { + var nullableType = createNode(253 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 47 /* ExclamationToken */) { - var nonNullableType = createNode(253 /* JSDocNonNullableType */, type.pos); + else if (token === 48 /* ExclamationToken */) { + var nonNullableType = createNode(254 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -11740,85 +11938,85 @@ var ts; } function parseBasicTypeExpression() { switch (token) { - case 36 /* AsteriskToken */: + case 37 /* AsteriskToken */: return parseJSDocAllType(); - case 51 /* QuestionToken */: + case 52 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return parseJSDocUnionType(); - case 18 /* OpenBracketToken */: + case 19 /* OpenBracketToken */: return parseJSDocTupleType(); - case 47 /* ExclamationToken */: + case 48 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return parseJSDocRecordType(); - case 84 /* FunctionKeyword */: + case 85 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 21 /* DotDotDotToken */: + case 22 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 89 /* NewKeyword */: + case 90 /* NewKeyword */: return parseJSDocConstructorType(); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return parseJSDocThisType(); - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(261 /* JSDocThisType */); + var result = createNode(262 /* JSDocThisType */); nextToken(); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(260 /* JSDocConstructorType */); + var result = createNode(261 /* JSDocConstructorType */); nextToken(); - parseExpected(52 /* ColonToken */); + parseExpected(53 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(259 /* JSDocVariadicType */); + var result = createNode(260 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(258 /* JSDocFunctionType */); + var result = createNode(259 /* JSDocFunctionType */); nextToken(); - parseExpected(16 /* OpenParenToken */); + parseExpected(17 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(17 /* CloseParenToken */); - if (token === 52 /* ColonToken */) { + parseExpected(18 /* CloseParenToken */); + if (token === 53 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(135 /* Parameter */); + var parameter = createNode(136 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(257 /* JSDocOptionalType */, type.pos); + var result = createNode(258 /* JSDocOptionalType */, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(256 /* JSDocTypeReference */); + var result = createNode(257 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); - while (parseOptional(20 /* DotToken */)) { - if (token === 24 /* LessThanToken */) { + while (parseOptional(21 /* DotToken */)) { + if (token === 25 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); break; } @@ -11834,7 +12032,7 @@ var ts; var typeArguments = parseDelimitedList(23 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(26 /* GreaterThanToken */); + parseExpected(27 /* GreaterThanToken */); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -11845,40 +12043,40 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(132 /* QualifiedName */, left.pos); + var result = createNode(133 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(254 /* JSDocRecordType */); + var result = createNode(255 /* JSDocRecordType */); nextToken(); result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); - parseExpected(15 /* CloseBraceToken */); + parseExpected(16 /* CloseBraceToken */); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(255 /* JSDocRecordMember */); + var result = createNode(256 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); - if (token === 52 /* ColonToken */) { + if (token === 53 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(253 /* JSDocNonNullableType */); + var result = createNode(254 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(251 /* JSDocTupleType */); + var result = createNode(252 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(19 /* CloseBracketToken */); + parseExpected(20 /* CloseBracketToken */); return finishNode(result); } function checkForTrailingComma(list) { @@ -11888,10 +12086,10 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(250 /* JSDocUnionType */); + var result = createNode(251 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(17 /* CloseParenToken */); + parseExpected(18 /* CloseParenToken */); return finishNode(result); } function parseJSDocTypeList(firstType) { @@ -11899,14 +12097,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(45 /* BarToken */)) { + while (parseOptional(46 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(247 /* JSDocAllType */); + var result = createNode(248 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -11923,24 +12121,24 @@ var ts; // Foo // Foo(?= // (?| - if (token === 23 /* CommaToken */ || - token === 15 /* CloseBraceToken */ || - token === 17 /* CloseParenToken */ || - token === 26 /* GreaterThanToken */ || - token === 54 /* EqualsToken */ || - token === 45 /* BarToken */) { - var result = createNode(248 /* JSDocUnknownType */, pos); + if (token === 24 /* CommaToken */ || + token === 16 /* CloseBraceToken */ || + token === 18 /* CloseParenToken */ || + token === 27 /* GreaterThanToken */ || + token === 55 /* EqualsToken */ || + token === 46 /* BarToken */) { + var result = createNode(249 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(252 /* JSDocNullableType */, pos); + var result = createNode(253 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, undefined); - var jsDocComment = parseJSDocComment(undefined, start, length); + initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined); + var jsDocComment = parseJSDocComment(/*parent:*/ undefined, start, length); var diagnostics = parseDiagnostics; clearState(); return jsDocComment ? { jsDocComment: jsDocComment, diagnostics: diagnostics } : undefined; @@ -12021,7 +12219,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(262 /* JSDocComment */, start); + var result = createNode(263 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -12032,7 +12230,7 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); - var atToken = createNode(53 /* AtToken */, pos - 1); + var atToken = createNode(54 /* AtToken */, pos - 1); atToken.end = pos; var tagName = scanIdentifier(); if (!tagName) { @@ -12058,7 +12256,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(263 /* JSDocTag */, atToken.pos); + var result = createNode(264 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -12098,7 +12296,6 @@ var ts; } if (!name) { parseErrorAtPosition(pos, 0, ts.Diagnostics.Identifier_expected); - return undefined; } var preName, postName; if (typeExpression) { @@ -12110,7 +12307,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(264 /* JSDocParameterTag */, atToken.pos); + var result = createNode(265 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -12120,27 +12317,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 265 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(265 /* JSDocReturnTag */, atToken.pos); + var result = createNode(266 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(266 /* JSDocTypeTag */, atToken.pos); + var result = createNode(267 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 268 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -12153,7 +12350,7 @@ var ts; parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(134 /* TypeParameter */, name_8.pos); + var typeParameter = createNode(135 /* TypeParameter */, name_8.pos); typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); @@ -12164,7 +12361,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(267 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(268 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -12185,7 +12382,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(66 /* Identifier */, startPos); + var result = createNode(67 /* Identifier */, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -12205,7 +12402,7 @@ var ts; if (sourceFile.statements.length === 0) { // If we don't have any statements in the current source file, then there's no real // way to incrementally parse. So just do a full parse instead. - return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true); + return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setNodeParents*/ true); } // Make sure we're not trying to incrementally update a source file more than once. Once // we do an update the original source file is considered unusbale from that point onwards. @@ -12261,7 +12458,7 @@ var ts; // inconsistent tree. Setting the parents on the new tree should be very fast. We // will immediately bail out of walking any subtrees when we can see that their parents // are already correct. - var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true); + var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true); return result; } IncrementalParser.updateSourceFile = updateSourceFile; @@ -12274,7 +12471,7 @@ var ts; } return; function visitNode(node) { - var text = ''; + var text = ""; if (aggressiveChecks && shouldCheckNode(node)) { text = oldText.substring(node.pos, node.end); } @@ -12306,9 +12503,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: - case 66 /* Identifier */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 67 /* Identifier */: return true; } return false; @@ -12400,7 +12597,7 @@ var ts; if (child.pos > changeRangeOldEnd) { // Node is entirely past the change range. We need to move both its pos and // end, forward or backward appropriately. - moveElementEntirelyPastChangeRange(child, false, delta, oldText, newText, aggressiveChecks); + moveElementEntirelyPastChangeRange(child, /*isArray*/ false, delta, oldText, newText, aggressiveChecks); return; } // Check if the element intersects the change range. If it does, then it is not @@ -12424,7 +12621,7 @@ var ts; if (array.pos > changeRangeOldEnd) { // Array is entirely after the change range. We need to move it, and move any of // its children. - moveElementEntirelyPastChangeRange(array, true, delta, oldText, newText, aggressiveChecks); + moveElementEntirelyPastChangeRange(array, /*isArray*/ true, delta, oldText, newText, aggressiveChecks); return; } // Check if the element intersects the change range. If it does, then it is not @@ -12717,17 +12914,20 @@ var ts; isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, + // The language service will always care about the narrowed type of a symbol, because that is + // the type the language says the symbol should have. + getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, + getBaseTypes: getBaseTypes, getReturnTypeOfSignature: getReturnTypeOfSignature, getSymbolsInScope: getSymbolsInScope, getSymbolAtLocation: getSymbolAtLocation, getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeAtLocation, + getTypeAtLocation: getTypeOfNode, typeToString: typeToString, getSymbolDisplayBuilder: getSymbolDisplayBuilder, symbolToString: symbolToString, @@ -12744,7 +12944,8 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getJsxElementAttributesType: getJsxElementAttributesType, - getJsxIntrinsicTagNames: getJsxIntrinsicTagNames + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, + isOptionalParameter: isOptionalParameter }; var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); @@ -12752,16 +12953,19 @@ var ts; var stringType = createIntrinsicType(2 /* String */, "string"); var numberType = createIntrinsicType(4 /* Number */, "number"); var booleanType = createIntrinsicType(8 /* Boolean */, "boolean"); - var esSymbolType = createIntrinsicType(4194304 /* ESSymbol */, "symbol"); + var esSymbolType = createIntrinsicType(16777216 /* ESSymbol */, "symbol"); var voidType = createIntrinsicType(16 /* Void */, "void"); - var undefinedType = createIntrinsicType(32 /* Undefined */ | 1048576 /* ContainsUndefinedOrNull */, "undefined"); - var nullType = createIntrinsicType(64 /* Null */ | 1048576 /* ContainsUndefinedOrNull */, "null"); + var undefinedType = createIntrinsicType(32 /* Undefined */ | 2097152 /* ContainsUndefinedOrNull */, "undefined"); + var nullType = createIntrinsicType(64 /* Null */ | 2097152 /* ContainsUndefinedOrNull */, "null"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); var circularType = createIntrinsicType(1 /* Any */, "__circular__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = {}; var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated + // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. + anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); @@ -12806,6 +13010,7 @@ var ts; var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; + var resolutionPropertyNames = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; @@ -12827,7 +13032,7 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 4194304 /* ESSymbol */ + flags: 16777216 /* ESSymbol */ } }; var JsxNames = { @@ -12840,6 +13045,15 @@ var ts; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; + // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. + var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); initializeTypeChecker(); return checker; function getEmitResolver(sourceFile, cancellationToken) { @@ -12984,10 +13198,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 245 /* SourceFile */); + return ts.getAncestor(node, 246 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 245 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 246 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -13013,7 +13227,7 @@ var ts; if (file1 === file2) { return node1.pos <= node2.pos; } - if (!compilerOptions.out) { + if (!compilerOptions.outFile && !compilerOptions.out) { return true; } var sourceFiles = host.getSourceFiles(); @@ -13044,13 +13258,13 @@ var ts; } } switch (location.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 245 /* SourceFile */ || - (location.kind === 215 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { + if (location.kind === 246 /* SourceFile */ || + (location.kind === 216 /* ModuleDeclaration */ && location.name.kind === 9 /* StringLiteral */)) { // It's an external module. Because of module/namespace merging, a module's exports are in scope, // yet we never want to treat an export specifier as putting a member in scope. Therefore, // if the name we find is purely an export specifier, it is not actually considered in scope. @@ -13064,7 +13278,7 @@ var ts; // which is not the desired behavior. if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 227 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 228 /* ExportSpecifier */)) { break; } result = moduleExports["default"]; @@ -13078,13 +13292,13 @@ var ts; break loop; } break; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -13101,9 +13315,9 @@ var ts; } } break; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -13114,7 +13328,7 @@ var ts; } break loop; } - if (location.kind === 183 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 184 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -13130,9 +13344,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 212 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 213 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -13140,19 +13354,19 @@ var ts; } } break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 170 /* FunctionExpression */: + case 171 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -13165,7 +13379,7 @@ var ts; } } break; - case 136 /* Decorator */: + case 137 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -13174,7 +13388,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 135 /* Parameter */) { + if (location.parent && location.parent.kind === 136 /* Parameter */) { location = location.parent; } // @@ -13209,7 +13423,18 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (result.flags & 2 /* BlockScopedVariable */) { + // Only check for block-scoped variable if we are looking for the + // name with variable meaning + // For example, + // declare module foo { + // interface bar {} + // } + // let foo/*1*/: foo/*2*/.bar; + // The foo at /*1*/ and /*2*/ will share same symbol with two meaning + // block - scope variable and namespace module. However, only when we + // try to resolve name in /*1*/ which is used in variable position, + // we want to check for block- scoped + if (meaning & 2 /* BlockScopedVariable */ && result.flags & 2 /* BlockScopedVariable */) { checkResolvedBlockScopedVariable(result, errorLocation); } } @@ -13230,16 +13455,16 @@ var ts; // for (let x in x) // for (let x of x) // climb up to the variable declaration skipping binding patterns - var variableDeclaration = ts.getAncestor(declaration, 208 /* VariableDeclaration */); + var variableDeclaration = ts.getAncestor(declaration, 209 /* VariableDeclaration */); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 190 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 196 /* ForStatement */) { + if (variableDeclaration.parent.parent.kind === 191 /* VariableStatement */ || + variableDeclaration.parent.parent.kind === 197 /* ForStatement */) { // variable statement/for statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 198 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 197 /* ForInStatement */) { + else if (variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */ || + variableDeclaration.parent.parent.kind === 198 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); @@ -13266,10 +13491,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 219 /* ImportDeclaration */) { + while (node && node.kind !== 220 /* ImportDeclaration */) { node = node.parent; } return node; @@ -13279,7 +13504,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 229 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 230 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -13386,17 +13611,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 220 /* ImportClause */: + case 221 /* ImportClause */: return getTargetOfImportClause(node); - case 221 /* NamespaceImport */: + case 222 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 223 /* ImportSpecifier */: + case 224 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 227 /* ExportSpecifier */: + case 228 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -13441,11 +13666,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 224 /* ExportAssignment */) { + if (node.kind === 225 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 227 /* ExportSpecifier */) { + else if (node.kind === 228 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -13458,7 +13683,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 218 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 219 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -13467,17 +13692,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 66 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 67 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 66 /* Identifier */ || entityName.parent.kind === 132 /* QualifiedName */) { + if (entityName.kind === 67 /* Identifier */ || entityName.parent.kind === 133 /* QualifiedName */) { return resolveEntityName(entityName, 1536 /* Namespace */); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 218 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 219 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -13490,16 +13715,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 132 /* QualifiedName */ || name.kind === 163 /* PropertyAccessExpression */) { - var left = name.kind === 132 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 132 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 133 /* QualifiedName */ || name.kind === 164 /* PropertyAccessExpression */) { + var left = name.kind === 133 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 133 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; @@ -13524,7 +13749,7 @@ var ts; return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; } function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 8 /* StringLiteral */) { + if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { return; } var moduleReferenceLiteral = moduleReferenceExpression; @@ -13532,29 +13757,18 @@ var ts; // Module names are escaped in our symbol table. However, string literal values aren't. // Escape the name in the "require(...)" clause to ensure we find the right symbol. var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) + if (moduleName === undefined) { return; + } var isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); if (symbol) { return symbol; } } - var fileName; - var sourceFile; - while (true) { - fileName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - sourceFile = ts.forEach(ts.supportedExtensions, function (extension) { return host.getSourceFile(fileName + extension); }); - if (sourceFile || isRelative) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } + var resolvedModule = ts.getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); + var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { return sourceFile.symbol; @@ -13662,7 +13876,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 141 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 142 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -13732,17 +13946,17 @@ var ts; } } switch (location_1.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location_1)) { break; } - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -13783,7 +13997,7 @@ var ts; return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -13820,7 +14034,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 228 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -13836,7 +14050,7 @@ var ts; var meaningToLook = meaning; while (symbol) { // Symbol is accessible if it by itself is accessible - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, false); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, /*useOnlyExternalAliasing*/ false); if (accessibleSymbolChain) { var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); if (!hasAccessibleDeclarations) { @@ -13893,8 +14107,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 215 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || - (declaration.kind === 245 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 216 /* ModuleDeclaration */ && declaration.name.kind === 9 /* StringLiteral */) || + (declaration.kind === 246 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -13930,12 +14144,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 151 /* TypeQuery */) { + if (entityName.parent.kind === 152 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 132 /* QualifiedName */ || entityName.kind === 163 /* PropertyAccessExpression */ || - entityName.parent.kind === 218 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 133 /* QualifiedName */ || entityName.kind === 164 /* PropertyAccessExpression */ || + entityName.parent.kind === 219 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -13945,7 +14159,7 @@ var ts; meaning = 793056 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); - var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined); + var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol)) || { accessibility: 1 /* NotAccessible */, @@ -13990,17 +14204,15 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 157 /* ParenthesizedType */) { + while (node.kind === 158 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 214 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } return undefined; } - // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. - var _displayBuilder; function getSymbolDisplayBuilder() { function getNameOfSymbol(symbol) { if (symbol.declarations && symbol.declarations.length) { @@ -14009,10 +14221,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return "(Anonymous class)"; - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -14042,7 +14254,7 @@ var ts; buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 20 /* DotToken */); + writePunctuation(writer, 21 /* DotToken */); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -14098,7 +14310,7 @@ var ts; return writeType(type, globalFlags); function writeType(type, flags) { // Write undefined/null type as any - if (type.flags & 4194431 /* Intrinsic */) { + if (type.flags & 16777343 /* Intrinsic */) { // Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving writer.writeKeyword(!(globalFlags & 16 /* WriteOwnNameForAnyLike */) && isTypeAny(type) ? "any" @@ -14126,23 +14338,23 @@ var ts; else { // Should never get here // { ... } - writePunctuation(writer, 14 /* OpenBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); writeSpace(writer); - writePunctuation(writer, 21 /* DotDotDotToken */); + writePunctuation(writer, 22 /* DotDotDotToken */); writeSpace(writer); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 23 /* CommaToken */) { + if (delimiter !== 24 /* CommaToken */) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 23 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); + writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end) { @@ -14152,22 +14364,22 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793056 /* Type */); } if (pos < end) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); writeType(typeArguments[pos++], 0 /* None */); while (pos < end) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); writeType(typeArguments[pos++], 0 /* None */); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments; if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 18 /* OpenBracketToken */); - writePunctuation(writer, 19 /* CloseBracketToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writePunctuation(writer, 20 /* CloseBracketToken */); } else { // Write the type reference in the format f.g.C where A and B are type arguments @@ -14188,7 +14400,7 @@ var ts; // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_3, typeArguments, start, i); - writePunctuation(writer, 20 /* DotToken */); + writePunctuation(writer, 21 /* DotToken */); } } } @@ -14196,17 +14408,17 @@ var ts; } } function writeTupleType(type) { - writePunctuation(writer, 18 /* OpenBracketToken */); - writeTypeList(type.elementTypes, 23 /* CommaToken */); - writePunctuation(writer, 19 /* CloseBracketToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writeTypeList(type.elementTypes, 24 /* CommaToken */); + writePunctuation(writer, 20 /* CloseBracketToken */); } function writeUnionOrIntersectionType(type, flags) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } - writeTypeList(type.types, type.flags & 16384 /* Union */ ? 45 /* BarToken */ : 44 /* AmpersandToken */); + writeTypeList(type.types, type.flags & 16384 /* Union */ ? 46 /* BarToken */ : 45 /* AmpersandToken */); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } } function writeAnonymousType(type, flags) { @@ -14228,7 +14440,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 114 /* AnyKeyword */); + writeKeyword(writer, 115 /* AnyKeyword */); } } else { @@ -14252,7 +14464,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 245 /* SourceFile */ || declaration.parent.kind === 216 /* ModuleBlock */; + return declaration.parent.kind === 246 /* SourceFile */ || declaration.parent.kind === 217 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -14262,7 +14474,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 98 /* TypeOfKeyword */); + writeKeyword(writer, 99 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } @@ -14280,76 +14492,76 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 14 /* OpenBraceToken */); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); } - writeKeyword(writer, 89 /* NewKeyword */); + writeKeyword(writer, 90 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } return; } } - writePunctuation(writer, 14 /* OpenBraceToken */); + writePunctuation(writer, 15 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 89 /* NewKeyword */); + writeKeyword(writer, 90 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } if (resolved.stringIndexType) { // [x: string]: - writePunctuation(writer, 18 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, /*fallbackName*/ "x")); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 127 /* StringKeyword */); - writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 52 /* ColonToken */); + writeKeyword(writer, 128 /* StringKeyword */); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } if (resolved.numberIndexType) { // [x: number]: - writePunctuation(writer, 18 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 19 /* OpenBracketToken */); + writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, /*fallbackName*/ "x")); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 125 /* NumberKeyword */); - writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 52 /* ColonToken */); + writeKeyword(writer, 126 /* NumberKeyword */); + writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(resolved.numberIndexType, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { @@ -14361,32 +14573,32 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } } else { buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); - writePunctuation(writer, 22 /* SemicolonToken */); + writePunctuation(writer, 23 /* SemicolonToken */); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 15 /* CloseBraceToken */); + writePunctuation(writer, 16 /* CloseBraceToken */); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */) { + if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */ || targetSymbol.flags & 524288 /* TypeAlias */) { buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } @@ -14395,7 +14607,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 80 /* ExtendsKeyword */); + writeKeyword(writer, 81 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -14403,67 +14615,67 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 21 /* DotDotDotToken */); + writePunctuation(writer, 22 /* DotDotDotToken */); } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 51 /* QuestionToken */); + writePunctuation(writer, 52 /* QuestionToken */); } - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 24 /* LessThanToken */); + writePunctuation(writer, 25 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); } - writePunctuation(writer, 26 /* GreaterThanToken */); + writePunctuation(writer, 27 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 16 /* OpenParenToken */); + writePunctuation(writer, 17 /* OpenParenToken */); for (var i = 0; i < parameters.length; i++) { if (i > 0) { - writePunctuation(writer, 23 /* CommaToken */); + writePunctuation(writer, 24 /* CommaToken */); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 17 /* CloseParenToken */); + writePunctuation(writer, 18 /* CloseParenToken */); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 33 /* EqualsGreaterThanToken */); + writePunctuation(writer, 34 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 52 /* ColonToken */); + writePunctuation(writer, 53 /* ColonToken */); } writeSpace(writer); var returnType; if (signature.typePredicate) { writer.writeParameter(signature.typePredicate.parameterName); writeSpace(writer); - writeKeyword(writer, 121 /* IsKeyword */); + writeKeyword(writer, 122 /* IsKeyword */); writeSpace(writer); returnType = signature.typePredicate.type; } @@ -14485,15 +14697,12 @@ var ts; buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack); } return _displayBuilder || (_displayBuilder = { - symbolToString: symbolToString, - typeToString: typeToString, buildSymbolDisplay: buildSymbolDisplay, buildTypeDisplay: buildTypeDisplay, buildTypeParameterDisplay: buildTypeParameterDisplay, buildParameterDisplay: buildParameterDisplay, buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildDisplayForTypeArgumentsAndDelimiters: buildDisplayForTypeArgumentsAndDelimiters, buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, buildSignatureDisplay: buildSignatureDisplay, buildReturnTypeDisplay: buildReturnTypeDisplay @@ -14502,12 +14711,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 215 /* ModuleDeclaration */) { - if (node.name.kind === 8 /* StringLiteral */) { + if (node.kind === 216 /* ModuleDeclaration */) { + if (node.name.kind === 9 /* StringLiteral */) { return node; } } - else if (node.kind === 245 /* SourceFile */) { + else if (node.kind === 246 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -14556,70 +14765,70 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 160 /* BindingElement */: + case 161 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 210 /* FunctionDeclaration */: - case 214 /* EnumDeclaration */: - case 218 /* ImportEqualsDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 211 /* FunctionDeclaration */: + case 215 /* EnumDeclaration */: + case 219 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 218 /* ImportEqualsDeclaration */ && parent_4.kind !== 245 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 219 /* ImportEqualsDeclaration */ && parent_4.kind !== 246 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 141 /* Constructor */: - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 146 /* IndexSignature */: - case 135 /* Parameter */: - case 216 /* ModuleBlock */: - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 152 /* TypeLiteral */: - case 148 /* TypeReference */: - case 153 /* ArrayType */: - case 154 /* TupleType */: - case 155 /* UnionType */: - case 156 /* IntersectionType */: - case 157 /* ParenthesizedType */: + case 142 /* Constructor */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 147 /* IndexSignature */: + case 136 /* Parameter */: + case 217 /* ModuleBlock */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 153 /* TypeLiteral */: + case 149 /* TypeReference */: + case 154 /* ArrayType */: + case 155 /* TupleType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: + case 158 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: return false; // Type parameters are always visible - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: // Source file is always visible - case 245 /* SourceFile */: + case 246 /* SourceFile */: return true; // Export assignements do not create name bindings outside the module - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -14635,11 +14844,14 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 224 /* ExportAssignment */) { - exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, node); + if (node.parent && node.parent.kind === 225 /* ExportAssignment */) { + exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 227 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent); + else if (node.parent.kind === 228 /* ExportSpecifier */) { + var exportSpecifier = node.parent; + exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? + getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : + resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } var result = []; if (exportSymbol) { @@ -14663,40 +14875,71 @@ var ts; }); } } - // Push an entry on the type resolution stack. If an entry with the given target is not already on the stack, - // a new entry with that target and an associated result value of true is pushed on the stack, and the value - // true is returned. Otherwise, a circularity has occurred and the result values of the existing entry and - // all entries pushed after it are changed to false, and the value false is returned. The target object provides - // a unique identity for a particular type resolution result: Symbol instances are used to track resolution of - // SymbolLinks.type, SymbolLinks instances are used to track resolution of SymbolLinks.declaredType, and - // Signature instances are used to track resolution of Signature.resolvedReturnType. - function pushTypeResolution(target) { - var i = 0; - var count = resolutionTargets.length; - while (i < count && resolutionTargets[i] !== target) { - i++; - } - if (i < count) { - do { - resolutionResults[i++] = false; - } while (i < count); + /** + * Push an entry on the type resolution stack. If an entry with the given target and the given property name + * is already on the stack, and no entries in between already have a type, then a circularity has occurred. + * In this case, the result values of the existing entry and all entries pushed after it are changed to false, + * and the value false is returned. Otherwise, the new entry is just pushed onto the stack, and true is returned. + * In order to see if the same query has already been done before, the target object and the propertyName both + * must match the one passed in. + * + * @param target The symbol, type, or signature whose type is being queried + * @param propertyName The property name that should be used to query the target for its type + */ + function pushTypeResolution(target, propertyName) { + var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); + if (resolutionCycleStartIndex >= 0) { + // A cycle was found + var length_2 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_2; i++) { + resolutionResults[i] = false; + } return false; } resolutionTargets.push(target); resolutionResults.push(true); + resolutionPropertyNames.push(propertyName); return true; } + function findResolutionCycleStartIndex(target, propertyName) { + for (var i = resolutionTargets.length - 1; i >= 0; i--) { + if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) { + return -1; + } + if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) { + return i; + } + } + return -1; + } + function hasType(target, propertyName) { + if (propertyName === 0 /* Type */) { + return getSymbolLinks(target).type; + } + if (propertyName === 2 /* DeclaredType */) { + return getSymbolLinks(target).declaredType; + } + if (propertyName === 1 /* ResolvedBaseConstructorType */) { + ts.Debug.assert(!!(target.flags & 1024 /* Class */)); + return target.resolvedBaseConstructorType; + } + if (propertyName === 3 /* ResolvedReturnType */) { + return target.resolvedReturnType; + } + ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + } // Pop an entry from the type resolution stack and return its associated result value. The result value will // be true if no circularities were detected, or false if a circularity was found. function popTypeResolution() { resolutionTargets.pop(); + resolutionPropertyNames.pop(); return resolutionResults.pop(); } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 208 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 209 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -14732,7 +14975,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 158 /* ObjectBindingPattern */) { + if (pattern.kind === 159 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_10 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, @@ -14749,11 +14992,8 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); + var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false); if (!declaration.dotDotDotToken) { - if (isTypeAny(elementType)) { - return elementType; - } // Use specific property type when parent is a tuple or numeric index type when parent is an array var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) @@ -14779,10 +15019,10 @@ var ts; // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 197 /* ForInStatement */) { + if (declaration.parent.parent.kind === 198 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 198 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 199 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -14796,11 +15036,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135 /* Parameter */) { + if (declaration.kind === 136 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 143 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 142 /* GetAccessor */); + if (func.kind === 144 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 143 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -14816,54 +15056,58 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 243 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 244 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } + // If the declaration specifies a binding pattern, use the type implied by the binding pattern + if (ts.isBindingPattern(declaration.name)) { + return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false); + } // No type specified and nothing can be inferred return undefined; } // Return the type implied by a binding pattern element. This is the type of the initializer of the element if // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding // pattern. Otherwise, it is the type any. - function getTypeFromBindingElement(element) { + function getTypeFromBindingElement(element, includePatternInType) { if (element.initializer) { return getWidenedType(checkExpressionCached(element.initializer)); } if (ts.isBindingPattern(element.name)) { - return getTypeFromBindingPattern(element.name); + return getTypeFromBindingPattern(element.name, includePatternInType); } return anyType; } // Return the type implied by an object binding pattern - function getTypeFromObjectBindingPattern(pattern) { + function getTypeFromObjectBindingPattern(pattern, includePatternInType) { var members = {}; ts.forEach(pattern.elements, function (e) { var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0); var name = e.propertyName || e.name; var symbol = createSymbol(flags, name.text); - symbol.type = getTypeFromBindingElement(e); + symbol.type = getTypeFromBindingElement(e, includePatternInType); + symbol.bindingElement = e; members[symbol.name] = symbol; }); - return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + if (includePatternInType) { + result.pattern = pattern; + } + return result; } // Return the type implied by an array binding pattern - function getTypeFromArrayBindingPattern(pattern) { - var hasSpreadElement = false; - var elementTypes = []; - ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 184 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); - if (e.dotDotDotToken) { - hasSpreadElement = true; - } - }); - if (!elementTypes.length) { + function getTypeFromArrayBindingPattern(pattern, includePatternInType) { + var elements = pattern.elements; + if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; } - else if (hasSpreadElement) { - var unionOfElements = getUnionType(elementTypes); - return languageVersion >= 2 /* ES6 */ ? createIterableType(unionOfElements) : createArrayType(unionOfElements); - } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. + var elementTypes = ts.map(elements, function (e) { return e.kind === 185 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); }); + if (includePatternInType) { + var result = createNewTupleType(elementTypes); + result.pattern = pattern; + return result; + } return createTupleType(elementTypes); } // Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself @@ -14873,10 +15117,10 @@ var ts; // used as the contextual type of an initializer associated with the binding pattern. Also, for a destructuring // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. - function getTypeFromBindingPattern(pattern) { - return pattern.kind === 158 /* ObjectBindingPattern */ - ? getTypeFromObjectBindingPattern(pattern) - : getTypeFromArrayBindingPattern(pattern); + function getTypeFromBindingPattern(pattern, includePatternInType) { + return pattern.kind === 159 /* ObjectBindingPattern */ + ? getTypeFromObjectBindingPattern(pattern, includePatternInType) + : getTypeFromArrayBindingPattern(pattern, includePatternInType); } // Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type // specified in a type annotation or inferred from an initializer. However, in the case of a destructuring declaration it @@ -14896,19 +15140,14 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - return declaration.kind !== 242 /* PropertyAssignment */ ? getWidenedType(type) : type; - } - // If no type was specified and nothing could be inferred, and if the declaration specifies a binding pattern, use - // the type implied by the binding pattern - if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return declaration.kind !== 243 /* PropertyAssignment */ ? getWidenedType(type) : type; } // Rest parameters default to type any[], other parameters default to type any type = declaration.dotDotDotToken ? anyArrayType : anyType; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 135 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 136 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -14923,18 +15162,18 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 241 /* CatchClause */) { + if (declaration.parent.kind === 242 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 224 /* ExportAssignment */) { + if (declaration.kind === 225 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var type = getWidenedTypeForVariableLikeDeclaration(declaration, true); + var type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); if (!popTypeResolution()) { if (symbol.valueDeclaration.type) { // Variable has type annotation that circularly references the variable itself @@ -14955,7 +15194,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 142 /* GetAccessor */) { + if (accessor.kind === 143 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -14968,11 +15207,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol)) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 142 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 143 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 144 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -15001,7 +15240,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 142 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 143 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -15101,9 +15340,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 211 /* ClassDeclaration */ || node.kind === 183 /* ClassExpression */ || - node.kind === 210 /* FunctionDeclaration */ || node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */ || node.kind === 171 /* ArrowFunction */) { + if (node.kind === 212 /* ClassDeclaration */ || node.kind === 184 /* ClassExpression */ || + node.kind === 211 /* FunctionDeclaration */ || node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */ || node.kind === 172 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -15113,7 +15352,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 212 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -15122,8 +15361,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 212 /* InterfaceDeclaration */ || node.kind === 211 /* ClassDeclaration */ || - node.kind === 183 /* ClassExpression */ || node.kind === 213 /* TypeAliasDeclaration */) { + if (node.kind === 213 /* InterfaceDeclaration */ || node.kind === 212 /* ClassDeclaration */ || + node.kind === 184 /* ClassExpression */ || node.kind === 214 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -15166,7 +15405,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type)) { + if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -15234,7 +15473,7 @@ var ts; return; } if (type === baseType || hasBaseType(baseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); return; } type.resolvedBaseTypes = [baseType]; @@ -15243,7 +15482,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 212 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 213 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -15253,7 +15492,7 @@ var ts; type.resolvedBaseTypes.push(baseType); } else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); + error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */)); } } else { @@ -15289,10 +15528,10 @@ var ts; if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(links)) { + if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 213 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 214 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -15325,7 +15564,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -15487,48 +15726,75 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); + var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noSubtypeReduction*/ true))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } - function signatureListsIdentical(s, t) { - if (s.length !== t.length) { - return false; - } - for (var i = 0; i < s.length; i++) { - if (!compareSignatures(s[i], t[i], false, compareTypes)) { - return false; + function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { + for (var _i = 0; _i < signatureList.length; _i++) { + var s = signatureList[_i]; + if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { + return s; } } - return true; } - // If the lists of call or construct signatures in the given types are all identical except for return types, - // and if none of the signatures are generic, return a list of signatures that has substitutes a union of the - // return types of the corresponding signatures in each resulting signature. - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var signatures = signatureLists[0]; - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; - if (signature.typeParameters) { - return emptyArray; + function findMatchingSignatures(signatureLists, signature, listIndex) { + if (signature.typeParameters) { + // We require an exact match for generic signatures, so we only return signatures from the first + // signature list and only if they have exact matches in the other signature lists. + if (listIndex > 0) { + return undefined; } - } - for (var i_1 = 1; i_1 < signatureLists.length; i_1++) { - if (!signatureListsIdentical(signatures, signatureLists[i_1])) { - return emptyArray; + for (var i = 1; i < signatureLists.length; i++) { + if (!findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ false)) { + return undefined; + } } + return [signature]; } - var result = ts.map(signatures, cloneSignature); - for (var i = 0; i < result.length; i++) { - var s = result[i]; - // Clear resolved return type we possibly got from cloneSignature - s.resolvedReturnType = undefined; - s.unionSignatures = ts.map(signatureLists, function (signatures) { return signatures[i]; }); + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + // Allow matching non-generic signatures to have excess parameters and different return types + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreReturnTypes*/ true); + if (!match) { + return undefined; + } + if (!ts.contains(result, match)) { + (result || (result = [])).push(match); + } } return result; } + // The signatures of a union type are those signatures that are present in each of the constituent types. + // Generic signatures must match exactly, but non-generic signatures are allowed to have extra optional + // parameters and may differ in return types. When signatures differ in return types, the resulting return + // type is the union of the constituent return types. + function getUnionSignatures(types, kind) { + var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); + var result = undefined; + for (var i = 0; i < signatureLists.length; i++) { + for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { + var signature = _a[_i]; + // Only process signatures with parameter lists that aren't already in the result list + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true)) { + var unionSignatures = findMatchingSignatures(signatureLists, signature, i); + if (unionSignatures) { + var s = signature; + // Union the result types when more than one signature matches + if (unionSignatures.length > 1) { + s = cloneSignature(signature); + // Clear resolved return type we possibly got from cloneSignature + s.resolvedReturnType = undefined; + s.unionSignatures = unionSignatures; + } + (result || (result = [])).push(s); + } + } + } + } + return result || emptyArray; + } function getUnionIndexType(types, kind) { var indexTypes = []; for (var _i = 0; _i < types.length; _i++) { @@ -15679,9 +15945,6 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - if (type.flags & 16384 /* Union */) { - type = getReducedTypeOfUnionType(type); - } if (type.flags & 512 /* TypeParameter */) { do { type = getConstraintOfTypeParameter(type); @@ -15699,7 +15962,7 @@ var ts; else if (type.flags & 8 /* Boolean */) { type = globalBooleanType; } - else if (type.flags & 4194304 /* ESSymbol */) { + else if (type.flags & 16777216 /* ESSymbol */) { type = globalESSymbolType; } return type; @@ -15791,8 +16054,10 @@ var ts; } return emptyArray; } - // Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and - // maps primitive types and type parameters are to their apparent types. + /** + * Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and + * maps primitive types and type parameters are to their apparent types. + */ function getSignaturesOfType(type, kind) { return getSignaturesOfStructuredType(getApparentType(type), kind); } @@ -15845,12 +16110,22 @@ var ts; return result; } function isOptionalParameter(node) { - return ts.hasQuestionToken(node) || !!node.initializer; + if (ts.hasQuestionToken(node)) { + return true; + } + if (node.initializer) { + var signatureDeclaration = node.parent; + var signature = getSignatureFromDeclaration(signatureDeclaration); + var parameterIndex = signatureDeclaration.parameters.indexOf(node); + ts.Debug.assert(parameterIndex >= 0); + return parameterIndex >= signature.minArgumentCount; + } + return false; } function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 141 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 142 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -15859,14 +16134,18 @@ var ts; for (var i = 0, n = declaration.parameters.length; i < n; i++) { var param = declaration.parameters[i]; parameters.push(param.symbol); - if (param.type && param.type.kind === 8 /* StringLiteral */) { + if (param.type && param.type.kind === 9 /* StringLiteral */) { hasStringLiterals = true; } - if (minArgumentCount < 0) { - if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (param.initializer || param.questionToken || param.dotDotDotToken) { + if (minArgumentCount < 0) { minArgumentCount = i; } } + else { + // If we see any required parameters, it means the prior ones were not in fact optional. + minArgumentCount = -1; + } } if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length; @@ -15878,7 +16157,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 147 /* TypePredicate */) { + if (declaration.type.kind === 148 /* TypePredicate */) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -15890,8 +16169,8 @@ var ts; else { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 142 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 143 /* SetAccessor */); + if (declaration.kind === 143 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 144 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -15909,19 +16188,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -15938,7 +16217,7 @@ var ts; } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature)) { + if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { return unknownType; } var type; @@ -15998,7 +16277,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 141 /* Constructor */ || signature.declaration.kind === 145 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 142 /* Constructor */ || signature.declaration.kind === 146 /* ConstructSignature */; var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -16012,7 +16291,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 125 /* NumberKeyword */ : 127 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 126 /* NumberKeyword */ : 128 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -16041,13 +16320,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 134 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 135 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 134 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 135 /* TypeParameter */).parent); } function getTypeListId(types) { switch (types.length) { @@ -16066,22 +16345,23 @@ var ts; return result; } } - // This function is used to propagate widening flags when creating new object types references and union types. - // It is only necessary to do so if a constituent type might be the undefined type, the null type, or the type - // of an object literal (since those types have widening related information we need to track). - function getWideningFlagsOfTypes(types) { + // This function is used to propagate certain flags when creating new object type references and union types. + // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type + // of an object literal or the anyFunctionType. This is because there are operations in the type checker + // that care about the presence of such types at arbitrary depth in a containing type. + function getPropagatingFlagsOfTypes(types) { var result = 0; for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; result |= type.flags; } - return result & 3145728 /* RequiresWidening */; + return result & 14680064 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations[id]; if (!type) { - var flags = 4096 /* Reference */ | getWideningFlagsOfTypes(typeArguments); + var flags = 4096 /* Reference */ | getPropagatingFlagsOfTypes(typeArguments); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -16100,16 +16380,16 @@ var ts; currentNode = currentNode.parent; } // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 134 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 135 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 148 /* TypeReference */ && n.typeName.kind === 66 /* Identifier */) { + if (n.kind === 149 /* TypeReference */ && n.typeName.kind === 67 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { - var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, undefined, undefined); + var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); if (symbol && (symbol.flags & 262144 /* TypeParameter */)) { // TypeScript 1.0 spec (April 2014): 3.4.1 // Type parameters declared in a particular type parameter list @@ -16138,7 +16418,7 @@ var ts; var typeParameters = type.localTypeParameters; if (typeParameters) { if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); + error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); return unknownType; } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -16193,7 +16473,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 148 /* TypeReference */ ? node.typeName : + var typeNameOrExpression = node.kind === 149 /* TypeReference */ ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; @@ -16225,9 +16505,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: return declaration; } } @@ -16261,14 +16541,14 @@ var ts; } function tryGetGlobalType(name, arity) { if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, undefined), arity); + return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, /*diagnostic*/ undefined), arity); } /** * Returns a type that is inside a namespace at the global scope, e.g. * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type */ function getExportedTypeFromNamespace(namespace, name) { - var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, undefined); + var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } @@ -16280,7 +16560,7 @@ var ts; */ function createTypedPropertyDescriptorType(propertyType) { var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyObjectType + return globalTypedPropertyDescriptorType !== emptyGenericType ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } @@ -16308,11 +16588,11 @@ var ts; } function createTupleType(elementTypes) { var id = getTypeListId(elementTypes); - var type = tupleTypes[id]; - if (!type) { - type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getWideningFlagsOfTypes(elementTypes)); - type.elementTypes = elementTypes; - } + return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); + } + function createNewTupleType(elementTypes) { + var type = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes)); + type.elementTypes = elementTypes; return type; } function getTypeFromTupleTypeNode(node) { @@ -16339,9 +16619,8 @@ var ts; } } function isSubtypeOfAny(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; - if (candidate !== type && isTypeSubtypeOf(candidate, type)) { + for (var i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { return true; } } @@ -16374,24 +16653,23 @@ var ts; } } } - function compareTypeIds(type1, type2) { - return type1.id - type2.id; - } - // The noSubtypeReduction flag is there because it isn't possible to always do subtype reduction. The flag - // is true when creating a union type from a type node and when instantiating a union type. In both of those - // cases subtype reduction has to be deferred to properly support recursive union types. For example, a - // type alias of the form "type Item = string | (() => Item)" cannot be reduced during its declaration. + // We reduce the constituent type set to only include types that aren't subtypes of other types, unless + // the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on + // object identity. Subtype reduction is possible only when union types are known not to circularly + // reference themselves (as is the case with union types created by expression constructs such as array + // literals and the || and ?: operators). Named types can circularly reference themselves and therefore + // cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is + // a named type that circularly references itself. function getUnionType(types, noSubtypeReduction) { if (types.length === 0) { return emptyObjectType; } var typeSet = []; addTypesToSet(typeSet, types, 16384 /* Union */); - typeSet.sort(compareTypeIds); + if (containsTypeAny(typeSet)) { + return anyType; + } if (noSubtypeReduction) { - if (containsTypeAny(typeSet)) { - return anyType; - } removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } @@ -16404,37 +16682,19 @@ var ts; var id = getTypeListId(typeSet); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 /* Union */ | getWideningFlagsOfTypes(typeSet)); + type = unionTypes[id] = createObjectType(16384 /* Union */ | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; - type.reducedType = noSubtypeReduction ? undefined : type; } return type; } - // Subtype reduction is basically an optimization we do to avoid excessively large union types, which take longer - // to process and look strange in quick info and error messages. Semantically there is no difference between the - // reduced type and the type itself. So, when we detect a circularity we simply say that the reduced type is the - // type itself. - function getReducedTypeOfUnionType(type) { - if (!type.reducedType) { - type.reducedType = circularType; - var reducedType = getUnionType(type.types, false); - if (type.reducedType === circularType) { - type.reducedType = reducedType; - } - } - else if (type.reducedType === circularType) { - type.reducedType = type; - } - return type.reducedType; - } function getTypeFromUnionTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), true); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true); } return links.resolvedType; } - // We do not perform supertype reduction on intersection types. Intersection types are created only by the & + // We do not perform structural deduplication on intersection types. Intersection types are created only by the & // type operator and we can't reduce those because we want to support recursive intersection types. For example, // a type alias of the form "type List = T & { next: List }" cannot be reduced during its declaration. // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution @@ -16454,7 +16714,7 @@ var ts; var id = getTypeListId(typeSet); var type = intersectionTypes[id]; if (!type) { - type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getWideningFlagsOfTypes(typeSet)); + type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getPropagatingFlagsOfTypes(typeSet)); type.types = typeSet; } return type; @@ -16491,47 +16751,47 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 114 /* AnyKeyword */: + case 115 /* AnyKeyword */: return anyType; - case 127 /* StringKeyword */: + case 128 /* StringKeyword */: return stringType; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: return numberType; - case 117 /* BooleanKeyword */: + case 118 /* BooleanKeyword */: return booleanType; - case 128 /* SymbolKeyword */: + case 129 /* SymbolKeyword */: return esSymbolType; - case 100 /* VoidKeyword */: + case 101 /* VoidKeyword */: return voidType; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return getTypeFromTypeReference(node); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return booleanType; - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 154 /* TupleType */: + case 155 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 155 /* UnionType */: + case 156 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 156 /* IntersectionType */: + case 157 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 152 /* TypeLiteral */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 153 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 66 /* Identifier */: - case 132 /* QualifiedName */: - var symbol = getSymbolInfo(node); + case 67 /* Identifier */: + case 133 /* QualifiedName */: + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: return unknownType; @@ -16590,7 +16850,7 @@ var ts; }; } function createInferenceMapper(context) { - return function (t) { + var mapper = function (t) { for (var i = 0; i < context.typeParameters.length; i++) { if (t === context.typeParameters[i]) { context.inferences[i].isFixed = true; @@ -16599,6 +16859,8 @@ var ts; } return t; }; + mapper.context = context; + return mapper; } function identityMapper(type) { return type; @@ -16659,6 +16921,15 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { + if (mapper.instantiations) { + var cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol); result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); @@ -16671,6 +16942,7 @@ var ts; result.stringIndexType = instantiateType(stringIndexType, mapper); if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper); + mapper.instantiations[type.id] = result; return result; } function instantiateType(type, mapper) { @@ -16689,7 +16961,7 @@ var ts; return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); } if (type.flags & 16384 /* Union */) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), true); + return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noSubtypeReduction*/ true); } if (type.flags & 32768 /* Intersection */) { return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); @@ -16700,27 +16972,27 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 178 /* BinaryExpression */: - return node.operatorToken.kind === 50 /* BarBarToken */ && + case 179 /* BinaryExpression */: + return node.operatorToken.kind === 51 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -16744,16 +17016,16 @@ var ts; } // TYPE CHECKING function isTypeIdenticalTo(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined); + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined); } function compareTypes(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined) ? -1 /* True */ : 0 /* False */; + return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? -1 /* True */ : 0 /* False */; } function isTypeSubtypeOf(source, target) { - return checkTypeSubtypeOf(source, target, undefined); + return checkTypeSubtypeOf(source, target, /*errorNode*/ undefined); } function isTypeAssignableTo(source, target) { - return checkTypeAssignableTo(source, target, undefined); + return checkTypeAssignableTo(source, target, /*errorNode*/ undefined); } function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); @@ -16764,7 +17036,7 @@ var ts; function isSignatureAssignableTo(source, target) { var sourceType = getOrCreateTypeFromSignature(source); var targetType = getOrCreateTypeFromSignature(target); - return checkTypeRelatedTo(sourceType, targetType, assignableRelation, undefined); + return checkTypeRelatedTo(sourceType, targetType, assignableRelation, /*errorNode*/ undefined); } /** * Checks if 'source' is related to 'target' (e.g.: is a assignable to). @@ -16772,7 +17044,7 @@ var ts; * @param target The right-hand-side of the relation. * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. * Used as both to determine which checks are performed and as a cache of previously computed results. - * @param errorNode The node upon which all errors will be reported, if defined. + * @param errorNode The suggested node upon which all errors will be reported, if defined. This may or may not be the actual node used. * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. * @param containingMessageChain A chain of errors to prepend any new errors found. */ @@ -16809,6 +17081,15 @@ var ts; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } + function reportRelationError(message, source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if (sourceType === targetType) { + sourceType = typeToString(source, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); + targetType = typeToString(target, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); + } + reportError(message || ts.Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + } // Compare two types and return // Ternary.True if they are related with no assumptions, // Ternary.Maybe if they are related with assumptions of other relationships, or @@ -16818,110 +17099,170 @@ var ts; // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return -1 /* True */; - if (relation !== identityRelation) { - if (isTypeAny(target)) + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + if (isTypeAny(target)) + return -1 /* True */; + if (source === undefinedType) + return -1 /* True */; + if (source === nullType && target !== undefinedType) + return -1 /* True */; + if (source.flags & 128 /* Enum */ && target === numberType) + return -1 /* True */; + if (source.flags & 256 /* StringLiteral */ && target === stringType) + return -1 /* True */; + if (relation === assignableRelation) { + if (isTypeAny(source)) return -1 /* True */; - if (source === undefinedType) + if (source === numberType && target.flags & 128 /* Enum */) return -1 /* True */; - if (source === nullType && target !== undefinedType) - return -1 /* True */; - if (source.flags & 128 /* Enum */ && target === numberType) - return -1 /* True */; - if (source.flags & 256 /* StringLiteral */ && target === stringType) - return -1 /* True */; - if (relation === assignableRelation) { - if (isTypeAny(source)) - return -1 /* True */; - if (source === numberType && target.flags & 128 /* Enum */) - return -1 /* True */; + } + if (source.flags & 1048576 /* FreshObjectLiteral */) { + if (hasExcessProperties(source, target, reportErrors)) { + if (reportErrors) { + reportRelationError(headMessage, source, target); + } + return 0 /* False */; + } + // Above we check for excess properties with respect to the entire target type. When union + // and intersection types are further deconstructed on the target side, we don't want to + // make the check again (as it might fail for a partial target type). Therefore we obtain + // the regular source type and proceed with that. + if (target.flags & 49152 /* UnionOrIntersection */) { + source = getRegularTypeOfObjectLiteral(source); } } var saveErrorInfo = errorInfo; - if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - // We have type references to same target type, see if relationship holds for all type arguments - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + // Note that the "each" checks must precede the "some" checks to produce the correct results + if (source.flags & 16384 /* Union */) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { return result; } } - else if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { - if (result = typeParameterRelatedTo(source, target, reportErrors)) { + else if (target.flags & 32768 /* Intersection */) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { return result; } } - else if (relation !== identityRelation) { - // Note that the "each" checks must precede the "some" checks to produce the correct results - if (source.flags & 16384 /* Union */) { - if (result = eachTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 32768 /* Intersection */) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else { - // It is necessary to try "each" checks on both sides because there may be nested "some" checks - // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or - // A & B = (A & B) | (C & D). - if (source.flags & 32768 /* Intersection */) { - // If target is a union type the following check will report errors so we suppress them here - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { - return result; - } - } - if (target.flags & 16384 /* Union */) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { - return result; - } - } - } - } else { - if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || - source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } + // It is necessary to try "some" checks on both sides because there may be nested "each" checks + // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or + // A & B = (A & B) | (C & D). + if (source.flags & 32768 /* Intersection */) { + // If target is a union type the following check will report errors so we suppress them here + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { + return result; + } + } + if (target.flags & 16384 /* Union */) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; } } } - // Even if relationship doesn't hold for unions, type parameters, or generic type references, - // it may hold in a structural comparison. - // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - // Identity relation does not use apparent type - var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates - // to X. Failing both of those we want to check if the aggregation of A and B's members structurally - // relates to X. Thus, we include intersection types on the source side here. - if (sourceOrApparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { - if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + if (source.flags & 512 /* TypeParameter */) { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1 /* Any */) { + constraint = emptyObjectType; + } + // Report constraint errors only if the constraint is not the empty object type + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 512 /* TypeParameter */ && sourceOrApparentType.flags & 49152 /* UnionOrIntersection */) { - // We clear the errors first because the following check often gives a better error than - // the union or intersection comparison above if it is applicable. - errorInfo = saveErrorInfo; - if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { - return result; + else { + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if relationship holds for all type arguments + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; + } + } + // Even if relationship doesn't hold for unions, intersections, or generic type references, + // it may hold in a structural comparison. + var apparentType = getApparentType(source); + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. + if (apparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { + // Report structural errors only if we haven't reported any errors yet + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; + if (result = objectTypeRelatedTo(apparentType, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } if (reportErrors) { - headMessage = headMessage || ts.Diagnostics.Type_0_is_not_assignable_to_type_1; - var sourceType = typeToString(source); - var targetType = typeToString(target); - if (sourceType === targetType) { - sourceType = typeToString(source, undefined, 128 /* UseFullyQualifiedType */); - targetType = typeToString(target, undefined, 128 /* UseFullyQualifiedType */); - } - reportError(headMessage, sourceType, targetType); + reportRelationError(headMessage, source, target); } return 0 /* False */; } + function isIdenticalTo(source, target) { + var result; + if (source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */) { + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if all type arguments are identical + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, /*reportErrors*/ false)) { + return result; + } + } + return objectTypeRelatedTo(source, target, /*reportErrors*/ false); + } + if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { + return typeParameterIdenticalTo(source, target); + } + if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || + source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } + } + return 0 /* False */; + } + // Check if a property with the given name is known anywhere in the given type. In an object type, a property + // is considered known if the object type is empty and the check is for assignability, if the object type has + // index signatures, or if the property is actually declared in the object type. In a union or intersection + // type, a property is considered known if it is known in any constituent type. + function isKnownProperty(type, name) { + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); + if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || + resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + return true; + } + return false; + } + if (type.flags & 49152 /* UnionOrIntersection */) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } + function hasExcessProperties(source, target, reportErrors) { + for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { + var prop = _a[_i]; + if (!isKnownProperty(target, prop.name)) { + if (reportErrors) { + // We know *exactly* where things went wrong when comparing the types. + // Use this property as the error node as this will be more helpful in + // reasoning about what went wrong. + errorNode = prop.valueDeclaration; + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + } + return true; + } + } + } function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; var sourceTypes = source.types; @@ -16992,31 +17333,18 @@ var ts; } return result; } - function typeParameterRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - if (source.symbol.name !== target.symbol.name) { - return 0 /* False */; - } - // covers case when both type parameters does not have constraint (both equal to noConstraintType) - if (source.constraint === target.constraint) { - return -1 /* True */; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0 /* False */; - } - return isRelatedTo(source.constraint, target.constraint, reportErrors); - } - else { - while (true) { - var constraint = getConstraintOfTypeParameter(source); - if (constraint === target) - return -1 /* True */; - if (!(constraint && constraint.flags & 512 /* TypeParameter */)) - break; - source = constraint; - } + function typeParameterIdenticalTo(source, target) { + if (source.symbol.name !== target.symbol.name) { return 0 /* False */; } + // covers case when both type parameters does not have constraint (both equal to noConstraintType) + if (source.constraint === target.constraint) { + return -1 /* True */; + } + if (source.constraint === noConstraintType || target.constraint === noConstraintType) { + return 0 /* False */; + } + return isIdenticalTo(source.constraint, target.constraint); } // Determine if two object types are related by structure. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. @@ -17211,26 +17539,20 @@ var ts; var targetSignatures = getSignaturesOfType(target, kind); var result = -1 /* True */; var saveErrorInfo = errorInfo; - // Because the "abstractness" of a class is the same across all construct signatures - // (internally we are checking the corresponding declaration), it is enough to perform - // the check and report an error once over all pairs of source and target construct signatures. - var sourceSig = sourceSignatures[0]; - // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. - var targetSig = targetSignatures[0]; - if (sourceSig && targetSig) { - var sourceErasedSignature = getErasedSignature(sourceSig); - var targetErasedSignature = getErasedSignature(targetSig); - var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); - var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 211 /* ClassDeclaration */); - var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 211 /* ClassDeclaration */); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; - if (sourceIsAbstract && !targetIsAbstract) { - if (reportErrors) { - reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); - } - return 0 /* False */; + if (kind === 1 /* Construct */) { + // Only want to compare the construct signatures for abstractness guarantees. + // Because the "abstractness" of a class is the same across all construct signatures + // (internally we are checking the corresponding declaration), it is enough to perform + // the check and report an error once over all pairs of source and target construct signatures. + // + // sourceSig and targetSig are (possibly) undefined. + // + // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. + var sourceSig = sourceSignatures[0]; + var targetSig = targetSignatures[0]; + result &= abstractSignatureRelatedTo(source, sourceSig, target, targetSig); + if (result !== -1 /* True */) { + return result; } } outer: for (var _i = 0; _i < targetSignatures.length; _i++) { @@ -17255,6 +17577,33 @@ var ts; } } return result; + function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) { + if (sourceSig && targetSig) { + var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); + var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); + if (!sourceDecl) { + // If the source object isn't itself a class declaration, it can be freely assigned, regardless + // of whether the constructed object is abstract or not. + return -1 /* True */; + } + var sourceErasedSignature = getErasedSignature(sourceSig); + var targetErasedSignature = getErasedSignature(targetSig); + var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); + var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; + if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { + // if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment. + if (reportErrors) { + reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return 0 /* False */; + } + } + return -1 /* True */; + } } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { @@ -17345,7 +17694,7 @@ var ts; } var result = -1 /* True */; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { return 0 /* False */; } @@ -17358,7 +17707,7 @@ var ts; return indexTypesIdenticalTo(0 /* String */, source, target); } var targetType = getIndexTypeOfType(target, 0 /* String */); - if (targetType) { + if (targetType && !(targetType.flags & 1 /* Any */)) { var sourceType = getIndexTypeOfType(source, 0 /* String */); if (!sourceType) { if (reportErrors) { @@ -17382,7 +17731,7 @@ var ts; return indexTypesIdenticalTo(1 /* Number */, source, target); } var targetType = getIndexTypeOfType(target, 1 /* Number */); - if (targetType) { + if (targetType && !(targetType.flags & 1 /* Any */)) { var sourceStringType = getIndexTypeOfType(source, 0 /* String */); var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */); if (!(sourceStringType || sourceNumberType)) { @@ -17469,14 +17818,18 @@ var ts; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } - function compareSignatures(source, target, compareReturnTypes, compareTypes) { + function compareSignatures(source, target, partialMatch, ignoreReturnTypes, compareTypes) { if (source === target) { return -1 /* True */; } if (source.parameters.length !== target.parameters.length || source.minArgumentCount !== target.minArgumentCount || source.hasRestParameter !== target.hasRestParameter) { - return 0 /* False */; + if (!partialMatch || + source.parameters.length < target.parameters.length && !source.hasRestParameter || + source.minArgumentCount > target.minArgumentCount) { + return 0 /* False */; + } } var result = -1 /* True */; if (source.typeParameters && target.typeParameters) { @@ -17498,16 +17851,18 @@ var ts; // M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N source = getErasedSignature(source); target = getErasedSignature(target); - for (var i = 0, len = source.parameters.length; i < len; i++) { - var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); + var sourceLen = source.parameters.length; + var targetLen = target.parameters.length; + for (var i = 0; i < targetLen; i++) { + var s = source.hasRestParameter && i === sourceLen - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); + var t = target.hasRestParameter && i === targetLen - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); var related = compareTypes(s, t); if (!related) { return 0 /* False */; } result &= related; } - if (compareReturnTypes) { + if (!ignoreReturnTypes) { result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; @@ -17573,6 +17928,24 @@ var ts; function isTupleType(type) { return !!(type.flags & 8192 /* Tuple */); } + function getRegularTypeOfObjectLiteral(type) { + if (type.flags & 1048576 /* FreshObjectLiteral */) { + var regularType = type.regularType; + if (!regularType) { + regularType = createType(type.flags & ~1048576 /* FreshObjectLiteral */); + regularType.symbol = type.symbol; + regularType.members = type.members; + regularType.properties = type.properties; + regularType.callSignatures = type.callSignatures; + regularType.constructSignatures = type.constructSignatures; + regularType.stringIndexType = type.stringIndexType; + regularType.numberIndexType = type.numberIndexType; + type.regularType = regularType; + } + return regularType; + } + return type; + } function getWidenedTypeOfObjectLiteral(type) { var properties = getPropertiesOfObjectType(type); var members = {}; @@ -17600,7 +17973,7 @@ var ts; return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); } function getWidenedType(type) { - if (type.flags & 3145728 /* RequiresWidening */) { + if (type.flags & 6291456 /* RequiresWidening */) { if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { return anyType; } @@ -17608,7 +17981,7 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 16384 /* Union */) { - return getUnionType(ts.map(type.types, getWidenedType)); + return getUnionType(ts.map(type.types, getWidenedType), /*noSubtypeReduction*/ true); } if (isArrayType(type)) { return createArrayType(getWidenedType(type.typeArguments[0])); @@ -17655,7 +18028,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 1048576 /* ContainsUndefinedOrNull */) { + if (t.flags & 2097152 /* ContainsUndefinedOrNull */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -17669,22 +18042,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 135 /* Parameter */: + case 136 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -17697,7 +18070,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 1048576 /* ContainsUndefinedOrNull */) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152 /* ContainsUndefinedOrNull */) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); @@ -17734,7 +18107,9 @@ var ts; var inferences = []; for (var _i = 0; _i < typeParameters.length; _i++) { var unused = typeParameters[_i]; - inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); + inferences.push({ + primary: undefined, secondary: undefined, isFixed: false + }); } return { typeParameters: typeParameters, @@ -17758,11 +18133,16 @@ var ts; return false; } function inferFromTypes(source, target) { - if (source === anyFunctionType) { - return; - } if (target.flags & 512 /* TypeParameter */) { - // If target is a type parameter, make an inference + // If target is a type parameter, make an inference, unless the source type contains + // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). + // Because the anyFunctionType is internal, it should not be exposed to the user by adding + // it as an inference candidate. Hopefully, a better candidate will come along that does + // not contain anyFunctionType when we come back to this argument for its second round + // of inference. + if (source.flags & 8388608 /* ContainsAnyFunctionType */) { + return; + } var typeParameters = context.typeParameters; for (var i = 0; i < typeParameters.length; i++) { if (target === typeParameters[i]) { @@ -17793,6 +18173,14 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 8192 /* Tuple */ && target.flags & 8192 /* Tuple */ && source.elementTypes.length === target.elementTypes.length) { + // If source and target are tuples of the same size, infer from element types + var sourceTypes = source.elementTypes; + var targetTypes = target.elementTypes; + for (var i = 0; i < sourceTypes.length; i++) { + inferFromTypes(sourceTypes[i], targetTypes[i]); + } + } else if (target.flags & 49152 /* UnionOrIntersection */) { var targetTypes = target.types; var typeParameterCount = 0; @@ -17959,10 +18347,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return true; - case 66 /* Identifier */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 133 /* QualifiedName */: node = node.parent; continue; default: @@ -18008,12 +18396,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 54 /* FirstAssignment */ && node.operatorToken.kind <= 65 /* LastAssignment */) { + if (node.operatorToken.kind >= 55 /* FirstAssignment */ && node.operatorToken.kind <= 66 /* LastAssignment */) { var n = node.left; - while (n.kind === 169 /* ParenthesizedExpression */) { + while (n.kind === 170 /* ParenthesizedExpression */) { n = n.expression; } - if (n.kind === 66 /* Identifier */ && getResolvedSymbol(n) === symbol) { + if (n.kind === 67 /* Identifier */ && getResolvedSymbol(n) === symbol) { return true; } } @@ -18027,96 +18415,60 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: - case 169 /* ParenthesizedExpression */: - case 176 /* PrefixUnaryExpression */: - case 172 /* DeleteExpression */: - case 175 /* AwaitExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 177 /* PostfixUnaryExpression */: - case 181 /* YieldExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 189 /* Block */: - case 190 /* VariableStatement */: - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 201 /* ReturnStatement */: - case 202 /* WithStatement */: - case 203 /* SwitchStatement */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 205 /* ThrowStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 235 /* JsxAttribute */: - case 236 /* JsxSpreadAttribute */: - case 232 /* JsxOpeningElement */: - case 237 /* JsxExpression */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: + case 170 /* ParenthesizedExpression */: + case 177 /* PrefixUnaryExpression */: + case 173 /* DeleteExpression */: + case 176 /* AwaitExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 178 /* PostfixUnaryExpression */: + case 182 /* YieldExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 190 /* Block */: + case 191 /* VariableStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 202 /* ReturnStatement */: + case 203 /* WithStatement */: + case 204 /* SwitchStatement */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 206 /* ThrowStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + case 233 /* JsxOpeningElement */: + case 238 /* JsxExpression */: return ts.forEachChild(node, isAssignedIn); } return false; } } - function resolveLocation(node) { - // Resolve location from top down towards node if it is a context sensitive expression - // That helps in making sure not assigning types as any when resolved out of order - var containerNodes = []; - for (var parent_5 = node.parent; parent_5; parent_5 = parent_5.parent) { - if ((ts.isExpression(parent_5) || ts.isObjectLiteralMethod(node)) && - isContextSensitive(parent_5)) { - containerNodes.unshift(parent_5); - } - } - ts.forEach(containerNodes, function (node) { getTypeOfNode(node); }); - } - function getSymbolAtLocation(node) { - resolveLocation(node); - return getSymbolInfo(node); - } - function getTypeAtLocation(node) { - resolveLocation(node); - return getTypeOfNode(node); - } - function getTypeOfSymbolAtLocation(symbol, node) { - resolveLocation(node); - // Get the narrowed type of symbol at given location instead of just getting - // the type of the symbol. - // eg. - // function foo(a: string | number) { - // if (typeof a === "string") { - // a/**/ - // } - // } - // getTypeOfSymbol for a would return type of parameter symbol string | number - // Unless we provide location /**/, checker wouldn't know how to narrow the type - // By using getNarrowedTypeOfSymbol would return string since it would be able to narrow - // it by typeguard in the if true condition - return getNarrowedTypeOfSymbol(symbol, node); - } // Get the narrowed type of a given symbol at a given location function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); @@ -18128,37 +18480,37 @@ var ts; node = node.parent; var narrowedType = type; switch (node.kind) { - case 193 /* IfStatement */: + case 194 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node.expression) { - narrowedType = narrowType(type, node.expression, child === node.thenStatement); + narrowedType = narrowType(type, node.expression, /*assumeTrue*/ child === node.thenStatement); } break; - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node.condition) { - narrowedType = narrowType(type, node.condition, child === node.whenTrue); + narrowedType = narrowType(type, node.condition, /*assumeTrue*/ child === node.whenTrue); } break; - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { - if (node.operatorToken.kind === 49 /* AmpersandAmpersandToken */) { - narrowedType = narrowType(type, node.left, true); + if (node.operatorToken.kind === 50 /* AmpersandAmpersandToken */) { + narrowedType = narrowType(type, node.left, /*assumeTrue*/ true); } - else if (node.operatorToken.kind === 50 /* BarBarToken */) { - narrowedType = narrowType(type, node.left, false); + else if (node.operatorToken.kind === 51 /* BarBarToken */) { + narrowedType = narrowType(type, node.left, /*assumeTrue*/ false); } } break; - case 245 /* SourceFile */: - case 215 /* ModuleDeclaration */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: + case 246 /* SourceFile */: + case 216 /* ModuleDeclaration */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -18175,23 +18527,23 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 173 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { + if (expr.left.kind !== 174 /* TypeOfExpression */ || expr.right.kind !== 9 /* StringLiteral */) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 66 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 67 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 32 /* ExclamationEqualsEqualsToken */) { + if (expr.operatorToken.kind === 33 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue) { // Assumed result is true. If check was not for a primitive type, remove all primitive types if (!typeInfo) { - return removeTypesFromUnionType(type, 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 4194304 /* ESSymbol */, - /*isOfTypeKind*/ true, false); + return removeTypesFromUnionType(type, /*typeKind*/ 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 16777216 /* ESSymbol */, + /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); } // Check was for a primitive type, return that primitive type if it is a subtype if (isTypeSubtypeOf(typeInfo.type, type)) { @@ -18199,12 +18551,12 @@ var ts; } // Otherwise, remove all types that aren't of the primitive type kind. This can happen when the type is // union of enum types and other types. - return removeTypesFromUnionType(type, typeInfo.flags, false, false); + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ false, /*allowEmptyUnionResult*/ false); } else { // Assumed result is false. If check was for a primitive type, remove that primitive type if (typeInfo) { - return removeTypesFromUnionType(type, typeInfo.flags, true, false); + return removeTypesFromUnionType(type, /*typeKind*/ typeInfo.flags, /*isOfTypeKind*/ true, /*allowEmptyUnionResult*/ false); } // Otherwise we don't have enough information to do anything. return type; @@ -18213,14 +18565,14 @@ var ts; function narrowTypeByAnd(type, expr, assumeTrue) { if (assumeTrue) { // The assumed result is true, therefore we narrow assuming each operand to be true. - return narrowType(narrowType(type, expr.left, true), expr.right, true); + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true); } else { // The assumed result is false. This means either the first operand was false, or the first operand was true // and the second operand was false. We narrow with those assumptions and union the two resulting types. return getUnionType([ - narrowType(type, expr.left, false), - narrowType(narrowType(type, expr.left, true), expr.right, false) + narrowType(type, expr.left, /*assumeTrue*/ false), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ false) ]); } } @@ -18229,18 +18581,18 @@ var ts; // The assumed result is true. This means either the first operand was true, or the first operand was false // and the second operand was true. We narrow with those assumptions and union the two resulting types. return getUnionType([ - narrowType(type, expr.left, true), - narrowType(narrowType(type, expr.left, false), expr.right, true) + narrowType(type, expr.left, /*assumeTrue*/ true), + narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ true) ]); } else { // The assumed result is false, therefore we narrow assuming each operand to be false. - return narrowType(narrowType(type, expr.left, false), expr.right, false); + return narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); } } function narrowTypeByInstanceof(type, expr, assumeTrue) { // Check that type is not any, assumed result is true, and we have variable symbol on the left - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 66 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 67 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } // Check that right operand is a function type with a prototype property @@ -18276,13 +18628,17 @@ var ts; return type; } function getNarrowedType(originalType, narrowedTypeCandidate) { - // Narrow to the target type if it's a subtype of the current type - if (isTypeSubtypeOf(narrowedTypeCandidate, originalType)) { - return narrowedTypeCandidate; - } - // If the current type is a union type, remove all constituents that aren't subtypes of the target. + // If the current type is a union type, remove all constituents that aren't assignable to target. If that produces + // 0 candidates, fall back to the assignability check if (originalType.flags & 16384 /* Union */) { - return getUnionType(ts.filter(originalType.types, function (t) { return isTypeSubtypeOf(t, narrowedTypeCandidate); })); + var assignableConstituents = ts.filter(originalType.types, function (t) { return isTypeAssignableTo(t, narrowedTypeCandidate); }); + if (assignableConstituents.length) { + return getUnionType(assignableConstituents); + } + } + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { + // Narrow to the target type if it's assignable to the current type + return narrowedTypeCandidate; } return originalType; } @@ -18308,27 +18664,27 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 165 /* CallExpression */: + case 166 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: var operator = expr.operatorToken.kind; - if (operator === 31 /* EqualsEqualsEqualsToken */ || operator === 32 /* ExclamationEqualsEqualsToken */) { + if (operator === 32 /* EqualsEqualsEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 49 /* AmpersandAmpersandToken */) { + else if (operator === 50 /* AmpersandAmpersandToken */) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 50 /* BarBarToken */) { + else if (operator === 51 /* BarBarToken */) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 88 /* InstanceOfKeyword */) { + else if (operator === 89 /* InstanceOfKeyword */) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 176 /* PrefixUnaryExpression */: - if (expr.operator === 47 /* ExclamationToken */) { + case 177 /* PrefixUnaryExpression */: + if (expr.operator === 48 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -18346,7 +18702,7 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (container.kind === 171 /* ArrowFunction */) { + if (container.kind === 172 /* ArrowFunction */) { if (languageVersion < 2 /* ES6 */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -18377,7 +18733,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 241 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 242 /* CatchClause */) { return; } // - check if binding is used in some function @@ -18386,19 +18742,19 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 209 /* VariableDeclarationList */) { + while (container.kind !== 210 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 190 /* VariableStatement */) { + if (container.kind === 191 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } var inFunction = isInsideFunction(node.parent, container); var current = container; while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (isIterationStatement(current, false)) { + if (isIterationStatement(current, /*lookInLabeledStatements*/ false)) { if (inFunction) { grammarErrorOnFirstToken(current, ts.Diagnostics.Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher, ts.declarationNameToString(node)); } @@ -18411,7 +18767,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 138 /* PropertyDeclaration */ || container.kind === 141 /* Constructor */) { + if (container.kind === 139 /* PropertyDeclaration */ || container.kind === 142 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -18422,35 +18778,35 @@ var ts; function checkThisExpression(node) { // Stop at the first arrow function so that we can // tell whether 'this' needs to be captured. - var container = ts.getThisContainer(node, true); + var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 171 /* ArrowFunction */) { - container = ts.getThisContainer(container, false); + if (container.kind === 172 /* ArrowFunction */) { + container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); } switch (container.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 141 /* Constructor */: + case 142 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -18465,103 +18821,110 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 135 /* Parameter */) { + if (n.kind === 136 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 165 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; + var container = ts.getSuperContainer(node, /*includeFunctions*/ true); + var needToCaptureLexicalThis = false; + if (!isCallExpression) { + // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting + while (container && container.kind === 172 /* ArrowFunction */) { + container = ts.getSuperContainer(container, /*includeFunctions*/ true); + needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; + } + } + var canUseSuperExpression = isLegalUsageOfSuperExpression(container); + var nodeCheckFlag = 0; + // always set NodeCheckFlags for 'super' expression node + if (canUseSuperExpression) { + if ((container.flags & 128 /* Static */) || isCallExpression) { + nodeCheckFlag = 512 /* SuperStatic */; + } + else { + nodeCheckFlag = 256 /* SuperInstance */; + } + getNodeLinks(node).flags |= nodeCheckFlag; + if (needToCaptureLexicalThis) { + // call expressions are allowed only in constructors so they should always capture correct 'this' + // super property access expressions can also appear in arrow functions - + // in this case they should also use correct lexical this + captureLexicalThis(node.parent, container); + } + } if (!baseClassType) { if (!classDeclaration || !ts.getClassExtendsHeritageClauseElement(classDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); } return unknownType; } - var container = ts.getSuperContainer(node, true); - if (container) { - var canUseSuperExpression = false; - var needToCaptureLexicalThis; + if (!canUseSuperExpression) { + if (container && container.kind === 134 /* ComputedPropertyName */) { + error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); + } + else if (isCallExpression) { + error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); + } + else { + error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); + } + return unknownType; + } + if (container.kind === 142 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) + error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); + return unknownType; + } + return nodeCheckFlag === 512 /* SuperStatic */ + ? getBaseConstructorTypeOfClass(classType) + : baseClassType; + function isLegalUsageOfSuperExpression(container) { + if (!container) { + return false; + } if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - canUseSuperExpression = container.kind === 141 /* Constructor */; + return container.kind === 142 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) // 'super' property access is allowed // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor - // super property access might appear in arrow functions with arbitrary deep nesting - needToCaptureLexicalThis = false; - while (container && container.kind === 171 /* ArrowFunction */) { - container = ts.getSuperContainer(container, true); - needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; - } // topmost container must be something that is directly nested in the class declaration if (container && ts.isClassLike(container.parent)) { if (container.flags & 128 /* Static */) { - canUseSuperExpression = - container.kind === 140 /* MethodDeclaration */ || - container.kind === 139 /* MethodSignature */ || - container.kind === 142 /* GetAccessor */ || - container.kind === 143 /* SetAccessor */; + return container.kind === 141 /* MethodDeclaration */ || + container.kind === 140 /* MethodSignature */ || + container.kind === 143 /* GetAccessor */ || + container.kind === 144 /* SetAccessor */; } else { - canUseSuperExpression = - container.kind === 140 /* MethodDeclaration */ || - container.kind === 139 /* MethodSignature */ || - container.kind === 142 /* GetAccessor */ || - container.kind === 143 /* SetAccessor */ || - container.kind === 138 /* PropertyDeclaration */ || - container.kind === 137 /* PropertySignature */ || - container.kind === 141 /* Constructor */; + return container.kind === 141 /* MethodDeclaration */ || + container.kind === 140 /* MethodSignature */ || + container.kind === 143 /* GetAccessor */ || + container.kind === 144 /* SetAccessor */ || + container.kind === 139 /* PropertyDeclaration */ || + container.kind === 138 /* PropertySignature */ || + container.kind === 142 /* Constructor */; } } } - if (canUseSuperExpression) { - var returnType; - if ((container.flags & 128 /* Static */) || isCallExpression) { - getNodeLinks(node).flags |= 512 /* SuperStatic */; - returnType = getBaseConstructorTypeOfClass(classType); - } - else { - getNodeLinks(node).flags |= 256 /* SuperInstance */; - returnType = baseClassType; - } - if (container.kind === 141 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { - // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) - error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - returnType = unknownType; - } - if (!isCallExpression && needToCaptureLexicalThis) { - // call expressions are allowed only in constructors so they should always capture correct 'this' - // super property access expressions can also appear in arrow functions - - // in this case they should also use correct lexical this - captureLexicalThis(node.parent, container); - } - return returnType; - } + return false; } - if (container && container.kind === 133 /* ComputedPropertyName */) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); - } - else if (isCallExpression) { - error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); - } - else { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; } // Return contextual type of parameter or undefined if no contextual type is available function getContextuallyTypedParameterType(parameter) { - if (isFunctionExpressionOrArrowFunction(parameter.parent)) { - var func = parameter.parent; + var func = parameter.parent; + if (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) { if (isContextSensitive(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -18592,14 +18955,14 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 135 /* Parameter */) { + if (declaration.kind === 136 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; } } if (ts.isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true); } } return undefined; @@ -18625,7 +18988,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 135 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 136 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -18636,8 +18999,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 141 /* Constructor */ || - functionDecl.kind === 142 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 143 /* SetAccessor */))) { + functionDecl.kind === 142 /* Constructor */ || + functionDecl.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 144 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -18659,7 +19022,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 167 /* TaggedTemplateExpression */) { + if (template.parent.kind === 168 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -18667,13 +19030,13 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 54 /* FirstAssignment */ && operator <= 65 /* LastAssignment */) { + if (operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { // In an assignment expression, the right operand is contextually typed by the type of the left operand. if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 50 /* BarBarToken */) { + else if (operator === 51 /* BarBarToken */) { // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); @@ -18769,7 +19132,7 @@ var ts; var index = ts.indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, 1 /* Number */) - || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, undefined) : undefined); + || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); } return undefined; } @@ -18780,7 +19143,7 @@ var ts; } function getContextualTypeForJsxExpression(expr) { // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) - if (expr.parent.kind === 235 /* JsxAttribute */) { + if (expr.parent.kind === 236 /* JsxAttribute */) { var attrib = expr.parent; var attrsType = getJsxElementAttributesType(attrib.parent); if (!attrsType || isTypeAny(attrsType)) { @@ -18790,7 +19153,7 @@ var ts; return getTypeOfPropertyOfType(attrsType, attrib.name.text); } } - if (expr.kind === 236 /* JsxSpreadAttribute */) { + if (expr.kind === 237 /* JsxSpreadAttribute */) { return getJsxElementAttributesType(expr.parent); } return undefined; @@ -18811,38 +19174,38 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 208 /* VariableDeclaration */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 161 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 171 /* ArrowFunction */: - case 201 /* ReturnStatement */: + case 172 /* ArrowFunction */: + case 202 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 187 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 180 /* TemplateExpression */); + case 188 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 181 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return getContextualType(parent); - case 237 /* JsxExpression */: - case 236 /* JsxSpreadAttribute */: + case 238 /* JsxExpression */: + case 237 /* JsxSpreadAttribute */: return getContextualTypeForJsxExpression(parent); } return undefined; @@ -18859,7 +19222,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 170 /* FunctionExpression */ || node.kind === 171 /* ArrowFunction */; + return node.kind === 171 /* FunctionExpression */ || node.kind === 172 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -18873,7 +19236,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -18887,19 +19250,13 @@ var ts; var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; - // The signature set of all constituent type with call signatures should match - // So number of signatures allowed is either 0 or 1 - if (signatureList && - getSignaturesOfStructuredType(current, 0 /* Call */).length > 1) { - return undefined; - } var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { // This signature will contribute to contextual union signature signatureList = [signature]; } - else if (!compareSignatures(signatureList[0], signature, false, compareTypes)) { + else if (!compareSignatures(signatureList[0], signature, /*partialMatch*/ false, /*ignoreReturnTypes*/ true, compareTypes)) { // Signatures aren't identical, do not use return undefined; } @@ -18919,23 +19276,36 @@ var ts; } return result; } - // Presence of a contextual type mapper indicates inferential typing, except the identityMapper object is - // used as a special marker for other purposes. + /** + * Detect if the mapper implies an inference context. Specifically, there are 4 possible values + * for a mapper. Let's go through each one of them: + * + * 1. undefined - this means we are not doing inferential typing, but we may do contextual typing, + * which could cause us to assign a parameter a type + * 2. identityMapper - means we want to avoid assigning a parameter a type, whether or not we are in + * inferential typing (context is undefined for the identityMapper) + * 3. a mapper created by createInferenceMapper - we are doing inferential typing, we want to assign + * types to parameters and fix type parameters (context is defined) + * 4. an instantiation mapper created by createTypeMapper or createTypeEraser - this should never be + * passed as the contextual mapper when checking an expression (context is undefined for these) + * + * isInferentialContext is detecting if we are in case 3 + */ function isInferentialContext(mapper) { - return mapper && mapper !== identityMapper; + return mapper && mapper.context; } // A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property // assignment in an object literal that is an assignment target, or if it is parented by an array literal that is // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 178 /* BinaryExpression */ && parent.operatorToken.kind === 54 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 179 /* BinaryExpression */ && parent.operatorToken.kind === 55 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 242 /* PropertyAssignment */) { + if (parent.kind === 243 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 161 /* ArrayLiteralExpression */) { + if (parent.kind === 162 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -18948,19 +19318,20 @@ var ts; // So the fact that contextualMapper is passed is not important, because the operand of a spread // element is not contextually typed. var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); + } + function hasDefaultValue(node) { + return (node.kind === 161 /* BindingElement */ && !!node.initializer) || + (node.kind === 179 /* BinaryExpression */ && node.operatorToken.kind === 55 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; - if (!elements.length) { - return createArrayType(undefinedType); - } var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 182 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 183 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -18975,7 +19346,7 @@ var ts; // if there is no index type / iterated type. var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1 /* Number */) || - (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(restArrayType, undefined) : undefined); + (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); if (restElementType) { elementTypes.push(restElementType); } @@ -18984,18 +19355,45 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 182 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 183 /* SpreadElementExpression */; } if (!hasSpreadElement) { + // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such + // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". + if (inDestructuringPattern && elementTypes.length) { + var type = createNewTupleType(elementTypes); + type.pattern = node; + return type; + } var contextualType = getContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) { - return createTupleType(elementTypes); + if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { + var pattern = contextualType.pattern; + // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting + // tuple type with the corresponding binding or assignment element types to make the lengths equal. + if (pattern && (pattern.kind === 160 /* ArrayBindingPattern */ || pattern.kind === 162 /* ArrayLiteralExpression */)) { + var patternElements = pattern.elements; + for (var i = elementTypes.length; i < patternElements.length; i++) { + var patternElement = patternElements[i]; + if (hasDefaultValue(patternElement)) { + elementTypes.push(contextualType.elementTypes[i]); + } + else { + if (patternElement.kind !== 185 /* OmittedExpression */) { + error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + elementTypes.push(unknownType); + } + } + } + if (elementTypes.length) { + return createTupleType(elementTypes); + } } } - return createArrayType(getUnionType(elementTypes)); + return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name) { - return name.kind === 133 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 134 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -19035,11 +19433,11 @@ var ts; links.resolvedType = checkExpression(node.expression); // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 4194304 /* ESSymbol */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 16777216 /* ESSymbol */)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true); + checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); } } return links.resolvedType; @@ -19050,26 +19448,47 @@ var ts; var propertiesTable = {}; var propertiesArray = []; var contextualType = getContextualType(node); - var typeFlags; + var contextualTypeHasPattern = contextualType && contextualType.pattern && + (contextualType.pattern.kind === 159 /* ObjectBindingPattern */ || contextualType.pattern.kind === 163 /* ObjectLiteralExpression */); + var inDestructuringPattern = isAssignmentTarget(node); + var typeFlags = 0; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 242 /* PropertyAssignment */ || - memberDecl.kind === 243 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 243 /* PropertyAssignment */ || + memberDecl.kind === 244 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 242 /* PropertyAssignment */) { + if (memberDecl.kind === 243 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 140 /* MethodDeclaration */) { + else if (memberDecl.kind === 141 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 243 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 244 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name); + if (inDestructuringPattern) { + // If object literal is an assignment pattern and if the assignment pattern specifies a default value + // for the property, make the property optional. + if (memberDecl.kind === 243 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) { + prop.flags |= 536870912 /* Optional */; + } + } + else if (contextualTypeHasPattern) { + // If object literal is contextually typed by the implied type of a binding pattern, and if the + // binding pattern specifies a default value for the property, make the property optional. + var impliedProp = getPropertyOfType(contextualType, member.name); + if (impliedProp) { + prop.flags |= impliedProp.flags & 536870912 /* Optional */; + } + else if (!compilerOptions.suppressExcessPropertyErrors) { + error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); + } + } prop.declarations = member.declarations; prop.parent = member.parent; if (member.valueDeclaration) { @@ -19085,7 +19504,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 142 /* GetAccessor */ || memberDecl.kind === 143 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 143 /* GetAccessor */ || memberDecl.kind === 144 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -19093,10 +19512,28 @@ var ts; } propertiesArray.push(member); } + // If object literal is contextually typed by the implied type of a binding pattern, augment the result + // type with those properties for which the binding pattern specifies a default value. + if (contextualTypeHasPattern) { + for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) { + var prop = _c[_b]; + if (!ts.hasProperty(propertiesTable, prop.name)) { + if (!(prop.flags & 536870912 /* Optional */)) { + error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + propertiesTable[prop.name] = prop; + propertiesArray.push(prop); + } + } + } var stringIndexType = getIndexType(0 /* String */); var numberIndexType = getIndexType(1 /* Number */); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 524288 /* ObjectLiteral */ | 2097152 /* ContainsObjectLiteral */ | (typeFlags & 1048576 /* ContainsUndefinedOrNull */); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */; + result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */); + if (inDestructuringPattern) { + result.pattern = node; + } return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -19129,35 +19566,39 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 66 /* Identifier */) { + if (lhs.kind === 67 /* Identifier */) { return lhs.text === rhs.text; } return lhs.right.text === rhs.right.text && tagNamesAreEquivalent(lhs.left, rhs.left); } function checkJsxElement(node) { + // Check attributes + checkJsxOpeningLikeElement(node.openingElement); // Check that the closing tag matches if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); } - // Check attributes - checkJsxOpeningLikeElement(node.openingElement); + else { + // Perform resolution on the closing tag so that rename/go to definition/etc work + getJsxElementTagSymbol(node.closingElement); + } // Check children for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: checkJsxExpression(child); break; - case 230 /* JsxElement */: + case 231 /* JsxElement */: checkJsxElement(child); break; - case 231 /* JsxSelfClosingElement */: + case 232 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; default: // No checks for JSX Text - ts.Debug.assert(child.kind === 233 /* JsxText */); + ts.Debug.assert(child.kind === 234 /* JsxText */); } } return jsxElementType || anyType; @@ -19173,7 +19614,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 132 /* QualifiedName */) { + if (tagName.kind === 133 /* QualifiedName */) { return false; } else { @@ -19190,10 +19631,19 @@ var ts; else if (elementAttributesType && !isTypeAny(elementAttributesType)) { var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - // If there's no corresponding property with this name, error - if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { - error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); - return unknownType; + if (isUnhyphenatedJsxName(node.name.text)) { + // Maybe there's a string indexer? + var indexerType = getIndexTypeOfType(elementAttributesType, 0 /* String */); + if (indexerType) { + correspondingPropType = indexerType; + } + else { + // If there's no corresponding property with this name, error + if (!correspondingPropType) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } } } var exprType; @@ -19269,7 +19719,7 @@ var ts; return intrinsicElementsType.symbol; } // Wasn't found - error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, 'JSX.' + JsxNames.IntrinsicElements); + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, "JSX." + JsxNames.IntrinsicElements); return unknownSymbol; } else { @@ -19279,22 +19729,24 @@ var ts; } } function lookupClassTag(node) { - var valueSymbol; + var valueSymbol = resolveJsxTagName(node); // Look up the value in the current scope - if (node.tagName.kind === 66 /* Identifier */) { - var tag = node.tagName; - var sym = getResolvedSymbol(tag); - valueSymbol = sym.exportSymbol || sym; - } - else { - valueSymbol = checkQualifiedName(node.tagName).symbol; - } if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= 4 /* ClassElement */; getSymbolLinks(valueSymbol).referenced = true; } return valueSymbol || unknownSymbol; } + function resolveJsxTagName(node) { + if (node.tagName.kind === 67 /* Identifier */) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + return sym.exportSymbol || sym; + } + else { + return checkQualifiedName(node.tagName).symbol; + } + } } /** * Given a JSX element that is a class element, finds the Element Instance Type. If the @@ -19302,10 +19754,9 @@ var ts; * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). */ function getJsxElementInstanceType(node) { - if (!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */)) { - // There is no such thing as an instance type for a non-class element - return undefined; - } + // There is no such thing as an instance type for a non-class element. This + // line shouldn't be hit. + ts.Debug.assert(!!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */), "Should not call getJsxElementInstanceType on non-class Element"); var classSymbol = getJsxElementTagSymbol(node); if (classSymbol === unknownSymbol) { // Couldn't find the class instance type. Error has already been issued @@ -19324,15 +19775,10 @@ var ts; if (signatures.length === 0) { // We found no signatures at all, which is an error error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); - return undefined; + return unknownType; } } - // Check that the constructor/factory returns an object type - var returnType = getUnionType(signatures.map(function (s) { return getReturnTypeOfSignature(s); })); - if (!isTypeAny(returnType) && !(returnType.flags & 80896 /* ObjectType */)) { - error(node.tagName, ts.Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); - return undefined; - } + var returnType = getUnionType(signatures.map(getReturnTypeOfSignature)); // Issue an error if this return type isn't assignable to JSX.ElementClass var elemClassType = getJsxGlobalElementClassType(); if (elemClassType) { @@ -19347,7 +19793,7 @@ var ts; /// non-instrinsic elements' attributes type is the element instance type) function getJsxElementPropertiesName() { // JSX - var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, undefined); + var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, /*diagnosticMessage*/ undefined); // JSX.ElementAttributesProperty [symbol] var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056 /* Type */); // JSX.ElementAttributesProperty [type] @@ -19383,7 +19829,7 @@ var ts; if (links.jsxFlags & 4 /* ClassElement */) { var elemInstanceType = getJsxElementInstanceType(node); if (isTypeAny(elemInstanceType)) { - return links.resolvedJsxType = anyType; + return links.resolvedJsxType = elemInstanceType; } var propsName = getJsxElementPropertiesName(); if (propsName === undefined) { @@ -19465,7 +19911,7 @@ var ts; // be marked as 'used' so we don't incorrectly elide its import. And if there // is no 'React' symbol in scope, we should issue an error. if (compilerOptions.jsx === 2 /* React */) { - var reactSym = resolveName(node.tagName, 'React', 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, 'React'); + var reactSym = resolveName(node.tagName, "React", 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, "React"); if (reactSym) { getSymbolLinks(reactSym).referenced = true; } @@ -19477,11 +19923,11 @@ var ts; // thus should have their types ignored var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 235 /* JsxAttribute */) { + if (node.attributes[i].kind === 236 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 236 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 237 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -19511,7 +19957,7 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 138 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 139 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; @@ -19527,8 +19973,8 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (left.kind === 92 /* SuperKeyword */) { - var errorNode = node.kind === 163 /* PropertyAccessExpression */ ? + if (left.kind === 93 /* SuperKeyword */) { + var errorNode = node.kind === 164 /* PropertyAccessExpression */ ? node.name : node.right; // TS 1.0 spec (April 2014): 4.8.2 @@ -19538,7 +19984,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (getDeclarationKindFromSymbol(prop) !== 140 /* MethodDeclaration */) { + if (getDeclarationKindFromSymbol(prop) !== 141 /* MethodDeclaration */) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -19571,7 +20017,7 @@ var ts; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (left.kind === 92 /* SuperKeyword */) { + if (left.kind === 93 /* SuperKeyword */) { return true; } // A protected property is accessible in the declaring class and classes derived from it @@ -19621,7 +20067,7 @@ var ts; return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 163 /* PropertyAccessExpression */ + var left = node.kind === 164 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -19637,7 +20083,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 166 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -19656,7 +20102,7 @@ var ts; } var isConstEnum = isConstEnumObjectType(objectType); if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 8 /* StringLiteral */)) { + (!node.argumentExpression || node.argumentExpression.kind !== 9 /* StringLiteral */)) { error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } @@ -19684,7 +20130,7 @@ var ts; } } // Check for compatible indexer types. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 4194304 /* ESSymbol */)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { // Try to use a number indexer. if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */)) { var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); @@ -19714,10 +20160,10 @@ var ts; * Otherwise, returns undefined. */ function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 8 /* StringLiteral */ || indexArgumentExpression.kind === 7 /* NumericLiteral */) { + if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } - if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { + if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { var rightHandSideName = indexArgumentExpression.name.text; return ts.getPropertyNameForKnownSymbolName(rightHandSideName); } @@ -19739,7 +20185,7 @@ var ts; return false; } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 4194304 /* ESSymbol */) === 0) { + if ((expressionType.flags & 16777216 /* ESSymbol */) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -19766,10 +20212,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 136 /* Decorator */) { + else if (node.kind !== 137 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -19799,13 +20245,13 @@ var ts; for (var _i = 0; _i < signatures.length; _i++) { var signature = signatures[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_6 = signature.declaration && signature.declaration.parent; + var parent_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_6 === lastParent) { + if (lastParent && parent_5 === lastParent) { index++; } else { - lastParent = parent_6; + lastParent = parent_5; index = cutoffIndex; } } @@ -19813,7 +20259,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_6; + lastParent = parent_5; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -19835,7 +20281,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 182 /* SpreadElementExpression */) { + if (arg && arg.kind === 183 /* SpreadElementExpression */) { return i; } } @@ -19847,13 +20293,13 @@ var ts; var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments var isDecorator; var spreadArgIndex = -1; - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 180 /* TemplateExpression */) { + if (tagExpression.template.kind === 181 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var templateExpression = tagExpression.template; @@ -19866,20 +20312,20 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 10 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 11 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { isDecorator = true; typeArguments = undefined; - adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); + adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); } else { var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 166 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 167 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -19922,7 +20368,7 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature.typeParameters, true); + var context = createInferenceContext(signature.typeParameters, /*inferUnionTypes*/ true); forEachMatchingParameterType(contextualSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type inferTypes(context, instantiateType(source, contextualMapper), target); @@ -19958,7 +20404,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 184 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type @@ -20017,14 +20463,14 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 184 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 185 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { - argType = arg.kind === 8 /* StringLiteral */ && !reportErrors + argType = arg.kind === 9 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -20049,16 +20495,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 167 /* TaggedTemplateExpression */) { + if (node.kind === 168 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 180 /* TemplateExpression */) { + if (template.kind === 181 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -20083,25 +20529,25 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { switch (node.parent.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 135 /* Parameter */: + case 136 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -20126,25 +20572,25 @@ var ts; function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. switch (node.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 135 /* Parameter */: + case 136 /* Parameter */: // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } // fall-through - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -20173,35 +20619,35 @@ var ts; function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 135 /* Parameter */: + case 136 /* Parameter */: node = node.parent; - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. // fall-through - case 138 /* PropertyDeclaration */: - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; switch (element.name.kind) { - case 66 /* Identifier */: - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: + case 67 /* Identifier */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: return getStringLiteralType(element.name); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 4194304 /* ESSymbol */)) { + if (allConstituentTypesHaveKind(nameType, 16777216 /* ESSymbol */)) { return nameType; } else { @@ -20227,18 +20673,18 @@ var ts; // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a paramter decorator switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 135 /* Parameter */: + case 136 /* Parameter */: // The `parameterIndex` for a parameter decorator is always a number return numberType; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -20271,10 +20717,10 @@ var ts; // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { return globalTemplateStringsArrayType; } // This is not a synthetic argument, so we return 'undefined' @@ -20286,8 +20732,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 136 /* Decorator */ || - (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */)) { + if (node.kind === 137 /* Decorator */ || + (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -20296,11 +20742,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 136 /* Decorator */) { + if (node.kind === 137 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 168 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -20309,13 +20755,13 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 167 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 136 /* Decorator */; + var isTaggedTemplate = node.kind === 168 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 137 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 92 /* SuperKeyword */) { + if (node.expression.kind !== 93 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -20412,17 +20858,18 @@ var ts; // in arguments too early. If possible, we'd like to only type them once we know the correct // overload. However, this matters for the case where the call is correct. When the call is // an error, we don't need to exclude any arguments, although it would cause no harm to do so. - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); + checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true); } else if (candidateForTypeArgumentError) { if (!isTaggedTemplate && !isDecorator && typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true, headMessage); + checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], /*reportErrors*/ true, headMessage); } else { ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); - var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); + var diagnosticChainHead = ts.chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError + ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); if (headMessage) { diagnosticChainHead = ts.chainDiagnosticMessages(diagnosticChainHead, headMessage); } @@ -20441,6 +20888,9 @@ var ts; for (var _i = 0; _i < candidates.length; _i++) { var candidate = candidates[_i]; if (hasCorrectArity(node, args, candidate)) { + if (candidate.typeParameters && typeArguments) { + candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); + } return candidate; } } @@ -20463,7 +20913,7 @@ var ts; var candidate = void 0; var typeArgumentsAreValid = void 0; var inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate.typeParameters, false) + ? createInferenceContext(originalCandidate.typeParameters, /*inferUnionTypes*/ false) : undefined; while (true) { candidate = originalCandidate; @@ -20471,7 +20921,7 @@ var ts; var typeArgumentTypes = void 0; if (typeArguments) { typeArgumentTypes = new Array(candidate.typeParameters.length); - typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); + typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false); } else { inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); @@ -20483,7 +20933,7 @@ var ts; } candidate = getSignatureInstantiation(candidate, typeArgumentTypes); } - if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { + if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { break; } var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; @@ -20518,7 +20968,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated @@ -20592,7 +21042,7 @@ var ts; // Note, only class declarations can be declared abstract. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 211 /* ClassDeclaration */); + var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); if (valueDecl && valueDecl.flags & 256 /* Abstract */) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); @@ -20651,16 +21101,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 135 /* Parameter */: + case 136 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -20697,16 +21147,16 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 165 /* CallExpression */) { + if (node.kind === 166 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 166 /* NewExpression */) { + else if (node.kind === 167 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 168 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 136 /* Decorator */) { + else if (node.kind === 137 /* Decorator */) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -20724,15 +21174,15 @@ var ts; // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { return voidType; } - if (node.kind === 166 /* NewExpression */) { + if (node.kind === 167 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 141 /* Constructor */ && - declaration.kind !== 145 /* ConstructSignature */ && - declaration.kind !== 150 /* ConstructorType */) { + declaration.kind !== 142 /* Constructor */ && + declaration.kind !== 146 /* ConstructSignature */ && + declaration.kind !== 151 /* ConstructorType */) { // When resolved signature is a call signature (and not a construct signature) the result type is any if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); @@ -20746,7 +21196,7 @@ var ts; return getReturnTypeOfSignature(getResolvedSignature(node)); } function checkAssertion(node) { - var exprType = checkExpression(node.expression); + var exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { var widenedType = getWidenedType(exprType); @@ -20765,19 +21215,57 @@ var ts; var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeAtPosition(context, i), mapper); + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); } if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { var parameter = ts.lastOrUndefined(signature.parameters); - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } + } + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + var links = getSymbolLinks(parameter); + if (!links.type) { + links.type = instantiateType(contextualType, mapper); + } + else if (isInferentialContext(mapper)) { + // Even if the parameter already has a type, it might be because it was given a type while + // processing the function as an argument to a prior signature during overload resolution. + // If this was the case, it may have caused some type parameters to be fixed. So here, + // we need to ensure that type parameters at the same positions get fixed again. This is + // done by calling instantiateType to attach the mapper to the contextualType, and then + // calling inferTypes to force a walk of contextualType so that all the correct fixing + // happens. The choice to pass in links.type may seem kind of arbitrary, but it serves + // to make sure that all the correct positions in contextualType are reached by the walk. + // Here is an example: + // + // interface Base { + // baseProp; + // } + // interface Derived extends Base { + // toBase(): Base; + // } + // + // var derived: Derived; + // + // declare function foo(x: T, func: (p: T) => T): T; + // declare function foo(x: T, func: (p: T) => T): T; + // + // var result = foo(derived, d => d.toBase()); + // + // We are typing d while checking the second overload. But we've already given d + // a type (Derived) from the first overload. However, we still want to fix the + // T in the second overload so that we do not infer Base as a candidate for T + // (inferring Base would make type argument inference inconsistent between the two + // overloads). + inferTypes(mapper.context, links.type, instantiateType(contextualType, mapper)); } } function createPromiseType(promisedType) { // creates a `Promise` type where `T` is the promisedType argument var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyObjectType) { + if (globalPromiseType !== emptyGenericType) { // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type promisedType = getAwaitedType(promisedType); return createTypeReference(globalPromiseType, [promisedType]); @@ -20791,7 +21279,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 189 /* Block */) { + if (func.body.kind !== 190 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -20910,7 +21398,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 205 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 206 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -20925,7 +21413,7 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 189 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 190 /* Block */) { return; } var bodyBlock = func.body; @@ -20943,10 +21431,10 @@ var ts; error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 170 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 171 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -20959,37 +21447,44 @@ var ts; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); - // Check if function expression is contextually typed and assign parameter types if so - if (!(links.flags & 1024 /* ContextChecked */)) { + var contextSensitive = isContextSensitive(node); + var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + // Check if function expression is contextually typed and assign parameter types if so. + // See the comment in assignTypeToParameterAndFixTypeParameters to understand why we need to + // check mightFixTypeParameters. + if (mightFixTypeParameters || !(links.flags & 1024 /* ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 1024 /* ContextChecked */)) { + var contextChecked = !!(links.flags & 1024 /* ContextChecked */); + if (mightFixTypeParameters || !contextChecked) { links.flags |= 1024 /* ContextChecked */; if (contextualSignature) { var signature = getSignaturesOfType(type, 0 /* Call */)[0]; - if (isContextSensitive(node)) { + if (contextSensitive) { assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); } - if (!node.type && !signature.resolvedReturnType) { + if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { var returnType = getReturnTypeFromBody(node, contextualMapper); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } } } - checkSignatureDeclaration(node); + if (!contextChecked) { + checkSignatureDeclaration(node); + } } } - if (produceDiagnostics && node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 141 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); if (isAsync) { emitAwaiter = true; @@ -21011,7 +21506,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 189 /* Block */) { + if (node.body.kind === 190 /* Block */) { checkSourceElement(node.body); } else { @@ -21057,24 +21552,24 @@ var ts; // and property accesses(section 4.10). // All other expression constructs described in this chapter are classified as values. switch (n.kind) { - case 66 /* Identifier */: { + case 67 /* Identifier */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.3 // An identifier expression that references a variable or parameter is classified as a reference. // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; } - case 163 /* PropertyAccessExpression */: { + case 164 /* PropertyAccessExpression */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; } - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: // old compiler doesn't check indexed assess return true; - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -21082,22 +21577,22 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: { + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: { var symbol = findSymbol(n); return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; } - case 164 /* ElementAccessExpression */: { + case 165 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 8 /* StringLiteral */) { + if (symbol && index && index.kind === 9 /* StringLiteral */) { var name_12 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768 /* Const */) !== 0; } return false; } - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -21141,17 +21636,17 @@ var ts; function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - if (someConstituentTypeHasKind(operandType, 4194304 /* ESSymbol */)) { + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + if (someConstituentTypeHasKind(operandType, 16777216 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 47 /* ExclamationToken */: + case 48 /* ExclamationToken */: return booleanType; - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -21217,7 +21712,7 @@ var ts; // and the right operand to be of type Any or a subtype of the 'Function' interface type. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported - if (allConstituentTypesHaveKind(leftType, 4194814 /* Primitive */)) { + if (allConstituentTypesHaveKind(leftType, 16777726 /* Primitive */)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -21231,7 +21726,7 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 4194304 /* ESSymbol */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 16777216 /* ESSymbol */)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { @@ -21243,7 +21738,7 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 242 /* PropertyAssignment */ || p.kind === 243 /* ShorthandPropertyAssignment */) { + if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_13 = p.name; var type = isTypeAny(sourceType) @@ -21268,12 +21763,12 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(sourceType, node, false) || unknownType; + var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184 /* OmittedExpression */) { - if (e.kind !== 182 /* SpreadElementExpression */) { + if (e.kind !== 185 /* OmittedExpression */) { + if (e.kind !== 183 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -21298,7 +21793,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 178 /* BinaryExpression */ && restExpression.operatorToken.kind === 54 /* EqualsToken */) { + if (restExpression.kind === 179 /* BinaryExpression */ && restExpression.operatorToken.kind === 55 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -21311,14 +21806,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 178 /* BinaryExpression */ && target.operatorToken.kind === 54 /* EqualsToken */) { + if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 162 /* ObjectLiteralExpression */) { + if (target.kind === 163 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 161 /* ArrayLiteralExpression */) { + if (target.kind === 162 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -21326,38 +21821,38 @@ var ts; function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { - checkTypeAssignableTo(sourceType, targetType, target, undefined); + checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); } return sourceType; } function checkBinaryExpression(node, contextualMapper) { var operator = node.operatorToken.kind; - if (operator === 54 /* EqualsToken */ && (node.left.kind === 162 /* ObjectLiteralExpression */ || node.left.kind === 161 /* ArrayLiteralExpression */)) { + if (operator === 55 /* EqualsToken */ && (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 36 /* AsteriskToken */: - case 57 /* AsteriskEqualsToken */: - case 37 /* SlashToken */: - case 58 /* SlashEqualsToken */: - case 38 /* PercentToken */: - case 59 /* PercentEqualsToken */: - case 35 /* MinusToken */: - case 56 /* MinusEqualsToken */: - case 41 /* LessThanLessThanToken */: - case 60 /* LessThanLessThanEqualsToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 45 /* BarToken */: - case 64 /* BarEqualsToken */: - case 46 /* CaretToken */: - case 65 /* CaretEqualsToken */: - case 44 /* AmpersandToken */: - case 63 /* AmpersandEqualsToken */: + case 37 /* AsteriskToken */: + case 58 /* AsteriskEqualsToken */: + case 38 /* SlashToken */: + case 59 /* SlashEqualsToken */: + case 39 /* PercentToken */: + case 60 /* PercentEqualsToken */: + case 36 /* MinusToken */: + case 57 /* MinusEqualsToken */: + case 42 /* LessThanLessThanToken */: + case 61 /* LessThanLessThanEqualsToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 46 /* BarToken */: + case 65 /* BarEqualsToken */: + case 47 /* CaretToken */: + case 66 /* CaretEqualsToken */: + case 45 /* AmpersandToken */: + case 64 /* AmpersandEqualsToken */: // TypeScript 1.0 spec (April 2014): 4.15.1 // These operators require their operands to be of type Any, the Number primitive type, // or an enum type. Operands of an enum type are treated @@ -21385,8 +21880,8 @@ var ts; } } return numberType; - case 34 /* PlusToken */: - case 55 /* PlusEqualsToken */: + case 35 /* PlusToken */: + case 56 /* PlusEqualsToken */: // TypeScript 1.0 spec (April 2014): 4.15.2 // The binary + operator requires both operands to be of the Number primitive type or an enum type, // or at least one of the operands to be of type Any or the String primitive type. @@ -21420,44 +21915,44 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 55 /* PlusEqualsToken */) { + if (operator === 56 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } // Fall through - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 88 /* InstanceOfKeyword */: + case 89 /* InstanceOfKeyword */: return checkInstanceOfExpression(node, leftType, rightType); - case 87 /* InKeyword */: + case 88 /* InKeyword */: return checkInExpression(node, leftType, rightType); - case 49 /* AmpersandAmpersandToken */: + case 50 /* AmpersandAmpersandToken */: return rightType; - case 50 /* BarBarToken */: + case 51 /* BarBarToken */: return getUnionType([leftType, rightType]); - case 54 /* EqualsToken */: + case 55 /* EqualsToken */: checkAssignmentOperator(rightType); - return rightType; - case 23 /* CommaToken */: + return getRegularTypeOfObjectLiteral(rightType); + case 24 /* CommaToken */: return rightType; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 4194304 /* ESSymbol */) ? node.left : - someConstituentTypeHasKind(rightType, 4194304 /* ESSymbol */) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 16777216 /* ESSymbol */) ? node.left : + someConstituentTypeHasKind(rightType, 16777216 /* ESSymbol */) ? node.right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -21467,21 +21962,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 45 /* BarToken */: - case 64 /* BarEqualsToken */: - return 50 /* BarBarToken */; - case 46 /* CaretToken */: - case 65 /* CaretEqualsToken */: - return 32 /* ExclamationEqualsEqualsToken */; - case 44 /* AmpersandToken */: - case 63 /* AmpersandEqualsToken */: - return 49 /* AmpersandAmpersandToken */; + case 46 /* BarToken */: + case 65 /* BarEqualsToken */: + return 51 /* BarBarToken */; + case 47 /* CaretToken */: + case 66 /* CaretEqualsToken */: + return 33 /* ExclamationEqualsEqualsToken */; + case 45 /* AmpersandToken */: + case 64 /* AmpersandEqualsToken */: + return 50 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 54 /* FirstAssignment */ && operator <= 65 /* LastAssignment */) { + if (produceDiagnostics && operator >= 55 /* FirstAssignment */ && operator <= 66 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr @@ -21492,7 +21987,7 @@ var ts; // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableTo(valueType, leftType, node.left, undefined); + checkTypeAssignableTo(valueType, leftType, node.left, /*headMessage*/ undefined); } } } @@ -21530,7 +22025,7 @@ var ts; // If the user's code is syntactically correct, the func should always have a star. After all, // we are in a yield context. if (func && func.asteriskToken) { - var expressionType = checkExpressionCached(node.expression, undefined); + var expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); var expressionElementType; var nodeIsYieldStar = !!node.asteriskToken; if (nodeIsYieldStar) { @@ -21542,10 +22037,10 @@ var ts; if (func.type) { var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); } else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(expressionType, signatureElementType, node.expression, /*headMessage*/ undefined); } } } @@ -21588,7 +22083,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -21599,14 +22094,14 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (contextualMapper && contextualMapper !== identityMapper) { + if (isInferentialContext(contextualMapper)) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getContextualType(node); @@ -21629,7 +22124,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 132 /* QualifiedName */) { + if (node.kind === 133 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -21641,9 +22136,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -21657,78 +22152,78 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return checkIdentifier(node); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return checkThisExpression(node); - case 92 /* SuperKeyword */: + case 93 /* SuperKeyword */: return checkSuperExpression(node); - case 90 /* NullKeyword */: + case 91 /* NullKeyword */: return nullType; - case 96 /* TrueKeyword */: - case 81 /* FalseKeyword */: + case 97 /* TrueKeyword */: + case 82 /* FalseKeyword */: return booleanType; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return checkNumericLiteral(node); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return checkTemplateExpression(node); - case 8 /* StringLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: + case 9 /* StringLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: return stringType; - case 9 /* RegularExpressionLiteral */: + case 10 /* RegularExpressionLiteral */: return globalRegExpType; - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return checkCallExpression(node); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return checkClassExpression(node); - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: return checkAssertion(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return checkDeleteExpression(node); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return checkVoidExpression(node); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return checkAwaitExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 184 /* OmittedExpression */: + case 185 /* OmittedExpression */: return undefinedType; - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return checkYieldExpression(node); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return checkJsxExpression(node); - case 230 /* JsxElement */: + case 231 /* JsxElement */: return checkJsxElement(node); - case 231 /* JsxSelfClosingElement */: + case 232 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 232 /* JsxOpeningElement */: + case 233 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -21757,7 +22252,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 141 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 142 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -21774,15 +22269,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 140 /* MethodDeclaration */ || - node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */; + return node.kind === 141 /* MethodDeclaration */ || + node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 66 /* Identifier */ && + if (param.name.kind === 67 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -21792,31 +22287,31 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 171 /* ArrowFunction */: - case 144 /* CallSignature */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 149 /* FunctionType */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 172 /* ArrowFunction */: + case 145 /* CallSignature */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 150 /* FunctionType */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 149 /* FunctionType */ || node.kind === 210 /* FunctionDeclaration */ || node.kind === 150 /* ConstructorType */ || - node.kind === 144 /* CallSignature */ || node.kind === 141 /* Constructor */ || - node.kind === 145 /* ConstructSignature */) { + else if (node.kind === 150 /* FunctionType */ || node.kind === 211 /* FunctionDeclaration */ || node.kind === 151 /* ConstructorType */ || + node.kind === 145 /* CallSignature */ || node.kind === 142 /* Constructor */ || + node.kind === 146 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 147 /* TypePredicate */) { + if (node.type.kind === 148 /* TypePredicate */) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -21825,7 +22320,7 @@ var ts; error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - checkTypeAssignableTo(typePredicate.type, getTypeAtLocation(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(node.parameters[typePredicate.parameterIndex]), typePredicateNode.type); } } else if (typePredicateNode.parameterName) { @@ -21835,19 +22330,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 158 /* ObjectBindingPattern */ || - param.name.kind === 159 /* ArrayBindingPattern */) { + if (param.name.kind === 159 /* ObjectBindingPattern */ || + param.name.kind === 160 /* ArrayBindingPattern */) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 66 /* Identifier */ && + if (element.name.kind === 67 /* Identifier */ && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 159 /* ArrayBindingPattern */ || - element.name.kind === 158 /* ObjectBindingPattern */) { + else if (element.name.kind === 160 /* ArrayBindingPattern */ || + element.name.kind === 159 /* ObjectBindingPattern */) { checkBindingPattern(element.name); } } @@ -21871,10 +22366,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 144 /* CallSignature */: + case 145 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -21902,7 +22397,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 212 /* InterfaceDeclaration */) { + if (node.kind === 213 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -21922,7 +22417,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 127 /* StringKeyword */: + case 128 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -21930,7 +22425,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 125 /* NumberKeyword */: + case 126 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -21979,56 +22474,80 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 165 /* CallExpression */ && n.expression.kind === 92 /* SuperKeyword */; + return n.kind === 166 /* CallExpression */ && n.expression.kind === 93 /* SuperKeyword */; + } + function containsSuperCallAsComputedPropertyName(n) { + return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } - switch (n.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 162 /* ObjectLiteralExpression */: return false; - default: return ts.forEachChild(n, containsSuperCall); + else if (ts.isFunctionLike(n)) { + return false; } + else if (ts.isClassLike(n)) { + return ts.forEach(n.members, containsSuperCallAsComputedPropertyName); + } + return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 94 /* ThisKeyword */) { + if (n.kind === 95 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 170 /* FunctionExpression */ && n.kind !== 210 /* FunctionDeclaration */) { + else if (n.kind !== 171 /* FunctionExpression */ && n.kind !== 211 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 138 /* PropertyDeclaration */ && + return n.kind === 139 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } // TS 1.0 spec (April 2014): 8.3.2 // Constructors of classes with no extends clause may not contain super calls, whereas // constructors of derived classes must contain at least one super call somewhere in their function body. - if (ts.getClassExtendsHeritageClauseElement(node.parent)) { + var containingClassDecl = node.parent; + if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + var containingClassSymbol = getSymbolOfNode(containingClassDecl); + var containingClassInstanceType = getDeclaredTypeOfSymbol(containingClassSymbol); + var baseConstructorType = getBaseConstructorTypeOfClass(containingClassInstanceType); if (containsSuperCall(node.body)) { - // The first statement in the body of a constructor must be a super call if both of the following are true: + if (baseConstructorType === nullType) { + error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); + } + // The first statement in the body of a constructor (excluding prologue directives) must be a super call + // if both of the following are true: // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); + // Skip past any prologue directives to find the first statement + // to ensure that it was a super call. if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 192 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + var superCallStatement; + for (var _i = 0; _i < statements.length; _i++) { + var statement = statements[_i]; + if (statement.kind === 193 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { + superCallStatement = statement; + break; + } + if (!ts.isPrologueDirective(statement)) { + break; + } + } + if (!superCallStatement) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { // In such a required super call, it is a compile-time error for argument expressions to reference this. - markThisReferencesAsErrors(statements[0].expression); + markThisReferencesAsErrors(superCallStatement.expression); } } } - else { + else if (baseConstructorType !== nullType) { error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); } } @@ -22037,7 +22556,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 142 /* GetAccessor */) { + if (node.kind === 143 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } @@ -22045,7 +22564,7 @@ var ts; if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 142 /* GetAccessor */ ? 143 /* SetAccessor */ : 142 /* GetAccessor */; + var otherKind = node.kind === 143 /* GetAccessor */ ? 144 /* SetAccessor */ : 143 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -22141,9 +22660,9 @@ var ts; var signaturesToCheck; // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 212 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 144 /* CallSignature */ || signatureDeclarationNode.kind === 145 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 144 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 213 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 145 /* CallSignature */ || signatureDeclarationNode.kind === 146 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 145 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -22161,7 +22680,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 212 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 213 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -22247,7 +22766,7 @@ var ts; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */); + ts.Debug.assert(node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -22283,7 +22802,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 212 /* InterfaceDeclaration */ || node.parent.kind === 152 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 213 /* InterfaceDeclaration */ || node.parent.kind === 153 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -22294,7 +22813,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 210 /* FunctionDeclaration */ || node.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */ || node.kind === 141 /* Constructor */) { + if (node.kind === 211 /* FunctionDeclaration */ || node.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */ || node.kind === 142 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -22378,8 +22897,6 @@ var ts; if (!produceDiagnostics) { return; } - // Exports should be checked only if enclosing module contains both exported and non exported declarations. - // In case if all declarations are non-exported check is unnecessary. // if localSymbol is defined on node then node itself is exported - check is required var symbol = node.localSymbol; if (!symbol) { @@ -22397,38 +22914,55 @@ var ts; } // we use SymbolFlags.ExportValue, SymbolFlags.ExportType and SymbolFlags.ExportNamespace // to denote disjoint declarationSpaces (without making new enum type). - var exportedDeclarationSpaces = 0; - var nonExportedDeclarationSpaces = 0; - ts.forEach(symbol.declarations, function (d) { + var exportedDeclarationSpaces = 0 /* None */; + var nonExportedDeclarationSpaces = 0 /* None */; + var defaultExportedDeclarationSpaces = 0 /* None */; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - if (getEffectiveDeclarationFlags(d, 1 /* Export */)) { - exportedDeclarationSpaces |= declarationSpaces; + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); + if (effectiveDeclarationFlags & 1 /* Export */) { + if (effectiveDeclarationFlags & 1024 /* Default */) { + defaultExportedDeclarationSpaces |= declarationSpaces; + } + else { + exportedDeclarationSpaces |= declarationSpaces; + } } else { nonExportedDeclarationSpaces |= declarationSpaces; } - }); - var commonDeclarationSpace = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - if (commonDeclarationSpace) { + } + // Spaces for anyting not declared a 'default export'. + var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; + var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; + var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; + if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) { // declaration spaces for exported and non-exported declarations intersect - ts.forEach(symbol.declarations, function (d) { - if (getDeclarationSpaces(d) & commonDeclarationSpace) { + for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declarationSpaces = getDeclarationSpaces(d); + // Only error on the declarations that conributed to the intersecting spaces. + if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { + error(d.name, ts.Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, ts.declarationNameToString(d.name)); + } + else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); } - }); + } } function getDeclarationSpaces(d) { switch (d.kind) { - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 215 /* ModuleDeclaration */: - return d.name.kind === 8 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ + case 216 /* ModuleDeclaration */: + return d.name.kind === 9 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -22505,7 +23039,7 @@ var ts; * The runtime behavior of the `await` keyword. */ function getAwaitedType(type) { - return checkAwaitedType(type, undefined, undefined); + return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); } function checkAwaitedType(type, location, message) { return checkAwaitedTypeWorker(type); @@ -22672,22 +23206,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 135 /* Parameter */: + case 136 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -22700,11 +23234,18 @@ var ts; // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 148 /* TypeReference */) { + if (node && node.kind === 149 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var rootSymbol = resolveName(root, root.text, 107455 /* Value */, undefined, undefined); - if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); + var meaning = root.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + // Resolve type so we know which symbol is referenced + var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + // Resolved symbol is alias + if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */) { + var aliasTarget = resolveAlias(rootSymbol); + // If alias has value symbol - mark alias as referenced + if (aliasTarget.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } } } } @@ -22714,19 +23255,19 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 135 /* Parameter */: + case 136 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } @@ -22755,25 +23296,25 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 143 /* SetAccessor */: - case 142 /* GetAccessor */: - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 144 /* SetAccessor */: + case 143 /* GetAccessor */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 135 /* Parameter */) { + if (node.kind === 136 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -22799,7 +23340,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 134 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -22848,11 +23389,11 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 189 /* Block */) { + if (node.kind === 190 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 216 /* ModuleBlock */) { + if (ts.isFunctionBlock(node) || node.kind === 217 /* ModuleBlock */) { checkFunctionAndClassExpressionBodies(node); } } @@ -22871,12 +23412,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 138 /* PropertyDeclaration */ || - node.kind === 137 /* PropertySignature */ || - node.kind === 140 /* MethodDeclaration */ || - node.kind === 139 /* MethodSignature */ || - node.kind === 142 /* GetAccessor */ || - node.kind === 143 /* SetAccessor */) { + if (node.kind === 139 /* PropertyDeclaration */ || + node.kind === 138 /* PropertySignature */ || + node.kind === 141 /* MethodDeclaration */ || + node.kind === 140 /* MethodSignature */ || + node.kind === 143 /* GetAccessor */ || + node.kind === 144 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -22885,7 +23426,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 135 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 136 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -22901,7 +23442,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 66 /* Identifier */; + var isDeclaration_1 = node.kind !== 67 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -22924,7 +23465,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 66 /* Identifier */; + var isDeclaration_2 = node.kind !== 67 /* Identifier */; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -22938,12 +23479,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 215 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 216 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 245 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 246 /* SourceFile */ && ts.isExternalModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -22978,27 +23519,27 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 208 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 209 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); if (symbol.flags & 1 /* FunctionScopedVariable */) { - var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, undefined, undefined); + var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 209 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 190 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 210 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 191 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 189 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 216 /* ModuleBlock */ || - container.kind === 215 /* ModuleDeclaration */ || - container.kind === 245 /* SourceFile */); + (container.kind === 190 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 217 /* ModuleBlock */ || + container.kind === 216 /* ModuleDeclaration */ || + container.kind === 246 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -23013,18 +23554,18 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 135 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 136 /* Parameter */) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 66 /* Identifier */) { + if (n.kind === 67 /* Identifier */) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 135 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 136 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -23050,7 +23591,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -23061,14 +23602,14 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 135 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 136 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } return; @@ -23078,7 +23619,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } } @@ -23090,13 +23631,13 @@ var ts; error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); } if (node.initializer) { - checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); + checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); } } - if (node.kind !== 138 /* PropertyDeclaration */ && node.kind !== 137 /* PropertySignature */) { + if (node.kind !== 139 /* PropertyDeclaration */ && node.kind !== 138 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 208 /* VariableDeclaration */ || node.kind === 160 /* BindingElement */) { + if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -23119,7 +23660,7 @@ var ts; } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && node.parent.kind === 162 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 163 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -23157,12 +23698,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -23182,14 +23723,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 161 /* ArrayLiteralExpression */ || varExpr.kind === 162 /* ObjectLiteralExpression */) { + if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -23197,14 +23738,14 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, + checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, /*constantVariableMessage*/ ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside // getElementTypeOfIterable. if (iteratedType) { - checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); + checkTypeAssignableTo(iteratedType, leftType, varExpr, /*headMessage*/ undefined); } } } @@ -23218,7 +23759,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -23232,7 +23773,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 161 /* ArrayLiteralExpression */ || varExpr.kind === 162 /* ObjectLiteralExpression */) { + if (varExpr.kind === 162 /* ArrayLiteralExpression */ || varExpr.kind === 163 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -23261,7 +23802,7 @@ var ts; } function checkRightHandSideOfForOf(rhsExpression) { var expressionType = getTypeOfExpression(rhsExpression); - return checkIteratedTypeOrElementType(expressionType, rhsExpression, true); + return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true); } function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { if (isTypeAny(inputType)) { @@ -23404,8 +23945,8 @@ var ts; if ((type.flags & 4096 /* Reference */) && type.target === globalIterableIteratorType) { return type.typeArguments[0]; } - return getElementTypeOfIterable(type, undefined) || - getElementTypeOfIterator(type, undefined); + return getElementTypeOfIterable(type, /*errorNode*/ undefined) || + getElementTypeOfIterator(type, /*errorNode*/ undefined); } /** * This function does the following steps: @@ -23428,7 +23969,7 @@ var ts; ts.Debug.assert(languageVersion < 2 /* ES6 */); // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the remaining type is the same as the initial type. - var arrayType = removeTypesFromUnionType(arrayOrStringType, 258 /* StringLike */, true, true); + var arrayType = removeTypesFromUnionType(arrayOrStringType, 258 /* StringLike */, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true); var hasStringConstituent = arrayOrStringType !== arrayType; var reportedError = false; if (hasStringConstituent) { @@ -23471,7 +24012,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 142 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 143 /* SetAccessor */))); + return !!(node.kind === 143 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 144 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -23494,10 +24035,10 @@ var ts; // for generators. return; } - if (func.kind === 143 /* SetAccessor */) { + if (func.kind === 144 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 141 /* Constructor */) { + else if (func.kind === 142 /* Constructor */) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -23533,7 +24074,7 @@ var ts; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 239 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 240 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -23545,14 +24086,14 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 238 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 239 /* CaseClause */) { var caseClause = clause; // TypeScript 1.0 spec (April 2014):5.9 // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { // check 'expressionType isAssignableTo caseType' failed, try the reversed check and report errors if it fails - checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); + checkTypeAssignableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined); } } ts.forEach(clause.statements, checkSourceElement); @@ -23566,7 +24107,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 204 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 205 /* LabeledStatement */ && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -23596,7 +24137,7 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 66 /* Identifier */) { + if (catchClause.variableDeclaration.name.kind !== 67 /* Identifier */) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -23671,7 +24212,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 133 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 134 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -23756,6 +24297,7 @@ var ts; if (baseTypes.length && produceDiagnostics) { var baseType = baseTypes[0]; var staticBaseType = getBaseConstructorTypeOfClass(type); + checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { @@ -23811,6 +24353,9 @@ var ts; // so we'll need to get back original 'target' symbol to work with correct set of flags return s.flags & 16777216 /* Instantiated */ ? getSymbolLinks(s).target : s; } + function getClassLikeDeclarationOfSymbol(symbol) { + return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; }); + } function checkKindsOfPropertyMemberOverrides(type, baseType) { // TypeScript 1.0 spec (April 2014): 8.2.3 // A derived class inherits all members from its base class it doesn't override. @@ -23842,12 +24387,17 @@ var ts; // type declaration, derived and base resolve to the same symbol even in the case of generic classes. if (derived === base) { // derived class inherits base without override/redeclaration - var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 211 /* ClassDeclaration */); + var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + if (derivedClassDecl.kind === 184 /* ClassExpression */) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } } } else { @@ -23890,7 +24440,7 @@ var ts; } } function isAccessor(kind) { - return kind === 142 /* GetAccessor */ || kind === 143 /* SetAccessor */; + return kind === 143 /* GetAccessor */ || kind === 144 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -23960,7 +24510,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 212 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 213 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -23981,7 +24531,7 @@ var ts; if (symbol && symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 211 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { + if (declaration.kind === 212 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); break; } @@ -24014,32 +24564,12 @@ var ts; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 133 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 134 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer); - if (autoValue === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (!ambient) { - // Only here do we need to check that the initializer is assignable to the enum type. - // If it is a constant value (not undefined), it is syntactically constrained to be a number. - // Also, we do not need to check this for ambients because there is already - // a syntax error if it is not a constant. - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); - } - } - else if (enumIsConst) { - if (isNaN(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } + autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { autoValue = undefined; @@ -24050,22 +24580,48 @@ var ts; }); nodeLinks.flags |= 8192 /* EnumValuesComputed */; } - function getConstantValueForEnumMemberInitializer(initializer) { - return evalConstant(initializer); + function computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient) { + // Controls if error should be reported after evaluation of constant value is completed + // Can be false if another more precise error was already reported during evaluation. + var reportError = true; + var value = evalConstant(initializer); + if (reportError) { + if (value === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + // Only here do we need to check that the initializer is assignable to the enum type. + // If it is a constant value (not undefined), it is syntactically constrained to be a number. + // Also, we do not need to check this for ambients because there is already + // a syntax error if it is not a constant. + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); + } + } + else if (enumIsConst) { + if (isNaN(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(value)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } + return value; function evalConstant(e) { switch (e.kind) { - case 176 /* PrefixUnaryExpression */: - var value = evalConstant(e.operand); - if (value === undefined) { + case 177 /* PrefixUnaryExpression */: + var value_1 = evalConstant(e.operand); + if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 34 /* PlusToken */: return value; - case 35 /* MinusToken */: return -value; - case 48 /* TildeToken */: return ~value; + case 35 /* PlusToken */: return value_1; + case 36 /* MinusToken */: return -value_1; + case 49 /* TildeToken */: return ~value_1; } return undefined; - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -24075,41 +24631,41 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 45 /* BarToken */: return left | right; - case 44 /* AmpersandToken */: return left & right; - case 42 /* GreaterThanGreaterThanToken */: return left >> right; - case 43 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 41 /* LessThanLessThanToken */: return left << right; - case 46 /* CaretToken */: return left ^ right; - case 36 /* AsteriskToken */: return left * right; - case 37 /* SlashToken */: return left / right; - case 34 /* PlusToken */: return left + right; - case 35 /* MinusToken */: return left - right; - case 38 /* PercentToken */: return left % right; + case 46 /* BarToken */: return left | right; + case 45 /* AmpersandToken */: return left & right; + case 43 /* GreaterThanGreaterThanToken */: return left >> right; + case 44 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 42 /* LessThanLessThanToken */: return left << right; + case 47 /* CaretToken */: return left ^ right; + case 37 /* AsteriskToken */: return left * right; + case 38 /* SlashToken */: return left / right; + case 35 /* PlusToken */: return left + right; + case 36 /* MinusToken */: return left - right; + case 39 /* PercentToken */: return left % right; } return undefined; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return +e.text; - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 66 /* Identifier */: - case 164 /* ElementAccessExpression */: - case 163 /* PropertyAccessExpression */: + case 67 /* Identifier */: + case 165 /* ElementAccessExpression */: + case 164 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType; + var enumType_1; var propertyName; - if (e.kind === 66 /* Identifier */) { + if (e.kind === 67 /* Identifier */) { // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. // instead pick current enum type and later try to fetch member from the type - enumType = currentType; + enumType_1 = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 164 /* ElementAccessExpression */) { + if (e.kind === 165 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || - e.argumentExpression.kind !== 8 /* StringLiteral */) { + e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; } expression = e.expression; @@ -24122,26 +24678,26 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 66 /* Identifier */) { + if (current.kind === 67 /* Identifier */) { break; } - else if (current.kind === 163 /* PropertyAccessExpression */) { + else if (current.kind === 164 /* PropertyAccessExpression */) { current = current.expression; } else { return undefined; } } - enumType = checkExpression(expression); + enumType_1 = checkExpression(expression); // allow references to constant members of other enums - if (!(enumType.symbol && (enumType.symbol.flags & 384 /* Enum */))) { + if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384 /* Enum */))) { return undefined; } } if (propertyName === undefined) { return undefined; } - var property = getPropertyOfObjectType(enumType, propertyName); + var property = getPropertyOfObjectType(enumType_1, propertyName); if (!property || !(property.flags & 8 /* EnumMember */)) { return undefined; } @@ -24152,6 +24708,8 @@ var ts; } // illegal case: forward reference if (!isDefinedBefore(propertyDecl, member)) { + reportError = false; + error(e, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; } return getNodeLinks(propertyDecl).enumMemberValue; @@ -24194,7 +24752,7 @@ var ts; var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 214 /* EnumDeclaration */) { + if (declaration.kind !== 215 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -24217,8 +24775,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 211 /* ClassDeclaration */ || - (declaration.kind === 210 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 212 /* ClassDeclaration */ || + (declaration.kind === 211 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -24241,7 +24799,7 @@ var ts; function checkModuleDeclaration(node) { if (produceDiagnostics) { // Grammar checking - var isAmbientExternalModule = node.name.kind === 8 /* StringLiteral */; + var isAmbientExternalModule = node.name.kind === 9 /* StringLiteral */; var contextErrorMessage = isAmbientExternalModule ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module; @@ -24250,7 +24808,7 @@ var ts; return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) { - if (!ts.isInAmbientContext(node) && node.name.kind === 8 /* StringLiteral */) { + if (!ts.isInAmbientContext(node) && node.name.kind === 9 /* StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -24274,7 +24832,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 211 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 212 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -24294,28 +24852,28 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 132 /* QualifiedName */) { + if (node.kind === 133 /* QualifiedName */) { node = node.left; } - else if (node.kind === 163 /* PropertyAccessExpression */) { + else if (node.kind === 164 /* PropertyAccessExpression */) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 66 /* Identifier */); + ts.Debug.assert(node.kind === 67 /* Identifier */); return node; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 8 /* StringLiteral */) { + if (!ts.nodeIsMissing(moduleName) && moduleName.kind !== 9 /* StringLiteral */) { error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 216 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 245 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 225 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 226 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -24338,7 +24896,7 @@ var ts; (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 227 /* ExportSpecifier */ ? + var message = node.kind === 228 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -24365,7 +24923,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -24402,7 +24960,7 @@ var ts; } } else { - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES6 */ && !ts.isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); } @@ -24422,8 +24980,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 216 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 245 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 217 /* ModuleBlock */ && node.parent.parent.name.kind === 9 /* StringLiteral */; + if (node.parent.kind !== 246 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -24437,7 +24995,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 245 /* SourceFile */ && node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 215 /* ModuleDeclaration */) { + if (node.parent.kind !== 246 /* SourceFile */ && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 216 /* ModuleDeclaration */) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -24452,8 +25010,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 245 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 215 /* ModuleDeclaration */ && container.name.kind === 66 /* Identifier */) { + var container = node.parent.kind === 246 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 216 /* ModuleDeclaration */ && container.name.kind === 67 /* Identifier */) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -24461,7 +25019,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { markExportAsReferenced(node); } else { @@ -24480,10 +25038,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 245 /* SourceFile */) { + if (node.kind === 246 /* SourceFile */) { return node.statements; } - if (node.kind === 215 /* ModuleDeclaration */ && node.body.kind === 216 /* ModuleBlock */) { + if (node.kind === 216 /* ModuleDeclaration */ && node.body.kind === 217 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -24522,118 +25080,118 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessivly // hitting the cancellation token on every node we check. switch (kind) { - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: return checkTypeParameter(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return checkParameter(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return checkPropertyDeclaration(node); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return checkSignatureDeclaration(node); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return checkMethodDeclaration(node); - case 141 /* Constructor */: + case 142 /* Constructor */: return checkConstructorDeclaration(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return checkAccessorDeclaration(node); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return checkTypeReferenceNode(node); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return checkTypePredicate(node); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return checkTypeQuery(node); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return checkTypeLiteral(node); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return checkArrayType(node); - case 154 /* TupleType */: + case 155 /* TupleType */: return checkTupleType(node); - case 155 /* UnionType */: - case 156 /* IntersectionType */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return checkSourceElement(node.type); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return checkBlock(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return checkVariableStatement(node); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return checkExpressionStatement(node); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return checkIfStatement(node); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return checkDoStatement(node); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return checkWhileStatement(node); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return checkForStatement(node); - case 197 /* ForInStatement */: + case 198 /* ForInStatement */: return checkForInStatement(node); - case 198 /* ForOfStatement */: + case 199 /* ForOfStatement */: return checkForOfStatement(node); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return checkReturnStatement(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return checkWithStatement(node); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return checkSwitchStatement(node); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return checkLabeledStatement(node); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return checkThrowStatement(node); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return checkTryStatement(node); - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 160 /* BindingElement */: + case 161 /* BindingElement */: return checkBindingElement(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return checkClassDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return checkImportDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return checkExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return checkExportAssignment(node); - case 191 /* EmptyStatement */: + case 192 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 228 /* MissingDeclaration */: + case 229 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -24648,95 +25206,97 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: ts.forEach(node.members, checkSourceElement); break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 202 /* WithStatement */: + case 203 /* WithStatement */: checkFunctionAndClassExpressionBodies(node.expression); break; - case 136 /* Decorator */: - case 135 /* Parameter */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 160 /* BindingElement */: - case 161 /* ArrayLiteralExpression */: - case 162 /* ObjectLiteralExpression */: - case 242 /* PropertyAssignment */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 167 /* TaggedTemplateExpression */: - case 180 /* TemplateExpression */: - case 187 /* TemplateSpan */: - case 168 /* TypeAssertionExpression */: - case 186 /* AsExpression */: - case 169 /* ParenthesizedExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 175 /* AwaitExpression */: - case 172 /* DeleteExpression */: - case 176 /* PrefixUnaryExpression */: - case 177 /* PostfixUnaryExpression */: - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 182 /* SpreadElementExpression */: - case 181 /* YieldExpression */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 190 /* VariableStatement */: - case 192 /* ExpressionStatement */: - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: - case 201 /* ReturnStatement */: - case 203 /* SwitchStatement */: - case 217 /* CaseBlock */: - case 238 /* CaseClause */: - case 239 /* DefaultClause */: - case 204 /* LabeledStatement */: - case 205 /* ThrowStatement */: - case 206 /* TryStatement */: - case 241 /* CatchClause */: - case 208 /* VariableDeclaration */: - case 209 /* VariableDeclarationList */: - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 224 /* ExportAssignment */: - case 245 /* SourceFile */: - case 237 /* JsxExpression */: - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: - case 235 /* JsxAttribute */: - case 236 /* JsxSpreadAttribute */: - case 232 /* JsxOpeningElement */: + case 137 /* Decorator */: + case 136 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 161 /* BindingElement */: + case 162 /* ArrayLiteralExpression */: + case 163 /* ObjectLiteralExpression */: + case 243 /* PropertyAssignment */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 168 /* TaggedTemplateExpression */: + case 181 /* TemplateExpression */: + case 188 /* TemplateSpan */: + case 169 /* TypeAssertionExpression */: + case 187 /* AsExpression */: + case 170 /* ParenthesizedExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 176 /* AwaitExpression */: + case 173 /* DeleteExpression */: + case 177 /* PrefixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 183 /* SpreadElementExpression */: + case 182 /* YieldExpression */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 191 /* VariableStatement */: + case 193 /* ExpressionStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: + case 202 /* ReturnStatement */: + case 204 /* SwitchStatement */: + case 218 /* CaseBlock */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: + case 205 /* LabeledStatement */: + case 206 /* ThrowStatement */: + case 207 /* TryStatement */: + case 242 /* CatchClause */: + case 209 /* VariableDeclaration */: + case 210 /* VariableDeclarationList */: + case 212 /* ClassDeclaration */: + case 241 /* HeritageClause */: + case 186 /* ExpressionWithTypeArguments */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 225 /* ExportAssignment */: + case 246 /* SourceFile */: + case 238 /* JsxExpression */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + case 233 /* JsxOpeningElement */: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -24822,7 +25382,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 202 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 203 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -24845,25 +25405,25 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } // fall through; this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -24872,13 +25432,16 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 170 /* FunctionExpression */: + case 171 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); } break; } + if (ts.introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } memberFlags = location.flags; location = location.parent; } @@ -24912,43 +25475,43 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 66 /* Identifier */ && + return name.kind === 67 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 134 /* TypeParameter */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: + case 135 /* TypeParameter */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 132 /* QualifiedName */) { + while (node.parent && node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 148 /* TypeReference */; + return node.parent && node.parent.kind === 149 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 163 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 164 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 185 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 186 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 132 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 133 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 218 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 219 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 224 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 225 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -24960,11 +25523,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 224 /* ExportAssignment */) { + if (entityName.parent.kind === 225 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 163 /* PropertyAccessExpression */) { + if (entityName.kind !== 164 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -24974,11 +25537,13 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 185 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 186 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if ((entityName.parent.kind === 232 /* JsxOpeningElement */) || (entityName.parent.kind === 231 /* JsxSelfClosingElement */)) { + else if ((entityName.parent.kind === 233 /* JsxOpeningElement */) || + (entityName.parent.kind === 232 /* JsxSelfClosingElement */) || + (entityName.parent.kind === 235 /* JsxClosingElement */)) { return getJsxElementTagSymbol(entityName.parent); } else if (ts.isExpression(entityName)) { @@ -24986,20 +25551,20 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 66 /* Identifier */) { + if (entityName.kind === 67 /* Identifier */) { // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 163 /* PropertyAccessExpression */) { + else if (entityName.kind === 164 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 132 /* QualifiedName */) { + else if (entityName.kind === 133 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -25008,22 +25573,22 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 148 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 149 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.parent.kind === 235 /* JsxAttribute */) { + else if (entityName.parent.kind === 236 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 147 /* TypePredicate */) { - return resolveEntityName(entityName, 1 /* FunctionScopedVariable */); + if (entityName.parent.kind === 148 /* TypePredicate */) { + return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } - function getSymbolInfo(node) { + function getSymbolAtLocation(node) { if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; @@ -25032,39 +25597,50 @@ var ts; // This is a declaration, call getSymbolOfNode return getSymbolOfNode(node.parent); } - if (node.kind === 66 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 224 /* ExportAssignment */ - ? getSymbolOfEntityNameOrPropertyAccessExpression(node) - : getSymbolOfPartOfRightHandSideOfImportEquals(node); + if (node.kind === 67 /* Identifier */) { + if (isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 225 /* ExportAssignment */ + ? getSymbolOfEntityNameOrPropertyAccessExpression(node) + : getSymbolOfPartOfRightHandSideOfImportEquals(node); + } + else if (node.parent.kind === 161 /* BindingElement */ && + node.parent.parent.kind === 159 /* ObjectBindingPattern */ && + node === node.parent.propertyName) { + var typeOfPattern = getTypeOfNode(node.parent.parent); + var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); + if (propertyDeclaration) { + return propertyDeclaration; + } + } } switch (node.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: var type = checkExpression(node); return type.symbol; - case 118 /* ConstructorKeyword */: + case 119 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 141 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 142 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 219 /* ImportDeclaration */ || node.parent.kind === 225 /* ExportDeclaration */) && + ((node.parent.kind === 220 /* ImportDeclaration */ || node.parent.kind === 226 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } // Fall through - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -25081,7 +25657,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 243 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 244 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -25103,28 +25679,28 @@ var ts; return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; } if (isTypeDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); return getDeclaredTypeOfSymbol(symbol); } if (isTypeDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); } if (ts.isDeclaration(node)) { - // In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration + // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration var symbol = getSymbolOfNode(node); return getTypeOfSymbol(symbol); } if (ts.isDeclarationName(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); return symbol && getTypeOfSymbol(symbol); } if (ts.isBindingPattern(node)) { return getTypeForVariableLikeDeclaration(node.parent); } if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolInfo(node); + var symbol = getSymbolAtLocation(node); var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); } @@ -25165,7 +25741,10 @@ var ts; var symbols = []; var name_15 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - symbols.push(getPropertyOfType(t, name_15)); + var symbol = getPropertyOfType(t, name_15); + if (symbol) { + symbols.push(symbol); + } }); return symbols; } @@ -25195,11 +25774,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 245 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 246 /* SourceFile */) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 215 /* ModuleDeclaration */ || n.kind === 214 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 216 /* ModuleDeclaration */ || n.kind === 215 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -25214,11 +25793,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 189 /* Block */: - case 217 /* CaseBlock */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 190 /* Block */: + case 218 /* CaseBlock */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return true; } return false; @@ -25229,7 +25808,7 @@ var ts; if (links.isNestedRedeclaration === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, 107455 /* Value */, undefined, undefined); + !!resolveName(container.parent, symbol.name, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); } return links.isNestedRedeclaration; } @@ -25248,22 +25827,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 224 /* ExportAssignment */: - return node.expression && node.expression.kind === 66 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 225 /* ExportAssignment */: + return node.expression && node.expression.kind === 67 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 245 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 246 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -25276,7 +25855,11 @@ var ts; return true; } // const enums and modules that contain only const enums are not considered values from the emit perespective - return target !== unknownSymbol && target && target.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(target); + // unless 'preserveConstEnums' option is set to true + return target !== unknownSymbol && + target && + target.flags & 107455 /* Value */ && + (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || s.constEnumOnlyModule; @@ -25321,7 +25904,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 244 /* EnumMember */) { + if (node.kind === 245 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -25336,14 +25919,20 @@ var ts; function isFunctionType(type) { return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 0 /* Call */).length > 0; } - function getTypeReferenceSerializationKind(node) { + function getTypeReferenceSerializationKind(typeName) { // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var symbol = resolveEntityName(node.typeName, 107455 /* Value */, true); - var constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + var valueSymbol = resolveEntityName(typeName, 107455 /* Value */, /*ignoreErrors*/ true); + var constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined; if (constructorType && isConstructorType(constructorType)) { return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; } - var type = getTypeFromTypeNode(node); + // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. + var typeSymbol = resolveEntityName(typeName, 793056 /* Type */, /*ignoreErrors*/ true); + // We might not be able to resolve type symbol so use unknown type in that case (eg error case) + if (!typeSymbol) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + var type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } @@ -25365,7 +25954,7 @@ var ts; else if (allConstituentTypesHaveKind(type, 8192 /* Tuple */)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (allConstituentTypesHaveKind(type, 4194304 /* ESSymbol */)) { + else if (allConstituentTypesHaveKind(type, 16777216 /* ESSymbol */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -25400,7 +25989,7 @@ var ts; function getReferencedValueSymbol(reference) { return getNodeLinks(reference).resolvedSymbol || resolveName(reference, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, - /*nodeNotFoundMessage*/ undefined, undefined); + /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); } function getReferencedValueDeclaration(reference) { ts.Debug.assert(!ts.nodeIsSynthesized(reference)); @@ -25409,13 +25998,13 @@ var ts; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 160 /* BindingElement */ || (n.parent.kind === 208 /* VariableDeclaration */ && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 161 /* BindingElement */ || (n.parent.kind === 209 /* VariableDeclaration */ && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || - resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); + resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); var isLetOrConst = symbol && (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 241 /* CatchClause */; + symbol.valueDeclaration.parent.kind !== 242 /* CatchClause */; if (isLetOrConst) { // side-effect of calling this method: // assign id to symbol if it was not yet set @@ -25457,7 +26046,8 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - getTypeReferenceSerializationKind: getTypeReferenceSerializationKind + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, + isOptionalParameter: isOptionalParameter }; } function initializeTypeChecker() { @@ -25477,7 +26067,7 @@ var ts; getSymbolLinks(unknownSymbol).type = unknownType; globals[undefinedSymbol.name] = undefinedSymbol; // Initialize special types - globalArrayType = getGlobalType("Array", 1); + globalArrayType = getGlobalType("Array", /*arity*/ 1); globalObjectType = getGlobalType("Object"); globalFunctionType = getGlobalType("Function"); globalStringType = getGlobalType("String"); @@ -25489,10 +26079,10 @@ var ts; getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); - getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); - getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); - tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, undefined) && getGlobalPromiseType(); }); - getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); + getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", /*arity*/ 1); }); + getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", /*arity*/ 1); }); + tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, /*diagnostic*/ undefined) && getGlobalPromiseType(); }); + getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", /*arity*/ 1); }); getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); @@ -25503,9 +26093,9 @@ var ts; globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"); - globalIterableType = getGlobalType("Iterable", 1); - globalIteratorType = getGlobalType("Iterator", 1); - globalIterableIteratorType = getGlobalType("IterableIterator", 1); + globalIterableType = getGlobalType("Iterable", /*arity*/ 1); + globalIteratorType = getGlobalType("Iterator", /*arity*/ 1); + globalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1); } else { globalTemplateStringsArrayType = unknownType; @@ -25522,7 +26112,7 @@ var ts; } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyObjectType) { + if (promiseLikeType !== emptyGenericType) { return createTypeReference(promiseLikeType, [anyType]); } return emptyObjectType; @@ -25549,7 +26139,7 @@ var ts; else if (languageVersion < 1 /* ES5 */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 142 /* GetAccessor */ || node.kind === 143 /* SetAccessor */) { + else if (node.kind === 143 /* GetAccessor */ || node.kind === 144 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -25559,38 +26149,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 146 /* IndexSignature */: - case 215 /* ModuleDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 225 /* ExportDeclaration */: - case 224 /* ExportAssignment */: - case 135 /* Parameter */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 147 /* IndexSignature */: + case 216 /* ModuleDeclaration */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + case 225 /* ExportAssignment */: + case 136 /* Parameter */: break; - case 210 /* FunctionDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 115 /* AsyncKeyword */) && - node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 211 /* FunctionDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 116 /* AsyncKeyword */) && + node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 190 /* VariableStatement */: - case 213 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 191 /* VariableStatement */: + case 214 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 214 /* EnumDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 71 /* ConstKeyword */) && - node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + case 215 /* EnumDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 72 /* ConstKeyword */) && + node.parent.kind !== 217 /* ModuleBlock */ && node.parent.kind !== 246 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -25605,14 +26195,14 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { - case 109 /* PublicKeyword */: - case 108 /* ProtectedKeyword */: - case 107 /* PrivateKeyword */: + case 110 /* PublicKeyword */: + case 109 /* ProtectedKeyword */: + case 108 /* PrivateKeyword */: var text = void 0; - if (modifier.kind === 109 /* PublicKeyword */) { + if (modifier.kind === 110 /* PublicKeyword */) { text = "public"; } - else if (modifier.kind === 108 /* ProtectedKeyword */) { + else if (modifier.kind === 109 /* ProtectedKeyword */) { text = "protected"; lastProtected = modifier; } @@ -25629,11 +26219,11 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } else if (flags & 256 /* Abstract */) { - if (modifier.kind === 107 /* PrivateKeyword */) { + if (modifier.kind === 108 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -25642,17 +26232,17 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 110 /* StaticKeyword */: + case 111 /* StaticKeyword */: if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + else if (node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 256 /* Abstract */) { @@ -25661,7 +26251,7 @@ var ts; flags |= 128 /* Static */; lastStatic = modifier; break; - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -25674,42 +26264,42 @@ var ts; else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 119 /* DeclareKeyword */: + case 120 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 216 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 217 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 112 /* AbstractKeyword */: + case 113 /* AbstractKeyword */: if (flags & 256 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 211 /* ClassDeclaration */) { - if (node.kind !== 140 /* MethodDeclaration */) { + if (node.kind !== 212 /* ClassDeclaration */) { + if (node.kind !== 141 /* MethodDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 211 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + if (!(node.parent.kind === 212 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 128 /* Static */) { @@ -25721,14 +26311,14 @@ var ts; } flags |= 256 /* Abstract */; break; - case 115 /* AsyncKeyword */: + case 116 /* AsyncKeyword */: if (flags & 512 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 135 /* Parameter */) { + else if (node.kind === 136 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 512 /* Async */; @@ -25736,7 +26326,7 @@ var ts; break; } } - if (node.kind === 141 /* Constructor */) { + if (node.kind === 142 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -25754,10 +26344,10 @@ var ts; } return; } - else if ((node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 220 /* ImportDeclaration */ || node.kind === 219 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 135 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 136 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } if (flags & 512 /* Async */) { @@ -25769,10 +26359,10 @@ var ts; return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); } switch (node.kind) { - case 140 /* MethodDeclaration */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -25820,16 +26410,14 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken || parameter.initializer) { + else if (parameter.questionToken) { seenOptionalParameter = true; - if (parameter.questionToken && parameter.initializer) { + if (parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } - else { - if (seenOptionalParameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } + else if (seenOptionalParameter && !parameter.initializer) { + return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); } } } @@ -25840,7 +26428,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 171 /* ArrowFunction */) { + if (node.kind === 172 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -25875,7 +26463,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 127 /* StringKeyword */ && parameter.type.kind !== 125 /* NumberKeyword */) { + if (parameter.type.kind !== 128 /* StringKeyword */ && parameter.type.kind !== 126 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -25908,7 +26496,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0; _i < args.length; _i++) { var arg = args[_i]; - if (arg.kind === 184 /* OmittedExpression */) { + if (arg.kind === 185 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -25935,7 +26523,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80 /* ExtendsKeyword */) { + if (heritageClause.token === 81 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -25948,7 +26536,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -25964,14 +26552,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 80 /* ExtendsKeyword */) { + if (heritageClause.token === 81 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 104 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -25982,19 +26570,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 133 /* ComputedPropertyName */) { + if (node.kind !== 134 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 178 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { + if (computedPropertyName.expression.kind === 179 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -26020,8 +26608,8 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_16 = prop.name; - if (prop.kind === 184 /* OmittedExpression */ || - name_16.kind === 133 /* ComputedPropertyName */) { + if (prop.kind === 185 /* OmittedExpression */ || + name_16.kind === 134 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_16); continue; @@ -26035,21 +26623,21 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 242 /* PropertyAssignment */ || prop.kind === 243 /* ShorthandPropertyAssignment */) { + if (prop.kind === 243 /* PropertyAssignment */ || prop.kind === 244 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_16.kind === 7 /* NumericLiteral */) { + if (name_16.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name_16); } currentKind = Property; } - else if (prop.kind === 140 /* MethodDeclaration */) { + else if (prop.kind === 141 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 142 /* GetAccessor */) { + else if (prop.kind === 143 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 143 /* SetAccessor */) { + else if (prop.kind === 144 /* SetAccessor */) { currentKind = SetAccesor; } else { @@ -26081,7 +26669,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 236 /* JsxSpreadAttribute */) { + if (attr.kind === 237 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; @@ -26093,7 +26681,7 @@ var ts; return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 237 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 238 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -26102,24 +26690,24 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 209 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 210 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 198 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -26142,10 +26730,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 142 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 143 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 143 /* SetAccessor */) { + else if (kind === 144 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -26170,7 +26758,7 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 133 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 134 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } @@ -26180,7 +26768,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 162 /* ObjectLiteralExpression */) { + if (node.parent.kind === 163 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -26204,22 +26792,22 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 212 /* InterfaceDeclaration */) { + else if (node.parent.kind === 213 /* InterfaceDeclaration */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 152 /* TypeLiteral */) { + else if (node.parent.kind === 153 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: return true; - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -26231,26 +26819,26 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 199 /* ContinueStatement */ - && !isIterationStatement(current.statement, true); + var isMisplacedContinueLabel = node.kind === 200 /* ContinueStatement */ + && !isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); } return false; } break; - case 203 /* SwitchStatement */: - if (node.kind === 200 /* BreakStatement */ && !node.label) { + case 204 /* SwitchStatement */: + if (node.kind === 201 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } break; default: - if (isIterationStatement(current, false) && !node.label) { + if (isIterationStatement(current, /*lookInLabeledStatement*/ false) && !node.label) { // unlabeled break or continue within iteration statement - ok return false; } @@ -26259,13 +26847,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 200 /* BreakStatement */ + var message = node.kind === 201 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 200 /* BreakStatement */ + var message = node.kind === 201 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -26277,7 +26865,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 159 /* ArrayBindingPattern */ || node.name.kind === 158 /* ObjectBindingPattern */) { + if (node.name.kind === 160 /* ArrayBindingPattern */ || node.name.kind === 159 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -26287,7 +26875,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 197 /* ForInStatement */ && node.parent.parent.kind !== 198 /* ForOfStatement */) { + if (node.parent.parent.kind !== 198 /* ForInStatement */ && node.parent.parent.kind !== 199 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -26314,7 +26902,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -26323,7 +26911,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 184 /* OmittedExpression */) { + if (element.kind !== 185 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -26340,15 +26928,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 193 /* IfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 194 /* IfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return false; - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -26364,13 +26952,13 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 176 /* PrefixUnaryExpression */) { + if (expression.kind === 177 /* PrefixUnaryExpression */) { var unaryExpression = expression; - if (unaryExpression.operator === 34 /* PlusToken */ || unaryExpression.operator === 35 /* MinusToken */) { + if (unaryExpression.operator === 35 /* PlusToken */ || unaryExpression.operator === 36 /* MinusToken */) { expression = unaryExpression.operand; } } - if (expression.kind === 7 /* NumericLiteral */) { + if (expression.kind === 8 /* NumericLiteral */) { // Allows for scientific notation since literalExpression.text was formed by // coercing a number to a string. Sometimes this coercion can yield a string // in scientific notation. @@ -26393,7 +26981,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 133 /* ComputedPropertyName */) { + if (node.name.kind === 134 /* ComputedPropertyName */) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -26436,7 +27024,7 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkGrammarConstructorTypeParameters(node) { @@ -26456,12 +27044,12 @@ var ts; return true; } } - else if (node.parent.kind === 212 /* InterfaceDeclaration */) { + else if (node.parent.kind === 213 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 152 /* TypeLiteral */) { + else if (node.parent.kind === 153 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -26481,11 +27069,11 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 212 /* InterfaceDeclaration */ || - node.kind === 219 /* ImportDeclaration */ || - node.kind === 218 /* ImportEqualsDeclaration */ || - node.kind === 225 /* ExportDeclaration */ || - node.kind === 224 /* ExportAssignment */ || + if (node.kind === 213 /* InterfaceDeclaration */ || + node.kind === 220 /* ImportDeclaration */ || + node.kind === 219 /* ImportEqualsDeclaration */ || + node.kind === 226 /* ExportDeclaration */ || + node.kind === 225 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || (node.flags & (1 /* Export */ | 1024 /* Default */))) { return false; @@ -26495,7 +27083,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 190 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 191 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -26521,7 +27109,7 @@ var ts; // to prevent noisyness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 189 /* Block */ || node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { + if (node.parent.kind === 190 /* Block */ || node.parent.kind === 217 /* ModuleBlock */ || node.parent.kind === 246 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -26542,7 +27130,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2)); + diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), /*length*/ 0, message, arg0, arg1, arg2)); return true; } } @@ -26603,7 +27191,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 219 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 220 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -26679,10 +27267,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 208 /* VariableDeclaration */) { + if (declaration.kind === 209 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 222 /* NamedImports */ || declaration.kind === 223 /* ImportSpecifier */ || declaration.kind === 220 /* ImportClause */) { + else if (declaration.kind === 223 /* NamedImports */ || declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 221 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -26700,7 +27288,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 219 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 220 /* ImportDeclaration */) { // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; @@ -26710,12 +27298,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 215 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 215 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 216 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -26798,7 +27386,7 @@ var ts; var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); // jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, jsDocComments, true, newLine, ts.writeCommentRange); + ts.emitComments(currentSourceFile, writer, jsDocComments, /*trailingSeparator*/ true, newLine, ts.writeCommentRange); } } function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { @@ -26807,49 +27395,49 @@ var ts; } function emitType(type) { switch (type.kind) { - case 114 /* AnyKeyword */: - case 127 /* StringKeyword */: - case 125 /* NumberKeyword */: - case 117 /* BooleanKeyword */: - case 128 /* SymbolKeyword */: - case 100 /* VoidKeyword */: - case 8 /* StringLiteral */: + case 115 /* AnyKeyword */: + case 128 /* StringKeyword */: + case 126 /* NumberKeyword */: + case 118 /* BooleanKeyword */: + case 129 /* SymbolKeyword */: + case 101 /* VoidKeyword */: + case 9 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 185 /* ExpressionWithTypeArguments */: + case 186 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 148 /* TypeReference */: + case 149 /* TypeReference */: return emitTypeReference(type); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return emitTypeQuery(type); - case 153 /* ArrayType */: + case 154 /* ArrayType */: return emitArrayType(type); - case 154 /* TupleType */: + case 155 /* TupleType */: return emitTupleType(type); - case 155 /* UnionType */: + case 156 /* UnionType */: return emitUnionType(type); - case 156 /* IntersectionType */: + case 157 /* IntersectionType */: return emitIntersectionType(type); - case 157 /* ParenthesizedType */: + case 158 /* ParenthesizedType */: return emitParenType(type); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 152 /* TypeLiteral */: + case 153 /* TypeLiteral */: return emitTypeLiteral(type); - case 66 /* Identifier */: + case 67 /* Identifier */: return emitEntityName(type); - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return emitEntityName(type); - case 147 /* TypePredicate */: + case 148 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 66 /* Identifier */) { + if (entityName.kind === 67 /* Identifier */) { writeTextOfNode(currentSourceFile, entityName); } else { - var left = entityName.kind === 132 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 132 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 133 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 133 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentSourceFile, right); @@ -26858,13 +27446,13 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 218 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 219 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 66 /* Identifier */ || node.expression.kind === 163 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 67 /* Identifier */ || node.expression.kind === 164 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -26945,7 +27533,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -26965,7 +27553,7 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 66 /* Identifier */) { + if (node.expression.kind === 67 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); @@ -26984,10 +27572,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 218 /* ImportEqualsDeclaration */ || - (node.parent.kind === 245 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 219 /* ImportEqualsDeclaration */ || + (node.parent.kind === 246 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 245 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 246 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -26997,7 +27585,7 @@ var ts; }); } else { - if (node.kind === 219 /* ImportDeclaration */) { + if (node.kind === 220 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -27015,23 +27603,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return writeVariableStatement(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return writeClassDeclaration(node); - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -27047,7 +27635,7 @@ var ts; if (node.flags & 1024 /* Default */) { write("default "); } - else if (node.kind !== 212 /* InterfaceDeclaration */) { + else if (node.kind !== 213 /* InterfaceDeclaration */) { write("declare "); } } @@ -27096,7 +27684,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 221 /* NamespaceImport */) { + if (namedBindings.kind === 222 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -27124,7 +27712,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -27182,7 +27770,7 @@ var ts; write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 216 /* ModuleBlock */) { + while (node.body.kind !== 217 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -27199,14 +27787,18 @@ var ts; enclosingDeclaration = prevEnclosingDeclaration; } function writeTypeAliasDeclaration(node) { + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; emitJsDocComments(node); emitModuleElementDeclarationFlags(node); write("type "); writeTextOfNode(currentSourceFile, node.name); + emitTypeParameters(node.typeParameters); write(" = "); emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); write(";"); writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, @@ -27243,7 +27835,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 140 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 141 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -27254,15 +27846,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 152 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 140 /* MethodDeclaration */ || - node.parent.kind === 139 /* MethodSignature */ || - node.parent.kind === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - node.parent.kind === 144 /* CallSignature */ || - node.parent.kind === 145 /* ConstructSignature */); + if (node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 153 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 141 /* MethodDeclaration */ || + node.parent.kind === 140 /* MethodSignature */ || + node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + node.parent.kind === 145 /* CallSignature */ || + node.parent.kind === 146 /* ConstructSignature */); emitType(node.constraint); } else { @@ -27273,31 +27865,31 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 144 /* CallSignature */: + case 145 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 212 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -27325,10 +27917,13 @@ var ts; if (ts.isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } + else if (!isImplementsList && node.expression.kind === 91 /* NullKeyword */) { + write("null"); + } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 211 /* ClassDeclaration */) { + if (node.parent.parent.kind === 212 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -27368,9 +27963,9 @@ var ts; emitTypeParameters(node.typeParameters); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); + emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); } - emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), true); + emitHeritageClause(ts.getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); write(" {"); writeLine(); increaseIndent(); @@ -27389,7 +27984,7 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); + emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false); write(" {"); writeLine(); increaseIndent(); @@ -27412,7 +28007,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 208 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 209 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -27422,10 +28017,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) && node.parent.kind === 152 /* TypeLiteral */) { + if ((node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) && node.parent.kind === 153 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -27434,14 +28029,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 208 /* VariableDeclaration */) { + if (node.kind === 209 /* VariableDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) { + else if (node.kind === 139 /* PropertyDeclaration */ || node.kind === 138 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -27450,7 +28045,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -27482,7 +28077,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 184 /* OmittedExpression */) { + if (element.kind !== 185 /* OmittedExpression */) { elements.push(element); } } @@ -27503,7 +28098,7 @@ var ts; } else { writeTextOfNode(currentSourceFile, bindingElement.name); - writeTypeOfDeclaration(bindingElement, undefined, getBindingElementTypeVisibilityError); + writeTypeOfDeclaration(bindingElement, /*type*/ undefined, getBindingElementTypeVisibilityError); } } } @@ -27552,7 +28147,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 142 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 143 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -27565,7 +28160,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 142 /* GetAccessor */ + return accessor.kind === 143 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -27574,7 +28169,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 143 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 144 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -27624,17 +28219,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 140 /* MethodDeclaration */) { + else if (node.kind === 141 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 141 /* Constructor */) { + else if (node.kind === 142 /* Constructor */) { write("constructor"); } else { @@ -27652,11 +28247,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 145 /* ConstructSignature */ || node.kind === 150 /* ConstructorType */) { + if (node.kind === 146 /* ConstructSignature */ || node.kind === 151 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { write("["); } else { @@ -27666,22 +28261,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 146 /* IndexSignature */) { + if (node.kind === 147 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 149 /* FunctionType */ || node.kind === 150 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 152 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 150 /* FunctionType */ || node.kind === 151 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 153 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 141 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 142 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -27692,26 +28287,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 144 /* CallSignature */: + case 145 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -27719,7 +28314,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.kind === 212 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -27733,7 +28328,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -27764,13 +28359,13 @@ var ts; else { writeTextOfNode(currentSourceFile, node.name); } - if (node.initializer || ts.hasQuestionToken(node)) { + if (resolver.isOptionalParameter(node)) { write("?"); } decreaseIndent(); - if (node.parent.kind === 149 /* FunctionType */ || - node.parent.kind === 150 /* ConstructorType */ || - node.parent.parent.kind === 152 /* TypeLiteral */) { + if (node.parent.kind === 150 /* FunctionType */ || + node.parent.kind === 151 /* ConstructorType */ || + node.parent.parent.kind === 153 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -27786,24 +28381,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 141 /* Constructor */: + case 142 /* Constructor */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 144 /* CallSignature */: + case 145 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -27811,7 +28406,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 211 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 212 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -27824,7 +28419,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -27836,12 +28431,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 158 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 159 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 159 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 160 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -27860,7 +28455,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 184 /* OmittedExpression */) { + if (bindingElement.kind === 185 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -27869,7 +28464,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 160 /* BindingElement */) { + else if (bindingElement.kind === 161 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -27879,10 +28474,8 @@ var ts; // emit : declare function foo({y: [a, b, c]}: { y: [any, any, any] }) void; writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); - // If bindingElement has propertyName property, then its name must be another bindingPattern of SyntaxKind.ObjectBindingPattern - emitBindingPattern(bindingElement.name); } - else if (bindingElement.name) { + if (bindingElement.name) { if (ts.isBindingPattern(bindingElement.name)) { // If it is a nested binding pattern, we will recursively descend into each element and emit each one separately. // In the case of rest element, we will omit rest element. @@ -27894,7 +28487,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 66 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 67 /* Identifier */); // If the node is just an identifier, we will simply emit the text associated with the node's name // Example: // original: function foo({y = 10, x}) {} @@ -27910,40 +28503,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 215 /* ModuleDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 212 /* InterfaceDeclaration */: - case 211 /* ClassDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: + case 211 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 213 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible - return emitModuleElement(node, !node.importClause); - case 225 /* ExportDeclaration */: + return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); + case 226 /* ExportDeclaration */: return emitExportDeclaration(node); - case 141 /* Constructor */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 142 /* Constructor */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return writeFunctionDeclaration(node); - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 146 /* IndexSignature */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 147 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return emitAccessorDeclaration(node); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return emitPropertyDeclaration(node); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return emitExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return emitSourceFile(node); } } @@ -27952,7 +28545,7 @@ var ts; ? referencedFile.fileName // Declaration file, use declaration file name : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file - : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; // Global out file + : ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; // Global out file declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); referencePathsOutput += "/// " + newLine; @@ -28026,18 +28619,18 @@ var ts; emitFile(jsFilePath, sourceFile); } }); - if (compilerOptions.out) { - emitFile(compilerOptions.out); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } else { // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ts.forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } - else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { - emitFile(compilerOptions.out); + else if (!ts.isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } // Sort and make the unique list of diagnostics @@ -28068,11 +28661,7 @@ var ts; } function emitJavaScript(jsFilePath, root) { var writer = ts.createTextWriter(newLine); - var write = writer.write; - var writeTextOfNode = writer.writeTextOfNode; - var writeLine = writer.writeLine; - var increaseIndent = writer.increaseIndent; - var decreaseIndent = writer.decreaseIndent; + var write = writer.write, writeTextOfNode = writer.writeTextOfNode, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var currentSourceFile; // name of an exporter function if file is a System external module // System.register([...], function () {...}) @@ -28100,7 +28689,7 @@ var ts; var detachedCommentsInfo; var writeComment = ts.writeCommentRange; /** Emit a node */ - var emit = emitNodeWithoutSourceMap; + var emit = emitNodeWithCommentsAndWithoutSourcemap; /** Called just before starting emit of a node */ var emitStart = function (node) { }; /** Called once the emit of the node is done */ @@ -28120,6 +28709,8 @@ var ts; var scopeEmitEnd = function () { }; /** Sourcemap data that will get encoded */ var sourceMapData; + /** If removeComments is true, no leading-comments needed to be emitted **/ + var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker; if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); } @@ -28135,7 +28726,7 @@ var ts; }); } writeLine(); - writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); + writeEmittedFiles(writer.getText(), /*writeByteOrderMark*/ compilerOptions.emitBOM); return; function emitSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -28195,7 +28786,7 @@ var ts; } function generateNameForImportOrExportDeclaration(node) { var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 8 /* StringLiteral */ ? + var baseName = expr.kind === 9 /* StringLiteral */ ? ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; return makeUniqueName(baseName); } @@ -28207,19 +28798,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return makeUniqueName(node.text); - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 219 /* ImportDeclaration */: - case 225 /* ExportDeclaration */: + case 220 /* ImportDeclaration */: + case 226 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 210 /* FunctionDeclaration */: - case 211 /* ClassDeclaration */: - case 224 /* ExportAssignment */: + case 211 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: + case 225 /* ExportAssignment */: return generateNameForExportDefault(); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return generateNameForClassExpression(); } } @@ -28285,7 +28876,7 @@ var ts; function base64VLQFormatEncode(inValue) { function base64FormatEncode(inValue) { if (inValue < 64) { - return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue); + return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(inValue); } throw TypeError(inValue + ": not a 64 based value"); } @@ -28391,7 +28982,7 @@ var ts; // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. var name_21 = node.name; - if (!name_21 || name_21.kind !== 133 /* ComputedPropertyName */) { + if (!name_21 || name_21.kind !== 134 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -28409,20 +29000,20 @@ var ts; // The scope was already given a name use it recordScopeNameStart(scopeName); } - else if (node.kind === 210 /* FunctionDeclaration */ || - node.kind === 170 /* FunctionExpression */ || - node.kind === 140 /* MethodDeclaration */ || - node.kind === 139 /* MethodSignature */ || - node.kind === 142 /* GetAccessor */ || - node.kind === 143 /* SetAccessor */ || - node.kind === 215 /* ModuleDeclaration */ || - node.kind === 211 /* ClassDeclaration */ || - node.kind === 214 /* EnumDeclaration */) { + else if (node.kind === 211 /* FunctionDeclaration */ || + node.kind === 171 /* FunctionExpression */ || + node.kind === 141 /* MethodDeclaration */ || + node.kind === 140 /* MethodSignature */ || + node.kind === 143 /* GetAccessor */ || + node.kind === 144 /* SetAccessor */ || + node.kind === 216 /* ModuleDeclaration */ || + node.kind === 212 /* ClassDeclaration */ || + node.kind === 215 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { var name_22 = node.name; // For computed property names, the text will include the brackets - scopeName = name_22.kind === 133 /* ComputedPropertyName */ + scopeName = name_22.kind === 134 /* ComputedPropertyName */ ? ts.getTextOfNode(name_22) : node.name.text; } @@ -28481,7 +29072,7 @@ var ts; } else { // Write source map file - ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, false); + ts.writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false); sourceMapUrl = "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL; } // Write sourcemap url to the js file and write the js file @@ -28517,7 +29108,9 @@ var ts; if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { // The relative paths are relative to the common directory sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), host.getCurrentDirectory(), host.getCanonicalFileName, + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath + ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap + host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ true); } else { @@ -28532,7 +29125,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 245 /* SourceFile */) { + if (node.kind !== 246 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -28543,8 +29136,11 @@ var ts; } } } + function emitNodeWithCommentsAndWithSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); + } writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithSourceMap; + emit = emitNodeWithCommentsAndWithSourcemap; emitStart = recordEmitNodeStartSpan; emitEnd = recordEmitNodeEndSpan; emitToken = writeTextWithSpanRecord; @@ -28557,7 +29153,7 @@ var ts; } // Create a temporary variable with a unique unused name. function createTempVariable(flags) { - var result = ts.createSynthesizedNode(66 /* Identifier */); + var result = ts.createSynthesizedNode(67 /* Identifier */); result.text = makeTempVariableName(flags); return result; } @@ -28667,7 +29263,14 @@ var ts; write(", "); } } - emitNode(nodes[start + i]); + var node = nodes[start + i]; + // This emitting is to make sure we emit following comment properly + // ...(x, /*comment1*/ y)... + // ^ => node.pos + // "comment1" is not considered leading comment for "y" but rather + // considered as trailing comment of the previous node. + emitTrailingCommentsOfPosition(node.pos); + emitNode(node); leadingComma = true; } if (trailingComma) { @@ -28680,11 +29283,11 @@ var ts; } function emitCommaList(nodes) { if (nodes) { - emitList(nodes, 0, nodes.length, false, false); + emitList(nodes, 0, nodes.length, /*multiline*/ false, /*trailingComma*/ false); } } function emitLines(nodes) { - emitLinesStartingAt(nodes, 0); + emitLinesStartingAt(nodes, /*startIndex*/ 0); } function emitLinesStartingAt(nodes, startIndex) { for (var i = startIndex; i < nodes.length; i++) { @@ -28693,7 +29296,7 @@ var ts; } } function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 7 /* NumericLiteral */ && text.length > 1) { + if (node.kind === 8 /* NumericLiteral */ && text.length > 1) { switch (text.charCodeAt(1)) { case 98 /* b */: case 66 /* B */: @@ -28706,7 +29309,7 @@ var ts; } function emitLiteral(node) { var text = getLiteralText(node); - if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 8 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === 9 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { @@ -28720,7 +29323,7 @@ var ts; // Any template literal or string literal with an extended escape // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. if (languageVersion < 2 /* ES6 */ && (ts.isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); + return getQuotedEscapedLiteralText("\"", node.text, "\""); } // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. @@ -28730,17 +29333,17 @@ var ts; // If we can't reach the original source text, use the canonical form if it's a number, // or an escaped quoted form of the original text if it's string-like. switch (node.kind) { - case 8 /* StringLiteral */: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 10 /* NoSubstitutionTemplateLiteral */: - return getQuotedEscapedLiteralText('`', node.text, '`'); - case 11 /* TemplateHead */: - return getQuotedEscapedLiteralText('`', node.text, '${'); - case 12 /* TemplateMiddle */: - return getQuotedEscapedLiteralText('}', node.text, '${'); - case 13 /* TemplateTail */: - return getQuotedEscapedLiteralText('}', node.text, '`'); - case 7 /* NumericLiteral */: + case 9 /* StringLiteral */: + return getQuotedEscapedLiteralText("\"", node.text, "\""); + case 11 /* NoSubstitutionTemplateLiteral */: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 12 /* TemplateHead */: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 13 /* TemplateMiddle */: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 14 /* TemplateTail */: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8 /* NumericLiteral */: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -28757,18 +29360,18 @@ var ts; // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - var isLast = node.kind === 10 /* NoSubstitutionTemplateLiteral */ || node.kind === 13 /* TemplateTail */; + var isLast = node.kind === 11 /* NoSubstitutionTemplateLiteral */ || node.kind === 14 /* TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's // and LineTerminatorSequences are normalized to for both TV and TRV. text = text.replace(/\r\n?/g, "\n"); text = ts.escapeString(text); - write('"' + text + '"'); + write("\"" + text + "\""); } function emitDownlevelTaggedTemplateArray(node, literalEmitter) { write("["); - if (node.template.kind === 10 /* NoSubstitutionTemplateLiteral */) { + if (node.template.kind === 11 /* NoSubstitutionTemplateLiteral */) { literalEmitter(node.template); } else { @@ -28795,11 +29398,11 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 180 /* TemplateExpression */) { + if (node.template.kind === 181 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 178 /* BinaryExpression */ - && templateSpan.expression.operatorToken.kind === 23 /* CommaToken */; + var needsParens = templateSpan.expression.kind === 179 /* BinaryExpression */ + && templateSpan.expression.operatorToken.kind === 24 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); } @@ -28833,7 +29436,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 169 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 170 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; if (i > 0 || headEmitted) { // If this is the first span and the head was not emitted, then this templateSpan's @@ -28875,11 +29478,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: return parent.expression === template; - case 167 /* TaggedTemplateExpression */: - case 169 /* ParenthesizedExpression */: + case 168 /* TaggedTemplateExpression */: + case 170 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -28900,20 +29503,20 @@ var ts; // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. switch (expression.kind) { - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: switch (expression.operatorToken.kind) { - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: return 1 /* GreaterThan */; - case 34 /* PlusToken */: - case 35 /* MinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: return 0 /* EqualTo */; default: return -1 /* LessThan */; } - case 181 /* YieldExpression */: - case 179 /* ConditionalExpression */: + case 182 /* YieldExpression */: + case 180 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -28928,10 +29531,10 @@ var ts; /// Emit a tag name, which is either '"div"' for lower-cased names, or /// 'Div' for upper-cased or dotted names function emitTagName(name) { - if (name.kind === 66 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { - write('"'); + if (name.kind === 67 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -28942,9 +29545,9 @@ var ts; /// about keywords, just non-identifier characters function emitAttributeName(name) { if (/[A-Za-z_]+[\w*]/.test(name.text)) { - write('"'); + write("\""); emit(name); - write('"'); + write("\""); } else { emit(name); @@ -28962,9 +29565,13 @@ var ts; } } function emitJsxElement(openingNode, children) { + var syntheticReactRef = ts.createSynthesizedNode(67 /* Identifier */); + syntheticReactRef.text = 'React'; + syntheticReactRef.parent = openingNode; // Call React.createElement(tag, ... emitLeadingComments(openingNode); - write("React.createElement("); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); emitTagName(openingNode.tagName); write(", "); // Attribute list @@ -28976,37 +29583,38 @@ var ts; // Either emit one big object literal (no spread attribs), or // a call to React.__spread var attrs = openingNode.attributes; - if (ts.forEach(attrs, function (attr) { return attr.kind === 236 /* JsxSpreadAttribute */; })) { - write("React.__spread("); + if (ts.forEach(attrs, function (attr) { return attr.kind === 237 /* JsxSpreadAttribute */; })) { + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); var haveOpenedObjectLiteral = false; - for (var i_2 = 0; i_2 < attrs.length; i_2++) { - if (attrs[i_2].kind === 236 /* JsxSpreadAttribute */) { + for (var i_1 = 0; i_1 < attrs.length; i_1++) { + if (attrs[i_1].kind === 237 /* JsxSpreadAttribute */) { // If this is the first argument, we need to emit a {} as the first argument - if (i_2 === 0) { + if (i_1 === 0) { write("{}, "); } if (haveOpenedObjectLiteral) { write("}"); haveOpenedObjectLiteral = false; } - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } - emit(attrs[i_2].expression); + emit(attrs[i_1].expression); } else { - ts.Debug.assert(attrs[i_2].kind === 235 /* JsxAttribute */); + ts.Debug.assert(attrs[i_1].kind === 236 /* JsxAttribute */); if (haveOpenedObjectLiteral) { write(", "); } else { haveOpenedObjectLiteral = true; - if (i_2 > 0) { + if (i_1 > 0) { write(", "); } write("{"); } - emitJsxAttribute(attrs[i_2]); + emitJsxAttribute(attrs[i_1]); } } if (haveOpenedObjectLiteral) @@ -29029,16 +29637,16 @@ var ts; if (children) { for (var i = 0; i < children.length; i++) { // Don't emit empty expressions - if (children[i].kind === 237 /* JsxExpression */ && !(children[i].expression)) { + if (children[i].kind === 238 /* JsxExpression */ && !(children[i].expression)) { continue; } // Don't emit empty strings - if (children[i].kind === 233 /* JsxText */) { + if (children[i].kind === 234 /* JsxText */) { var text = getTextToEmit(children[i]); if (text !== undefined) { - write(', "'); + write(", \""); write(text); - write('"'); + write("\""); } } else { @@ -29051,19 +29659,21 @@ var ts; write(")"); // closes "React.createElement(" emitTrailingComments(openingNode); } - if (node.kind === 230 /* JsxElement */) { + if (node.kind === 231 /* JsxElement */) { emitJsxElement(node.openingElement, node.children); } else { - ts.Debug.assert(node.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); emitJsxElement(node); } } function jsxEmitPreserve(node) { function emitJsxAttribute(node) { emit(node.name); - write("="); - emit(node.initializer); + if (node.initializer) { + write("="); + emit(node.initializer); + } } function emitJsxSpreadAttribute(node) { write("{..."); @@ -29075,11 +29685,11 @@ var ts; if (i > 0) { write(" "); } - if (attribs[i].kind === 236 /* JsxSpreadAttribute */) { + if (attribs[i].kind === 237 /* JsxSpreadAttribute */) { emitJsxSpreadAttribute(attribs[i]); } else { - ts.Debug.assert(attribs[i].kind === 235 /* JsxAttribute */); + ts.Debug.assert(attribs[i].kind === 236 /* JsxAttribute */); emitJsxAttribute(attribs[i]); } } @@ -29087,11 +29697,11 @@ var ts; function emitJsxOpeningOrSelfClosingElement(node) { write("<"); emit(node.tagName); - if (node.attributes.length > 0 || (node.kind === 231 /* JsxSelfClosingElement */)) { + if (node.attributes.length > 0 || (node.kind === 232 /* JsxSelfClosingElement */)) { write(" "); } emitAttributes(node.attributes); - if (node.kind === 231 /* JsxSelfClosingElement */) { + if (node.kind === 232 /* JsxSelfClosingElement */) { write("/>"); } else { @@ -29110,11 +29720,11 @@ var ts; } emitJsxClosingElement(node.closingElement); } - if (node.kind === 230 /* JsxElement */) { + if (node.kind === 231 /* JsxElement */) { emitJsxElement(node); } else { - ts.Debug.assert(node.kind === 231 /* JsxSelfClosingElement */); + ts.Debug.assert(node.kind === 232 /* JsxSelfClosingElement */); emitJsxOpeningOrSelfClosingElement(node); } } @@ -29122,11 +29732,11 @@ var ts; // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 160 /* BindingElement */); - if (node.kind === 8 /* StringLiteral */) { + ts.Debug.assert(node.kind !== 161 /* BindingElement */); + if (node.kind === 9 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 133 /* ComputedPropertyName */) { + else if (node.kind === 134 /* ComputedPropertyName */) { // if this is a decorated computed property, we will need to capture the result // of the property expression so that we can apply decorators later. This is to ensure // we don't introduce unintended side effects: @@ -29158,7 +29768,7 @@ var ts; } else { write("\""); - if (node.kind === 7 /* NumericLiteral */) { + if (node.kind === 8 /* NumericLiteral */) { write(node.text); } else { @@ -29170,58 +29780,60 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 161 /* ArrayLiteralExpression */: - case 178 /* BinaryExpression */: - case 165 /* CallExpression */: - case 238 /* CaseClause */: - case 133 /* ComputedPropertyName */: - case 179 /* ConditionalExpression */: - case 136 /* Decorator */: - case 172 /* DeleteExpression */: - case 194 /* DoStatement */: - case 164 /* ElementAccessExpression */: - case 224 /* ExportAssignment */: - case 192 /* ExpressionStatement */: - case 185 /* ExpressionWithTypeArguments */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 193 /* IfStatement */: - case 231 /* JsxSelfClosingElement */: - case 232 /* JsxOpeningElement */: - case 166 /* NewExpression */: - case 169 /* ParenthesizedExpression */: - case 177 /* PostfixUnaryExpression */: - case 176 /* PrefixUnaryExpression */: - case 201 /* ReturnStatement */: - case 243 /* ShorthandPropertyAssignment */: - case 182 /* SpreadElementExpression */: - case 203 /* SwitchStatement */: - case 167 /* TaggedTemplateExpression */: - case 187 /* TemplateSpan */: - case 205 /* ThrowStatement */: - case 168 /* TypeAssertionExpression */: - case 173 /* TypeOfExpression */: - case 174 /* VoidExpression */: - case 195 /* WhileStatement */: - case 202 /* WithStatement */: - case 181 /* YieldExpression */: + case 162 /* ArrayLiteralExpression */: + case 179 /* BinaryExpression */: + case 166 /* CallExpression */: + case 239 /* CaseClause */: + case 134 /* ComputedPropertyName */: + case 180 /* ConditionalExpression */: + case 137 /* Decorator */: + case 173 /* DeleteExpression */: + case 195 /* DoStatement */: + case 165 /* ElementAccessExpression */: + case 225 /* ExportAssignment */: + case 193 /* ExpressionStatement */: + case 186 /* ExpressionWithTypeArguments */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 194 /* IfStatement */: + case 232 /* JsxSelfClosingElement */: + case 233 /* JsxOpeningElement */: + case 237 /* JsxSpreadAttribute */: + case 238 /* JsxExpression */: + case 167 /* NewExpression */: + case 170 /* ParenthesizedExpression */: + case 178 /* PostfixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: + case 202 /* ReturnStatement */: + case 244 /* ShorthandPropertyAssignment */: + case 183 /* SpreadElementExpression */: + case 204 /* SwitchStatement */: + case 168 /* TaggedTemplateExpression */: + case 188 /* TemplateSpan */: + case 206 /* ThrowStatement */: + case 169 /* TypeAssertionExpression */: + case 174 /* TypeOfExpression */: + case 175 /* VoidExpression */: + case 196 /* WhileStatement */: + case 203 /* WithStatement */: + case 182 /* YieldExpression */: return true; - case 160 /* BindingElement */: - case 244 /* EnumMember */: - case 135 /* Parameter */: - case 242 /* PropertyAssignment */: - case 138 /* PropertyDeclaration */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 245 /* EnumMember */: + case 136 /* Parameter */: + case 243 /* PropertyAssignment */: + case 139 /* PropertyDeclaration */: + case 209 /* VariableDeclaration */: return parent.initializer === node; - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return parent.expression === node; - case 171 /* ArrowFunction */: - case 170 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 171 /* FunctionExpression */: return parent.body === node; - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return parent.moduleReference === node; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return parent.left === node; } return false; @@ -29233,7 +29845,7 @@ var ts; } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 245 /* SourceFile */) { + if (container.kind === 246 /* SourceFile */) { // Identifier references module export if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { write("exports."); @@ -29248,17 +29860,24 @@ var ts; else if (languageVersion < 2 /* ES6 */) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 220 /* ImportClause */) { + if (declaration.kind === 221 /* ImportClause */) { // Identifier references default import write(getGeneratedNameForNode(declaration.parent)); - write(languageVersion === 0 /* ES3 */ ? '["default"]' : ".default"); + write(languageVersion === 0 /* ES3 */ ? "[\"default\"]" : ".default"); return; } - else if (declaration.kind === 223 /* ImportSpecifier */) { + else if (declaration.kind === 224 /* ImportSpecifier */) { // Identifier references named import write(getGeneratedNameForNode(declaration.parent.parent.parent)); - write("."); - writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); + var name = declaration.propertyName || declaration.name; + var identifier = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, name); + if (languageVersion === 0 /* ES3 */ && identifier === "default") { + write("[\"default\"]"); + } + else { + write("."); + write(identifier); + } return; } } @@ -29268,17 +29887,22 @@ var ts; return; } } - writeTextOfNode(currentSourceFile, node); + if (ts.nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } } function isNameOfNestedRedeclaration(node) { if (languageVersion < 2 /* ES6 */) { - var parent_7 = node.parent; - switch (parent_7.kind) { - case 160 /* BindingElement */: - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 208 /* VariableDeclaration */: - return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); + var parent_6 = node.parent; + switch (parent_6.kind) { + case 161 /* BindingElement */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 209 /* VariableDeclaration */: + return parent_6.name === node && resolver.isNestedRedeclaration(parent_6); } } return false; @@ -29293,6 +29917,9 @@ var ts; else if (isNameOfNestedRedeclaration(node)) { write(getGeneratedNameForNode(node)); } + else if (ts.nodeIsSynthesized(node)) { + write(node.text); + } else { writeTextOfNode(currentSourceFile, node); } @@ -29322,13 +29949,13 @@ var ts; function emitObjectBindingPattern(node) { write("{ "); var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); write(" }"); } function emitArrayBindingPattern(node) { write("["); var elements = node.elements; - emitList(elements, 0, elements.length, false, elements.hasTrailingComma); + emitList(elements, 0, elements.length, /*multiLine*/ false, /*trailingComma*/ elements.hasTrailingComma); write("]"); } function emitBindingElement(node) { @@ -29352,7 +29979,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(111 /* YieldKeyword */)); + write(ts.tokenToString(112 /* YieldKeyword */)); if (node.asteriskToken) { write("*"); } @@ -29366,7 +29993,7 @@ var ts; if (needsParenthesis) { write("("); } - write(ts.tokenToString(111 /* YieldKeyword */)); + write(ts.tokenToString(112 /* YieldKeyword */)); write(" "); emit(node.expression); if (needsParenthesis) { @@ -29374,22 +30001,22 @@ var ts; } } function needsParenthesisForAwaitExpressionAsYield(node) { - if (node.parent.kind === 178 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + if (node.parent.kind === 179 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { return true; } - else if (node.parent.kind === 179 /* ConditionalExpression */ && node.parent.condition === node) { + else if (node.parent.kind === 180 /* ConditionalExpression */ && node.parent.condition === node) { return true; } return false; } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 66 /* Identifier */: - case 161 /* ArrayLiteralExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: - case 165 /* CallExpression */: - case 169 /* ParenthesizedExpression */: + case 67 /* Identifier */: + case 162 /* ArrayLiteralExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 170 /* ParenthesizedExpression */: // This list is not exhaustive and only includes those cases that are relevant // to the check in emitArrayLiteral. More cases can be added as needed. return false; @@ -29409,17 +30036,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 182 /* SpreadElementExpression */) { + if (e.kind === 183 /* SpreadElementExpression */) { e = e.expression; - emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); + emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 161 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 162 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 182 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 183 /* SpreadElementExpression */) { i++; } write("["); @@ -29442,7 +30069,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 182 /* SpreadElementExpression */; + return node.kind === 183 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -29451,12 +30078,12 @@ var ts; } else if (languageVersion >= 2 /* ES6 */ || !ts.forEach(elements, isSpreadElementExpression)) { write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, false); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, /*spacesBetweenBraces:*/ false); write("]"); } else { - emitListWithSpread(elements, true, (node.flags & 2048 /* MultiLine */) !== 0, - /*trailingComma*/ elements.hasTrailingComma, true); + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, + /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); } } function emitObjectLiteralBody(node, numElements) { @@ -29471,7 +30098,7 @@ var ts; // then try to preserve the original shape of the object literal. // Otherwise just try to preserve the formatting. if (numElements === properties.length) { - emitLinePreservingList(node, properties, languageVersion >= 1 /* ES5 */, true); + emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); } else { var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; @@ -29481,7 +30108,7 @@ var ts; else { increaseIndent(); } - emitList(properties, 0, numElements, multiLine, false); + emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false); if (!multiLine) { write(" "); } @@ -29512,7 +30139,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 142 /* GetAccessor */ || property.kind === 143 /* SetAccessor */) { + if (property.kind === 143 /* GetAccessor */ || property.kind === 144 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -29564,13 +30191,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 242 /* PropertyAssignment */) { + if (property.kind === 243 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 243 /* ShorthandPropertyAssignment */) { + else if (property.kind === 244 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 140 /* MethodDeclaration */) { + else if (property.kind === 141 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -29604,7 +30231,7 @@ var ts; // Everything until that point can be emitted as part of the initial object literal. var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 133 /* ComputedPropertyName */) { + if (properties[i].name.kind === 134 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -29620,21 +30247,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(178 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(179 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(163 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(164 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); - result.dotToken = ts.createSynthesizedNode(20 /* DotToken */); + result.dotToken = ts.createSynthesizedNode(21 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(164 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(165 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -29642,7 +30269,7 @@ var ts; function parenthesizeForAccess(expr) { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 168 /* TypeAssertionExpression */ || expr.kind === 186 /* AsExpression */) { + while (expr.kind === 169 /* TypeAssertionExpression */ || expr.kind === 187 /* AsExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -29654,11 +30281,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 166 /* NewExpression */ && - expr.kind !== 7 /* NumericLiteral */) { + expr.kind !== 167 /* NewExpression */ && + expr.kind !== 8 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(169 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(170 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -29680,12 +30307,20 @@ var ts; function emitPropertyAssignment(node) { emit(node.name); write(": "); + // This is to ensure that we emit comment in the following case: + // For example: + // obj = { + // id: /*comment1*/ ()=>void + // } + // "comment1" is not considered to be leading comment for node.initializer + // but rather a trailing comment on the previous node. + emitTrailingCommentsOfPosition(node.initializer.pos); emit(node.initializer); } // Return true if identifier resolves to an exported member of a namespace function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 245 /* SourceFile */; + return container && container.kind !== 246 /* SourceFile */; } function emitShorthandPropertyAssignment(node) { // The name property of a short-hand property assignment is considered an expression position, so here @@ -29707,21 +30342,25 @@ var ts; } } function tryEmitConstantValue(node) { - if (compilerOptions.isolatedModules) { - // do not inline enum values in separate compilation mode - return false; - } - var constantValue = resolver.getConstantValue(node); + var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 163 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 164 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; } return false; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return node.kind === 164 /* PropertyAccessExpression */ || node.kind === 165 /* ElementAccessExpression */ + ? resolver.getConstantValue(node) + : undefined; + } // Returns 'true' if the code was actually indented, false otherwise. // If the code is not indented, an optional valueToWriteWhenNotIndenting will be // emitted instead. @@ -29748,10 +30387,20 @@ var ts; emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); // 1 .toString is a valid property access, emit a space after the literal + // Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal var shouldEmitSpace; - if (!indentedBeforeDot && node.expression.kind === 7 /* NumericLiteral */) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); - shouldEmitSpace = text.indexOf(ts.tokenToString(20 /* DotToken */)) < 0; + if (!indentedBeforeDot) { + if (node.expression.kind === 8 /* NumericLiteral */) { + // check if numeric literal was originally written with a dot + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; + } + else { + // check if constant enum value is integer + var constantValue = tryGetConstEnumValue(node.expression); + // isFinite handles cases when constantValue is undefined + shouldEmitSpace = isFinite(constantValue) && Math.floor(constantValue) === constantValue; + } } if (shouldEmitSpace) { write(" ."); @@ -29769,7 +30418,7 @@ var ts; emit(node.right); } function emitQualifiedNameAsExpression(node, useFallback) { - if (node.left.kind === 66 /* Identifier */) { + if (node.left.kind === 67 /* Identifier */) { emitEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -29777,19 +30426,19 @@ var ts; write("("); emitNodeWithoutSourceMap(temp); write(" = "); - emitEntityNameAsExpression(node.left, true); + emitEntityNameAsExpression(node.left, /*useFallback*/ true); write(") && "); emitNodeWithoutSourceMap(temp); } else { - emitEntityNameAsExpression(node.left, false); + emitEntityNameAsExpression(node.left, /*useFallback*/ false); } write("."); - emitNodeWithoutSourceMap(node.right); + emit(node.right); } function emitEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: if (useFallback) { write("typeof "); emitExpressionIdentifier(node); @@ -29797,7 +30446,7 @@ var ts; } emitExpressionIdentifier(node); break; - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: emitQualifiedNameAsExpression(node, useFallback); break; } @@ -29812,16 +30461,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 182 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 183 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 169 /* ParenthesizedExpression */ || node.kind === 168 /* TypeAssertionExpression */ || node.kind === 186 /* AsExpression */) { + while (node.kind === 170 /* ParenthesizedExpression */ || node.kind === 169 /* TypeAssertionExpression */ || node.kind === 187 /* AsExpression */) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 66 /* Identifier */ || node.kind === 94 /* ThisKeyword */ || node.kind === 92 /* SuperKeyword */) { + if (node.kind === 67 /* Identifier */ || node.kind === 95 /* ThisKeyword */ || node.kind === 93 /* SuperKeyword */) { emit(node); return node; } @@ -29836,20 +30485,20 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 163 /* PropertyAccessExpression */) { + if (expr.kind === 164 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 164 /* ElementAccessExpression */) { + else if (expr.kind === 165 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 92 /* SuperKeyword */) { + else if (expr.kind === 93 /* SuperKeyword */) { target = expr; write("_super"); } @@ -29858,7 +30507,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 92 /* SuperKeyword */) { + if (target.kind === 93 /* SuperKeyword */) { // Calls of form super(...) and super.foo(...) emitThis(target); } @@ -29872,7 +30521,7 @@ var ts; write("void 0"); } write(", "); - emitListWithSpread(node.arguments, false, false, false, true); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); write(")"); } function emitCallExpression(node) { @@ -29881,13 +30530,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 92 /* SuperKeyword */) { + if (node.expression.kind === 93 /* SuperKeyword */) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 163 /* PropertyAccessExpression */ && node.expression.expression.kind === 92 /* SuperKeyword */; + superCall = node.expression.kind === 164 /* PropertyAccessExpression */ && node.expression.expression.kind === 93 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -29929,7 +30578,7 @@ var ts; write(".bind.apply("); emit(target); write(", [void 0].concat("); - emitListWithSpread(node.arguments, false, false, false, false); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false); write(")))"); write("()"); } @@ -29956,12 +30605,12 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 171 /* ArrowFunction */) { - if (node.expression.kind === 168 /* TypeAssertionExpression */ || node.expression.kind === 186 /* AsExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 172 /* ArrowFunction */) { + if (node.expression.kind === 169 /* TypeAssertionExpression */ || node.expression.kind === 187 /* AsExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind === 168 /* TypeAssertionExpression */ || operand.kind === 186 /* AsExpression */) { + while (operand.kind === 169 /* TypeAssertionExpression */ || operand.kind === 187 /* AsExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -29972,14 +30621,15 @@ var ts; // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 176 /* PrefixUnaryExpression */ && - operand.kind !== 174 /* VoidExpression */ && - operand.kind !== 173 /* TypeOfExpression */ && - operand.kind !== 172 /* DeleteExpression */ && - operand.kind !== 177 /* PostfixUnaryExpression */ && - operand.kind !== 166 /* NewExpression */ && - !(operand.kind === 165 /* CallExpression */ && node.parent.kind === 166 /* NewExpression */) && - !(operand.kind === 170 /* FunctionExpression */ && node.parent.kind === 165 /* CallExpression */)) { + if (operand.kind !== 177 /* PrefixUnaryExpression */ && + operand.kind !== 175 /* VoidExpression */ && + operand.kind !== 174 /* TypeOfExpression */ && + operand.kind !== 173 /* DeleteExpression */ && + operand.kind !== 178 /* PostfixUnaryExpression */ && + operand.kind !== 167 /* NewExpression */ && + !(operand.kind === 166 /* CallExpression */ && node.parent.kind === 167 /* NewExpression */) && + !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */) && + !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 164 /* PropertyAccessExpression */)) { emit(operand); return; } @@ -29990,29 +30640,29 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(75 /* DeleteKeyword */)); + write(ts.tokenToString(76 /* DeleteKeyword */)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(100 /* VoidKeyword */)); + write(ts.tokenToString(101 /* VoidKeyword */)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(98 /* TypeOfKeyword */)); + write(ts.tokenToString(99 /* TypeOfKeyword */)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 66 /* Identifier */ || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 67 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 208 /* VariableDeclaration */ || node.parent.kind === 160 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 209 /* VariableDeclaration */ || node.parent.kind === 161 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); - return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, true); + return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); } function emitPrefixUnaryExpression(node) { var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); @@ -30038,12 +30688,12 @@ var ts; // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operand.kind === 176 /* PrefixUnaryExpression */) { + if (node.operand.kind === 177 /* PrefixUnaryExpression */) { var operand = node.operand; - if (node.operator === 34 /* PlusToken */ && (operand.operator === 34 /* PlusToken */ || operand.operator === 39 /* PlusPlusToken */)) { + if (node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 40 /* PlusPlusToken */)) { write(" "); } - else if (node.operator === 35 /* MinusToken */ && (operand.operator === 35 /* MinusToken */ || operand.operator === 40 /* MinusMinusToken */)) { + else if (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 41 /* MinusMinusToken */)) { write(" "); } } @@ -30063,7 +30713,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 39 /* PlusPlusToken */) { + if (node.operator === 40 /* PlusPlusToken */) { write(") - 1)"); } else { @@ -30076,7 +30726,7 @@ var ts; } } function shouldHoistDeclarationInSystemJsModule(node) { - return isSourceFileLevelDeclarationInSystemJsModule(node, false); + return isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ false); } /* * Checks if given node is a source file level declaration (not nested in module/function). @@ -30094,10 +30744,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 245 /* SourceFile */) { + if (current.kind === 246 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 216 /* ModuleBlock */) { + else if (ts.isFunctionLike(current) || current.kind === 217 /* ModuleBlock */) { return false; } else { @@ -30106,13 +30756,13 @@ var ts; } } function emitBinaryExpression(node) { - if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 54 /* EqualsToken */ && - (node.left.kind === 162 /* ObjectLiteralExpression */ || node.left.kind === 161 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 192 /* ExpressionStatement */); + if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 55 /* EqualsToken */ && + (node.left.kind === 163 /* ObjectLiteralExpression */ || node.left.kind === 162 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 193 /* ExpressionStatement */); } else { - var exportChanged = node.operatorToken.kind >= 54 /* FirstAssignment */ && - node.operatorToken.kind <= 65 /* LastAssignment */ && + var exportChanged = node.operatorToken.kind >= 55 /* FirstAssignment */ && + node.operatorToken.kind <= 66 /* LastAssignment */ && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { // emit assignment 'x y' as 'exports("x", x y)' @@ -30121,7 +30771,7 @@ var ts; write("\", "); } emit(node.left); - var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 23 /* CommaToken */ ? " " : undefined); + var indentedBeforeOperator = indentIfOnDifferentLines(node, node.left, node.operatorToken, node.operatorToken.kind !== 24 /* CommaToken */ ? " " : undefined); write(ts.tokenToString(node.operatorToken.kind)); var indentedAfterOperator = indentIfOnDifferentLines(node, node.operatorToken, node.right, " "); emit(node.right); @@ -30160,36 +30810,36 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 189 /* Block */) { + if (node && node.kind === 190 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } } function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - emitToken(14 /* OpenBraceToken */, node.pos); + emitToken(15 /* OpenBraceToken */, node.pos); write(" "); - emitToken(15 /* CloseBraceToken */, node.statements.end); + emitToken(16 /* CloseBraceToken */, node.statements.end); return; } - emitToken(14 /* OpenBraceToken */, node.pos); + emitToken(15 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 216 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 215 /* ModuleDeclaration */); + if (node.kind === 217 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 216 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 216 /* ModuleBlock */) { - emitTempDeclarations(true); + if (node.kind === 217 /* ModuleBlock */) { + emitTempDeclarations(/*newLine*/ true); } decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.statements.end); + emitToken(16 /* CloseBraceToken */, node.statements.end); scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 189 /* Block */) { + if (node.kind === 190 /* Block */) { write(" "); emit(node); } @@ -30201,20 +30851,20 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 171 /* ArrowFunction */); + emitParenthesizedIf(node.expression, /*parenthesized*/ node.expression.kind === 172 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(85 /* IfKeyword */, node.pos); + var endPos = emitToken(86 /* IfKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); + endPos = emitToken(17 /* OpenParenToken */, endPos); emit(node.expression); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(77 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 193 /* IfStatement */) { + emitToken(78 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 194 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -30226,7 +30876,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 189 /* Block */) { + if (node.statement.kind === 190 /* Block */) { write(" "); } else { @@ -30248,17 +30898,17 @@ var ts; * in system modules where such variable declarations are hoisted. */ function tryEmitStartOfVariableDeclarationList(decl, startPos) { - if (shouldHoistVariable(decl, true)) { + if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) { // variables in variable declaration list were already hoisted return false; } - var tokenKind = 99 /* VarKeyword */; + var tokenKind = 100 /* VarKeyword */; if (decl && languageVersion >= 2 /* ES6 */) { if (ts.isLet(decl)) { - tokenKind = 105 /* LetKeyword */; + tokenKind = 106 /* LetKeyword */; } else if (ts.isConst(decl)) { - tokenKind = 71 /* ConstKeyword */; + tokenKind = 72 /* ConstKeyword */; } } if (startPos !== undefined) { @@ -30267,13 +30917,13 @@ var ts; } else { switch (tokenKind) { - case 99 /* VarKeyword */: + case 100 /* VarKeyword */: write("var "); break; - case 105 /* LetKeyword */: + case 106 /* LetKeyword */: write("let "); break; - case 71 /* ConstKeyword */: + case 72 /* ConstKeyword */: write("const "); break; } @@ -30298,10 +30948,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 209 /* VariableDeclarationList */) { + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer && node.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -30322,13 +30972,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 198 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 199 /* ForOfStatement */) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + endPos = emitToken(17 /* OpenParenToken */, endPos); + if (node.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -30338,14 +30988,14 @@ var ts; else { emit(node.initializer); } - if (node.kind === 197 /* ForInStatement */) { + if (node.kind === 198 /* ForInStatement */) { write(" in "); } else { write(" of "); } emit(node.expression); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitDownLevelForOfStatement(node) { @@ -30369,9 +31019,9 @@ var ts; // all destructuring. // Note also that because an extra statement is needed to assign to the LHS, // for-of bodies are always emitted as blocks. - var endPos = emitToken(83 /* ForKeyword */, node.pos); + var endPos = emitToken(84 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(16 /* OpenParenToken */, endPos); + endPos = emitToken(17 /* OpenParenToken */, endPos); // Do not emit the LHS let declaration yet, because it might contain destructuring. // Do not call recordTempDeclaration because we are declaring the temps // right here. Recording means they will be declared later. @@ -30380,7 +31030,7 @@ var ts; // for (let v of arr) { } // // we don't want to emit a temporary variable for the RHS, just use it directly. - var rhsIsIdentifier = node.expression.kind === 66 /* Identifier */; + var rhsIsIdentifier = node.expression.kind === 67 /* Identifier */; var counter = createTempVariable(268435456 /* _i */); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); // This is the let keyword for the counter and rhsReference. The let keyword for @@ -30405,7 +31055,7 @@ var ts; emitStart(node.initializer); emitNodeWithoutSourceMap(counter); write(" < "); - emitNodeWithoutSourceMap(rhsReference); + emitNodeWithCommentsAndWithoutSourcemap(rhsReference); write(".length"); emitEnd(node.initializer); write("; "); @@ -30414,7 +31064,7 @@ var ts; emitNodeWithoutSourceMap(counter); write("++"); emitEnd(node.initializer); - emitToken(17 /* CloseParenToken */, node.expression.end); + emitToken(18 /* CloseParenToken */, node.expression.end); // Body write(" {"); writeLine(); @@ -30423,7 +31073,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 209 /* VariableDeclarationList */) { + if (node.initializer.kind === 210 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -30431,12 +31081,12 @@ var ts; if (ts.isBindingPattern(declaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. - emitDestructuring(declaration, false, rhsIterationValue); + emitDestructuring(declaration, /*isAssignmentExpressionStatement*/ false, rhsIterationValue); } else { // The following call does not include the initializer, so we have // to emit it separately. - emitNodeWithoutSourceMap(declaration); + emitNodeWithCommentsAndWithoutSourcemap(declaration); write(" = "); emitNodeWithoutSourceMap(rhsIterationValue); } @@ -30452,19 +31102,19 @@ var ts; else { // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. - var assignmentExpression = createBinaryExpression(node.initializer, 54 /* EqualsToken */, rhsIterationValue, false); - if (node.initializer.kind === 161 /* ArrayLiteralExpression */ || node.initializer.kind === 162 /* ObjectLiteralExpression */) { + var assignmentExpression = createBinaryExpression(node.initializer, 55 /* EqualsToken */, rhsIterationValue, /*startsOnNewLine*/ false); + if (node.initializer.kind === 162 /* ArrayLiteralExpression */ || node.initializer.kind === 163 /* ObjectLiteralExpression */) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. - emitDestructuring(assignmentExpression, true, undefined); + emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined); } else { - emitNodeWithoutSourceMap(assignmentExpression); + emitNodeWithCommentsAndWithoutSourcemap(assignmentExpression); } } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 189 /* Block */) { + if (node.statement.kind === 190 /* Block */) { emitLines(node.statement.statements); } else { @@ -30476,12 +31126,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 200 /* BreakStatement */ ? 67 /* BreakKeyword */ : 72 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 201 /* BreakStatement */ ? 68 /* BreakKeyword */ : 73 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(91 /* ReturnKeyword */, node.pos); + emitToken(92 /* ReturnKeyword */, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -30492,21 +31142,21 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(93 /* SwitchKeyword */, node.pos); + var endPos = emitToken(94 /* SwitchKeyword */, node.pos); write(" "); - emitToken(16 /* OpenParenToken */, endPos); + emitToken(17 /* OpenParenToken */, endPos); emit(node.expression); - endPos = emitToken(17 /* CloseParenToken */, node.expression.end); + endPos = emitToken(18 /* CloseParenToken */, node.expression.end); write(" "); emitCaseBlock(node.caseBlock, endPos); } function emitCaseBlock(node, startPos) { - emitToken(14 /* OpenBraceToken */, startPos); + emitToken(15 /* OpenBraceToken */, startPos); increaseIndent(); emitLines(node.clauses); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.clauses.end); + emitToken(16 /* CloseBraceToken */, node.clauses.end); } function nodeStartPositionsAreOnSameLine(node1, node2) { return ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === @@ -30521,7 +31171,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 238 /* CaseClause */) { + if (node.kind === 239 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -30556,16 +31206,16 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(69 /* CatchKeyword */, node.pos); + var endPos = emitToken(70 /* CatchKeyword */, node.pos); write(" "); - emitToken(16 /* OpenParenToken */, endPos); + emitToken(17 /* OpenParenToken */, endPos); emit(node.variableDeclaration); - emitToken(17 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); + emitToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : endPos); write(" "); emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(73 /* DebuggerKeyword */, node.pos); + emitToken(74 /* DebuggerKeyword */, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -30576,7 +31226,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 215 /* ModuleDeclaration */); + } while (node && node.kind !== 216 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -30595,16 +31245,35 @@ var ts; write("exports."); } } - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); emitEnd(node.name); } function createVoidZero() { - var zero = ts.createSynthesizedNode(7 /* NumericLiteral */); + var zero = ts.createSynthesizedNode(8 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(174 /* VoidExpression */); + var result = ts.createSynthesizedNode(175 /* VoidExpression */); result.expression = zero; return result; } + function emitEs6ExportDefaultCompat(node) { + if (node.parent.kind === 246 /* SourceFile */) { + ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 225 /* ExportAssignment */); + // only allow export default at a source file level + if (compilerOptions.module === 1 /* CommonJS */ || compilerOptions.module === 2 /* AMD */ || compilerOptions.module === 3 /* UMD */) { + if (!currentSourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 1 /* ES5 */) { + // default value of configurable, enumerable, writable are `false`. + write("Object.defineProperty(exports, \"__esModule\", { value: true });"); + writeLine(); + } + else if (languageVersion === 0 /* ES3 */) { + write("exports.__esModule = true;"); + writeLine(); + } + } + } + } + } function emitExportMemberAssignment(node) { if (node.flags & 1 /* Export */) { writeLine(); @@ -30618,7 +31287,7 @@ var ts; write("default"); } else { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } write("\", "); emitDeclarationName(node); @@ -30626,6 +31295,7 @@ var ts; } else { if (node.flags & 1024 /* Default */) { + emitEs6ExportDefaultCompat(node); if (languageVersion === 0 /* ES3 */) { write("exports[\"default\"]"); } @@ -30644,32 +31314,39 @@ var ts; } } function emitExportMemberAssignments(name) { + if (compilerOptions.module === 4 /* System */) { + return; + } if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { for (var _a = 0, _b = exportSpecifiers[name.text]; _a < _b.length; _a++) { var specifier = _b[_a]; writeLine(); - if (compilerOptions.module === 4 /* System */) { - emitStart(specifier.name); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(specifier.name); - write("\", "); - emitExpressionIdentifier(name); - write(")"); - emitEnd(specifier.name); - } - else { - emitStart(specifier.name); - emitContainingModuleName(specifier); - write("."); - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier.name); - write(" = "); - emitExpressionIdentifier(name); - } + emitStart(specifier.name); + emitContainingModuleName(specifier); + write("."); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + emitEnd(specifier.name); + write(" = "); + emitExpressionIdentifier(name); write(";"); } } } + function emitExportSpecifierInSystemModule(specifier) { + ts.Debug.assert(compilerOptions.module === 4 /* System */); + if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier)) { + return; + } + writeLine(); + emitStart(specifier.name); + write(exportFunctionForFile + "(\""); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); + write("\", "); + emitExpressionIdentifier(specifier.propertyName || specifier.name); + write(")"); + emitEnd(specifier.name); + write(";"); + } function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; // An exported declaration is actually emitted as an assignment (to a property on the module object), so @@ -30677,15 +31354,15 @@ var ts; // Also temporary variables should be explicitly allocated for source level declarations when module target is system // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; - if (root.kind === 208 /* VariableDeclaration */) { + if (root.kind === 209 /* VariableDeclaration */) { var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 135 /* Parameter */) { + else if (root.kind === 136 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 178 /* BinaryExpression */) { + if (root.kind === 179 /* BinaryExpression */) { emitAssignmentExpression(root); } else { @@ -30696,11 +31373,11 @@ var ts; if (emitCount++) { write(", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 208 /* VariableDeclaration */ || name.parent.kind === 160 /* BindingElement */); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 209 /* VariableDeclaration */ || name.parent.kind === 161 /* BindingElement */); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(name); + emitNodeWithCommentsAndWithoutSourcemap(name); write("\", "); } if (isVariableDeclarationOrBindingElement) { @@ -30715,39 +31392,48 @@ var ts; write(")"); } } - function ensureIdentifier(expr) { - if (expr.kind !== 66 /* Identifier */) { - var identifier = createTempVariable(0 /* Auto */); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expr); - expr = identifier; + /** + * Ensures that there exists a declared identifier whose value holds the given expression. + * This function is useful to ensure that the expression's value can be read from in subsequent expressions. + * Unless 'reuseIdentifierExpressions' is false, 'expr' will be returned if it is just an identifier. + * + * @param expr the expression whose value needs to be bound. + * @param reuseIdentifierExpressions true if identifier expressions can simply be returned; + * false if it is necessary to always emit an identifier. + */ + function ensureIdentifier(expr, reuseIdentifierExpressions) { + if (expr.kind === 67 /* Identifier */ && reuseIdentifierExpressions) { + return expr; } - return expr; + var identifier = createTempVariable(0 /* Auto */); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expr); + return identifier; } function createDefaultValueCheck(value, defaultValue) { // The value expression will be evaluated twice, so for anything but a simple identifier // we need to generate a temporary variable - value = ensureIdentifier(value); + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(178 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(179 /* BinaryExpression */); equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(31 /* EqualsEqualsEqualsToken */); + equals.operatorToken = ts.createSynthesizedNode(32 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(179 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(180 /* ConditionalExpression */); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(51 /* QuestionToken */); + cond.questionToken = ts.createSynthesizedNode(52 /* QuestionToken */); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(52 /* ColonToken */); + cond.colonToken = ts.createSynthesizedNode(53 /* ColonToken */); cond.whenFalse = whenFalse; return cond; } function createNumericLiteral(value) { - var node = ts.createSynthesizedNode(7 /* NumericLiteral */); + var node = ts.createSynthesizedNode(8 /* NumericLiteral */); node.text = "" + value; return node; } @@ -30756,14 +31442,14 @@ var ts; // otherwise occur when the identifier is emitted. var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 66 /* Identifier */) { + if (syntheticName.kind !== 67 /* Identifier */) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(165 /* CallExpression */); - var sliceIdentifier = ts.createSynthesizedNode(66 /* Identifier */); + var call = ts.createSynthesizedNode(166 /* CallExpression */); + var sliceIdentifier = ts.createSynthesizedNode(67 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -30775,11 +31461,11 @@ var ts; if (properties.length !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. - value = ensureIdentifier(value); + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 242 /* PropertyAssignment */ || p.kind === 243 /* ShorthandPropertyAssignment */) { + if (p.kind === 243 /* PropertyAssignment */ || p.kind === 244 /* ShorthandPropertyAssignment */) { var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -30790,12 +31476,12 @@ var ts; if (elements.length !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. - value = ensureIdentifier(value); + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 184 /* OmittedExpression */) { - if (e.kind !== 182 /* SpreadElementExpression */) { + if (e.kind !== 185 /* OmittedExpression */) { + if (e.kind !== 183 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -30805,14 +31491,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 178 /* BinaryExpression */ && target.operatorToken.kind === 54 /* EqualsToken */) { + if (target.kind === 179 /* BinaryExpression */ && target.operatorToken.kind === 55 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 162 /* ObjectLiteralExpression */) { + if (target.kind === 163 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 161 /* ArrayLiteralExpression */) { + else if (target.kind === 162 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value); } else { @@ -30822,18 +31508,21 @@ var ts; function emitAssignmentExpression(root) { var target = root.left; var value = root.right; - if (isAssignmentExpressionStatement) { + if (ts.isEmptyObjectLiteralOrArrayLiteral(target)) { + emit(value); + } + else if (isAssignmentExpressionStatement) { emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 169 /* ParenthesizedExpression */) { + if (root.parent.kind !== 170 /* ParenthesizedExpression */) { write("("); } - value = ensureIdentifier(value); + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 169 /* ParenthesizedExpression */) { + if (root.parent.kind !== 170 /* ParenthesizedExpression */) { write(")"); } } @@ -30850,24 +31539,27 @@ var ts; if (ts.isBindingPattern(target.name)) { var pattern = target.name; var elements = pattern.elements; - if (elements.length !== 1) { - // For anything but a single element destructuring we need to generate a temporary - // to ensure value is evaluated exactly once. - value = ensureIdentifier(value); + var numElements = elements.length; + if (numElements !== 1) { + // For anything other than a single-element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. Additionally, if we have zero elements + // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, + // so in that case, we'll intentionally create that temporary. + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0); } - for (var i = 0; i < elements.length; i++) { + for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (pattern.kind === 158 /* ObjectBindingPattern */) { + if (pattern.kind === 159 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 184 /* OmittedExpression */) { + else if (element.kind !== 185 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } - else if (i === elements.length - 1) { + else if (i === numElements - 1) { emitBindingElement(element, createSliceCall(value, i)); } } @@ -30881,7 +31573,7 @@ var ts; function emitVariableDeclaration(node) { if (ts.isBindingPattern(node.name)) { if (languageVersion < 2 /* ES6 */) { - emitDestructuring(node, false); + emitDestructuring(node, /*isAssignmentExpressionStatement*/ false); } else { emit(node.name); @@ -30901,15 +31593,15 @@ var ts; (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet && - node.parent.parent.kind !== 197 /* ForInStatement */ && - node.parent.parent.kind !== 198 /* ForOfStatement */) { + node.parent.parent.kind !== 198 /* ForInStatement */ && + node.parent.parent.kind !== 199 /* ForOfStatement */) { initializer = createVoidZero(); } } var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.name); if (exportChanged) { write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); write("\", "); } emitModuleMemberName(node); @@ -30920,11 +31612,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 184 /* OmittedExpression */) { + if (node.kind === 185 /* OmittedExpression */) { return; } var name = node.name; - if (name.kind === 66 /* Identifier */) { + if (name.kind === 67 /* Identifier */) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -30932,7 +31624,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 208 /* VariableDeclaration */ && node.parent.kind !== 160 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 209 /* VariableDeclaration */ && node.parent.kind !== 161 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -30940,7 +31632,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1 /* Export */) && languageVersion >= 2 /* ES6 */ && - node.parent.kind === 245 /* SourceFile */; + node.parent.kind === 246 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -31029,7 +31721,7 @@ var ts; writeLine(); write("var "); if (hasBindingElements) { - emitDestructuring(parameter, false, tempParameters[tempIndex]); + emitDestructuring(parameter, /*isAssignmentExpressionStatement*/ false, tempParameters[tempIndex]); } else { emit(tempParameters[tempIndex]); @@ -31049,9 +31741,9 @@ var ts; emitEnd(parameter); write(" { "); emitStart(parameter); - emitNodeWithoutSourceMap(paramName); + emitNodeWithCommentsAndWithoutSourcemap(paramName); write(" = "); - emitNodeWithoutSourceMap(initializer); + emitNodeWithCommentsAndWithoutSourcemap(initializer); emitEnd(parameter); write("; }"); } @@ -31071,7 +31763,7 @@ var ts; emitLeadingComments(restParam); emitStart(restParam); write("var "); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -31092,7 +31784,7 @@ var ts; increaseIndent(); writeLine(); emitStart(restParam); - emitNodeWithoutSourceMap(restParam.name); + emitNodeWithCommentsAndWithoutSourcemap(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -31101,39 +31793,54 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 142 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 143 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 171 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 172 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { - emitNodeWithoutSourceMap(node.name); + emitNodeWithCommentsAndWithoutSourcemap(node.name); } else { write(getGeneratedNameForNode(node)); } } function shouldEmitFunctionName(node) { - if (node.kind === 170 /* FunctionExpression */) { + if (node.kind === 171 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) return !!node.name || languageVersion < 2 /* ES6 */; } } function emitFunctionDeclaration(node) { if (ts.nodeIsMissing(node.body)) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } - if (node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { - // Methods will emit the comments as part of emitting method declaration + // TODO (yuisu) : we should not have special cases to condition emitting comments + // but have one place to fix check for these conditions. + if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */ && + node.parent && node.parent.kind !== 243 /* PropertyAssignment */ && + node.parent.kind !== 166 /* CallExpression */) { + // 1. Methods will emit the comments as part of emitting method declaration + // 2. If the function is a property of object literal, emitting leading-comments + // is done by emitNodeWithoutSourceMap which then call this function. + // In particular, we would like to avoid emit comments twice in following case: + // For example: + // var obj = { + // id: + // /*comment*/ () => void + // } + // 3. If the function is an argument in call expression, emitting of comments will be + // taken care of in emit list of arguments inside of emitCallexpression emitLeadingComments(node); } + emitStart(node); // For targeting below es6, emit functions-like declaration including arrow function using function keyword. // When targeting ES6, emit arrow function natively in ES6 by omitting function keyword and using fat arrow instead if (!shouldEmitAsArrowFunction(node)) { @@ -31153,10 +31860,11 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 210 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 /* ES6 */ && node.kind === 211 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { + emitEnd(node); + if (node.kind !== 141 /* MethodDeclaration */ && node.kind !== 140 /* MethodSignature */) { emitTrailingComments(node); } } @@ -31174,7 +31882,7 @@ var ts; if (node) { var parameters = node.parameters; var omitCount = languageVersion < 2 /* ES6 */ && ts.hasRestParameter(node) ? 1 : 0; - emitList(parameters, 0, parameters.length - omitCount, false, false); + emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false); } write(")"); decreaseIndent(); @@ -31189,7 +31897,7 @@ var ts; } function emitAsyncFunctionBodyForES6(node) { var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); - var isArrowFunction = node.kind === 171 /* ArrowFunction */; + var isArrowFunction = node.kind === 172 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; var args; // An async function is emit as an outer function that calls an inner @@ -31310,7 +32018,7 @@ var ts; write(" { }"); } else { - if (node.body.kind === 189 /* Block */) { + if (node.body.kind === 190 /* Block */) { emitBlockFunctionBody(node, node.body); } else { @@ -31365,10 +32073,10 @@ var ts; write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 168 /* TypeAssertionExpression */) { + while (current.kind === 169 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 162 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 163 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -31388,7 +32096,7 @@ var ts; emit(body); emitEnd(body); write(";"); - emitTempDeclarations(false); + emitTempDeclarations(/*newLine*/ false); write(" "); } else { @@ -31399,7 +32107,7 @@ var ts; emit(body); write(";"); emitTrailingComments(node.body); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); decreaseIndent(); writeLine(); } @@ -31416,7 +32124,7 @@ var ts; emitDetachedComments(body.statements); // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). - var startIndex = emitDirectivePrologues(body.statements, true); + var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); emitFunctionBodyPreamble(node); decreaseIndent(); var preambleEmitted = writer.getTextPos() !== initialTextPos; @@ -31426,29 +32134,29 @@ var ts; write(" "); emit(statement); } - emitTempDeclarations(false); + emitTempDeclarations(/*newLine*/ false); write(" "); emitLeadingCommentsOfPosition(body.statements.end); } else { increaseIndent(); emitLinesStartingAt(body.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); writeLine(); emitLeadingCommentsOfPosition(body.statements.end); decreaseIndent(); } - emitToken(15 /* CloseBraceToken */, body.statements.end); + emitToken(16 /* CloseBraceToken */, body.statements.end); scopeEmitEnd(); } function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 192 /* ExpressionStatement */) { + if (statement && statement.kind === 193 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 165 /* CallExpression */) { + if (expr && expr.kind === 166 /* CallExpression */) { var func = expr.expression; - if (func && func.kind === 92 /* SuperKeyword */) { + if (func && func.kind === 93 /* SuperKeyword */) { return statement; } } @@ -31472,25 +32180,27 @@ var ts; }); } function emitMemberAccessForPropertyName(memberName) { - // TODO: (jfreeman,drosen): comment on why this is emitNodeWithoutSourceMap instead of emit here. - if (memberName.kind === 8 /* StringLiteral */ || memberName.kind === 7 /* NumericLiteral */) { + // This does not emit source map because it is emitted by caller as caller + // is aware how the property name changes to the property access + // eg. public x = 10; becomes this.x and static x = 10 becomes className.x + if (memberName.kind === 9 /* StringLiteral */ || memberName.kind === 8 /* NumericLiteral */) { write("["); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); write("]"); } - else if (memberName.kind === 133 /* ComputedPropertyName */) { + else if (memberName.kind === 134 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { write("."); - emitNodeWithoutSourceMap(memberName); + emitNodeWithCommentsAndWithoutSourcemap(memberName); } } function getInitializedProperties(node, isStatic) { var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 138 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 139 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -31530,13 +32240,13 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 188 /* SemicolonClassElement */) { + if (member.kind === 189 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */) { + else if (member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) { if (!member.body) { - return emitOnlyPinnedOrTripleSlashComments(member); + return emitCommentsOnNotEmittedNode(member); } writeLine(); emitLeadingComments(member); @@ -31546,14 +32256,12 @@ var ts; emitMemberAccessForPropertyName(member.name); emitEnd(member.name); write(" = "); - emitStart(member); emitFunctionDeclaration(member); emitEnd(member); - emitEnd(member); write(";"); emitTrailingComments(member); } - else if (member.kind === 142 /* GetAccessor */ || member.kind === 143 /* SetAccessor */) { + else if (member.kind === 143 /* GetAccessor */ || member.kind === 144 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -31603,22 +32311,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */) && !member.body) { - emitOnlyPinnedOrTripleSlashComments(member); + if ((member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) && !member.body) { + emitCommentsOnNotEmittedNode(member); } - else if (member.kind === 140 /* MethodDeclaration */ || - member.kind === 142 /* GetAccessor */ || - member.kind === 143 /* SetAccessor */) { + else if (member.kind === 141 /* MethodDeclaration */ || + member.kind === 143 /* GetAccessor */ || + member.kind === 144 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128 /* Static */) { write("static "); } - if (member.kind === 142 /* GetAccessor */) { + if (member.kind === 143 /* GetAccessor */) { write("get "); } - else if (member.kind === 143 /* SetAccessor */) { + else if (member.kind === 144 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -31629,7 +32337,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 188 /* SemicolonClassElement */) { + else if (member.kind === 189 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -31654,11 +32362,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 141 /* Constructor */ && !member.body) { - emitOnlyPinnedOrTripleSlashComments(member); + if (member.kind === 142 /* Constructor */ && !member.body) { + emitCommentsOnNotEmittedNode(member); } // Check if there is any non-static property assignment - if (member.kind === 138 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 139 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -31697,18 +32405,23 @@ var ts; } } } + var startIndex = 0; write(" {"); scopeEmitStart(node, "constructor"); increaseIndent(); if (ctor) { + // Emit all the directive prologues (like "use strict"). These have to come before + // any other preamble code we write (like parameter initializers). + startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); + var superCall; if (ctor) { emitDefaultValueAssignments(ctor); emitRestParameter(ctor); if (baseTypeElement) { - var superCall = findInitialSuperCall(ctor); + superCall = findInitialSuperCall(ctor); if (superCall) { writeLine(); emit(superCall); @@ -31729,21 +32442,21 @@ var ts; emitEnd(baseTypeElement); } } - emitPropertyDeclarations(node, getInitializedProperties(node, false)); + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ false)); if (ctor) { var statements = ctor.body.statements; if (superCall) { statements = statements.slice(1); } - emitLines(statements); + emitLinesStartingAt(statements, startIndex); } - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); writeLine(); if (ctor) { emitLeadingCommentsOfPosition(ctor.body.statements.end); } decreaseIndent(); - emitToken(15 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); + emitToken(16 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); if (ctor) { @@ -31766,7 +32479,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { if (thisNodeIsDecorated) { // To preserve the correct runtime semantics when decorators are applied to the class, // the emit needs to follow one of the following rules: @@ -31845,8 +32558,8 @@ var ts; // // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. - var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 183 /* ClassExpression */; + var staticProperties = getInitializedProperties(node, /*static:*/ true); + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 184 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -31874,7 +32587,7 @@ var ts; emitMemberFunctionsForES6AndHigher(node); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. // For a decorated class, we need to assign its name (if it has one). This is because we emit @@ -31897,7 +32610,7 @@ var ts; var property = staticProperties[_a]; write(","); writeLine(); - emitPropertyDeclaration(node, property, tempVariable, true); + emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); } write(","); writeLine(); @@ -31930,7 +32643,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -31965,23 +32678,23 @@ var ts; writeLine(); emitConstructor(node, baseTypeNode); emitMemberFunctionsForES5AndLower(node); - emitPropertyDeclarations(node, getInitializedProperties(node, true)); + emitPropertyDeclarations(node, getInitializedProperties(node, /*static:*/ true)); writeLine(); emitDecoratorsOfClass(node); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end, function () { + emitToken(16 /* CloseBraceToken */, node.members.end, function () { write("return "); emitDeclarationName(node); }); write(";"); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); tempFlags = saveTempFlags; tempVariables = saveTempVariables; tempParameters = saveTempParameters; computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames; decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); @@ -31989,11 +32702,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { emitExportMemberAssignment(node); } if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { @@ -32007,7 +32720,7 @@ var ts; } } function emitDecoratorsOfClass(node) { - emitDecoratorsOfMembers(node, 0); + emitDecoratorsOfMembers(node, /*staticFlag*/ 0); emitDecoratorsOfMembers(node, 128 /* Static */); emitDecoratorsOfConstructor(node); } @@ -32036,13 +32749,13 @@ var ts; increaseIndent(); writeLine(); var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); emit(decorator.expression); emitEnd(decorator); }); - argumentsWritten += emitDecoratorsOfParameters(constructor, argumentsWritten > 0); - emitSerializedTypeMetadata(node, argumentsWritten >= 0); + argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); + emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); decreaseIndent(); writeLine(); write("], "); @@ -32085,7 +32798,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 140 /* MethodDeclaration */) { + if (member.kind === 141 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -32123,7 +32836,7 @@ var ts; // writeLine(); emitStart(member); - if (member.kind !== 138 /* PropertyDeclaration */) { + if (member.kind !== 139 /* PropertyDeclaration */) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -32138,7 +32851,7 @@ var ts; increaseIndent(); writeLine(); var decoratorCount = decorators ? decorators.length : 0; - var argumentsWritten = emitList(decorators, 0, decoratorCount, true, false, false, true, function (decorator) { + var argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); emit(decorator.expression); emitEnd(decorator); @@ -32153,7 +32866,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 138 /* PropertyDeclaration */) { + if (member.kind !== 139 /* PropertyDeclaration */) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -32176,7 +32889,7 @@ var ts; var parameter = _b[_a]; if (ts.nodeIsDecorated(parameter)) { var decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, true, false, leadingComma, true, function (decorator) { + argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, function (decorator) { emitStart(decorator); write("__param(" + parameterIndex + ", "); emit(decorator.expression); @@ -32195,10 +32908,10 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 140 /* MethodDeclaration */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 138 /* PropertyDeclaration */: + case 141 /* MethodDeclaration */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 139 /* PropertyDeclaration */: return true; } return false; @@ -32208,7 +32921,7 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 140 /* MethodDeclaration */: + case 141 /* MethodDeclaration */: return true; } return false; @@ -32218,9 +32931,9 @@ var ts; // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 211 /* ClassDeclaration */: - case 140 /* MethodDeclaration */: - case 143 /* SetAccessor */: + case 212 /* ClassDeclaration */: + case 141 /* MethodDeclaration */: + case 144 /* SetAccessor */: return true; } return false; @@ -32235,22 +32948,22 @@ var ts; // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. // * The serialized type of any other FunctionLikeDeclaration is "Function". // * The serialized type of any other node is "void 0". - // + // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: write("Function"); return; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: emitSerializedTypeNode(node.type); return; - case 135 /* Parameter */: + case 136 /* Parameter */: emitSerializedTypeNode(node.type); return; - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: emitSerializedTypeNode(node.type); return; - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); return; } @@ -32261,67 +32974,75 @@ var ts; write("void 0"); } function emitSerializedTypeNode(node) { - switch (node.kind) { - case 100 /* VoidKeyword */: - write("void 0"); - return; - case 157 /* ParenthesizedType */: - emitSerializedTypeNode(node.type); - return; - case 149 /* FunctionType */: - case 150 /* ConstructorType */: - write("Function"); - return; - case 153 /* ArrayType */: - case 154 /* TupleType */: - write("Array"); - return; - case 147 /* TypePredicate */: - case 117 /* BooleanKeyword */: - write("Boolean"); - return; - case 127 /* StringKeyword */: - case 8 /* StringLiteral */: - write("String"); - return; - case 125 /* NumberKeyword */: - write("Number"); - return; - case 128 /* SymbolKeyword */: - write("Symbol"); - return; - case 148 /* TypeReference */: - emitSerializedTypeReferenceNode(node); - return; - case 151 /* TypeQuery */: - case 152 /* TypeLiteral */: - case 155 /* UnionType */: - case 156 /* IntersectionType */: - case 114 /* AnyKeyword */: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; + if (node) { + switch (node.kind) { + case 101 /* VoidKeyword */: + write("void 0"); + return; + case 158 /* ParenthesizedType */: + emitSerializedTypeNode(node.type); + return; + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + write("Function"); + return; + case 154 /* ArrayType */: + case 155 /* TupleType */: + write("Array"); + return; + case 148 /* TypePredicate */: + case 118 /* BooleanKeyword */: + write("Boolean"); + return; + case 128 /* StringKeyword */: + case 9 /* StringLiteral */: + write("String"); + return; + case 126 /* NumberKeyword */: + write("Number"); + return; + case 129 /* SymbolKeyword */: + write("Symbol"); + return; + case 149 /* TypeReference */: + emitSerializedTypeReferenceNode(node); + return; + case 152 /* TypeQuery */: + case 153 /* TypeLiteral */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: + case 115 /* AnyKeyword */: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } } write("Object"); } /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ function emitSerializedTypeReferenceNode(node) { - var typeName = node.typeName; - var result = resolver.getTypeReferenceSerializationKind(node); + var location = node.parent; + while (ts.isDeclaration(location) || ts.isTypeNode(location)) { + location = location.parent; + } + // Clone the type name and parent it to a location outside of the current declaration. + var typeName = ts.cloneEntityName(node.typeName); + typeName.parent = location; + var result = resolver.getTypeReferenceSerializationKind(typeName); switch (result) { case ts.TypeReferenceSerializationKind.Unknown: var temp = createAndRecordTempVariable(0 /* Auto */); write("(typeof ("); emitNodeWithoutSourceMap(temp); write(" = "); - emitEntityNameAsExpression(typeName, true); + emitEntityNameAsExpression(typeName, /*useFallback*/ true); write(") === 'function' && "); emitNodeWithoutSourceMap(temp); write(") || Object"); break; case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: - emitEntityNameAsExpression(typeName, false); + emitEntityNameAsExpression(typeName, /*useFallback*/ false); break; case ts.TypeReferenceSerializationKind.VoidType: write("void 0"); @@ -32360,11 +33081,11 @@ var ts; // // * If the declaration is a class, the parameters of the first constructor with a body are used. // * If the declaration is function-like and has a body, the parameters of the function are used. - // + // // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { var valueDeclaration; - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { valueDeclaration = ts.getFirstConstructorWithBody(node); } else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { @@ -32380,10 +33101,10 @@ var ts; } if (parameters[i].dotDotDotToken) { var parameterType = parameters[i].type; - if (parameterType.kind === 153 /* ArrayType */) { + if (parameterType.kind === 154 /* ArrayType */) { parameterType = parameterType.elementType; } - else if (parameterType.kind === 148 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + else if (parameterType.kind === 149 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { parameterType = parameterType.typeArguments[0]; } else { @@ -32401,7 +33122,7 @@ var ts; } /** Serializes the return type of function. Used by the __metadata decorator for a method. */ function emitSerializedReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { + if (node && ts.isFunctionLike(node) && node.type) { emitSerializedTypeNode(node.type); return; } @@ -32446,7 +33167,7 @@ var ts; return argumentsWritten; } function emitInterfaceDeclaration(node) { - emitOnlyPinnedOrTripleSlashComments(node); + emitCommentsOnNotEmittedNode(node); } function shouldEmitEnumDeclaration(node) { var isConstEnum = ts.isConst(node); @@ -32482,7 +33203,7 @@ var ts; emitLines(node.members); decreaseIndent(); writeLine(); - emitToken(15 /* CloseBraceToken */, node.members.end); + emitToken(16 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -32543,7 +33264,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 215 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -32558,7 +33279,7 @@ var ts; // Emit only if this module is non-ambient. var shouldEmit = shouldEmitModuleDeclaration(node); if (!shouldEmit) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); @@ -32579,7 +33300,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 216 /* ModuleBlock */) { + if (node.body.kind === 217 /* ModuleBlock */) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -32598,7 +33319,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(15 /* CloseBraceToken */, moduleBlock.statements.end); + emitToken(16 /* CloseBraceToken */, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -32612,7 +33333,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 66 /* Identifier */ && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 67 /* Identifier */ && node.parent === currentSourceFile) { if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); @@ -32624,29 +33345,45 @@ var ts; emitExportMemberAssignments(node.name); } } + /* + * Some bundlers (SystemJS builder) sometimes want to rename dependencies. + * Here we check if alternative name was provided for a given moduleName and return it if possible. + */ + function tryRenameExternalModule(moduleName) { + if (currentSourceFile.renamedDependencies && ts.hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { + return "\"" + currentSourceFile.renamedDependencies[moduleName.text] + "\""; + } + return undefined; + } function emitRequire(moduleName) { - if (moduleName.kind === 8 /* StringLiteral */) { + if (moduleName.kind === 9 /* StringLiteral */) { write("require("); - emitStart(moduleName); - emitLiteral(moduleName); - emitEnd(moduleName); - emitToken(17 /* CloseParenToken */, moduleName.end); + var text = tryRenameExternalModule(moduleName); + if (text) { + write(text); + } + else { + emitStart(moduleName); + emitLiteral(moduleName); + emitEnd(moduleName); + } + emitToken(18 /* CloseParenToken */, moduleName.end); } else { write("require()"); } } function getNamespaceDeclarationNode(node) { - if (node.kind === 218 /* ImportEqualsDeclaration */) { + if (node.kind === 219 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 222 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 219 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 220 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -32661,7 +33398,7 @@ var ts; // ES6 import if (node.importClause) { var shouldEmitDefaultBindings = resolver.isReferencedAliasDeclaration(node.importClause); - var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, true); + var shouldEmitNamedBindings = node.importClause.namedBindings && resolver.isReferencedAliasDeclaration(node.importClause.namedBindings, /* checkChildren */ true); if (shouldEmitDefaultBindings || shouldEmitNamedBindings) { write("import "); emitStart(node.importClause); @@ -32674,7 +33411,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 222 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -32700,7 +33437,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 218 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 219 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2 /* AMD */) { emitLeadingComments(node); @@ -32719,7 +33456,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 219 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 220 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -32770,16 +33507,33 @@ var ts; (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - if (isES6ExportedDeclaration(node)) { - write("export "); - write("var "); + // variable declaration for import-equals declaration can be hoisted in system modules + // in this case 'var' should be omitted and emit should contain only initialization + var variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); + // is it top level export import v = a.b.c in system module? + // if yes - it needs to be rewritten as exporter('v', v = a.b.c) + var isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); + if (!variableDeclarationIsHoisted) { + ts.Debug.assert(!isExported); + if (isES6ExportedDeclaration(node)) { + write("export "); + write("var "); + } + else if (!(node.flags & 1 /* Export */)) { + write("var "); + } } - else if (!(node.flags & 1 /* Export */)) { - write("var "); + if (isExported) { + write(exportFunctionForFile + "(\""); + emitNodeWithoutSourceMap(node.name); + write("\", "); } emitModuleMemberName(node); write(" = "); emit(node.moduleReference); + if (isExported) { + write(")"); + } write(";"); emitEnd(node); emitExportImportAssignments(node); @@ -32808,11 +33562,11 @@ var ts; emitStart(specifier); emitContainingModuleName(specifier); write("."); - emitNodeWithoutSourceMap(specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.name); write(" = "); write(generatedName); write("."); - emitNodeWithoutSourceMap(specifier.propertyName || specifier.name); + emitNodeWithCommentsAndWithoutSourcemap(specifier.propertyName || specifier.name); write(";"); emitEnd(specifier); } @@ -32835,7 +33589,6 @@ var ts; } else { if (!node.exportClause || resolver.isValueAliasDeclaration(node)) { - emitStart(node); write("export "); if (node.exportClause) { // export { x, y, ... } @@ -32848,10 +33601,9 @@ var ts; } if (node.moduleSpecifier) { write(" from "); - emitNodeWithoutSourceMap(node.moduleSpecifier); + emit(node.moduleSpecifier); } write(";"); - emitEnd(node); } } } @@ -32864,13 +33616,11 @@ var ts; if (needsComma) { write(", "); } - emitStart(specifier); if (specifier.propertyName) { - emitNodeWithoutSourceMap(specifier.propertyName); + emit(specifier.propertyName); write(" as "); } - emitNodeWithoutSourceMap(specifier.name); - emitEnd(specifier); + emit(specifier.name); needsComma = true; } } @@ -32883,8 +33633,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 210 /* FunctionDeclaration */ && - expression.kind !== 211 /* ClassDeclaration */) { + if (expression.kind !== 211 /* FunctionDeclaration */ && + expression.kind !== 212 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -32898,6 +33648,7 @@ var ts; write(")"); } else { + emitEs6ExportDefaultCompat(node); emitContainingModuleName(node); if (languageVersion === 0 /* ES3 */) { write("[\"default\"] = "); @@ -32920,9 +33671,9 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { + resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { // import "mod" // import x from "mod" where x is referenced // import * as x from "mod" where x is referenced @@ -32930,13 +33681,13 @@ var ts; externalImports.push(node); } break; - case 218 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 229 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 219 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 230 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -32957,7 +33708,7 @@ var ts; } } break; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -32983,17 +33734,17 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 219 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 220 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 225 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 226 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } function getExternalModuleNameText(importNode) { var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 8 /* StringLiteral */) { - return getLiteralText(moduleName); + if (moduleName.kind === 9 /* StringLiteral */) { + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); } return undefined; } @@ -33006,8 +33757,8 @@ var ts; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 225 /* ExportDeclaration */ || - (importNode.kind === 219 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 226 /* ExportDeclaration */ || + (importNode.kind === 220 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -33040,14 +33791,14 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 225 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 226 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } } if (!hasExportDeclarationWithExportClause) { // we still need to emit exportStar helper - return emitExportStarFunction(undefined); + return emitExportStarFunction(/*localNames*/ undefined); } } var exportedNamesStorageRef = makeUniqueName("exportedNames"); @@ -33072,7 +33823,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 225 /* ExportDeclaration */) { + if (externalImport.kind !== 226 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -33097,6 +33848,8 @@ var ts; write("function " + exportStarFunction + "(m) {"); increaseIndent(); writeLine(); + write("var exports = {};"); + writeLine(); write("for(var n in m) {"); increaseIndent(); writeLine(); @@ -33104,10 +33857,12 @@ var ts; if (localNames) { write("&& !" + localNames + ".hasOwnProperty(n)"); } - write(") " + exportFunctionForFile + "(n, m[n]);"); + write(") exports[n] = m[n];"); decreaseIndent(); writeLine(); write("}"); + writeLine(); + write(exportFunctionForFile + "(exports);"); decreaseIndent(); writeLine(); write("}"); @@ -33116,7 +33871,7 @@ var ts; function writeExportedName(node) { // do not record default exports // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 66 /* Identifier */ && node.flags & 1024 /* Default */) { + if (node.kind !== 67 /* Identifier */ && node.flags & 1024 /* Default */) { return; } if (started) { @@ -33127,8 +33882,8 @@ var ts; } writeLine(); write("'"); - if (node.kind === 66 /* Identifier */) { - emitNodeWithoutSourceMap(node); + if (node.kind === 67 /* Identifier */) { + emitNodeWithCommentsAndWithoutSourcemap(node); } else { emitDeclarationName(node); @@ -33156,7 +33911,7 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_25 = local.kind === 66 /* Identifier */ + var name_25 = local.kind === 67 /* Identifier */ ? local : local.name; if (name_25) { @@ -33172,13 +33927,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 211 /* ClassDeclaration */ || local.kind === 215 /* ModuleDeclaration */ || local.kind === 214 /* EnumDeclaration */) { + if (local.kind === 212 /* ClassDeclaration */ || local.kind === 216 /* ModuleDeclaration */ || local.kind === 215 /* EnumDeclaration */) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 66 /* Identifier */ ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 67 /* Identifier */ ? local.parent : local); if (flags & 1 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -33206,21 +33961,21 @@ var ts; if (node.flags & 2 /* Ambient */) { return; } - if (node.kind === 210 /* FunctionDeclaration */) { + if (node.kind === 211 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 211 /* ClassDeclaration */) { + if (node.kind === 212 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 214 /* EnumDeclaration */) { + if (node.kind === 215 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33229,7 +33984,7 @@ var ts; } return; } - if (node.kind === 215 /* ModuleDeclaration */) { + if (node.kind === 216 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -33238,10 +33993,10 @@ var ts; } return; } - if (node.kind === 208 /* VariableDeclaration */ || node.kind === 160 /* BindingElement */) { - if (shouldHoistVariable(node, false)) { + if (node.kind === 209 /* VariableDeclaration */ || node.kind === 161 /* BindingElement */) { + if (shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ false)) { var name_26 = node.name; - if (name_26.kind === 66 /* Identifier */) { + if (name_26.kind === 67 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } @@ -33253,6 +34008,13 @@ var ts; } return; } + if (ts.isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { + if (!hoistedVars) { + hoistedVars = []; + } + hoistedVars.push(node.name); + return; + } if (ts.isBindingPattern(node)) { ts.forEach(node.elements, visit); return; @@ -33272,12 +34034,12 @@ var ts; // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 245 /* SourceFile */; + ts.getEnclosingBlockScopeContainer(node).kind === 246 /* SourceFile */; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); } - function emitSystemModuleBody(node, startIndex) { + function emitSystemModuleBody(node, dependencyGroups, startIndex) { // shape of the body in system modules: // function (exports) { // @@ -33322,105 +34084,86 @@ var ts; write("return {"); increaseIndent(); writeLine(); - emitSetters(exportStarFunction); + emitSetters(exportStarFunction, dependencyGroups); writeLine(); emitExecute(node, startIndex); decreaseIndent(); writeLine(); write("}"); // return - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); } - function emitSetters(exportStarFunction) { + function emitSetters(exportStarFunction, dependencyGroups) { write("setters:["); - for (var i = 0; i < externalImports.length; ++i) { + for (var i = 0; i < dependencyGroups.length; ++i) { if (i !== 0) { write(","); } writeLine(); increaseIndent(); - var importNode = externalImports[i]; - var importVariableName = getLocalNameForExternalImport(importNode) || ""; - var parameterName = "_" + importVariableName; + var group = dependencyGroups[i]; + // derive a unique name for parameter from the first named entry in the group + var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); - switch (importNode.kind) { - case 219 /* ImportDeclaration */: - if (!importNode.importClause) { - // 'import "..."' case - // module is imported only for side-effects, setter body will be empty - break; - } - // fall-through - case 218 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - writeLine(); - // save import into the local - write(importVariableName + " = " + parameterName + ";"); - writeLine(); - var defaultName = importNode.kind === 219 /* ImportDeclaration */ - ? importNode.importClause.name - : importNode.name; - if (defaultName) { - // emit re-export for imported default name - // import n1 from 'foo1' - // import n2 = require('foo2') - // export {n1} - // export {n2} - emitExportMemberAssignments(defaultName); + increaseIndent(); + for (var _a = 0; _a < group.length; _a++) { + var entry = group[_a]; + var importVariableName = getLocalNameForExternalImport(entry) || ""; + switch (entry.kind) { + case 220 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 219 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== ""); writeLine(); - } - if (importNode.kind === 219 /* ImportDeclaration */ && - importNode.importClause.namedBindings) { - var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 221 /* NamespaceImport */) { - // emit re-export for namespace - // import * as n from 'foo' - // export {n} - emitExportMemberAssignments(namedBindings.name); + // save import into the local + write(importVariableName + " = " + parameterName + ";"); + writeLine(); + break; + case 226 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== ""); + if (entry.exportClause) { + // export {a, b as c} from 'foo' + // emit as: + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); writeLine(); + write(exportFunctionForFile + "({"); + writeLine(); + increaseIndent(); + for (var i_2 = 0, len = entry.exportClause.elements.length; i_2 < len; ++i_2) { + if (i_2 !== 0) { + write(","); + writeLine(); + } + var e = entry.exportClause.elements[i_2]; + write("\""); + emitNodeWithCommentsAndWithoutSourcemap(e.name); + write("\": " + parameterName + "[\""); + emitNodeWithCommentsAndWithoutSourcemap(e.propertyName || e.name); + write("\"]"); + } + decreaseIndent(); + writeLine(); + write("});"); } else { - // emit re-exports for named imports - // import {a, b} from 'foo' - // export {a, b as c} - for (var _a = 0, _b = namedBindings.elements; _a < _b.length; _a++) { - var element = _b[_a]; - emitExportMemberAssignments(element.name || element.propertyName); - writeLine(); - } - } - } - decreaseIndent(); - break; - case 225 /* ExportDeclaration */: - ts.Debug.assert(importVariableName !== ""); - increaseIndent(); - if (importNode.exportClause) { - // export {a, b as c} from 'foo' - // emit as: - // exports('a', _foo["a"]) - // exports('c', _foo["b"]) - for (var _c = 0, _d = importNode.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; writeLine(); - write(exportFunctionForFile + "(\""); - emitNodeWithoutSourceMap(e.name); - write("\", " + parameterName + "[\""); - emitNodeWithoutSourceMap(e.propertyName || e.name); - write("\"]);"); + // export * from 'foo' + // emit as: + // exportStar(_foo); + write(exportStarFunction + "(" + parameterName + ");"); } - } - else { writeLine(); - // export * from 'foo' - // emit as: - // exportStar(_foo); - write(exportStarFunction + "(" + parameterName + ");"); - } - writeLine(); - decreaseIndent(); - break; + break; + } } + decreaseIndent(); write("}"); decreaseIndent(); } @@ -33432,17 +34175,33 @@ var ts; writeLine(); for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; - // - imports/exports are not emitted for system modules - // - function declarations are not emitted because they were already hoisted switch (statement.kind) { - case 225 /* ExportDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 210 /* FunctionDeclaration */: + // - function declarations are not emitted because they were already hoisted + // - import declarations are not emitted since they are already handled in setters + // - export declarations with module specifiers are not emitted since they were already written in setters + // - export declarations without module specifiers are emitted preserving the order + case 211 /* FunctionDeclaration */: + case 220 /* ImportDeclaration */: continue; + case 226 /* ExportDeclaration */: + if (!statement.moduleSpecifier) { + for (var _a = 0, _b = statement.exportClause.elements; _a < _b.length; _a++) { + var element = _b[_a]; + // write call to exporter function for every export specifier in exports list + emitExportSpecifierInSystemModule(element); + } + } + continue; + case 219 /* ImportEqualsDeclaration */: + if (!ts.isInternalModuleImportEqualsDeclaration(statement)) { + // - import equals declarations that import external modules are not emitted + continue; + } + // fall-though for import declarations that import internal modules + default: + writeLine(); + emit(statement); } - writeLine(); - emit(statement); } decreaseIndent(); writeLine(); @@ -33467,8 +34226,20 @@ var ts; write("\"" + node.moduleName + "\", "); } write("["); + var groupIndices = {}; + var dependencyGroups = []; for (var i = 0; i < externalImports.length; ++i) { var text = getExternalModuleNameText(externalImports[i]); + if (ts.hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].push(externalImports[i]); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push([externalImports[i]]); + } if (i !== 0) { write(", "); } @@ -33477,8 +34248,9 @@ var ts; write("], function(" + exportFunctionForFile + ") {"); writeLine(); increaseIndent(); + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); - emitSystemModuleBody(node, startIndex); + emitSystemModuleBody(node, dependencyGroups, startIndex); decreaseIndent(); writeLine(); write("});"); @@ -33543,33 +34315,36 @@ var ts; } } function emitAMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); writeLine(); write("define("); if (node.moduleName) { write("\"" + node.moduleName + "\", "); } - emitAMDDependencies(node, true); + emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); write(") {"); increaseIndent(); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); decreaseIndent(); writeLine(); write("});"); } function emitCommonJSModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(false); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ false); } function emitUMDModule(node, startIndex) { + emitEmitHelpers(node); collectExternalModuleInfo(node); // Module is detected first to support Browserify users that load into a browser with an AMD loader writeLines("(function (deps, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(deps, factory);\n }\n})("); @@ -33579,8 +34354,8 @@ var ts; emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); - emitExportEquals(true); + emitTempDeclarations(/*newLine*/ true); + emitExportEquals(/*emitAsReturn*/ true); decreaseIndent(); writeLine(); write("});"); @@ -33590,9 +34365,10 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); // Emit exportDefault if it exists will happen as part // or normal statement emit. } @@ -33618,9 +34394,9 @@ var ts; break; } } - function trimReactWhitespace(node) { + function trimReactWhitespaceAndApplyEntities(node) { var result = undefined; - var text = ts.getTextOfNode(node); + var text = ts.getTextOfNode(node, /*includeTrivia*/ true); var firstNonWhitespace = 0; var lastNonWhitespace = -1; // JSX trims whitespace at the end and beginning of lines, except that the @@ -33631,7 +34407,7 @@ var ts; if (ts.isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; } firstNonWhitespace = -1; } @@ -33644,15 +34420,26 @@ var ts; } if (firstNonWhitespace !== -1) { var part = text.substr(firstNonWhitespace); - result = (result ? result + '" + \' \' + "' : '') + part; + result = (result ? result + "\" + ' ' + \"" : "") + part; + } + if (result) { + // Replace entities like   + result = result.replace(/&(\w+);/g, function (s, m) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); } return result; } function getTextToEmit(node) { switch (compilerOptions.jsx) { case 2 /* React */: - var text = trimReactWhitespace(node); - if (text.length === 0) { + var text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { return undefined; } else { @@ -33660,19 +34447,19 @@ var ts; } case 1 /* Preserve */: default: - return ts.getTextOfNode(node, true); + return ts.getTextOfNode(node, /*includeTrivia*/ true); } } function emitJsxText(node) { switch (compilerOptions.jsx) { case 2 /* React */: - write('"'); - write(trimReactWhitespace(node)); - write('"'); + write("\""); + write(trimReactWhitespaceAndApplyEntities(node)); + write("\""); break; case 1 /* Preserve */: default: - write(ts.getTextOfNode(node, true)); + writer.writeLiteral(ts.getTextOfNode(node, /*includeTrivia*/ true)); break; } } @@ -33681,9 +34468,9 @@ var ts; switch (compilerOptions.jsx) { case 1 /* Preserve */: default: - write('{'); + write("{"); emit(node.expression); - write('}'); + write("}"); break; case 2 /* React */: emit(node.expression); @@ -33716,12 +34503,7 @@ var ts; } } } - function emitSourceFileNode(node) { - // Start new file on new line - writeLine(); - emitDetachedComments(node); - // emit prologue directives prior to __extends - var startIndex = emitDirectivePrologues(node.statements, false); + function emitEmitHelpers(node) { // Only emit helpers if the user did not say otherwise. if (!compilerOptions.noEmitHelpers) { // Only Emit __extends function when target ES5. @@ -33746,6 +34528,14 @@ var ts; awaiterEmitted = true; } } + } + function emitSourceFileNode(node) { + // Start new file on new line + writeLine(); + emitShebang(); + emitDetachedComments(node); + // emit prologue directives prior to __extends + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2 /* ES6 */) { emitES6Module(node, startIndex); @@ -33768,57 +34558,76 @@ var ts; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); - emitTempDeclarations(true); + emitTempDeclarations(/*newLine*/ true); } emitLeadingComments(node.endOfFileToken); } + function emitNodeWithCommentsAndWithoutSourcemap(node) { + emitNodeConsideringCommentsOption(node, emitNodeWithoutSourceMap); + } + function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { + if (node) { + if (node.flags & 2 /* Ambient */) { + return emitCommentsOnNotEmittedNode(node); + } + if (isSpecializedCommentHandling(node)) { + // This is the node that will handle its own comments and sourcemap + return emitNodeWithoutSourceMap(node); + } + var emitComments_1 = shouldEmitLeadingAndTrailingComments(node); + if (emitComments_1) { + emitLeadingComments(node); + } + emitNodeConsideringSourcemap(node); + if (emitComments_1) { + emitTrailingComments(node); + } + } + } function emitNodeWithoutSourceMap(node) { - if (!node) { - return; + if (node) { + emitJavaScriptWorker(node); } - if (node.flags & 2 /* Ambient */) { - return emitOnlyPinnedOrTripleSlashComments(node); - } - var emitComments = shouldEmitLeadingAndTrailingComments(node); - if (emitComments) { - emitLeadingComments(node); - } - emitJavaScriptWorker(node); - if (emitComments) { - emitTrailingComments(node); + } + function isSpecializedCommentHandling(node) { + switch (node.kind) { + // All of these entities are emitted in a specialized fashion. As such, we allow + // the specialized methods for each to handle the comments on the nodes. + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 225 /* ExportAssignment */: + return true; } } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - // All of these entities are emitted in a specialized fashion. As such, we allow - // the specialized methods for each to handle the comments on the nodes. - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: - case 219 /* ImportDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 224 /* ExportAssignment */: - return false; - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); } + // If the node is emitted in specialized fashion, dont emit comments as this node will handle + // emitting comments when emitting itself + ts.Debug.assert(!isSpecializedCommentHandling(node)); // If this is the expression body of an arrow function that we're down-leveling, // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. - if (node.kind !== 189 /* Block */ && + if (node.kind !== 190 /* Block */ && node.parent && - node.parent.kind === 171 /* ArrowFunction */ && + node.parent.kind === 172 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -33829,170 +34638,170 @@ var ts; function emitJavaScriptWorker(node) { // Check if the node can be emitted regardless of the ScriptTarget switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return emitIdentifier(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return emitParameter(node); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return emitMethod(node); - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: return emitAccessor(node); - case 94 /* ThisKeyword */: + case 95 /* ThisKeyword */: return emitThis(node); - case 92 /* SuperKeyword */: + case 93 /* SuperKeyword */: return emitSuper(node); - case 90 /* NullKeyword */: + case 91 /* NullKeyword */: return write("null"); - case 96 /* TrueKeyword */: + case 97 /* TrueKeyword */: return write("true"); - case 81 /* FalseKeyword */: + case 82 /* FalseKeyword */: return write("false"); - case 7 /* NumericLiteral */: - case 8 /* StringLiteral */: - case 9 /* RegularExpressionLiteral */: - case 10 /* NoSubstitutionTemplateLiteral */: - case 11 /* TemplateHead */: - case 12 /* TemplateMiddle */: - case 13 /* TemplateTail */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 10 /* RegularExpressionLiteral */: + case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* TemplateHead */: + case 13 /* TemplateMiddle */: + case 14 /* TemplateTail */: return emitLiteral(node); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: return emitTemplateExpression(node); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return emitTemplateSpan(node); - case 230 /* JsxElement */: - case 231 /* JsxSelfClosingElement */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: return emitJsxElement(node); - case 233 /* JsxText */: + case 234 /* JsxText */: return emitJsxText(node); - case 237 /* JsxExpression */: + case 238 /* JsxExpression */: return emitJsxExpression(node); - case 132 /* QualifiedName */: + case 133 /* QualifiedName */: return emitQualifiedName(node); - case 158 /* ObjectBindingPattern */: + case 159 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 159 /* ArrayBindingPattern */: + case 160 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 160 /* BindingElement */: + case 161 /* BindingElement */: return emitBindingElement(node); - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 242 /* PropertyAssignment */: + case 243 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 243 /* ShorthandPropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 133 /* ComputedPropertyName */: + case 134 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 163 /* PropertyAccessExpression */: + case 164 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 165 /* CallExpression */: + case 166 /* CallExpression */: return emitCallExpression(node); - case 166 /* NewExpression */: + case 167 /* NewExpression */: return emitNewExpression(node); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: return emit(node.expression); - case 186 /* AsExpression */: + case 187 /* AsExpression */: return emit(node.expression); - case 169 /* ParenthesizedExpression */: + case 170 /* ParenthesizedExpression */: return emitParenExpression(node); - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 172 /* DeleteExpression */: + case 173 /* DeleteExpression */: return emitDeleteExpression(node); - case 173 /* TypeOfExpression */: + case 174 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 174 /* VoidExpression */: + case 175 /* VoidExpression */: return emitVoidExpression(node); - case 175 /* AwaitExpression */: + case 176 /* AwaitExpression */: return emitAwaitExpression(node); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 177 /* PostfixUnaryExpression */: + case 178 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return emitBinaryExpression(node); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return emitConditionalExpression(node); - case 182 /* SpreadElementExpression */: + case 183 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 181 /* YieldExpression */: + case 182 /* YieldExpression */: return emitYieldExpression(node); - case 184 /* OmittedExpression */: + case 185 /* OmittedExpression */: return; - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return emitBlock(node); - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: return emitVariableStatement(node); - case 191 /* EmptyStatement */: + case 192 /* EmptyStatement */: return write(";"); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return emitExpressionStatement(node); - case 193 /* IfStatement */: + case 194 /* IfStatement */: return emitIfStatement(node); - case 194 /* DoStatement */: + case 195 /* DoStatement */: return emitDoStatement(node); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: return emitWhileStatement(node); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return emitForStatement(node); - case 198 /* ForOfStatement */: - case 197 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 198 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 199 /* ContinueStatement */: - case 200 /* BreakStatement */: + case 200 /* ContinueStatement */: + case 201 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: return emitReturnStatement(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: return emitWithStatement(node); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return emitSwitchStatement(node); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: return emitLabelledStatement(node); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: return emitThrowStatement(node); - case 206 /* TryStatement */: + case 207 /* TryStatement */: return emitTryStatement(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return emitCatchClause(node); - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 183 /* ClassExpression */: + case 184 /* ClassExpression */: return emitClassExpression(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return emitClassDeclaration(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return emitEnumMember(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: return emitImportDeclaration(node); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: return emitExportDeclaration(node); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: return emitExportAssignment(node); - case 245 /* SourceFile */: + case 246 /* SourceFile */: return emitSourceFileNode(node); } } @@ -34010,21 +34819,32 @@ var ts; } return leadingComments; } - function filterComments(ranges, onlyPinnedOrTripleSlashComments) { - // If we're removing comments, then we want to strip out all but the pinned or - // triple slash comments. - if (ranges && onlyPinnedOrTripleSlashComments) { - ranges = ts.filter(ranges, isPinnedOrTripleSlashComment); - if (ranges.length === 0) { - return undefined; - } + function isPinnedComments(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; + } + /** + * Determine if the given comment is a triple-slash + * + * @return true if the comment is a triple-slash comment else false + **/ + function isTripleSlashComment(comment) { + // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text + // so that we don't end up computing comment string and doing match for all // comments + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */) { + var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || + textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ? + true : false; } - return ranges; + return false; } function getLeadingCommentsToEmit(node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 245 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 246 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -34039,32 +34859,71 @@ var ts; function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 245 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 246 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } } - function emitOnlyPinnedOrTripleSlashComments(node) { - emitLeadingCommentsWorker(node, true); + /** + * Emit comments associated with node that will not be emitted into JS file + */ + function emitCommentsOnNotEmittedNode(node) { + emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false); } function emitLeadingComments(node) { - return emitLeadingCommentsWorker(node, compilerOptions.removeComments); + return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true); } - function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) { - // If the caller only wants pinned or triple slash comments, then always filter - // down to that set. Otherwise, filter based on the current compiler options. - var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); + function emitLeadingCommentsWorker(node, isEmittedNode) { + if (compilerOptions.removeComments) { + return; + } + var leadingComments; + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, + // unless it is a triple slash comment at the top of the file. + // For Example: + // /// + // declare var x; + // /// + // interface F {} + // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted + if (node.pos === 0) { + leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment); + } + } ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment); } function emitTrailingComments(node) { + if (compilerOptions.removeComments) { + return; + } // Emit the trailing comments only if the parent's end doesn't match - var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments); + var trailingComments = getTrailingCommentsToEmit(node); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ - ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); } - function emitLeadingCommentsOfPosition(pos) { + /** + * Emit trailing comments at the position. The term trailing comment is used here to describe following comment: + * x, /comment1/ y + * ^ => pos; the function will emit "comment1" in the emitJS + */ + function emitTrailingCommentsOfPosition(pos) { + if (compilerOptions.removeComments) { + return; + } + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos); + // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ + ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); + } + function emitLeadingCommentsOfPositionWorker(pos) { + if (compilerOptions.removeComments) { + return; + } var leadingComments; if (hasDetachedComments(pos)) { // get comments without detached comments @@ -34074,13 +34933,26 @@ var ts; // get the leading comments from the node leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); } - leadingComments = filterComments(leadingComments, compilerOptions.removeComments); ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); } function emitDetachedComments(node) { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + var leadingComments; + if (compilerOptions.removeComments) { + // removeComments is true, only reserve pinned comment at the top of file + // For example: + // /*! Pinned Comment */ + // + // var x = 10; + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } + } + else { + // removeComments is false, just get detached as normal and bypass the process to filter comment + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } if (leadingComments) { var detachedComments = []; var lastComment; @@ -34107,7 +34979,7 @@ var ts; if (nodeLine >= lastCommentLine + 2) { // Valid detachedComments ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -34119,15 +34991,10 @@ var ts; } } } - function isPinnedOrTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; - } - else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */ && - currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { - return true; + function emitShebang() { + var shebang = ts.getShebang(currentSourceFile.text); + if (shebang) { + write(shebang); } } } @@ -34139,9 +35006,265 @@ var ts; } } ts.emitFiles = emitFiles; + var entities = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; })(ts || (ts = {})); /// /// +/// var ts; (function (ts) { /* @internal */ ts.programTime = 0; @@ -34149,7 +35272,8 @@ var ts; /* @internal */ ts.ioReadTime = 0; /* @internal */ ts.ioWriteTime = 0; /** The version of the TypeScript compiler release */ - ts.version = "1.5.3"; + var emptyArray = []; + ts.version = "1.7.0"; function findConfigFile(searchPath) { var fileName = "tsconfig.json"; while (true) { @@ -34166,6 +35290,161 @@ var ts; return undefined; } ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === 1 /* CommonJS */ ? 2 /* NodeJs */ : 1 /* Classic */; + switch (moduleResolution) { + case 2 /* NodeJs */: return nodeModuleNameResolver(moduleName, containingFile, host); + case 1 /* Classic */: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } + } + ts.resolveModuleName = resolveModuleName; + function nodeModuleNameResolver(moduleName, containingFile, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + if (ts.getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + var failedLookupLocations = []; + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + if (resolvedFileName) { + return { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations }; + } + resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + return resolvedFileName + ? { resolvedModule: { resolvedFileName: resolvedFileName }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function loadNodeModuleFromFile(candidate, loadOnlyDts, failedLookupLocation, host) { + if (loadOnlyDts) { + return tryLoad(".d.ts"); + } + else { + return ts.forEach(ts.supportedExtensions, tryLoad); + } + function tryLoad(ext) { + var fileName = ts.fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + function loadNodeModuleFromDirectory(candidate, loadOnlyDts, failedLookupLocation, host) { + var packageJsonPath = ts.combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + var jsonContent; + try { + var jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + // gracefully handle if readFile fails or returns not JSON + jsonContent = { typings: undefined }; + } + if (jsonContent.typings) { + var result = loadNodeModuleFromFile(ts.normalizePath(ts.combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocation.push(packageJsonPath); + } + return loadNodeModuleFromFile(ts.combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + } + function loadModuleFromNodeModules(moduleName, directory, host) { + var failedLookupLocations = []; + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + } + result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations: failedLookupLocations }; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + directory = parentPath; + } + return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + function nameStartsWithDotSlashOrDotDotSlash(name) { + var i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === 46 /* dot */); + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + // module names that contain '!' are used to reference resources and are not resolved to actual files on disk + if (moduleName.indexOf('!') != -1) { + return { resolvedModule: undefined, failedLookupLocations: [] }; + } + var searchPath = ts.getDirectoryPath(containingFile); + var searchName; + var failedLookupLocations = []; + var referencedSourceFile; + while (true) { + searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); + referencedSourceFile = ts.forEach(ts.supportedExtensions, function (extension) { + if (extension === ".tsx" && !compilerOptions.jsx) { + // resolve .tsx files only if jsx support is enabled + // 'logical not' handles both undefined and None cases + return undefined; + } + var candidate = searchName + extension; + if (host.fileExists(candidate)) { + return candidate; + } + else { + failedLookupLocations.push(candidate); + } + }); + if (referencedSourceFile) { + break; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + /* @internal */ + ts.defaultInitCompilerOptions = { + module: 1 /* CommonJS */, + target: 0 /* ES3 */, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false + }; function createCompilerHost(options, setParentNodes) { var currentDirectory; var existingDirectories = {}; @@ -34231,7 +35510,9 @@ var ts; getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); } }; } ts.createCompilerHost = createCompilerHost; @@ -34266,10 +35547,11 @@ var ts; } } ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function createProgram(rootNames, options, host) { + function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; - var diagnostics = ts.createDiagnosticCollection(); + var fileProcessingDiagnostics = ts.createDiagnosticCollection(); + var programDiagnostics = ts.createDiagnosticCollection(); var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; @@ -34277,18 +35559,38 @@ var ts; var skipDefaultLib = options.noLib; var start = new Date().getTime(); host = host || createCompilerHost(options); + var resolveModuleNamesWorker = host.resolveModuleNames + ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) + : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); var filesByName = ts.createFileMap(function (fileName) { return host.getCanonicalFileName(fileName); }); - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - // Do not process the default library if: - // - The '--noLib' flag is used. - // - A 'no-default-lib' reference comment is encountered in - // processing the root files. - if (!skipDefaultLib) { - processRootFile(host.getDefaultLibFileName(options), true); + if (oldProgram) { + // check properties that can affect structure of the program or module resolution strategy + // if any of these properties has changed - structure cannot be reused + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx)) { + oldProgram = undefined; + } + } + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + // Do not process the default library if: + // - The '--noLib' flag is used. + // - A 'no-default-lib' reference comment is encountered in + // processing the root files. + if (!skipDefaultLib) { + processRootFile(host.getDefaultLibFileName(options), true); + } } verifyCompilerOptions(); + // unconditionally set oldProgram to undefined to prevent it from being captured in closure + oldProgram = undefined; ts.programTime += new Date().getTime() - start; program = { + getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFiles: function () { return files; }, getCompilerOptions: function () { return options; }, @@ -34306,7 +35608,8 @@ var ts; getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, - getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); } + getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, + getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; } }; return program; function getClassifiableNames() { @@ -34321,6 +35624,84 @@ var ts; } return classifiableNames; } + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; + } + ts.Debug.assert(!oldProgram.structureIsReused); + // there is an old program, check if we can reuse its structure + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; + } + // check if program source files has changed in the way that can affect structure of the program + var newSourceFiles = []; + var modifiedSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + // value of no-default-lib has changed + // this will affect if default library is injected into the list of files + return false; + } + // check tripleslash references + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + // tripleslash references has changed + return false; + } + // check imports + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + // imports has changed + return false; + } + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); + // ensure that module resolution results are still correct + for (var i = 0; i < moduleNames.length; ++i) { + var newResolution = resolutions[i]; + var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]); + var resolutionChanged = oldResolution + ? !newResolution || + oldResolution.resolvedFileName !== newResolution.resolvedFileName || + !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport + : newResolution; + if (resolutionChanged) { + return false; + } + } + } + // pass the cache of module resolutions from the old source file + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + modifiedSourceFiles.push(newSourceFile); + } + else { + // file has no changes - use it as is + newSourceFile = oldSourceFile; + } + // if file has passed all checks it should be safe to reuse it + newSourceFiles.push(newSourceFile); + } + // update fileName -> file mapping + for (var _b = 0; _b < newSourceFiles.length; _b++) { + var file = newSourceFiles[_b]; + filesByName.set(file.fileName, file); + } + files = newSourceFiles; + fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); + for (var _c = 0; _c < modifiedSourceFiles.length; _c++) { + var modifiedFile = modifiedSourceFiles[_c]; + fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + } + oldProgram.structureIsReused = true; + return true; + } function getEmitHost(writeFileCallback) { return { getCanonicalFileName: function (fileName) { return host.getCanonicalFileName(fileName); }, @@ -34334,10 +35715,10 @@ var ts; }; } function getDiagnosticsProducingTypeChecker() { - return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); + return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); } function getTypeChecker() { - return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); + return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } function emit(sourceFile, writeFileCallback, cancellationToken) { var _this = this; @@ -34347,7 +35728,7 @@ var ts; // If the noEmitOnError flag is set, then check if we have any errors so far. If so, // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones - if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { + if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } // Create the emit resolver outside of the "emitTime" tracking code below. That way @@ -34358,7 +35739,7 @@ var ts; // This is because in the -out scenario all files need to be emitted, and therefore all // files need to be type checked. And the way to specify that all files need to be type // checked is to not pass the file to getEmitResolver. - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); var start = new Date().getTime(); var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); ts.emitTime += new Date().getTime() - start; @@ -34419,8 +35800,9 @@ var ts; ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); - var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); + var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); + var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); + return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); }); } function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { @@ -34435,7 +35817,8 @@ var ts; } function getOptionsDiagnostics() { var allDiagnostics = []; - ts.addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } function getGlobalDiagnostics() { @@ -34449,14 +35832,59 @@ var ts; function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - var start; - var length; - var diagnosticArgument; - if (refEnd !== undefined && refPos !== undefined) { - start = refPos; - length = refEnd - refPos; + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; } + var imports; + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 220 /* ImportDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 226 /* ExportDeclaration */: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { + break; + } + if (!moduleNameExpr.text) { + break; + } + (imports || (imports = [])).push(moduleNameExpr); + break; + case 216 /* ModuleDeclaration */: + if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An AmbientExternalModuleDeclaration declares an external module. + // This type of declaration is permitted only in the global module. + // The StringLiteral must specify a top - level external module name. + // Relative external module names are not permitted + ts.forEachChild(node.body, function (node) { + if (ts.isExternalModuleImportEqualsDeclaration(node) && + ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 9 /* StringLiteral */) { + var moduleName = ts.getExternalModuleImportEqualsDeclarationExpression(node); + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + if (moduleName) { + (imports || (imports = [])).push(moduleName); + } + } + }); + } + break; + } + } + file.imports = imports || emptyArray; + } + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(ts.supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { @@ -34487,34 +35915,34 @@ var ts; } } if (diagnostic) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, start, length, diagnostic].concat(diagnosticArgument))); + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); } else { - diagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); } } } // Get source file from normalized fileName - function findSourceFile(fileName, isDefaultLib, refFile, refStart, refLength) { + function findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var canonicalName = host.getCanonicalFileName(ts.normalizeSlashes(fileName)); if (filesByName.contains(canonicalName)) { // We've already looked for this file, use cached result - return getSourceFileFromCache(fileName, canonicalName, false); + return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false); } else { var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); + return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true); } // We haven't looked for this file, do so now and cache result var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } else { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } }); filesByName.set(canonicalName, file); @@ -34522,11 +35950,12 @@ var ts; skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; // Set the source file for normalized absolute path filesByName.set(canonicalAbsolutePath, file); + var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - var basePath = ts.getDirectoryPath(fileName); processReferencedFiles(file, basePath); - processImportedModules(file, basePath); } + // always process imported modules to record module name resolutions + processImportedModules(file, basePath); if (isDefaultLib) { file.isDefaultLib = true; files.unshift(file); @@ -34542,7 +35971,12 @@ var ts; if (file && host.useCaseSensitiveFileNames()) { var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; if (canonicalName !== sourceFileName) { - diagnostics.add(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + } } } return file; @@ -34550,57 +35984,45 @@ var ts; } function processReferencedFiles(file, basePath) { ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = ts.isRootedDiskPath(ref.fileName) ? ref.fileName : ts.combinePaths(basePath, ref.fileName); - processSourceFile(ts.normalizePath(referencedFileName), false, file, ref.pos, ref.end); + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, /* isDefaultLib */ false, file, ref.pos, ref.end); }); } function processImportedModules(file, basePath) { - ts.forEach(file.statements, function (node) { - if (node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */ || node.kind === 225 /* ExportDeclaration */) { - var moduleNameExpr = ts.getExternalModuleName(node); - if (moduleNameExpr && moduleNameExpr.kind === 8 /* StringLiteral */) { - var moduleNameText = moduleNameExpr.text; - if (moduleNameText) { - var searchPath = basePath; - var searchName; - while (true) { - searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleNameText)); - if (ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, moduleNameExpr); })) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; + collectExternalModuleReferences(file); + if (file.imports.length) { + file.resolvedModules = {}; + var moduleNames = ts.map(file.imports, function (name) { return name.text; }); + var resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); + for (var i = 0; i < file.imports.length; ++i) { + var resolution = resolutions[i]; + ts.setResolvedModule(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + var importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]); + if (importedFile && resolution.isExternalLibraryImport) { + if (!ts.isExternalModule(importedFile)) { + var start_2 = ts.getTokenPosOfNode(file.imports[i], file); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.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 (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) { + var start_3 = ts.getTokenPosOfNode(file.imports[i], file); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_3, file.imports[i].end - start_3, ts.Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition)); + } + else if (importedFile.referencedFiles.length) { + var firstRef = importedFile.referencedFiles[0]; + fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition)); } } } } - else if (node.kind === 215 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An AmbientExternalModuleDeclaration declares an external module. - // This type of declaration is permitted only in the global module. - // The StringLiteral must specify a top - level external module name. - // Relative external module names are not permitted - ts.forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportEqualsDeclaration(node) && - ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8 /* StringLiteral */) { - var nameLiteral = ts.getExternalModuleImportEqualsDeclarationExpression(node); - var moduleName = nameLiteral.text; - if (moduleName) { - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); - ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, nameLiteral); }); - } - } - }); - } - }); + } + else { + // no imports - drop cached module resolutions + file.resolvedModules = undefined; + } + return; function findModuleSourceFile(fileName, nameLiteral) { - return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); + return findSourceFile(fileName, /* isDefaultLib */ false, file, ts.skipTrivia(file.text, nameLiteral.pos), nameLiteral.end); } } function computeCommonSourceDirectory(sourceFiles) { @@ -34621,7 +36043,7 @@ var ts; for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { if (commonPathComponents[i] !== sourcePathComponents[i]) { if (i === 0) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); return; } // New common path found that is 0 -> i-1 @@ -34646,7 +36068,7 @@ var ts; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); allFilesBelongToPath = false; } } @@ -34656,72 +36078,76 @@ var ts; } function verifyCompilerOptions() { if (options.isolatedModules) { - if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules)); - } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); } if (options.noEmitOnError) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); } if (options.out) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); } } if (options.inlineSourceMap) { if (options.sourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); } if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); } } if (options.inlineSources) { if (!options.sourceMap && !options.inlineSourceMap) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); } } + if (options.out && options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { // Error to specify --mapRoot or --sourceRoot without mapSourceFiles if (options.mapRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } if (options.sourceRoot) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); } return; } var languageVersion = options.target || 0 /* ES3 */; + var outFile = options.outFile || options.out; var firstExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); if (options.isolatedModules) { if (!options.module && languageVersion < 2 /* ES6 */) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); } var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - diagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); + programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && !options.module) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); + programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } // Cannot specify module gen target when in es6 or above if (options.module && languageVersion >= 2 /* ES6 */) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); } // there has to be common source directory if user specified --outdir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted if (options.outDir || options.sourceRoot || (options.mapRoot && - (!options.out || firstExternalModuleSourceFile !== undefined))) { + (!outFile || firstExternalModuleSourceFile !== undefined))) { if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory()); @@ -34738,20 +36164,26 @@ var ts; } } if (options.noEmit) { - if (options.out || options.outDir) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir)); + if (options.out) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + if (options.outDir) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); } if (options.declaration) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); } } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.experimentalAsyncFunctions && options.target !== 2 /* ES6 */) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); } } } @@ -34789,6 +36221,11 @@ var ts; type: "boolean", description: ts.Diagnostics.Print_this_message }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + }, { name: "inlineSourceMap", type: "boolean" @@ -34879,6 +36316,13 @@ var ts; { name: "out", type: "string", + isFilePath: false, + // for correct behaviour, please use outFile + paramType: ts.Diagnostics.FILE + }, + { + name: "outFile", + type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: ts.Diagnostics.FILE @@ -34931,6 +36375,12 @@ var ts; description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, paramType: ts.Diagnostics.LOCATION }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", @@ -34977,20 +36427,40 @@ var ts; type: "boolean", experimental: true, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: { + "node": 2 /* NodeJs */, + "classic": 1 /* Classic */ + }, + description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic } ]; - function parseCommandLine(commandLine) { - var options = {}; - var fileNames = []; - var errors = []; - var shortOptionNames = {}; + var optionNameMapCache; + /* @internal */ + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } var optionNameMap = {}; + var shortOptionNames = {}; ts.forEach(ts.optionDeclarations, function (option) { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { shortOptionNames[option.shortName] = option.name; } }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function parseCommandLine(commandLine, readFile) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; parseStrings(commandLine); return { options: options, @@ -35048,7 +36518,7 @@ var ts; } } function parseResponseFile(fileName) { - var text = ts.sys.readFile(fileName); + var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); if (!text) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); return; @@ -35087,10 +36557,10 @@ var ts; * Read tsconfig.json file * @param fileName The path to the config file */ - function readConfigFile(fileName) { - var text = ''; + function readConfigFile(fileName, readFile) { + var text = ""; try { - text = ts.sys.readFile(fileName); + text = readFile(fileName); } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; @@ -35172,6 +36642,9 @@ var ts; if (json["files"] instanceof Array) { fileNames = ts.map(json["files"], function (s) { return ts.combinePaths(basePath, s); }); } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } } else { var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; @@ -35250,7 +36723,7 @@ var ts; } else if (currentComment.kind === 3 /* MultiLineCommentTrivia */) { combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); - addOutliningSpanComments(currentComment, false); + addOutliningSpanComments(currentComment, /*autoCollapse*/ false); singleLineCommentCount = 0; lastSingleLineCommentEnd = -1; isFirstSingleLineComment = true; @@ -35267,11 +36740,11 @@ var ts; end: end, kind: 2 /* SingleLineCommentTrivia */ }; - addOutliningSpanComments(multipleSingleLineComments, false); + addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false); } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 171 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 172 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -35283,34 +36756,34 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 189 /* Block */: + case 190 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_8 = n.parent; - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + var parent_7 = n.parent; + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_8.kind === 194 /* DoStatement */ || - parent_8.kind === 197 /* ForInStatement */ || - parent_8.kind === 198 /* ForOfStatement */ || - parent_8.kind === 196 /* ForStatement */ || - parent_8.kind === 193 /* IfStatement */ || - parent_8.kind === 195 /* WhileStatement */ || - parent_8.kind === 202 /* WithStatement */ || - parent_8.kind === 241 /* CatchClause */) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + if (parent_7.kind === 195 /* DoStatement */ || + parent_7.kind === 198 /* ForInStatement */ || + parent_7.kind === 199 /* ForOfStatement */ || + parent_7.kind === 197 /* ForStatement */ || + parent_7.kind === 194 /* IfStatement */ || + parent_7.kind === 196 /* WhileStatement */ || + parent_7.kind === 203 /* WithStatement */ || + parent_7.kind === 242 /* CatchClause */) { + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_8.kind === 206 /* TryStatement */) { + if (parent_7.kind === 207 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_8; + var tryStatement = parent_7; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_7, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -35329,25 +36802,25 @@ var ts; break; } // Fallthrough. - case 216 /* ModuleBlock */: { - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + case 217 /* ModuleBlock */: { + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 162 /* ObjectLiteralExpression */: - case 217 /* CaseBlock */: { - var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 163 /* ObjectLiteralExpression */: + case 218 /* CaseBlock */: { + var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 161 /* ArrayLiteralExpression */: - var openBracket = ts.findChildOfKind(n, 18 /* OpenBracketToken */, sourceFile); - var closeBracket = ts.findChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); + case 162 /* ArrayLiteralExpression */: + var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -35422,9 +36895,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 8 /* StringLiteral */ || - node.kind === 7 /* NumericLiteral */) { + if (node.kind === 67 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || + node.kind === 8 /* NumericLiteral */) { return node.text; } } @@ -35436,8 +36909,8 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 133 /* ComputedPropertyName */) { - return tryAddComputedPropertyName(declaration.name.expression, containers, true); + else if (declaration.name.kind === 134 /* ComputedPropertyName */) { + return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ true); } else { // Don't know how to add this. @@ -35457,12 +36930,12 @@ var ts; } return true; } - if (expression.kind === 163 /* PropertyAccessExpression */) { + if (expression.kind === 164 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); } - return tryAddComputedPropertyName(propertyAccess.expression, containers, true); + return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion:*/ true); } return false; } @@ -35470,8 +36943,8 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 133 /* ComputedPropertyName */) { - if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { + if (declaration.name.kind === 134 /* ComputedPropertyName */) { + if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion:*/ false)) { return undefined; } } @@ -35546,17 +37019,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: // If we have a module declared as A.B.C, it is more "intuitive" // to say it only has a single layer of depth do { current = current.parent; - } while (current.kind === 215 /* ModuleDeclaration */); + } while (current.kind === 216 /* ModuleDeclaration */); // fall through - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -35567,21 +37040,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -35593,7 +37066,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -35602,21 +37075,21 @@ var ts; } } break; - case 160 /* BindingElement */: - case 208 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 209 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: - case 215 /* ModuleDeclaration */: - case 210 /* FunctionDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 227 /* ExportSpecifier */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: + case 216 /* ModuleDeclaration */: + case 211 /* FunctionDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 228 /* ExportSpecifier */: childNodes.push(node); break; } @@ -35664,17 +37137,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 213 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -35685,12 +37158,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 210 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 211 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 189 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 190 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 210 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 211 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -35750,7 +37223,7 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 135 /* Parameter */: + case 136 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } @@ -35758,36 +37231,36 @@ var ts; return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 142 /* GetAccessor */: + case 143 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 143 /* SetAccessor */: + case 144 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 146 /* IndexSignature */: + case 147 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 244 /* EnumMember */: + case 245 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 144 /* CallSignature */: + case 145 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 145 /* ConstructSignature */: + case 146 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: var variableDeclarationNode; var name_29; - if (node.kind === 160 /* BindingElement */) { + if (node.kind === 161 /* BindingElement */) { name_29 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 208 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 209 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -35806,13 +37279,13 @@ var ts; else { return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); } - case 141 /* Constructor */: + case 142 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 227 /* ExportSpecifier */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: + case 228 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -35842,29 +37315,29 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 245 /* SourceFile */: + case 246 /* SourceFile */: return createSourceFileItem(node); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: return createClassItem(node); - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: return createEnumItem(node); - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: return createModuleItem(node); - case 210 /* FunctionDeclaration */: + case 211 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; function getModuleName(moduleDeclaration) { // We want to maintain quotation marks. - if (moduleDeclaration.name.kind === 8 /* StringLiteral */) { + if (moduleDeclaration.name.kind === 9 /* StringLiteral */) { return getTextOfNode(moduleDeclaration.name); } // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 215 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 216 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -35876,7 +37349,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.body && node.body.kind === 189 /* Block */) { + if (node.body && node.body.kind === 190 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -35897,7 +37370,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 141 /* Constructor */ && member; + return member.kind === 142 /* 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 @@ -35921,7 +37394,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 133 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 134 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -35930,13 +37403,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 215 /* ModuleDeclaration */) { + while (node.body.kind === 216 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 245 /* SourceFile */ + return node.kind === 246 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -36039,12 +37512,12 @@ var ts; if (chunk.text.length === candidate.length) { // a) Check if the part matches the candidate entirely, in an case insensitive or // sensitive manner. If it does, return that there was an exact match. - return createPatternMatch(PatternMatchKind.exact, punctuationStripped, candidate === chunk.text); + return createPatternMatch(PatternMatchKind.exact, punctuationStripped, /*isCaseSensitive:*/ candidate === chunk.text); } else { // b) Check if the part is a prefix of the candidate, in a case insensitive or sensitive // manner. If it does, return that there was a prefix match. - return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, startsWith(candidate, chunk.text)); + return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, /*isCaseSensitive:*/ startsWith(candidate, chunk.text)); } } var isLowercase = chunk.isLowerCase; @@ -36060,9 +37533,9 @@ var ts; var wordSpans = getWordSpans(candidate); for (var _i = 0; _i < wordSpans.length; _i++) { var span = wordSpans[_i]; - if (partStartsWith(candidate, span, chunk.text, true)) { + if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) { return createPatternMatch(PatternMatchKind.substring, punctuationStripped, - /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, false)); + /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false)); } } } @@ -36072,20 +37545,20 @@ var ts; // candidate in a case *sensitive* manner. If so, return that there was a substring // match. if (candidate.indexOf(chunk.text) > 0) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, true); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ true); } } if (!isLowercase) { // e) If the part was not entirely lowercase, then attempt a camel cased match as well. if (chunk.characterSpans.length > 0) { var candidateParts = getWordSpans(candidate); - var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, false); + var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false); if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, true, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ true, /*camelCaseWeight:*/ camelCaseWeight); } - camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, true); + camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ true); if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, false, camelCaseWeight); + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ false, /*camelCaseWeight:*/ camelCaseWeight); } } } @@ -36098,7 +37571,7 @@ var ts; // (Pattern: fogbar, Candidate: quuxfogbarFogBar). if (chunk.text.length < candidate.length) { if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, false); + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ false); } } } @@ -36122,7 +37595,7 @@ var ts; // Note: if the segment contains a space or an asterisk then we must assume that it's a // multi-word segment. if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) { - var match = matchTextChunk(candidate, segment.totalTextChunk, false); + var match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false); if (match) { return [match]; } @@ -36168,7 +37641,7 @@ var ts; for (var _i = 0; _i < subWordTextChunks.length; _i++) { var subWordTextChunk = subWordTextChunks[_i]; // Try to match the candidate with this word - var result = matchTextChunk(candidate, subWordTextChunk, true); + var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true); if (!result) { return undefined; } @@ -36434,11 +37907,11 @@ var ts; }; } /* @internal */ function breakIntoCharacterSpans(identifier) { - return breakIntoSpans(identifier, false); + return breakIntoSpans(identifier, /*word:*/ false); } ts.breakIntoCharacterSpans = breakIntoCharacterSpans; /* @internal */ function breakIntoWordSpans(identifier) { - return breakIntoSpans(identifier, true); + return breakIntoSpans(identifier, /*word:*/ true); } ts.breakIntoWordSpans = breakIntoWordSpans; function breakIntoSpans(identifier, word) { @@ -36731,15 +38204,15 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 165 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 166 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 66 /* Identifier */ + var name = expression.kind === 67 /* Identifier */ ? expression - : expression.kind === 163 /* PropertyAccessExpression */ + : expression.kind === 164 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -36772,7 +38245,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 165 /* CallExpression */ || node.parent.kind === 166 /* NewExpression */) { + if (node.parent.kind === 166 /* CallExpression */ || node.parent.kind === 167 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -36788,8 +38261,8 @@ var ts; // Case 3: // foo(a#, #b#) -> The token is buried inside a list, and should give sig help // Find out if 'node' is an argument, a type argument, or neither - if (node.kind === 24 /* LessThanToken */ || - node.kind === 16 /* OpenParenToken */) { + if (node.kind === 25 /* LessThanToken */ || + node.kind === 17 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); @@ -36825,27 +38298,27 @@ var ts; }; } } - else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 168 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { - return getArgumentListInfoForTemplate(node.parent, 0); + return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); } } - else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 168 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 187 /* TemplateSpan */ && node.parent.parent.parent.kind === 167 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 188 /* TemplateSpan */ && node.parent.parent.parent.kind === 168 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 180 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 181 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. - if (node.kind === 13 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -36873,7 +38346,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 23 /* CommaToken */) { + if (child.kind !== 24 /* CommaToken */) { argumentIndex++; } } @@ -36892,8 +38365,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, givin us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 23 /* CommaToken */; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 23 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24 /* CommaToken */; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24 /* CommaToken */) { argumentCount++; } return argumentCount; @@ -36923,7 +38396,7 @@ var ts; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex) { // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. - var argumentCount = tagExpression.template.kind === 10 /* NoSubstitutionTemplateLiteral */ + var argumentCount = tagExpression.template.kind === 11 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -36945,7 +38418,7 @@ var ts; // The applicable span is from the first bar to the second bar (inclusive, // but not including parentheses) var applicableSpanStart = argumentsList.getFullStart(); - var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), false); + var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), /*stopAfterLineBreak*/ false); return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getApplicableSpanForTaggedTemplate(taggedTemplate) { @@ -36961,16 +38434,16 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 180 /* TemplateExpression */) { + if (template.kind === 181 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { - applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); + applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); } } return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 245 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 246 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -37021,7 +38494,7 @@ var ts; var invocation = argumentListInfo.invocation; var callTarget = ts.getInvokedExpression(invocation); var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); - var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, undefined, undefined); + var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); var items = ts.map(candidates, function (candidateSignature) { var signatureHelpParameters; var prefixDisplayParts = []; @@ -37030,10 +38503,10 @@ var ts; ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(24 /* LessThanToken */)); + prefixDisplayParts.push(ts.punctuationPart(25 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(26 /* GreaterThanToken */)); + suffixDisplayParts.push(ts.punctuationPart(27 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); }); @@ -37044,10 +38517,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + prefixDisplayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + suffixDisplayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -37057,7 +38530,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(23 /* CommaToken */), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(24 /* CommaToken */), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -37081,12 +38554,11 @@ var ts; var displayParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); }); - var isOptional = ts.hasQuestionToken(parameter.valueDeclaration); return { name: parameter.name, documentation: parameter.getDocumentationComment(), displayParts: displayParts, - isOptional: isOptional + isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) }; } function createSignatureHelpParameterForTypeParameter(typeParameter) { @@ -37171,40 +38643,40 @@ var ts; return false; } switch (n.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 162 /* ObjectLiteralExpression */: - case 158 /* ObjectBindingPattern */: - case 152 /* TypeLiteral */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 217 /* CaseBlock */: - return nodeEndsWith(n, 15 /* CloseBraceToken */, sourceFile); - case 241 /* CatchClause */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 163 /* ObjectLiteralExpression */: + case 159 /* ObjectBindingPattern */: + case 153 /* TypeLiteral */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 218 /* CaseBlock */: + return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); + case 242 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 166 /* NewExpression */: + case 167 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 165 /* CallExpression */: - case 169 /* ParenthesizedExpression */: - case 157 /* ParenthesizedType */: - return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); - case 149 /* FunctionType */: - case 150 /* ConstructorType */: + case 166 /* CallExpression */: + case 170 /* ParenthesizedExpression */: + case 158 /* ParenthesizedType */: + return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); + case 150 /* FunctionType */: + case 151 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 145 /* ConstructSignature */: - case 144 /* CallSignature */: - case 171 /* ArrowFunction */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 146 /* ConstructSignature */: + case 145 /* CallSignature */: + case 172 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -37213,64 +38685,64 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 17 /* CloseParenToken */, sourceFile); - case 215 /* ModuleDeclaration */: + return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile); + case 216 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 193 /* IfStatement */: + case 194 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile); - case 161 /* ArrayLiteralExpression */: - case 159 /* ArrayBindingPattern */: - case 164 /* ElementAccessExpression */: - case 133 /* ComputedPropertyName */: - case 154 /* TupleType */: - return nodeEndsWith(n, 19 /* CloseBracketToken */, sourceFile); - case 146 /* IndexSignature */: + case 162 /* ArrayLiteralExpression */: + case 160 /* ArrayBindingPattern */: + case 165 /* ElementAccessExpression */: + case 134 /* ComputedPropertyName */: + case 155 /* TupleType */: + return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); + case 147 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + case 239 /* CaseClause */: + case 240 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 194 /* DoStatement */: + case 195 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - var hasWhileKeyword = findChildOfKind(n, 101 /* WhileKeyword */, sourceFile); + var hasWhileKeyword = findChildOfKind(n, 102 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); + return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 151 /* TypeQuery */: + case 152 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 173 /* TypeOfExpression */: - case 172 /* DeleteExpression */: - case 174 /* VoidExpression */: - case 181 /* YieldExpression */: - case 182 /* SpreadElementExpression */: + case 174 /* TypeOfExpression */: + case 173 /* DeleteExpression */: + case 175 /* VoidExpression */: + case 182 /* YieldExpression */: + case 183 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 167 /* TaggedTemplateExpression */: + case 168 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 180 /* TemplateExpression */: + case 181 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 187 /* TemplateSpan */: + case 188 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 176 /* PrefixUnaryExpression */: + case 177 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 178 /* BinaryExpression */: + case 179 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 179 /* ConditionalExpression */: + case 180 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -37288,7 +38760,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 22 /* SemicolonToken */ && children.length !== 1) { + else if (last.kind === 23 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -37326,7 +38798,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 268 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 269 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -37351,12 +38823,12 @@ var ts; ts.getTouchingPropertyName = getTouchingPropertyName; /** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */ function getTouchingToken(sourceFile, position, includeItemAtEndPosition) { - return getTokenAtPositionWorker(sourceFile, position, false, includeItemAtEndPosition); + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includeItemAtEndPosition); } ts.getTouchingToken = getTouchingToken; /** Returns a token if position is in [start-of-leading-trivia, end) */ function getTokenAtPosition(sourceFile, position) { - return getTokenAtPositionWorker(sourceFile, position, true, undefined); + return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includeItemAtEndPosition*/ undefined); } ts.getTokenAtPosition = getTokenAtPosition; /** Get the token whose text contains the position */ @@ -37432,41 +38904,50 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n)) { + if (isToken(n) || n.kind === 234 /* JsxText */) { return n; } var children = n.getChildren(); - var candidate = findRightmostChildNodeWithTokens(children, children.length); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n)) { + if (isToken(n) || n.kind === 234 /* JsxText */) { return n; } var children = n.getChildren(); for (var i = 0, len = children.length; i < len; i++) { var child = children[i]; - if (nodeHasTokens(child)) { - if (position <= child.end) { - if (child.getStart(sourceFile) >= position) { - // actual start of the node is past the position - previous token should be at the end of previous child - var candidate = findRightmostChildNodeWithTokens(children, i); - return candidate && findRightmostToken(candidate); - } - else { - // candidate should be in this node - return find(child); - } + // condition 'position < child.end' checks if child node end after the position + // in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc' + // aaaa___bbbb___$__ccc + // after we found child node with end after the position we check if start of the node is after the position. + // if yes - then position is in the trivia and we need to look into the previous child to find the token in question. + // if no - position is in the node itself so we should recurse in it. + // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia). + // if this is the case - then we should assume that token in question is located in previous child. + if (position < child.end && (nodeHasTokens(child) || child.kind === 234 /* JsxText */)) { + var start = child.getStart(sourceFile); + var lookInPreviousChild = (start >= position) || + (child.kind === 234 /* JsxText */ && start === child.end); // whitespace only JsxText + if (lookInPreviousChild) { + // actual start of the node is past the position - previous token should be at the end of previous child + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); + return candidate && findRightmostToken(candidate); + } + else { + // candidate should be in this node + return find(child); } } } - ts.Debug.assert(startNode !== undefined || n.kind === 245 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 246 /* SourceFile */); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. // Namely we are skipping the check: 'position < node.end' if (children.length) { - var candidate = findRightmostChildNodeWithTokens(children, children.length); + var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); return candidate && findRightmostToken(candidate); } } @@ -37480,6 +38961,86 @@ var ts; } } ts.findPrecedingToken = findPrecedingToken; + function isInString(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + return token && token.kind === 9 /* StringLiteral */ && position > token.getStart(); + } + ts.isInString = isInString; + function isInComment(sourceFile, position) { + return isInCommentHelper(sourceFile, position, /*predicate*/ undefined); + } + ts.isInComment = isInComment; + /** + * Returns true if the cursor at position in sourceFile is within a comment that additionally + * satisfies predicate, and false otherwise. + */ + function isInCommentHelper(sourceFile, position, predicate) { + var token = getTokenAtPosition(sourceFile, position); + if (token && position <= token.getStart()) { + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + // The end marker of a single-line comment does not include the newline character. + // In the following case, we are inside a comment (^ denotes the cursor position): + // + // // asdf ^\n + // + // But for multi-line comments, we don't want to be inside the comment in the following case: + // + // /* asdf */^ + // + // Internally, we represent the end of the comment at the newline and closing '/', respectively. + return predicate ? + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end) && + predicate(c); }) : + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end); }); + } + return false; + } + ts.isInCommentHelper = isInCommentHelper; + function hasDocComment(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + // First, we have to see if this position actually landed in a comment. + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return ts.forEach(commentRanges, jsDocPrefix); + function jsDocPrefix(c) { + var text = sourceFile.text; + return text.length >= c.pos + 3 && text[c.pos] === '/' && text[c.pos + 1] === '*' && text[c.pos + 2] === '*'; + } + } + ts.hasDocComment = hasDocComment; + /** + * Get the corresponding JSDocTag node if the position is in a jsDoc comment + */ + function getJsDocTagAtPosition(sourceFile, position) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (isToken(node)) { + switch (node.kind) { + case 100 /* VarKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + // if the current token is var, let or const, skip the VariableDeclarationList + node = node.parent === undefined ? undefined : node.parent.parent; + break; + default: + node = node.parent; + break; + } + } + if (node) { + var jsDocComment = node.jsDocComment; + if (jsDocComment) { + for (var _i = 0, _a = jsDocComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.pos <= position && position <= tag.end) { + return tag; + } + } + } + } + return undefined; + } + ts.getJsDocTagAtPosition = getJsDocTagAtPosition; function nodeHasTokens(n) { // If we have a token or node that has a non-zero width, it must have tokens. // Note, that getWidth() does not take trivia into account. @@ -37506,32 +39067,32 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 148 /* TypeReference */ || node.kind === 165 /* CallExpression */) { + if (node.kind === 149 /* TypeReference */ || node.kind === 166 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 211 /* ClassDeclaration */ || node.kind === 212 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 212 /* ClassDeclaration */ || node.kind === 213 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 131 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 132 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 66 /* Identifier */ || ts.isKeyword(kind); + return kind === 67 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { - return kind === 8 /* StringLiteral */ || kind === 7 /* NumericLiteral */ || isWord(kind); + return kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ || isWord(kind); } function isComment(kind) { return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; } ts.isComment = isComment; function isPunctuation(kind) { - return 14 /* FirstPunctuation */ <= kind && kind <= 65 /* LastPunctuation */; + return 15 /* FirstPunctuation */ <= kind && kind <= 66 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -37541,9 +39102,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: return true; } return false; @@ -37571,7 +39132,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 135 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 136 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -37706,6 +39267,14 @@ var ts; return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; + var carriageReturnLineFeed = "\r\n"; + /** + * The default is CRLF. + */ + function getNewLineOrDefaultFromHost(host) { + return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + } + ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; function lineBreakPart() { return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); } @@ -37750,7 +39319,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 223 /* ImportSpecifier */ || location.parent.kind === 227 /* ExportSpecifier */) && + (location.parent.kind === 224 /* ImportSpecifier */ || location.parent.kind === 228 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -37778,13 +39347,14 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var scanner = ts.createScanner(2 /* Latest */, false); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; ScanAction[ScanAction["RescanGreaterThanToken"] = 1] = "RescanGreaterThanToken"; ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken"; ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken"; + ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { scanner.setText(sourceFile.text); @@ -37848,25 +39418,37 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 28 /* GreaterThanEqualsToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 42 /* GreaterThanGreaterThanToken */: + case 29 /* GreaterThanEqualsToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 43 /* GreaterThanGreaterThanToken */: return true; } } return false; } + function shouldRescanJsxIdentifier(node) { + if (node.parent) { + switch (node.parent.kind) { + case 236 /* JsxAttribute */: + case 233 /* JsxOpeningElement */: + case 235 /* JsxClosingElement */: + case 232 /* JsxSelfClosingElement */: + return node.kind === 67 /* Identifier */; + } + } + return false; + } function shouldRescanSlashToken(container) { - return container.kind === 9 /* RegularExpressionLiteral */; + return container.kind === 10 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 12 /* TemplateMiddle */ || - container.kind === 13 /* TemplateTail */; + return container.kind === 13 /* TemplateMiddle */ || + container.kind === 14 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 37 /* SlashToken */ || t === 58 /* SlashEqualsToken */; + return t === 38 /* SlashToken */ || t === 59 /* SlashEqualsToken */; } function readTokenInfo(n) { if (!isOnToken()) { @@ -37885,7 +39467,9 @@ var ts; ? 2 /* RescanSlashToken */ : shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ - : 0 /* Scan */; + : shouldRescanJsxIdentifier(n) + ? 4 /* RescanJsxIdentifier */ + : 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -37902,7 +39486,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 26 /* GreaterThanToken */) { + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 27 /* GreaterThanToken */) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1 /* RescanGreaterThanToken */; @@ -37912,10 +39496,14 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2 /* RescanSlashToken */; } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 15 /* CloseBraceToken */) { + else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 16 /* CloseBraceToken */) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } + else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 67 /* Identifier */) { + currentToken = scanner.scanJsxIdentifier(); + lastScanAction = 4 /* RescanJsxIdentifier */; + } else { lastScanAction = 0 /* Scan */; } @@ -38041,8 +39629,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 14 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 15 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 15 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 16 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -38233,112 +39821,116 @@ var ts; this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1 /* Ignore */)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2 /* SingleLineCommentTrivia */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1 /* Ignore */)); // Space after keyword but not before ; or : or ? - this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Space after }. - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 77 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 101 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 19 /* CloseBracketToken */, 23 /* CommaToken */, 22 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - // No space for indexer and dot - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 78 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 102 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // No space for dot + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // No space before and after indexer + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); // Place a space before open brace in a function declaration this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; - this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([66 /* Identifier */, 3 /* MultiLineCommentTrivia */]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 3 /* MultiLineCommentTrivia */, 71 /* ClassKeyword */]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 76 /* DoKeyword */, 97 /* TryKeyword */, 82 /* FinallyKeyword */, 77 /* ElseKeyword */]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 77 /* DoKeyword */, 98 /* TryKeyword */, 83 /* FinallyKeyword */, 78 /* ElseKeyword */]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* OpenBraceToken */, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); // Insert new line after { and before } in multi-line contexts. - this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // For functions and control block place } on a new line [multi-line rule] - this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(39 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 39 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 40 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(39 /* PlusPlusToken */, 34 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* PlusToken */, 34 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* PlusToken */, 39 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* MinusMinusToken */, 35 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* MinusToken */, 35 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* MinusToken */, 40 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([99 /* VarKeyword */, 95 /* ThrowKeyword */, 89 /* NewKeyword */, 75 /* DeleteKeyword */, 91 /* ReturnKeyword */, 98 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105 /* LetKeyword */, 71 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(84 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(100 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(91 /* ReturnKeyword */, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 40 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */, 117 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106 /* LetKeyword */, 72 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(101 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(92 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 76 /* DoKeyword */, 77 /* ElseKeyword */, 68 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 77 /* DoKeyword */, 78 /* ElseKeyword */, 69 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([97 /* TryKeyword */, 82 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([98 /* TryKeyword */, 83 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([120 /* GetKeyword */, 126 /* SetKeyword */]), 66 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([121 /* GetKeyword */, 127 /* SetKeyword */]), 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); // TypeScript-specific higher priority rules // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([122 /* ModuleKeyword */, 124 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* ModuleKeyword */, 125 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* AbstractKeyword */, 70 /* ClassKeyword */, 119 /* DeclareKeyword */, 74 /* DefaultKeyword */, 78 /* EnumKeyword */, 79 /* ExportKeyword */, 80 /* ExtendsKeyword */, 120 /* GetKeyword */, 103 /* ImplementsKeyword */, 86 /* ImportKeyword */, 104 /* InterfaceKeyword */, 122 /* ModuleKeyword */, 123 /* NamespaceKeyword */, 107 /* PrivateKeyword */, 109 /* PublicKeyword */, 108 /* ProtectedKeyword */, 126 /* SetKeyword */, 110 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([80 /* ExtendsKeyword */, 103 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */, 130 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81 /* ExtendsKeyword */, 104 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8 /* StringLiteral */, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(33 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21 /* DotDotDotToken */, 66 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - // generics - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseParenToken */, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* LessThanToken */, formatting.Shared.TokenRange.TypeNames), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 26 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([16 /* OpenParenToken */, 18 /* OpenBracketToken */, 26 /* GreaterThanToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 67 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + // generics and type assertions + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([17 /* OpenParenToken */, 19 /* OpenBracketToken */, 27 /* GreaterThanToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); // Remove spaces in empty interface literals. e.g.: x: {} - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* OpenBraceToken */, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([112 /* AbstractKeyword */, 66 /* Identifier */, 79 /* ExportKeyword */, 74 /* DefaultKeyword */, 70 /* ClassKeyword */, 110 /* StaticKeyword */, 109 /* PublicKeyword */, 107 /* PrivateKeyword */, 108 /* ProtectedKeyword */, 120 /* GetKeyword */, 126 /* SetKeyword */, 18 /* OpenBracketToken */, 36 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 36 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(36 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(111 /* YieldKeyword */, 36 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([111 /* YieldKeyword */, 36 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 67 /* Identifier */, 80 /* ExportKeyword */, 75 /* DefaultKeyword */, 71 /* ClassKeyword */, 111 /* StaticKeyword */, 110 /* PublicKeyword */, 108 /* PrivateKeyword */, 109 /* ProtectedKeyword */, 121 /* GetKeyword */, 127 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + // Async-await + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + // template string + this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -38365,6 +39957,8 @@ var ts; this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, + this.SpaceBetweenAsyncAndFunctionKeyword, + this.SpaceBetweenTagAndTemplateString, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, @@ -38378,6 +39972,7 @@ var ts; this.NoSpaceAfterOpenAngularBracket, this.NoSpaceBeforeCloseAngularBracket, this.NoSpaceAfterCloseAngularBracket, + this.NoSpaceAfterTypeAssertion, this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, @@ -38388,8 +39983,8 @@ var ts; this.NoSpaceBeforeSemicolon, this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, this.NoSpaceBeforeComma, - this.NoSpaceBeforeOpenBracket, this.NoSpaceAfterOpenBracket, - this.NoSpaceBeforeCloseBracket, this.NoSpaceAfterCloseBracket, + this.NoSpaceBeforeOpenBracket, + this.NoSpaceAfterCloseBracket, this.SpaceAfterSemicolon, this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally @@ -38398,35 +39993,41 @@ var ts; /// Rules controlled by user options /// // Insert space after comma delimiter - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space before and after binary operators this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); // Insert space after keywords in control flow statements - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); // Open Brace braces after function //TypeScript: Function can have return types, which can be made of tons of different token kinds - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after TypeScript module/class/interface - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after control block - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Insert space after semicolon in for statement - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); // Insert space after opening and before closing nonempty parenthesis - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenParenToken */, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenParenToken */, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + // Insert space after opening and before closing nonempty brackets + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenBracketToken */, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(85 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -38441,38 +40042,40 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 196 /* ForStatement */; + return context.contextNode.kind === 197 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 178 /* BinaryExpression */: - case 179 /* ConditionalExpression */: - case 186 /* AsExpression */: - case 147 /* TypePredicate */: + case 179 /* BinaryExpression */: + case 180 /* ConditionalExpression */: + case 187 /* AsExpression */: + case 148 /* TypePredicate */: + case 156 /* UnionType */: + case 157 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 160 /* BindingElement */: + case 161 /* BindingElement */: // equals in type X = ... - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: // equal in p = 0; - case 135 /* Parameter */: - case 244 /* EnumMember */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - return context.currentTokenSpan.kind === 54 /* EqualsToken */ || context.nextTokenSpan.kind === 54 /* EqualsToken */; + case 136 /* Parameter */: + case 245 /* EnumMember */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + return context.currentTokenSpan.kind === 55 /* EqualsToken */ || context.nextTokenSpan.kind === 55 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 197 /* ForInStatement */: - return context.currentTokenSpan.kind === 87 /* InKeyword */ || context.nextTokenSpan.kind === 87 /* InKeyword */; + case 198 /* ForInStatement */: + return context.currentTokenSpan.kind === 88 /* InKeyword */ || context.nextTokenSpan.kind === 88 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 198 /* ForOfStatement */: - return context.currentTokenSpan.kind === 131 /* OfKeyword */ || context.nextTokenSpan.kind === 131 /* OfKeyword */; + case 199 /* ForOfStatement */: + return context.currentTokenSpan.kind === 132 /* OfKeyword */ || context.nextTokenSpan.kind === 132 /* OfKeyword */; } return false; }; @@ -38480,7 +40083,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 179 /* ConditionalExpression */; + return context.contextNode.kind === 180 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -38524,98 +40127,99 @@ var ts; return true; } switch (node.kind) { - case 189 /* Block */: - case 217 /* CaseBlock */: - case 162 /* ObjectLiteralExpression */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 218 /* CaseBlock */: + case 163 /* ObjectLiteralExpression */: + case 217 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 144 /* CallSignature */: - case 170 /* FunctionExpression */: - case 141 /* Constructor */: - case 171 /* ArrowFunction */: + case 145 /* CallSignature */: + case 171 /* FunctionExpression */: + case 142 /* Constructor */: + case 172 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 210 /* FunctionDeclaration */ || context.contextNode.kind === 170 /* FunctionExpression */; + return context.contextNode.kind === 211 /* FunctionDeclaration */ || context.contextNode.kind === 171 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 152 /* TypeLiteral */: - case 215 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 153 /* TypeLiteral */: + case 216 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 211 /* ClassDeclaration */: - case 215 /* ModuleDeclaration */: - case 214 /* EnumDeclaration */: - case 189 /* Block */: - case 241 /* CatchClause */: - case 216 /* ModuleBlock */: - case 203 /* SwitchStatement */: + case 212 /* ClassDeclaration */: + case 216 /* ModuleDeclaration */: + case 215 /* EnumDeclaration */: + case 190 /* Block */: + case 242 /* CatchClause */: + case 217 /* ModuleBlock */: + case 204 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 193 /* IfStatement */: - case 203 /* SwitchStatement */: - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: - case 206 /* TryStatement */: - case 194 /* DoStatement */: - case 202 /* WithStatement */: + case 194 /* IfStatement */: + case 204 /* SwitchStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 207 /* TryStatement */: + case 195 /* DoStatement */: + case 203 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 241 /* CatchClause */: + case 242 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 162 /* ObjectLiteralExpression */; + return context.contextNode.kind === 163 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 165 /* CallExpression */; + return context.contextNode.kind === 166 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 166 /* NewExpression */; + return context.contextNode.kind === 167 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 23 /* CommaToken */; + return context.currentTokenSpan.kind !== 24 /* CommaToken */; }; Rules.IsSameLineTokenContext = function (context) { return context.TokensAreOnSameLine(); @@ -38633,52 +40237,58 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 136 /* Decorator */; + return node.kind === 137 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 209 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 210 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 215 /* ModuleDeclaration */; + return context.contextNode.kind === 216 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 152 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 153 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; - Rules.IsTypeArgumentOrParameter = function (token, parent) { - if (token.kind !== 24 /* LessThanToken */ && token.kind !== 26 /* GreaterThanToken */) { + Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { + if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 148 /* TypeReference */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 149 /* TypeReference */: + case 169 /* TypeAssertionExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 186 /* ExpressionWithTypeArguments */: return true; default: return false; } }; - Rules.IsTypeArgumentOrParameterContext = function (context) { - return Rules.IsTypeArgumentOrParameter(context.currentTokenSpan, context.currentTokenParent) || - Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); + Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { + return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || + Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); + }; + Rules.IsTypeAssertionContext = function (context) { + return context.contextNode.kind === 169 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 100 /* VoidKeyword */ && context.currentTokenParent.kind === 174 /* VoidExpression */; + return context.currentTokenSpan.kind === 101 /* VoidKeyword */ && context.currentTokenParent.kind === 175 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 181 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 182 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -38702,7 +40312,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 131 /* LastToken */ + 1; + this.mapRowLength = 132 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); @@ -38897,7 +40507,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 131 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 132 /* LastToken */; token++) { result.push(token); } return result; @@ -38939,17 +40549,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(67 /* FirstKeyword */, 131 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 65 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([87 /* InKeyword */, 88 /* InstanceOfKeyword */, 131 /* OfKeyword */, 113 /* AsKeyword */, 121 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([39 /* PlusPlusToken */, 40 /* MinusMinusToken */, 48 /* TildeToken */, 47 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 66 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 89 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 89 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(68 /* FirstKeyword */, 132 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 66 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([88 /* InKeyword */, 89 /* InstanceOfKeyword */, 132 /* OfKeyword */, 114 /* AsKeyword */, 122 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([40 /* PlusPlusToken */, 41 /* MinusMinusToken */, 49 /* TildeToken */, 48 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 67 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 17 /* OpenParenToken */, 95 /* ThisKeyword */, 90 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([67 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 90 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([66 /* Identifier */, 125 /* NumberKeyword */, 127 /* StringKeyword */, 117 /* BooleanKeyword */, 128 /* SymbolKeyword */, 100 /* VoidKeyword */, 114 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([67 /* Identifier */, 126 /* NumberKeyword */, 128 /* StringKeyword */, 118 /* BooleanKeyword */, 129 /* SymbolKeyword */, 101 /* VoidKeyword */, 115 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -39027,6 +40637,16 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeCloseParen); rules.push(this.globalRules.NoSpaceBetweenParens); } + if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { + rules.push(this.globalRules.SpaceAfterOpenBracket); + rules.push(this.globalRules.SpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBracket); + rules.push(this.globalRules.NoSpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } if (options.InsertSpaceAfterSemicolonInForStatements) { rules.push(this.globalRules.SpaceAfterSemicolonInFor); } @@ -39085,11 +40705,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 22 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); + return formatOutermostParent(position, 23 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 15 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); + return formatOutermostParent(position, 16 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -39153,17 +40773,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 189 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 245 /* SourceFile */: - case 189 /* Block */: - case 216 /* ModuleBlock */: + return body && body.kind === 190 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 246 /* SourceFile */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -39336,9 +40956,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 245 /* SourceFile */ || - parent.kind === 238 /* CaseClause */ || - parent.kind === 239 /* DefaultClause */) { + parent.kind === 246 /* SourceFile */ || + parent.kind === 239 /* CaseClause */ || + parent.kind === 240 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -39374,35 +40994,36 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 211 /* ClassDeclaration */: return 70 /* ClassKeyword */; - case 212 /* InterfaceDeclaration */: return 104 /* InterfaceKeyword */; - case 210 /* FunctionDeclaration */: return 84 /* FunctionKeyword */; - case 214 /* EnumDeclaration */: return 214 /* EnumDeclaration */; - case 142 /* GetAccessor */: return 120 /* GetKeyword */; - case 143 /* SetAccessor */: return 126 /* SetKeyword */; - case 140 /* MethodDeclaration */: + case 212 /* ClassDeclaration */: return 71 /* ClassKeyword */; + case 213 /* InterfaceDeclaration */: return 105 /* InterfaceKeyword */; + case 211 /* FunctionDeclaration */: return 85 /* FunctionKeyword */; + case 215 /* EnumDeclaration */: return 215 /* EnumDeclaration */; + case 143 /* GetAccessor */: return 121 /* GetKeyword */; + case 144 /* SetAccessor */: return 127 /* SetKeyword */; + case 141 /* MethodDeclaration */: if (node.asteriskToken) { - return 36 /* AsteriskToken */; + return 37 /* AsteriskToken */; } // fall-through - case 138 /* PropertyDeclaration */: - case 135 /* Parameter */: + case 139 /* PropertyDeclaration */: + case 136 /* Parameter */: return node.name.kind; } } function getDynamicIndentation(node, nodeStartLine, indentation, delta) { return { - getIndentationForComment: function (kind) { + getIndentationForComment: function (kind, tokenIndentation) { switch (kind) { // preceding comment to the token that closes the indentation scope inherits the indentation from the scope // .. { // // comment // } - case 15 /* CloseBraceToken */: - case 19 /* CloseBracketToken */: + case 16 /* CloseBraceToken */: + case 20 /* CloseBracketToken */: + case 18 /* CloseParenToken */: return indentation + delta; } - return indentation; + return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; }, getIndentationForToken: function (line, kind) { if (nodeStartLine !== line && node.decorators) { @@ -39413,15 +41034,15 @@ var ts; } switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 14 /* OpenBraceToken */: - case 15 /* CloseBraceToken */: - case 18 /* OpenBracketToken */: - case 19 /* CloseBracketToken */: - case 16 /* OpenParenToken */: - case 17 /* CloseParenToken */: - case 77 /* ElseKeyword */: - case 101 /* WhileKeyword */: - case 53 /* AtToken */: + case 15 /* OpenBraceToken */: + case 16 /* CloseBraceToken */: + case 19 /* OpenBracketToken */: + case 20 /* CloseBracketToken */: + case 17 /* OpenParenToken */: + case 18 /* CloseParenToken */: + case 78 /* ElseKeyword */: + case 102 /* WhileKeyword */: + case 54 /* AtToken */: return indentation; default: // if token line equals to the line of containing node (this is a first token in the node) - use node indentation @@ -39468,7 +41089,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, false); + processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListElement*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -39521,7 +41142,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 136 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 137 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -39556,7 +41177,7 @@ var ts; var inheritedIndentation = -1 /* Unknown */; for (var _i = 0; _i < nodes.length; _i++) { var child = nodes[_i]; - inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, true); + inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true); } if (listEndToken !== 0 /* Unknown */) { if (formattingScanner.isOnToken()) { @@ -39604,8 +41225,12 @@ var ts; processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation); } if (indentToken) { - var indentNextTokenOrTrivia = true; + var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) : + -1 /* Unknown */; if (currentTokenInfo.leadingTrivia) { + var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation); + var indentNextTokenOrTrivia = true; for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) { var triviaItem = _a[_i]; if (!ts.rangeContainsRange(originalRange, triviaItem)) { @@ -39613,14 +41238,12 @@ var ts; } switch (triviaItem.kind) { case 3 /* MultiLineCommentTrivia */: - var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - indentMultilineComment(triviaItem, commentIndentation, !indentNextTokenOrTrivia); + indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); indentNextTokenOrTrivia = false; break; case 2 /* SingleLineCommentTrivia */: if (indentNextTokenOrTrivia) { - var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); - insertIndentation(triviaItem.pos, commentIndentation_1, false); + insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false); indentNextTokenOrTrivia = false; } break; @@ -39631,8 +41254,7 @@ var ts; } } // indent token only if is it is in target range and does not overlap with any error ranges - if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) { - var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind); + if (tokenIndentation !== -1 /* Unknown */) { insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); lastIndentedLine = tokenStart.line; indentationOnLastIndentedLine = tokenIndentation; @@ -39683,7 +41305,7 @@ var ts; // 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(false); + dynamicIndentation.recomputeIndentation(/*lineAdded*/ false); } } else if (rule.Operation.Action & 4 /* NewLine */ && currentStartLine === previousStartLine) { @@ -39692,7 +41314,7 @@ var ts; // 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) { - dynamicIndentation.recomputeIndentation(true); + dynamicIndentation.recomputeIndentation(/*lineAdded*/ true); } } // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -39732,7 +41354,7 @@ var ts; if (startLine === endLine) { if (!firstLineIsIndented) { // treat as single line comment - insertIndentation(commentRange.pos, indentation, false); + insertIndentation(commentRange.pos, indentation, /*lineAdded*/ false); } return; } @@ -39844,49 +41466,49 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 189 /* Block */: - case 216 /* ModuleBlock */: + case 190 /* Block */: + case 217 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 141 /* Constructor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 171 /* ArrowFunction */: + case 142 /* Constructor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 172 /* ArrowFunction */: if (node.typeParameters === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } else if (node.parameters === list) { - return 16 /* OpenParenToken */; + return 17 /* OpenParenToken */; } break; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: if (node.typeArguments === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } else if (node.arguments === list) { - return 16 /* OpenParenToken */; + return 17 /* OpenParenToken */; } break; - case 148 /* TypeReference */: + case 149 /* TypeReference */: if (node.typeArguments === list) { - return 24 /* LessThanToken */; + return 25 /* LessThanToken */; } } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 16 /* OpenParenToken */: - return 17 /* CloseParenToken */; - case 24 /* LessThanToken */: - return 26 /* GreaterThanToken */; + case 17 /* OpenParenToken */: + return 18 /* CloseParenToken */; + case 25 /* LessThanToken */: + return 27 /* GreaterThanToken */; } return 0 /* Unknown */; } @@ -39963,17 +41585,17 @@ var ts; return 0; } // no indentation in string \regex\template literals - var precedingTokenIsLiteral = precedingToken.kind === 8 /* StringLiteral */ || - precedingToken.kind === 9 /* RegularExpressionLiteral */ || - precedingToken.kind === 10 /* NoSubstitutionTemplateLiteral */ || - precedingToken.kind === 11 /* TemplateHead */ || - precedingToken.kind === 12 /* TemplateMiddle */ || - precedingToken.kind === 13 /* TemplateTail */; + var precedingTokenIsLiteral = precedingToken.kind === 9 /* StringLiteral */ || + precedingToken.kind === 10 /* RegularExpressionLiteral */ || + precedingToken.kind === 11 /* NoSubstitutionTemplateLiteral */ || + precedingToken.kind === 12 /* TemplateHead */ || + precedingToken.kind === 13 /* TemplateMiddle */ || + precedingToken.kind === 14 /* TemplateTail */; if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 178 /* BinaryExpression */) { + if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 179 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -40013,12 +41635,12 @@ var ts; // no parent was found - return 0 to be indented on the level of SourceFile return 0; } - return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); + return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); } SmartIndenter.getIndentation = getIndentation; function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); - return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, 0, sourceFile, options); + return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options); } SmartIndenter.getIndentationForNode = getIndentationForNode; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { @@ -40092,7 +41714,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 245 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 246 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -40103,11 +41725,11 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 14 /* OpenBraceToken */) { + if (nextToken.kind === 15 /* OpenBraceToken */) { // open braces are always indented at the parent level return true; } - else if (nextToken.kind === 15 /* CloseBraceToken */) { + else if (nextToken.kind === 16 /* CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -40125,8 +41747,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 193 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 77 /* ElseKeyword */, sourceFile); + if (parent.kind === 194 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 78 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -40137,23 +41759,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 148 /* TypeReference */: + case 149 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 162 /* ObjectLiteralExpression */: + case 163 /* ObjectLiteralExpression */: return node.parent.properties; - case 161 /* ArrayLiteralExpression */: + case 162 /* ArrayLiteralExpression */: return node.parent.elements; - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: { + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -40164,8 +41786,8 @@ var ts; } break; } - case 166 /* NewExpression */: - case 165 /* CallExpression */: { + case 167 /* NewExpression */: + case 166 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -40192,11 +41814,11 @@ var ts; function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { // actual indentation should not be used when: // - node is close parenthesis - this is the end of the expression - if (node.kind === 17 /* CloseParenToken */) { + if (node.kind === 18 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 165 /* CallExpression */ || - node.parent.kind === 166 /* NewExpression */) && + if (node.parent && (node.parent.kind === 166 /* CallExpression */ || + node.parent.kind === 167 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -40214,10 +41836,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 163 /* PropertyAccessExpression */: - case 164 /* ElementAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 164 /* PropertyAccessExpression */: + case 165 /* ElementAccessExpression */: node = node.expression; break; default: @@ -40234,7 +41856,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; --i) { - if (list[i].kind === 23 /* CommaToken */) { + if (list[i].kind === 24 /* CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -40282,28 +41904,42 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 161 /* ArrayLiteralExpression */: - case 189 /* Block */: - case 216 /* ModuleBlock */: - case 162 /* ObjectLiteralExpression */: - case 152 /* TypeLiteral */: - case 154 /* TupleType */: - case 217 /* CaseBlock */: - case 239 /* DefaultClause */: - case 238 /* CaseClause */: - case 169 /* ParenthesizedExpression */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: - case 190 /* VariableStatement */: - case 208 /* VariableDeclaration */: - case 224 /* ExportAssignment */: - case 201 /* ReturnStatement */: - case 179 /* ConditionalExpression */: - case 159 /* ArrayBindingPattern */: - case 158 /* ObjectBindingPattern */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 162 /* ArrayLiteralExpression */: + case 190 /* Block */: + case 217 /* ModuleBlock */: + case 163 /* ObjectLiteralExpression */: + case 153 /* TypeLiteral */: + case 155 /* TupleType */: + case 218 /* CaseBlock */: + case 240 /* DefaultClause */: + case 239 /* CaseClause */: + case 170 /* ParenthesizedExpression */: + case 164 /* PropertyAccessExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: + case 191 /* VariableStatement */: + case 209 /* VariableDeclaration */: + case 225 /* ExportAssignment */: + case 202 /* ReturnStatement */: + case 180 /* ConditionalExpression */: + case 160 /* ArrayBindingPattern */: + case 159 /* ObjectBindingPattern */: + case 231 /* JsxElement */: + case 232 /* JsxSelfClosingElement */: + case 140 /* MethodSignature */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 136 /* Parameter */: + case 150 /* FunctionType */: + case 151 /* ConstructorType */: + case 158 /* ParenthesizedType */: + case 168 /* TaggedTemplateExpression */: + case 176 /* AwaitExpression */: return true; } return false; @@ -40313,22 +41949,20 @@ var ts; return true; } switch (parent) { - case 194 /* DoStatement */: - case 195 /* WhileStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 196 /* ForStatement */: - case 193 /* IfStatement */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 144 /* CallSignature */: - case 171 /* ArrowFunction */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - return child !== 189 /* Block */; + case 195 /* DoStatement */: + case 196 /* WhileStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 197 /* ForStatement */: + case 194 /* IfStatement */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 141 /* MethodDeclaration */: + case 172 /* ArrowFunction */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + return child !== 190 /* Block */; default: return false; } @@ -40380,8 +42014,47 @@ var ts; } ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); - var scanner = ts.createScanner(2 /* Latest */, true); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); var emptyArray = []; + var jsDocTagNames = [ + "augments", + "author", + "argument", + "borrows", + "class", + "constant", + "constructor", + "constructs", + "default", + "deprecated", + "description", + "event", + "example", + "extends", + "field", + "fileOverview", + "function", + "ignore", + "inner", + "lends", + "link", + "memberOf", + "name", + "namespace", + "param", + "private", + "property", + "public", + "requires", + "returns", + "see", + "since", + "static", + "throws", + "type", + "version" + ]; + var jsDocCompletionEntries; function createNode(kind, pos, end, flags, parent) { var node = new (ts.getNodeConstructor(kind))(); node.pos = pos; @@ -40431,7 +42104,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(268 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); + var list = createNode(269 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -40450,7 +42123,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 132 /* FirstNode */) { + if (this.kind >= 133 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -40492,24 +42165,20 @@ var ts; return this._children; }; NodeObject.prototype.getFirstToken = function (sourceFile) { - var children = this.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; - if (child.kind < 132 /* FirstNode */) { - return child; - } - return child.getFirstToken(sourceFile); + var children = this.getChildren(sourceFile); + if (!children.length) { + return undefined; } + var child = children[0]; + return child.kind < 133 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); - for (var i = children.length - 1; i >= 0; i--) { - var child = children[i]; - if (child.kind < 132 /* FirstNode */) { - return child; - } - return child.getLastToken(sourceFile); + var child = ts.lastOrUndefined(children); + if (!child) { + return undefined; } + return child.kind < 133 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; })(); @@ -40550,15 +42219,15 @@ var ts; var jsDocCommentParts = []; ts.forEach(declarations, function (declaration, indexOfDeclaration) { // Make sure we are collecting doc comment from declaration once, - // In case of union property there might be same declaration multiple times + // In case of union property there might be same declaration multiple times // which only varies in type parameter // Eg. let a: Array | Array; a.length - // The property length will have two declarations of property length coming + // The property length will have two declarations of property length coming // from Array - Array and Array if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 135 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 136 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -40567,15 +42236,15 @@ var ts; }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 215 /* ModuleDeclaration */ && declaration.body.kind === 215 /* ModuleDeclaration */) { + if (declaration.kind === 216 /* ModuleDeclaration */ && declaration.body.kind === 216 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 215 /* ModuleDeclaration */ && declaration.parent.kind === 215 /* ModuleDeclaration */) { + while (declaration.kind === 216 /* ModuleDeclaration */ && declaration.parent.kind === 216 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 208 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 209 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { ts.addRange(jsDocCommentParts, cleanedJsDocComment); @@ -40588,7 +42257,7 @@ var ts; return ts.map(ts.getJsDocComments(node, sourceFile), function (jsDocComment) { return { pos: jsDocComment.pos + "/*".length, - end: jsDocComment.end - "*/".length // Trim off comment end indicator + end: jsDocComment.end - "*/".length // Trim off comment end indicator }; }); } @@ -40690,7 +42359,7 @@ var ts; if (isParamTag(pos, end, sourceFile)) { var blankLineCount = 0; var recordedParamTag = false; - // Consume leading spaces + // Consume leading spaces pos = consumeWhiteSpaces(pos + paramTag.length); if (pos >= end) { break; @@ -40740,7 +42409,7 @@ var ts; var firstLineParamHelpStringPos = pos; while (pos < end) { var ch = sourceFile.text.charCodeAt(pos); - // at line break, set this comment line text and go to next line + // at line break, set this comment line text and go to next line if (ts.isLineBreak(ch)) { if (paramHelpString) { pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); @@ -40793,7 +42462,7 @@ var ts; if (paramHelpStringMargin === undefined) { paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character; } - // Now consume white spaces max + // Now consume white spaces max var startOfLinePos = pos; pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile, paramHelpStringMargin); if (pos >= end) { @@ -40843,6 +42512,11 @@ var ts; TypeObject.prototype.getNumberIndexType = function () { return this.checker.getIndexTypeOfType(this, 1 /* Number */); }; + TypeObject.prototype.getBaseTypes = function () { + return this.flags & (1024 /* Class */ | 2048 /* Interface */) + ? this.checker.getBaseTypes(this) + : undefined; + }; return TypeObject; })(); var SignatureObject = (function () { @@ -40914,9 +42588,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 133 /* ComputedPropertyName */) { + if (declaration.name.kind === 134 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 163 /* PropertyAccessExpression */) { + if (expr.kind === 164 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -40926,9 +42600,9 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 8 /* StringLiteral */ || - node.kind === 7 /* NumericLiteral */) { + if (node.kind === 67 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || + node.kind === 8 /* NumericLiteral */) { return node.text; } } @@ -40936,9 +42610,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -40958,60 +42632,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 214 /* EnumDeclaration */: - case 215 /* ModuleDeclaration */: - case 218 /* ImportEqualsDeclaration */: - case 227 /* ExportSpecifier */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 220 /* ImportClause */: - case 221 /* NamespaceImport */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 152 /* TypeLiteral */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 215 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: + case 219 /* ImportEqualsDeclaration */: + case 228 /* ExportSpecifier */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 221 /* ImportClause */: + case 222 /* NamespaceImport */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 153 /* TypeLiteral */: addDeclaration(node); // fall through - case 141 /* Constructor */: - case 190 /* VariableStatement */: - case 209 /* VariableDeclarationList */: - case 158 /* ObjectBindingPattern */: - case 159 /* ArrayBindingPattern */: - case 216 /* ModuleBlock */: + case 142 /* Constructor */: + case 191 /* VariableStatement */: + case 210 /* VariableDeclarationList */: + case 159 /* ObjectBindingPattern */: + case 160 /* ArrayBindingPattern */: + case 217 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 135 /* Parameter */: + case 136 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 244 /* EnumMember */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 245 /* EnumMember */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: addDeclaration(node); break; - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -41023,7 +42697,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 222 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -41227,16 +42901,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 170 /* FunctionExpression */) { + if (declaration.kind === 171 /* FunctionExpression */) { return true; } - if (declaration.kind !== 208 /* VariableDeclaration */ && declaration.kind !== 210 /* FunctionDeclaration */) { + if (declaration.kind !== 209 /* VariableDeclaration */ && declaration.kind !== 211 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { + for (var parent_8 = declaration.parent; !ts.isFunctionBlock(parent_8); parent_8 = parent_8.parent) { // Reached source file or module block - if (parent_9.kind === 245 /* SourceFile */ || parent_9.kind === 216 /* ModuleBlock */) { + if (parent_8.kind === 246 /* SourceFile */ || parent_8.kind === 217 /* ModuleBlock */) { return false; } } @@ -41253,8 +42927,8 @@ var ts; }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - // Cache host information about scrip Should be refreshed - // at each language service public entry point, since we don't know when + // Cache host information about scrip Should be refreshed + // at each language service public entry point, since we don't know when // set of scripts handled by the host changes. var HostCache = (function () { function HostCache(host, getCanonicalFileName) { @@ -41331,7 +43005,7 @@ var ts; var sourceFile; if (this.currentFileName !== fileName) { // This is a new file, just parse it - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, true); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents:*/ true); } else if (this.currentFileVersion !== version) { // This is the same file, just a newer version. Incrementally parse the file. @@ -41356,52 +43030,76 @@ var ts; /* * This function will compile source text from 'input' argument using specified compiler options. * If not options are provided - it will use a set of default compiler options. - * Extra compiler options that will unconditionally be used bu this function are: + * Extra compiler options that will unconditionally be used by this function are: * - isolatedModules = true * - allowNonTsExtensions = true * - noLib = true * - noResolve = true */ - function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { - var options = compilerOptions ? ts.clone(compilerOptions) : getDefaultCompilerOptions(); + function transpileModule(input, transpileOptions) { + var options = transpileOptions.compilerOptions ? ts.clone(transpileOptions.compilerOptions) : getDefaultCompilerOptions(); options.isolatedModules = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, + // We are not returning a sourceFile for lib file when asked by the program, // so pass --noLib to avoid reporting a file not found error. options.noLib = true; // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. options.noResolve = true; // Parse - var inputFileName = fileName || "module.ts"; + var inputFileName = transpileOptions.fileName || "module.ts"; var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - if (moduleName) { - sourceFile.moduleName = moduleName; + if (transpileOptions.moduleName) { + sourceFile.moduleName = transpileOptions.moduleName; } + sourceFile.renamedDependencies = transpileOptions.renamedDependencies; var newLine = ts.getNewLineCharacter(options); // Output var outputText; + var sourceMapText; // Create a compilerHost object to allow the compiler to read and write files var compilerHost = { - getSourceFile: function (fileName, target) { return fileName === inputFileName ? sourceFile : undefined; }, + getSourceFile: function (fileName, target) { return fileName === ts.normalizeSlashes(inputFileName) ? sourceFile : undefined; }, writeFile: function (name, text, writeByteOrderMark) { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); - outputText = text; + if (ts.fileExtensionIs(name, ".map")) { + ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + sourceMapText = text; + } + else { + ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name); + outputText = text; + } }, getDefaultLibFileName: function () { return "lib.d.ts"; }, useCaseSensitiveFileNames: function () { return false; }, getCanonicalFileName: function (fileName) { return fileName; }, getCurrentDirectory: function () { return ""; }, - getNewLine: function () { return newLine; } + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return fileName === inputFileName; }, + readFile: function (fileName) { return ""; } }; var program = ts.createProgram([inputFileName], options, compilerHost); - ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); - ts.addRange(diagnostics, program.getOptionsDiagnostics()); + var diagnostics; + if (transpileOptions.reportDiagnostics) { + diagnostics = []; + ts.addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics()); + } // Emit program.emit(); ts.Debug.assert(outputText !== undefined, "Output generation failed"); - return outputText; + return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; + } + ts.transpileModule = transpileModule; + /* + * This is a shortcut function for transpileModule - it accepts transpileOptions as parameters and returns only outputText part of the result. + */ + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { + var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); + // addRange correctly handles cases when wither 'from' or 'to' argument is missing + ts.addRange(diagnostics, output.diagnostics); + return output.outputText; } ts.transpile = transpile; function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents) { @@ -41415,7 +43113,7 @@ var ts; ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; ts.disableIncrementalParsing = false; function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { - // If we were given a text change range, and our version or open-ness changed, then + // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. if (textChangeRange) { if (version !== sourceFile.version) { @@ -41461,7 +43159,7 @@ var ts; } } // Otherwise, just create a new source file. - return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true); + return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents:*/ true); } ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; function createGetCanonicalFileName(useCaseSensitivefileNames) { @@ -41469,13 +43167,14 @@ var ts; ? (function (fileName) { return fileName; }) : (function (fileName) { return fileName.toLowerCase(); }); } + ts.createGetCanonicalFileName = createGetCanonicalFileName; function createDocumentRegistry(useCaseSensitiveFileNames) { // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. var buckets = {}; var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { - return "_" + settings.target; // + "|" + settings.propagateEnumConstantoString() + return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx; } function getBucketForCompilationSettings(settings, createIfMissing) { var key = getKeyFromCompilationSettings(settings); @@ -41506,18 +43205,18 @@ var ts; return JSON.stringify(bucketInfoArray, null, 2); } function acquireDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, true); + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ true); } function updateDocument(fileName, compilationSettings, scriptSnapshot, version) { - return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, false); + return acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, /*acquiring:*/ false); } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { - var bucket = getBucketForCompilationSettings(compilationSettings, true); + var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); var entry = bucket.get(fileName); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. - var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); + var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents:*/ false); entry = { sourceFile: sourceFile, languageServiceRefCount: 0, @@ -41526,7 +43225,7 @@ var ts; bucket.set(fileName, entry); } else { - // We have an entry for this file. However, it may be for a different version of + // We have an entry for this file. However, it may be for a different version of // the script snapshot. If so, update it appropriately. Otherwise, we can just // return it as is. if (entry.sourceFile.version !== version) { @@ -41565,6 +43264,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } var referencedFiles = []; var importedFiles = []; + var ambientExternalModules; var isNoDefaultLib = false; function processTripleSlashDirectives() { var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); @@ -41580,6 +43280,12 @@ var ts; } }); } + function recordAmbientExternalModule() { + if (!ambientExternalModules) { + ambientExternalModules = []; + } + ambientExternalModules.push(scanner.getTokenValue()); + } function recordModuleName() { var importPath = scanner.getTokenValue(); var pos = scanner.getTokenPos(); @@ -41602,32 +43308,44 @@ var ts; // // export * from "mod" // export {a as b} from "mod" + // export import i = require("mod") while (token !== 1 /* EndOfFileToken */) { - if (token === 86 /* ImportKeyword */) { + if (token === 120 /* DeclareKeyword */) { + // declare module "mod" token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 123 /* ModuleKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + recordAmbientExternalModule(); + continue; + } + } + } + else if (token === 87 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { // import "mod"; recordModuleName(); continue; } else { - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */ || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import d from "mod"; recordModuleName(); continue; } } - else if (token === 54 /* EqualsToken */) { + else if (token === 55 /* EqualsToken */) { token = scanner.scan(); - if (token === 124 /* RequireKeyword */) { + if (token === 125 /* RequireKeyword */) { token = scanner.scan(); - if (token === 16 /* OpenParenToken */) { + if (token === 17 /* OpenParenToken */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import i = require("mod"); recordModuleName(); continue; @@ -41635,7 +43353,7 @@ var ts; } } } - else if (token === 23 /* CommaToken */) { + else if (token === 24 /* CommaToken */) { // consume comma and keep going token = scanner.scan(); } @@ -41644,17 +43362,17 @@ var ts; continue; } } - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== 15 /* CloseBraceToken */) { + while (token !== 16 /* CloseBraceToken */) { token = scanner.scan(); } - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -41662,15 +43380,15 @@ var ts; } } } - else if (token === 36 /* AsteriskToken */) { + else if (token === 37 /* AsteriskToken */) { token = scanner.scan(); - if (token === 113 /* AsKeyword */) { + if (token === 114 /* AsKeyword */) { token = scanner.scan(); - if (token === 66 /* Identifier */) { + if (token === 67 /* Identifier */ || ts.isKeyword(token)) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -41681,19 +43399,19 @@ var ts; } } } - else if (token === 79 /* ExportKeyword */) { + else if (token === 80 /* ExportKeyword */) { token = scanner.scan(); - if (token === 14 /* OpenBraceToken */) { + if (token === 15 /* OpenBraceToken */) { token = scanner.scan(); // consume "{ a as B, c, d as D}" clauses - while (token !== 15 /* CloseBraceToken */) { + while (token !== 16 /* CloseBraceToken */) { token = scanner.scan(); } - if (token === 15 /* CloseBraceToken */) { + if (token === 16 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -41701,16 +43419,35 @@ var ts; } } } - else if (token === 36 /* AsteriskToken */) { + else if (token === 37 /* AsteriskToken */) { token = scanner.scan(); - if (token === 130 /* FromKeyword */) { + if (token === 131 /* FromKeyword */) { token = scanner.scan(); - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // export * from "mod" recordModuleName(); } } } + else if (token === 87 /* ImportKeyword */) { + token = scanner.scan(); + if (token === 67 /* Identifier */ || ts.isKeyword(token)) { + token = scanner.scan(); + if (token === 55 /* EqualsToken */) { + token = scanner.scan(); + if (token === 125 /* RequireKeyword */) { + token = scanner.scan(); + if (token === 17 /* OpenParenToken */) { + token = scanner.scan(); + if (token === 9 /* StringLiteral */) { + // export import i = require("mod"); + recordModuleName(); + } + } + } + } + } + } } token = scanner.scan(); } @@ -41720,13 +43457,13 @@ var ts; processImport(); } processTripleSlashDirectives(); - return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib }; + return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientExternalModules }; } ts.preProcessFile = preProcessFile; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 204 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 205 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -41734,13 +43471,13 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 66 /* Identifier */ && - (node.parent.kind === 200 /* BreakStatement */ || node.parent.kind === 199 /* ContinueStatement */) && + return node.kind === 67 /* Identifier */ && + (node.parent.kind === 201 /* BreakStatement */ || node.parent.kind === 200 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 66 /* Identifier */ && - node.parent.kind === 204 /* LabeledStatement */ && + return node.kind === 67 /* Identifier */ && + node.parent.kind === 205 /* LabeledStatement */ && node.parent.label === node; } /** @@ -41748,7 +43485,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 204 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 205 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -41759,56 +43496,56 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 164 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 165 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 166 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 166 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 167 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 215 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 216 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 66 /* Identifier */ && + return node.kind === 67 /* Identifier */ && ts.isFunctionLike(node.parent) && 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) { - return (node.kind === 66 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && - (node.parent.kind === 242 /* PropertyAssignment */ || node.parent.kind === 243 /* ShorthandPropertyAssignment */) && node.parent.name === node; + return (node.kind === 67 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && + (node.parent.kind === 243 /* PropertyAssignment */ || node.parent.kind === 244 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { + if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 244 /* EnumMember */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 215 /* ModuleDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 245 /* EnumMember */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 216 /* ModuleDeclaration */: return node.parent.name === node; - case 164 /* ElementAccessExpression */: + case 165 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } return false; } function isNameOfExternalModuleImportOrDeclaration(node) { - if (node.kind === 8 /* StringLiteral */) { + if (node.kind === 9 /* StringLiteral */) { return isNameOfModuleDeclaration(node) || (ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node); } @@ -41860,7 +43597,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 67 /* FirstKeyword */; i <= 131 /* LastKeyword */; i++) { + for (var i = 68 /* FirstKeyword */; i <= 132 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -41875,17 +43612,17 @@ var ts; return undefined; } switch (node.kind) { - case 245 /* SourceFile */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 214 /* EnumDeclaration */: - case 215 /* ModuleDeclaration */: + case 246 /* SourceFile */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 215 /* EnumDeclaration */: + case 216 /* ModuleDeclaration */: return node; } } @@ -41893,38 +43630,38 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 215 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 211 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 212 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 213 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 214 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 208 /* VariableDeclaration */: + case 216 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 212 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 213 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 214 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 215 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 209 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 210 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 142 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 143 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 211 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 143 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 144 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 146 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 145 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 144 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 141 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 134 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 244 /* EnumMember */: return ScriptElementKind.variableElement; - case 135 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 218 /* ImportEqualsDeclaration */: - case 223 /* ImportSpecifier */: - case 220 /* ImportClause */: - case 227 /* ExportSpecifier */: - case 221 /* NamespaceImport */: + case 147 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 146 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 145 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 142 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 135 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 245 /* EnumMember */: return ScriptElementKind.variableElement; + case 136 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 219 /* ImportEqualsDeclaration */: + case 224 /* ImportSpecifier */: + case 221 /* ImportClause */: + case 228 /* ExportSpecifier */: + case 222 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; @@ -41995,26 +43732,44 @@ var ts; if (programUpToDate()) { return; } - // IMPORTANT - It is critical from this moment onward that we do not check + // IMPORTANT - It is critical from this moment onward that we do not check // cancellation tokens. We are about to mutate source files from a previous program // instance. If we cancel midway through, we may end up in an inconsistent state where - // the program points to old source files that have been invalidated because of + // the program points to old source files that have been invalidated because of // incremental parsing. var oldSettings = program && program.getCompilerOptions(); var newSettings = hostCache.compilationSettings(); - var changesInCompilationSettingsAffectSyntax = oldSettings && oldSettings.target !== newSettings.target; + var changesInCompilationSettingsAffectSyntax = oldSettings && + (oldSettings.target !== newSettings.target || + oldSettings.module !== newSettings.module || + oldSettings.noResolve !== newSettings.noResolve || + oldSettings.jsx !== newSettings.jsx); // Now create a new compiler - var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, { + var compilerHost = { getSourceFile: getOrCreateSourceFile, getCancellationToken: function () { return cancellationToken; }, getCanonicalFileName: getCanonicalFileName, useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, - getNewLine: function () { return host.getNewLine ? host.getNewLine() : "\r\n"; }, + getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); } - }); - // Release any files we have acquired in the old program but are + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + fileExists: function (fileName) { + // stub missing host functionality + ts.Debug.assert(!host.resolveModuleNames); + return hostCache.getOrCreateEntry(fileName) !== undefined; + }, + readFile: function (fileName) { + // stub missing host functionality + var entry = hostCache.getOrCreateEntry(fileName); + return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); + } + }; + if (host.resolveModuleNames) { + compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + } + var newProgram = ts.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) { var oldSourceFiles = program.getSourceFiles(); @@ -42030,7 +43785,7 @@ var ts; // It needs to be cleared to allow all collected snapshots to be released hostCache = undefined; program = newProgram; - // Make sure all the nodes in the program are both bound, and have their parent + // Make sure all the nodes in the program are both bound, and have their parent // pointers set property. program.getTypeChecker(); return; @@ -42050,7 +43805,7 @@ var ts; // Check if the old program had this file already var oldSourceFile = program && program.getSourceFile(fileName); if (oldSourceFile) { - // We already had a source file for this file name. Go to the registry to + // 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 // address the following 'race'. Specifically, say we have the following: // @@ -42061,15 +43816,15 @@ var ts; // LS2 // // Each LS has a reference to file 'foo.ts' at version 1. LS2 then updates - // it's version of 'foo.ts' to version 2. This will cause LS2 and the - // DocumentRegistry to have version 2 of the document. HOwever, LS1 will + // it's version of 'foo.ts' to version 2. This will cause LS2 and the + // DocumentRegistry to have version 2 of the document. HOwever, LS1 will // have version 1. And *importantly* this source file will be *corrupt*. // The act of creating version 2 of the file irrevocably damages the version // 1 file. // // So, later when we call into LS1, we need to make sure that it doesn't use // it's source file any more, and instead defers to DocumentRegistry to get - // either version 1, version 2 (or some other version) depending on what the + // either version 1, version 2 (or some other version) depending on what the // host says should be used. return documentRegistry.updateDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } @@ -42128,7 +43883,7 @@ var ts; synchronizeHostData(); var targetSourceFile = getValidSourceFile(fileName); // For JavaScript files, we don't want to report the normal typescript semantic errors. - // Instead, we just report errors for using TypeScript-only constructs from within a + // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. if (ts.isJavaScript(fileName)) { return getJavaScriptSemanticDiagnostics(targetSourceFile); @@ -42152,44 +43907,44 @@ var ts; return false; } switch (node.kind) { - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 240 /* HeritageClause */: + case 241 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 103 /* ImplementsKeyword */) { + if (heritageClause.token === 104 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 213 /* TypeAliasDeclaration */: + case 214 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 210 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -42197,20 +43952,20 @@ var ts; return true; } break; - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 208 /* VariableDeclaration */: + case 209 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -42218,7 +43973,7 @@ var ts; return true; } break; - case 135 /* Parameter */: + case 136 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -42234,17 +43989,17 @@ var ts; return true; } break; - case 138 /* PropertyDeclaration */: + case 139 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 168 /* TypeAssertionExpression */: + case 169 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 136 /* Decorator */: + case 137 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -42270,18 +44025,18 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - case 119 /* DeclareKeyword */: + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + case 120 /* DeclareKeyword */: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; // These are all legal modifiers. - case 110 /* StaticKeyword */: - case 79 /* ExportKeyword */: - case 71 /* ConstKeyword */: - case 74 /* DefaultKeyword */: - case 112 /* AbstractKeyword */: + case 111 /* StaticKeyword */: + case 80 /* ExportKeyword */: + case 72 /* ConstKeyword */: + case 75 /* DefaultKeyword */: + case 113 /* AbstractKeyword */: } } } @@ -42343,6 +44098,7 @@ var ts; var syntacticStart = new Date().getTime(); var sourceFile = getValidSourceFile(fileName); var isJavaScriptFile = ts.isJavaScript(fileName); + var isJsDocTagName = false; var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); log("getCompletionData: Get current token: " + (new Date().getTime() - start)); @@ -42351,8 +44107,40 @@ var ts; var insideComment = isInsideComment(sourceFile, currentToken, position); log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); if (insideComment) { - log("Returning an empty list because completion was inside a comment."); - return undefined; + // The current position is next to the '@' sign, when no tag name being provided yet. + // Provide a full list of tag names + if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + isJsDocTagName = true; + } + // Completion should work inside certain JsDoc tags. For example: + // /** @type {number | string} */ + // Completion should work in the brackets + var insideJsDocTagExpression = false; + var tag = ts.getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (tag.tagName.pos <= position && position <= tag.tagName.end) { + isJsDocTagName = true; + } + switch (tag.kind) { + case 267 /* JSDocTypeTag */: + case 265 /* JSDocParameterTag */: + case 266 /* JSDocReturnTag */: + var tagWithExpression = tag; + if (tagWithExpression.typeExpression) { + insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; + } + break; + } + } + if (isJsDocTagName) { + return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + } + if (!insideJsDocTagExpression) { + // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal + // comment or the plain text part of a jsDoc comment, so no completion should be available + log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); + return undefined; + } } start = new Date().getTime(); var previousToken = ts.findPrecedingToken(position, sourceFile); @@ -42363,9 +44151,9 @@ var ts; // Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| // Skip this partial identifier and adjust the contextToken to the token that precedes it. if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) { - var start_2 = new Date().getTime(); + var start_4 = new Date().getTime(); contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); - log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_2)); + log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_4)); } // Find the node where completion is requested on. // Also determine whether we are trying to complete with members of that node @@ -42380,13 +44168,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_10 = contextToken.parent, kind = contextToken.kind; - if (kind === 20 /* DotToken */) { - if (parent_10.kind === 163 /* PropertyAccessExpression */) { + var parent_9 = contextToken.parent, kind = contextToken.kind; + if (kind === 21 /* DotToken */) { + if (parent_9.kind === 164 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_10.kind === 132 /* QualifiedName */) { + else if (parent_9.kind === 133 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -42396,7 +44184,7 @@ var ts; return undefined; } } - else if (kind === 24 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { + else if (kind === 25 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { isRightOfOpenTag = true; location = contextToken; } @@ -42428,12 +44216,12 @@ var ts; } } log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; function getTypeScriptMemberSymbols() { // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */ || node.kind === 163 /* PropertyAccessExpression */) { + if (node.kind === 67 /* Identifier */ || node.kind === 133 /* QualifiedName */ || node.kind === 164 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -42462,7 +44250,7 @@ var ts; } } if (isJavaScriptFile && type.flags & 16384 /* Union */) { - // In javascript files, for union types, we don't just get the members that + // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that // each individual type has. This is because we're going to add all identifiers // anyways. So we might as well elevate the members that were at least part @@ -42489,7 +44277,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType; - if ((jsxContainer.kind === 231 /* JsxSelfClosingElement */) || (jsxContainer.kind === 232 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 232 /* JsxSelfClosingElement */) || (jsxContainer.kind === 233 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -42510,10 +44298,10 @@ var ts; // aggregating completion candidates. This is achieved in 'getScopeNode' // by finding the first node that encompasses a position, accounting for whether a node // is "complete" to decide whether a position belongs to the node. - // + // // However, at the end of an identifier, we are interested in the scope of the identifier // itself, but fall outside of the identifier. For instance: - // + // // xyz => x$ // // the cursor is outside of both the 'x' and the arrow function 'xyz => x', @@ -42563,41 +44351,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 23 /* CommaToken */: - return containingNodeKind === 165 /* CallExpression */ // func( a, | - || containingNodeKind === 141 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 166 /* NewExpression */ // new C(a, | - || containingNodeKind === 161 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 178 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 149 /* FunctionType */; // var x: (s: string, list| - case 16 /* OpenParenToken */: - return containingNodeKind === 165 /* CallExpression */ // func( | - || containingNodeKind === 141 /* Constructor */ // constructor( | - || containingNodeKind === 166 /* NewExpression */ // new C(a| - || containingNodeKind === 169 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 157 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 18 /* OpenBracketToken */: - return containingNodeKind === 161 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 146 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 133 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 122 /* ModuleKeyword */: // module | - case 123 /* NamespaceKeyword */: + case 24 /* CommaToken */: + return containingNodeKind === 166 /* CallExpression */ // func( a, | + || containingNodeKind === 142 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 167 /* NewExpression */ // new C(a, | + || containingNodeKind === 162 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 179 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 150 /* FunctionType */; // var x: (s: string, list| + case 17 /* OpenParenToken */: + return containingNodeKind === 166 /* CallExpression */ // func( | + || containingNodeKind === 142 /* Constructor */ // constructor( | + || containingNodeKind === 167 /* NewExpression */ // new C(a| + || containingNodeKind === 170 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 158 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 19 /* OpenBracketToken */: + return containingNodeKind === 162 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 147 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 134 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 123 /* ModuleKeyword */: // module | + case 124 /* NamespaceKeyword */: return true; - case 20 /* DotToken */: - return containingNodeKind === 215 /* ModuleDeclaration */; // module A.| - case 14 /* OpenBraceToken */: - return containingNodeKind === 211 /* ClassDeclaration */; // class A{ | - case 54 /* EqualsToken */: - return containingNodeKind === 208 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 178 /* BinaryExpression */; // x = a| - case 11 /* TemplateHead */: - return containingNodeKind === 180 /* TemplateExpression */; // `aa ${| - case 12 /* TemplateMiddle */: - return containingNodeKind === 187 /* TemplateSpan */; // `aa ${10} dd ${| - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - return containingNodeKind === 138 /* PropertyDeclaration */; // class A{ public | + case 21 /* DotToken */: + return containingNodeKind === 216 /* ModuleDeclaration */; // module A.| + case 15 /* OpenBraceToken */: + return containingNodeKind === 212 /* ClassDeclaration */; // class A{ | + case 55 /* EqualsToken */: + return containingNodeKind === 209 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 179 /* BinaryExpression */; // x = a| + case 12 /* TemplateHead */: + return containingNodeKind === 181 /* TemplateExpression */; // `aa ${| + case 13 /* TemplateMiddle */: + return containingNodeKind === 188 /* TemplateSpan */; // `aa ${10} dd ${| + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + return containingNodeKind === 139 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -42610,21 +44398,21 @@ var ts; return false; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 8 /* StringLiteral */ - || contextToken.kind === 9 /* RegularExpressionLiteral */ + if (contextToken.kind === 9 /* StringLiteral */ + || contextToken.kind === 10 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(contextToken.kind)) { - var start_3 = contextToken.getStart(); + var start_5 = contextToken.getStart(); var end = contextToken.getEnd(); // To be "in" one of these literals, the position has to be: // 1. entirely within the token text. // 2. at the end position of an unterminated token. // 3. at the end of a regular expression (due to trailing flags like '/foo/g'). - if (start_3 < position && position < end) { + if (start_5 < position && position < end) { return true; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 9 /* RegularExpressionLiteral */; + || contextToken.kind === 10 /* RegularExpressionLiteral */; } } return false; @@ -42640,18 +44428,29 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 162 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 163 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 158 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 159 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = objectLikeContainer.elements; + var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); + if (ts.isVariableLike(rootDeclaration)) { + // We don't want to complete using the type acquired by the shape + // of the binding pattern; we are only interested in types acquired + // through type declaration or inference. + if (rootDeclaration.initializer || rootDeclaration.type) { + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = objectLikeContainer.elements; + } + } + else { + ts.Debug.fail("Root declaration is not variable-like."); + } } else { ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); @@ -42682,9 +44481,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 222 /* NamedImports */ ? - 219 /* ImportDeclaration */ : - 225 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 223 /* NamedImports */ ? + 220 /* ImportDeclaration */ : + 226 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -42707,11 +44506,11 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14 /* OpenBraceToken */: // let x = { | - case 23 /* CommaToken */: - var parent_11 = contextToken.parent; - if (parent_11 && (parent_11.kind === 162 /* ObjectLiteralExpression */ || parent_11.kind === 158 /* ObjectBindingPattern */)) { - return parent_11; + case 15 /* OpenBraceToken */: // let x = { | + case 24 /* CommaToken */: + var parent_10 = contextToken.parent; + if (parent_10 && (parent_10.kind === 163 /* ObjectLiteralExpression */ || parent_10.kind === 159 /* ObjectBindingPattern */)) { + return parent_10; } break; } @@ -42725,11 +44524,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 14 /* OpenBraceToken */: // import { | - case 23 /* CommaToken */: + case 15 /* OpenBraceToken */: // import { | + case 24 /* CommaToken */: switch (contextToken.parent.kind) { - case 222 /* NamedImports */: - case 226 /* NamedExports */: + case 223 /* NamedImports */: + case 227 /* NamedExports */: return contextToken.parent; } } @@ -42738,24 +44537,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_12 = contextToken.parent; + var parent_11 = contextToken.parent; switch (contextToken.kind) { - case 25 /* LessThanSlashToken */: - case 37 /* SlashToken */: - case 66 /* Identifier */: - if (parent_12 && (parent_12.kind === 231 /* JsxSelfClosingElement */ || parent_12.kind === 232 /* JsxOpeningElement */)) { - return parent_12; + case 26 /* LessThanSlashToken */: + case 38 /* SlashToken */: + case 67 /* Identifier */: + case 236 /* JsxAttribute */: + case 237 /* JsxSpreadAttribute */: + if (parent_11 && (parent_11.kind === 232 /* JsxSelfClosingElement */ || parent_11.kind === 233 /* JsxOpeningElement */)) { + return parent_11; } break; - case 15 /* CloseBraceToken */: - // The context token is the closing } of an attribute, which means - // its parent is a JsxExpression, whose parent is a JsxAttribute, - // whose parent is a JsxOpeningLikeElement - if (parent_12 && - parent_12.kind === 237 /* JsxExpression */ && - parent_12.parent && - parent_12.parent.kind === 235 /* JsxAttribute */) { - return parent_12.parent.parent; + // The context token is the closing } or " of an attribute, which means + // its parent is a JsxExpression, whose parent is a JsxAttribute, + // whose parent is a JsxOpeningLikeElement + case 9 /* StringLiteral */: + if (parent_11 && ((parent_11.kind === 236 /* JsxAttribute */) || (parent_11.kind === 237 /* JsxSpreadAttribute */))) { + return parent_11.parent; + } + break; + case 16 /* CloseBraceToken */: + if (parent_11 && + parent_11.kind === 238 /* JsxExpression */ && + parent_11.parent && + (parent_11.parent.kind === 236 /* JsxAttribute */)) { + return parent_11.parent.parent; + } + if (parent_11 && parent_11.kind === 237 /* JsxSpreadAttribute */) { + return parent_11.parent; } break; } @@ -42764,16 +44573,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 144 /* CallSignature */: - case 145 /* ConstructSignature */: - case 146 /* IndexSignature */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 145 /* CallSignature */: + case 146 /* ConstructSignature */: + case 147 /* IndexSignature */: return true; } return false; @@ -42784,65 +44593,67 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 23 /* CommaToken */: - return containingNodeKind === 208 /* VariableDeclaration */ || - containingNodeKind === 209 /* VariableDeclarationList */ || - containingNodeKind === 190 /* VariableStatement */ || - containingNodeKind === 214 /* EnumDeclaration */ || + case 24 /* CommaToken */: + return containingNodeKind === 209 /* VariableDeclaration */ || + containingNodeKind === 210 /* VariableDeclarationList */ || + containingNodeKind === 191 /* VariableStatement */ || + containingNodeKind === 215 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 211 /* ClassDeclaration */ || - containingNodeKind === 210 /* FunctionDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || - containingNodeKind === 159 /* ArrayBindingPattern */; // var [x, y| - case 20 /* DotToken */: - return containingNodeKind === 159 /* ArrayBindingPattern */; // var [.| - case 52 /* ColonToken */: - return containingNodeKind === 160 /* BindingElement */; // var {x :html| - case 18 /* OpenBracketToken */: - return containingNodeKind === 159 /* ArrayBindingPattern */; // var [x| - case 16 /* OpenParenToken */: - return containingNodeKind === 241 /* CatchClause */ || + containingNodeKind === 212 /* ClassDeclaration */ || + containingNodeKind === 184 /* ClassExpression */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 160 /* ArrayBindingPattern */ || + containingNodeKind === 214 /* TypeAliasDeclaration */; // type Map, K, | + case 21 /* DotToken */: + return containingNodeKind === 160 /* ArrayBindingPattern */; // var [.| + case 53 /* ColonToken */: + return containingNodeKind === 161 /* BindingElement */; // var {x :html| + case 19 /* OpenBracketToken */: + return containingNodeKind === 160 /* ArrayBindingPattern */; // var [x| + case 17 /* OpenParenToken */: + return containingNodeKind === 242 /* CatchClause */ || isFunction(containingNodeKind); - case 14 /* OpenBraceToken */: - return containingNodeKind === 214 /* EnumDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || - containingNodeKind === 152 /* TypeLiteral */; // let x : { | - case 22 /* SemicolonToken */: - return containingNodeKind === 137 /* PropertySignature */ && + case 15 /* OpenBraceToken */: + return containingNodeKind === 215 /* EnumDeclaration */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 153 /* TypeLiteral */; // let x : { | + case 23 /* SemicolonToken */: + return containingNodeKind === 138 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 212 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 152 /* TypeLiteral */); // let x : { a; | - case 24 /* LessThanToken */: - return containingNodeKind === 211 /* ClassDeclaration */ || - containingNodeKind === 210 /* FunctionDeclaration */ || - containingNodeKind === 212 /* InterfaceDeclaration */ || + (contextToken.parent.parent.kind === 213 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 153 /* TypeLiteral */); // let x : { a; | + case 25 /* LessThanToken */: + return containingNodeKind === 212 /* ClassDeclaration */ || + containingNodeKind === 184 /* ClassExpression */ || + containingNodeKind === 213 /* InterfaceDeclaration */ || + containingNodeKind === 214 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); - case 110 /* StaticKeyword */: - return containingNodeKind === 138 /* PropertyDeclaration */; - case 21 /* DotDotDotToken */: - return containingNodeKind === 135 /* Parameter */ || + case 111 /* StaticKeyword */: + return containingNodeKind === 139 /* PropertyDeclaration */; + case 22 /* DotDotDotToken */: + return containingNodeKind === 136 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 159 /* ArrayBindingPattern */); // var [...z| - case 109 /* PublicKeyword */: - case 107 /* PrivateKeyword */: - case 108 /* ProtectedKeyword */: - return containingNodeKind === 135 /* Parameter */; - case 113 /* AsKeyword */: - containingNodeKind === 223 /* ImportSpecifier */ || - containingNodeKind === 227 /* ExportSpecifier */ || - containingNodeKind === 221 /* NamespaceImport */; - case 70 /* ClassKeyword */: - case 78 /* EnumKeyword */: - case 104 /* InterfaceKeyword */: - case 84 /* FunctionKeyword */: - case 99 /* VarKeyword */: - case 120 /* GetKeyword */: - case 126 /* SetKeyword */: - case 86 /* ImportKeyword */: - case 105 /* LetKeyword */: - case 71 /* ConstKeyword */: - case 111 /* YieldKeyword */: - case 129 /* TypeKeyword */: + contextToken.parent.parent.kind === 160 /* ArrayBindingPattern */); // var [...z| + case 110 /* PublicKeyword */: + case 108 /* PrivateKeyword */: + case 109 /* ProtectedKeyword */: + return containingNodeKind === 136 /* Parameter */; + case 114 /* AsKeyword */: + containingNodeKind === 224 /* ImportSpecifier */ || + containingNodeKind === 228 /* ExportSpecifier */ || + containingNodeKind === 222 /* NamespaceImport */; + case 71 /* ClassKeyword */: + case 79 /* EnumKeyword */: + case 105 /* InterfaceKeyword */: + case 85 /* FunctionKeyword */: + case 100 /* VarKeyword */: + case 121 /* GetKeyword */: + case 127 /* SetKeyword */: + case 87 /* ImportKeyword */: + case 106 /* LetKeyword */: + case 72 /* ConstKeyword */: + case 112 /* YieldKeyword */: + case 130 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -42861,7 +44672,7 @@ var ts; return false; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 7 /* NumericLiteral */) { + if (contextToken.kind === 8 /* NumericLiteral */) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } @@ -42906,9 +44717,9 @@ var ts; for (var _i = 0; _i < existingMembers.length; _i++) { var m = existingMembers[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 242 /* PropertyAssignment */ && - m.kind !== 243 /* ShorthandPropertyAssignment */ && - m.kind !== 160 /* BindingElement */) { + if (m.kind !== 243 /* PropertyAssignment */ && + m.kind !== 244 /* ShorthandPropertyAssignment */ && + m.kind !== 161 /* BindingElement */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -42916,7 +44727,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 160 /* BindingElement */ && m.propertyName) { + if (m.kind === 161 /* BindingElement */ && m.propertyName) { existingName = m.propertyName.text; } else { @@ -42943,7 +44754,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 235 /* JsxAttribute */) { + if (attr.kind === 236 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -42956,8 +44767,12 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot; + var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isRightOfDot = completionData.isRightOfDot, isJsDocTagName = completionData.isJsDocTagName; var entries; + if (isJsDocTagName) { + // If the current position is a jsDoc tag name, only tag names should be provided for completion + return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: getAllJsDocCompletionEntries() }; + } if (isRightOfDot && ts.isJavaScript(fileName)) { entries = getCompletionEntriesFromSymbols(symbols); ts.addRange(entries, getJavaScriptCompletionEntries()); @@ -42969,7 +44784,7 @@ var ts; entries = getCompletionEntriesFromSymbols(symbols); } // Add keywords if this is not a member completion list - if (!isMemberCompletion) { + if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; @@ -42983,7 +44798,7 @@ var ts; for (var name_32 in nameTable) { if (!allNames[name_32]) { allNames[name_32] = name_32; - var displayName = getCompletionEntryDisplayName(name_32, target, true); + var displayName = getCompletionEntryDisplayName(name_32, target, /*performCharacterChecks:*/ true); if (displayName) { var entry = { name: displayName, @@ -42998,18 +44813,28 @@ var ts; } return entries; } + function getAllJsDocCompletionEntries() { + return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } function createCompletionEntry(symbol, location) { - // Try to get a valid display name for this symbol, if we could not find one, then ignore it. + // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true, location); + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true, location); if (!displayName) { return undefined; } - // TODO(drosen): Right now we just permit *all* semantic meanings when calling - // 'getSymbolKind' which is permissible given that it is backwards compatible; but + // TODO(drosen): Right now we just permit *all* semantic meanings when calling + // 'getSymbolKind' which is permissible given that it is backwards compatible; but // really we should consider passing the meaning for the node so that we don't report - // that a suggestion for a value is an interface. We COULD also just do what + // that a suggestion for a value is an interface. We COULD also just do what // 'getSymbolModifiers' does, which is to use the first declaration. // Use a 'sortText' of 0' so that all symbol completion entries come before any other // entries (like JavaScript identifier entries). @@ -43049,10 +44874,10 @@ var ts; var symbols = completionData.symbols, location_2 = completionData.location; // Find the symbol with the matching entry name. var target = program.getCompilerOptions().target; - // We don't need to perform character checks here because we're only comparing the - // name against 'entryName' (which is known to be good), not building a new + // We don't need to perform character checks here because we're only comparing the + // name against 'entryName' (which is known to be good), not building a new // completion entry. - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false, location_2) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false, location_2) === entryName ? s : undefined; }); if (symbol) { var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { @@ -43081,7 +44906,7 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 183 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */) ? ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; @@ -43145,7 +44970,7 @@ var ts; ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); }); if (!unionPropertyKind) { - // If this was union of all methods, + // If this was union of all methods, //make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { @@ -43183,7 +45008,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 163 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 164 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -43192,7 +45017,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 165 /* CallExpression */ || location.kind === 166 /* NewExpression */) { + if (location.kind === 166 /* CallExpression */ || location.kind === 167 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -43205,10 +45030,10 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 166 /* NewExpression */ || callExpression.expression.kind === 92 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 167 /* NewExpression */ || callExpression.expression.kind === 93 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { - // Get the first signature if there + // Get the first signature if there signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { @@ -43222,7 +45047,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -43238,14 +45063,14 @@ var ts; case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(52 /* ColonToken */)); + displayParts.push(ts.punctuationPart(53 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); displayParts.push(ts.spacePart()); } if (!(type.flags & 65536 /* Anonymous */)) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */)); + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */)); } addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); break; @@ -43257,24 +45082,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 118 /* ConstructorKeyword */ && location.parent.kind === 141 /* Constructor */)) { + (location.kind === 119 /* ConstructorKeyword */ && location.parent.kind === 142 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 141 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 142 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 141 /* Constructor */) { + if (functionDeclaration.kind === 142 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 144 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 145 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -43283,7 +45108,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - if (ts.getDeclarationOfKind(symbol, 183 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 184 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class @@ -43291,7 +45116,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(70 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(71 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -43299,48 +45124,49 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(104 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(105 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(129 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(71 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(72 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(78 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(79 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 215 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 66 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 123 /* NamespaceKeyword */ : 122 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 216 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 67 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 124 /* NamespaceKeyword */ : 123 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(87 /* InKeyword */)); + displayParts.push(ts.keywordPart(88 /* InKeyword */)); displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter @@ -43349,26 +45175,39 @@ var ts; } else { // Method/function type parameter - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).parent; - var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 145 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(89 /* NewKeyword */)); + var container = ts.getContainingFunction(location); + if (container) { + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; + var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === 146 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(90 /* NewKeyword */)); + displayParts.push(ts.spacePart()); + } + else if (signatureDeclaration.kind !== 145 /* CallSignature */ && signatureDeclaration.name) { + addFullSymbolName(signatureDeclaration.symbol); + } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + } + else { + // Type aliash type parameter + // For example + // type list = T[]; // Both T will go through same code path + var declaration = ts.getDeclarationOfKind(symbol, 135 /* TypeParameter */).parent; + displayParts.push(ts.keywordPart(130 /* TypeKeyword */)); displayParts.push(ts.spacePart()); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); } - else if (signatureDeclaration.kind !== 144 /* CallSignature */ && signatureDeclaration.name) { - addFullSymbolName(signatureDeclaration.symbol); - } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } } if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 244 /* EnumMember */) { + if (declaration.kind === 245 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -43376,26 +45215,26 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(86 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(87 /* ImportKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 218 /* ImportEqualsDeclaration */) { + if (declaration.kind === 219 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(124 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(125 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(54 /* EqualsToken */)); + displayParts.push(ts.operatorPart(55 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -43412,7 +45251,7 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(52 /* ColonToken */)); + displayParts.push(ts.punctuationPart(53 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -43450,7 +45289,7 @@ var ts; } } function addFullSymbolName(symbol, enclosingDeclaration) { - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); ts.addRange(displayParts, fullSymbolDisplayParts); } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -43471,9 +45310,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); return; } } @@ -43481,12 +45320,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(34 /* PlusToken */)); + displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(35 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); } @@ -43512,11 +45351,11 @@ var ts; if (!symbol) { // Try getting just type at this position and show switch (node.kind) { - case 66 /* Identifier */: - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: - case 94 /* ThisKeyword */: - case 92 /* SuperKeyword */: + case 67 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 95 /* ThisKeyword */: + case 93 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -43560,7 +45399,7 @@ var ts; var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { - // Just add all the declarations. + // Just add all the declarations. ts.forEach(declarations, function (declaration) { result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); }); @@ -43569,18 +45408,24 @@ var ts; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (isNewExpressionTarget(location) || location.kind === 118 /* ConstructorKeyword */) { + if (isNewExpressionTarget(location) || location.kind === 119 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { - var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 211 /* ClassDeclaration */); - return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); + // Find the first class-like declaration and try to get the construct signature. + for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isClassLike(declaration)) { + return tryAddSignature(declaration.members, + /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); + } + } + ts.Debug.fail("Expected declaration to have at least one class-like declaration"); } } return false; } function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { - return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result); + return tryAddSignature(symbol.declarations, /*selectConstructors*/ false, symbolKind, symbolName, containerName, result); } return false; } @@ -43588,8 +45433,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 141 /* Constructor */) || - (!selectConstructors && (d.kind === 210 /* FunctionDeclaration */ || d.kind === 140 /* MethodDeclaration */ || d.kind === 139 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 142 /* Constructor */) || + (!selectConstructors && (d.kind === 211 /* FunctionDeclaration */ || d.kind === 141 /* MethodDeclaration */ || d.kind === 140 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -43618,7 +45463,7 @@ var ts; if (isJumpStatementTarget(node)) { var labelName = node.text; var label = getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, undefined)] : undefined; + return label ? [createDefinitionInfo(label, ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } /// Triple slash reference comments var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; }); @@ -43649,16 +45494,16 @@ var ts; // to jump to the implementation directly. if (symbol.flags & 8388608 /* Alias */) { var declaration = symbol.declarations[0]; - if (node.kind === 66 /* Identifier */ && node.parent === declaration) { + if (node.kind === 67 /* Identifier */ && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } // Because name in short-hand property assignment has two different meanings: property name and property value, // using go-to-definition at such position should go to the variable declaration of the property value rather than - // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition + // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 243 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 244 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -43692,7 +45537,7 @@ var ts; var result = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(result, getDefinitionFromSymbol(t.symbol, node)); + ts.addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node)); } }); return result; @@ -43706,7 +45551,7 @@ var ts; var results = getOccurrencesAtPositionCore(fileName, position); if (results) { var sourceFile = getCanonicalFileName(ts.normalizeSlashes(fileName)); - // Get occurrences only supports reporting occurrences for the file queried. So + // Get occurrences only supports reporting occurrences for the file queried. So // filter down to that list. results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile; }); } @@ -43732,12 +45577,12 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 66 /* Identifier */ || - node.kind === 94 /* ThisKeyword */ || - node.kind === 92 /* SuperKeyword */ || + if (node.kind === 67 /* Identifier */ || + node.kind === 95 /* ThisKeyword */ || + node.kind === 93 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { - var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); + var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferencedSymbols(referencedSymbols); } return undefined; @@ -43785,77 +45630,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 85 /* IfKeyword */: - case 77 /* ElseKeyword */: - if (hasKind(node.parent, 193 /* IfStatement */)) { + case 86 /* IfKeyword */: + case 78 /* ElseKeyword */: + if (hasKind(node.parent, 194 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 91 /* ReturnKeyword */: - if (hasKind(node.parent, 201 /* ReturnStatement */)) { + case 92 /* ReturnKeyword */: + if (hasKind(node.parent, 202 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 95 /* ThrowKeyword */: - if (hasKind(node.parent, 205 /* ThrowStatement */)) { + case 96 /* ThrowKeyword */: + if (hasKind(node.parent, 206 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 69 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 206 /* TryStatement */)) { + case 70 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 207 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 97 /* TryKeyword */: - case 82 /* FinallyKeyword */: - if (hasKind(parent(node), 206 /* TryStatement */)) { + case 98 /* TryKeyword */: + case 83 /* FinallyKeyword */: + if (hasKind(parent(node), 207 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 93 /* SwitchKeyword */: - if (hasKind(node.parent, 203 /* SwitchStatement */)) { + case 94 /* SwitchKeyword */: + if (hasKind(node.parent, 204 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 68 /* CaseKeyword */: - case 74 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 203 /* SwitchStatement */)) { + case 69 /* CaseKeyword */: + case 75 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 204 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 67 /* BreakKeyword */: - case 72 /* ContinueKeyword */: - if (hasKind(node.parent, 200 /* BreakStatement */) || hasKind(node.parent, 199 /* ContinueStatement */)) { - return getBreakOrContinueStatementOccurences(node.parent); + case 68 /* BreakKeyword */: + case 73 /* ContinueKeyword */: + if (hasKind(node.parent, 201 /* BreakStatement */) || hasKind(node.parent, 200 /* ContinueStatement */)) { + return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 83 /* ForKeyword */: - if (hasKind(node.parent, 196 /* ForStatement */) || - hasKind(node.parent, 197 /* ForInStatement */) || - hasKind(node.parent, 198 /* ForOfStatement */)) { + case 84 /* ForKeyword */: + if (hasKind(node.parent, 197 /* ForStatement */) || + hasKind(node.parent, 198 /* ForInStatement */) || + hasKind(node.parent, 199 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 101 /* WhileKeyword */: - case 76 /* DoKeyword */: - if (hasKind(node.parent, 195 /* WhileStatement */) || hasKind(node.parent, 194 /* DoStatement */)) { + case 102 /* WhileKeyword */: + case 77 /* DoKeyword */: + if (hasKind(node.parent, 196 /* WhileStatement */) || hasKind(node.parent, 195 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 118 /* ConstructorKeyword */: - if (hasKind(node.parent, 141 /* Constructor */)) { + case 119 /* ConstructorKeyword */: + if (hasKind(node.parent, 142 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 120 /* GetKeyword */: - case 126 /* SetKeyword */: - if (hasKind(node.parent, 142 /* GetAccessor */) || hasKind(node.parent, 143 /* SetAccessor */)) { + case 121 /* GetKeyword */: + case 127 /* SetKeyword */: + if (hasKind(node.parent, 143 /* GetAccessor */) || hasKind(node.parent, 144 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 190 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 191 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -43871,10 +45716,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 205 /* ThrowStatement */) { + if (node.kind === 206 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 206 /* TryStatement */) { + else if (node.kind === 207 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -43902,19 +45747,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_13 = child.parent; - if (ts.isFunctionBlock(parent_13) || parent_13.kind === 245 /* SourceFile */) { - return parent_13; + var parent_12 = child.parent; + if (ts.isFunctionBlock(parent_12) || parent_12.kind === 246 /* SourceFile */) { + return parent_12; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_13.kind === 206 /* TryStatement */) { - var tryStatement = parent_13; + if (parent_12.kind === 207 /* TryStatement */) { + var tryStatement = parent_12; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_13; + child = parent_12; } return undefined; } @@ -43923,7 +45768,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 200 /* BreakStatement */ || node.kind === 199 /* ContinueStatement */) { + if (node.kind === 201 /* BreakStatement */ || node.kind === 200 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -43939,16 +45784,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 203 /* SwitchStatement */: - if (statement.kind === 199 /* ContinueStatement */) { + case 204 /* SwitchStatement */: + if (statement.kind === 200 /* ContinueStatement */) { continue; } // Fall through. - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 195 /* WhileStatement */: - case 194 /* DoStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 195 /* DoStatement */: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -43967,24 +45812,24 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 211 /* ClassDeclaration */ || - container.kind === 183 /* ClassExpression */ || - (declaration.kind === 135 /* Parameter */ && hasKind(container, 141 /* Constructor */)))) { + if (!(container.kind === 212 /* ClassDeclaration */ || + container.kind === 184 /* ClassExpression */ || + (declaration.kind === 136 /* Parameter */ && hasKind(container, 142 /* Constructor */)))) { return undefined; } } - else if (modifier === 110 /* StaticKeyword */) { - if (!(container.kind === 211 /* ClassDeclaration */ || container.kind === 183 /* ClassExpression */)) { + else if (modifier === 111 /* StaticKeyword */) { + if (!(container.kind === 212 /* ClassDeclaration */ || container.kind === 184 /* ClassExpression */)) { return undefined; } } - else if (modifier === 79 /* ExportKeyword */ || modifier === 119 /* DeclareKeyword */) { - if (!(container.kind === 216 /* ModuleBlock */ || container.kind === 245 /* SourceFile */)) { + else if (modifier === 80 /* ExportKeyword */ || modifier === 120 /* DeclareKeyword */) { + if (!(container.kind === 217 /* ModuleBlock */ || container.kind === 246 /* SourceFile */)) { return undefined; } } - else if (modifier === 112 /* AbstractKeyword */) { - if (!(container.kind === 211 /* ClassDeclaration */ || declaration.kind === 211 /* ClassDeclaration */)) { + else if (modifier === 113 /* AbstractKeyword */) { + if (!(container.kind === 212 /* ClassDeclaration */ || declaration.kind === 212 /* ClassDeclaration */)) { return undefined; } } @@ -43996,8 +45841,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 216 /* ModuleBlock */: - case 245 /* SourceFile */: + case 217 /* ModuleBlock */: + case 246 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 256 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -44006,17 +45851,17 @@ var ts; nodes = container.statements; } break; - case 141 /* Constructor */: + case 142 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 211 /* ClassDeclaration */: - case 183 /* ClassExpression */: + case 212 /* ClassDeclaration */: + case 184 /* ClassExpression */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 141 /* Constructor */ && member; + return member.kind === 142 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -44037,19 +45882,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 109 /* PublicKeyword */: + case 110 /* PublicKeyword */: return 16 /* Public */; - case 107 /* PrivateKeyword */: + case 108 /* PrivateKeyword */: return 32 /* Private */; - case 108 /* ProtectedKeyword */: + case 109 /* ProtectedKeyword */: return 64 /* Protected */; - case 110 /* StaticKeyword */: + case 111 /* StaticKeyword */: return 128 /* Static */; - case 79 /* ExportKeyword */: + case 80 /* ExportKeyword */: return 1 /* Export */; - case 119 /* DeclareKeyword */: + case 120 /* DeclareKeyword */: return 2 /* Ambient */; - case 112 /* AbstractKeyword */: + case 113 /* AbstractKeyword */: return 256 /* Abstract */; default: ts.Debug.fail(); @@ -44069,13 +45914,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 142 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 144 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 120 /* GetKeyword */, 126 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 121 /* GetKeyword */, 127 /* SetKeyword */); }); } } } @@ -44084,19 +45929,19 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 118 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 119 /* ConstructorKeyword */); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 83 /* ForKeyword */, 101 /* WhileKeyword */, 76 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 84 /* ForKeyword */, 102 /* WhileKeyword */, 77 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 194 /* DoStatement */) { + if (loopNode.kind === 195 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 101 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 102 /* WhileKeyword */)) { break; } } @@ -44105,22 +45950,22 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67 /* BreakKeyword */, 72 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */, 73 /* ContinueKeyword */); } }); return ts.map(keywords, getHighlightSpanForNode); } - function getBreakOrContinueStatementOccurences(breakOrContinueStatement) { + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 196 /* ForStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: - case 194 /* DoStatement */: - case 195 /* WhileStatement */: + case 197 /* ForStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: + case 195 /* DoStatement */: + case 196 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -44128,14 +45973,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 93 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 94 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 68 /* CaseKeyword */, 74 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 69 /* CaseKeyword */, 75 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 67 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 68 /* BreakKeyword */); } }); }); @@ -44143,13 +45988,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 97 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 98 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 69 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 70 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 82 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 82 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 83 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 83 /* FinallyKeyword */); } return ts.map(keywords, getHighlightSpanForNode); } @@ -44160,13 +46005,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); }); } return ts.map(keywords, getHighlightSpanForNode); @@ -44174,36 +46019,36 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 189 /* Block */))) { + if (!(func && hasKind(func.body, 190 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 91 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 92 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 95 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 96 /* ThrowKeyword */); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 193 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 194 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 85 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 86 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 77 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 78 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 193 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 194 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -44212,7 +46057,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 77 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 78 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -44279,11 +46124,11 @@ var ts; return convertReferences(referencedSymbols); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); return convertReferences(referencedSymbols); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false); // Only include referenced symbols that have a valid definition. return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); } @@ -44294,7 +46139,7 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 66 /* Identifier */ && + if (node.kind !== 67 /* Identifier */ && // TODO (drosen): This should be enabled in a later release - currently breaks rename. //node.kind !== SyntaxKind.ThisKeyword && //node.kind !== SyntaxKind.SuperKeyword && @@ -44302,7 +46147,7 @@ var ts; !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 66 /* Identifier */ || node.kind === 7 /* NumericLiteral */ || node.kind === 8 /* StringLiteral */); + ts.Debug.assert(node.kind === 67 /* Identifier */ || node.kind === 8 /* NumericLiteral */ || node.kind === 9 /* StringLiteral */); return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { @@ -44320,10 +46165,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 94 /* ThisKeyword */) { + if (node.kind === 95 /* ThisKeyword */) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 92 /* SuperKeyword */) { + if (node.kind === 93 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -44383,7 +46228,7 @@ var ts; } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 223 /* ImportSpecifier */ || declaration.kind === 227 /* ExportSpecifier */; + return declaration.kind === 224 /* ImportSpecifier */ || declaration.kind === 228 /* ExportSpecifier */; }); } function getInternedName(symbol, location, declarations) { @@ -44410,14 +46255,14 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 170 /* FunctionExpression */ || valueDeclaration.kind === 183 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 171 /* FunctionExpression */ || valueDeclaration.kind === 184 /* ClassExpression */)) { return valueDeclaration; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 211 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 212 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -44443,7 +46288,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 245 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -44471,12 +46316,12 @@ var ts; // If we are past the end, stop looking if (position > end) break; - // We found a match. Make sure it's not part of a larger word (i.e. the char + // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 2 /* Latest */)) && (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 2 /* Latest */))) { - // Found a real match. Keep searching. + // Found a real match. Keep searching. positions.push(position); } position = text.indexOf(symbolName, position + symbolNameLength + 1); @@ -44514,16 +46359,16 @@ var ts; if (node) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: return node.getWidth() === searchSymbolName.length; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { // For string literals we have two additional chars for the quotes return node.getWidth() === searchSymbolName.length + 2; } break; - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { return node.getWidth() === searchSymbolName.length; } @@ -44547,11 +46392,11 @@ var ts; cancellationToken.throwIfCancellationRequested(); var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); if (!isValidReferencePosition(referenceLocation, searchText)) { - // This wasn't the start of a token. Check to see if it might be a + // This wasn't the start of a token. Check to see if it might be a // match in a comment or string if that's what the caller is asking // for. - if ((findInStrings && isInString(position)) || - (findInComments && isInComment(position))) { + if ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && isInNonReferenceComment(sourceFile, position))) { // In the case where we're looking inside comments/strings, we don't have // an actual definition. So just use 'undefined' here. Features like // 'Rename' won't care (as they ignore the definitions), and features like @@ -44600,44 +46445,29 @@ var ts; } return result[index]; } - function isInString(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - return token && token.kind === 8 /* StringLiteral */ && position > token.getStart(); - } - function isInComment(position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (token && position < token.getStart()) { - // First, we have to see if this position actually landed in a comment. - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - // Then we want to make sure that it wasn't in a "///<" directive comment - // We don't want to unintentionally update a file name. - return ts.forEach(commentRanges, function (c) { - if (c.pos < position && position < c.end) { - var commentText = sourceFile.text.substring(c.pos, c.end); - if (!tripleSlashDirectivePrefixRegex.test(commentText)) { - return true; - } - } - }); + function isInNonReferenceComment(sourceFile, position) { + return ts.isInCommentHelper(sourceFile, position, isNonReferenceComment); + function isNonReferenceComment(c) { + var commentText = sourceFile.text.substring(c.pos, c.end); + return !tripleSlashDirectivePrefixRegex.test(commentText); } - return false; } } function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, false); + var searchSpaceNode = ts.getSuperContainer(superKeyword, /*includeFunctions*/ false); if (!searchSpaceNode) { return undefined; } // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -44650,10 +46480,10 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 92 /* SuperKeyword */) { + if (!node || node.kind !== 93 /* SuperKeyword */) { return; } - var container = ts.getSuperContainer(node, false); + var container = ts.getSuperContainer(node, /*includeFunctions*/ false); // If we have a 'super' container, we must have an enclosing class. // Now make sure the owning class is the same as the search-space // and has the same static qualifier as the original 'super's owner. @@ -44665,31 +46495,31 @@ var ts; return [{ definition: definition, references: references }]; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 245 /* SourceFile */: + case 246 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. @@ -44698,7 +46528,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 245 /* SourceFile */) { + if (searchSpaceNode.kind === 246 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -44724,32 +46554,33 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 94 /* ThisKeyword */) { + if (!node || node.kind !== 95 /* ThisKeyword */) { return; } - var container = ts.getThisContainer(node, false); + var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 211 /* ClassDeclaration */: + case 184 /* ClassExpression */: + case 212 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 245 /* SourceFile */: - if (container.kind === 245 /* SourceFile */ && !ts.isExternalModule(container)) { + case 246 /* SourceFile */: + if (container.kind === 246 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -44803,11 +46634,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 211 /* ClassDeclaration */) { + if (declaration.kind === 212 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 212 /* InterfaceDeclaration */) { + else if (declaration.kind === 213 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -44839,7 +46670,7 @@ var ts; return aliasedSymbol; } } - // If the reference location is in an object literal, try to get the contextual type for the + // 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)) { @@ -44854,7 +46685,7 @@ var ts; if (searchSymbols.indexOf(rootSymbol) >= 0) { return rootSymbol; } - // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // Finally, try all properties with the same name in any type the containing type extended or implemented, and // see if any is in the list if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { var result_3 = []; @@ -44930,7 +46761,7 @@ var ts; function getReferenceEntryFromNode(node) { var start = node.getStart(); var end = node.getEnd(); - if (node.kind === 8 /* StringLiteral */) { + if (node.kind === 9 /* StringLiteral */) { start += 1; end -= 1; } @@ -44942,17 +46773,17 @@ var ts; } /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node) { - if (node.kind === 66 /* Identifier */ && ts.isDeclarationName(node)) { + if (node.kind === 67 /* Identifier */ && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 177 /* PostfixUnaryExpression */ || parent.kind === 176 /* PrefixUnaryExpression */) { + if (parent.kind === 178 /* PostfixUnaryExpression */ || parent.kind === 177 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 178 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 179 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; - return 54 /* FirstAssignment */ <= operator && operator <= 65 /* LastAssignment */; + return 55 /* FirstAssignment */ <= operator && operator <= 66 /* LastAssignment */; } } return false; @@ -44984,34 +46815,34 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 135 /* Parameter */: - case 208 /* VariableDeclaration */: - case 160 /* BindingElement */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: - case 242 /* PropertyAssignment */: - case 243 /* ShorthandPropertyAssignment */: - case 244 /* EnumMember */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 141 /* Constructor */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 210 /* FunctionDeclaration */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: - case 241 /* CatchClause */: + case 136 /* Parameter */: + case 209 /* VariableDeclaration */: + case 161 /* BindingElement */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: + case 243 /* PropertyAssignment */: + case 244 /* ShorthandPropertyAssignment */: + case 245 /* EnumMember */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 142 /* Constructor */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 211 /* FunctionDeclaration */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: + case 242 /* CatchClause */: return 1 /* Value */; - case 134 /* TypeParameter */: - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: - case 152 /* TypeLiteral */: + case 135 /* TypeParameter */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: + case 153 /* TypeLiteral */: return 2 /* Type */; - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 215 /* ModuleDeclaration */: - if (node.name.kind === 8 /* StringLiteral */) { + case 216 /* ModuleDeclaration */: + if (node.name.kind === 9 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { @@ -45020,15 +46851,15 @@ var ts; else { return 4 /* Namespace */; } - case 222 /* NamedImports */: - case 223 /* ImportSpecifier */: - case 218 /* ImportEqualsDeclaration */: - case 219 /* ImportDeclaration */: - case 224 /* ExportAssignment */: - case 225 /* ExportDeclaration */: + case 223 /* NamedImports */: + case 224 /* ImportSpecifier */: + case 219 /* ImportEqualsDeclaration */: + case 220 /* ImportDeclaration */: + case 225 /* ExportAssignment */: + case 226 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 245 /* SourceFile */: + case 246 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -45038,8 +46869,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 148 /* TypeReference */ || - (node.parent.kind === 185 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 149 /* TypeReference */ || + (node.parent.kind === 186 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -45047,50 +46878,50 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 163 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 163 /* PropertyAccessExpression */) { + if (root.parent.kind === 164 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 164 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 185 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 240 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 186 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 241 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 211 /* ClassDeclaration */ && root.parent.parent.token === 103 /* ImplementsKeyword */) || - (decl.kind === 212 /* InterfaceDeclaration */ && root.parent.parent.token === 80 /* ExtendsKeyword */); + return (decl.kind === 212 /* ClassDeclaration */ && root.parent.parent.token === 104 /* ImplementsKeyword */) || + (decl.kind === 213 /* InterfaceDeclaration */ && root.parent.parent.token === 81 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 132 /* QualifiedName */) { - while (root.parent && root.parent.kind === 132 /* QualifiedName */) { + if (root.parent.kind === 133 /* QualifiedName */) { + while (root.parent && root.parent.kind === 133 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 148 /* TypeReference */ && !isLastClause; + return root.parent.kind === 149 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 132 /* QualifiedName */) { + while (node.parent.kind === 133 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 66 /* Identifier */); + ts.Debug.assert(node.kind === 67 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 132 /* QualifiedName */ && + if (node.parent.kind === 133 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 218 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 219 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 224 /* ExportAssignment */) { + if (node.parent.kind === 225 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -45130,15 +46961,15 @@ var ts; return; } switch (node.kind) { - case 163 /* PropertyAccessExpression */: - case 132 /* QualifiedName */: - case 8 /* StringLiteral */: - case 81 /* FalseKeyword */: - case 96 /* TrueKeyword */: - case 90 /* NullKeyword */: - case 92 /* SuperKeyword */: - case 94 /* ThisKeyword */: - case 66 /* Identifier */: + case 164 /* PropertyAccessExpression */: + case 133 /* QualifiedName */: + case 9 /* StringLiteral */: + case 82 /* FalseKeyword */: + case 97 /* TrueKeyword */: + case 91 /* NullKeyword */: + case 93 /* SuperKeyword */: + case 95 /* ThisKeyword */: + case 67 /* Identifier */: break; // Cant create the text span default: @@ -45152,9 +46983,9 @@ var ts; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { // If this is name of a module declarations, check if this is right side of dotted module name - // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of + // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 215 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 216 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -45188,17 +47019,17 @@ var ts; // been canceled. That would be an enormous amount of chattyness, along with the all // the overhead of marshalling the data to/from the host. So instead we pick a few // reasonable node kinds to bother checking on. These node kinds represent high level - // constructs that we would expect to see commonly, but just at a far less frequent + // constructs that we would expect to see commonly, but just at a far less frequent // interval. // // For example, in checker.ts (around 750k) we only have around 600 of these constructs. // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 215 /* ModuleDeclaration */: - case 211 /* ClassDeclaration */: - case 212 /* InterfaceDeclaration */: - case 210 /* FunctionDeclaration */: + case 216 /* ModuleDeclaration */: + case 212 /* ClassDeclaration */: + case 213 /* InterfaceDeclaration */: + case 211 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -45252,7 +47083,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 215 /* ModuleDeclaration */ && + return declaration.kind === 216 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -45262,7 +47093,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(kind); - if (kind === 66 /* Identifier */ && !ts.nodeIsMissing(node)) { + if (kind === 67 /* Identifier */ && !ts.nodeIsMissing(node)) { var identifier = node; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run @@ -45323,8 +47154,8 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(2 /* Latest */, false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2 /* Latest */, false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(2 /* Latest */, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(2 /* Latest */, /*skipTrivia:*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; @@ -45355,13 +47186,13 @@ var ts; // Only bother with the trivia if it at least intersects the span of interest. if (ts.isComment(kind)) { classifyComment(token, kind, start, width); - // Classifying a comment might cause us to reuse the trivia scanner + // Classifying a comment might cause us to reuse the trivia scanner // (because of jsdoc comments). So after we classify the comment make // sure we set the scanner position back to where it needs to be. triviaScanner.setTextPos(end); continue; } - if (kind === 6 /* ConflictMarkerTrivia */) { + if (kind === 7 /* ConflictMarkerTrivia */) { var text = sourceFile.text; var ch = text.charCodeAt(start); // for the <<<<<<< and >>>>>>> markers, we just add them in as comments @@ -45399,7 +47230,7 @@ var ts; for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { var tag = _a[_i]; // As we walk through each tag, classify the portion of text from the end of - // the last tag (or the start of the entire doc comment) as 'comment'. + // the last tag (or the start of the entire doc comment) as 'comment'. if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } @@ -45407,16 +47238,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 264 /* JSDocParameterTag */: + case 265 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 267 /* JSDocTemplateTag */: + case 268 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 266 /* JSDocTypeTag */: + case 267 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 265 /* JSDocReturnTag */: + case 266 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -45451,7 +47282,7 @@ var ts; } } function classifyDisabledMergeCode(text, start, end) { - // Classify the line that the ======= marker is on as a comment. Then just lex + // Classify the line that the ======= marker is on as a comment. Then just lex // all further tokens and add them to the result. for (var i = start; i < end; i++) { if (ts.isLineBreak(text.charCodeAt(i))) { @@ -45487,7 +47318,7 @@ var ts; } } } - // for accurate classification, the actual token should be passed in. however, for + // for accurate classification, the actual token should be passed in. however, for // cases like 'disabled merge code' classification, we just get the token kind and // classify based on that instead. function classifyTokenType(tokenKind, token) { @@ -45496,7 +47327,7 @@ var ts; } // Special case < and > If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 24 /* LessThanToken */ || tokenKind === 26 /* GreaterThanToken */) { + if (tokenKind === 25 /* LessThanToken */ || tokenKind === 27 /* GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { @@ -45505,30 +47336,30 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 54 /* EqualsToken */) { + if (tokenKind === 55 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 208 /* VariableDeclaration */ || - token.parent.kind === 138 /* PropertyDeclaration */ || - token.parent.kind === 135 /* Parameter */) { + if (token.parent.kind === 209 /* VariableDeclaration */ || + token.parent.kind === 139 /* PropertyDeclaration */ || + token.parent.kind === 136 /* Parameter */) { return 5 /* operator */; } } - if (token.parent.kind === 178 /* BinaryExpression */ || - token.parent.kind === 176 /* PrefixUnaryExpression */ || - token.parent.kind === 177 /* PostfixUnaryExpression */ || - token.parent.kind === 179 /* ConditionalExpression */) { + if (token.parent.kind === 179 /* BinaryExpression */ || + token.parent.kind === 177 /* PrefixUnaryExpression */ || + token.parent.kind === 178 /* PostfixUnaryExpression */ || + token.parent.kind === 180 /* ConditionalExpression */) { return 5 /* operator */; } } return 10 /* punctuation */; } - else if (tokenKind === 7 /* NumericLiteral */) { + else if (tokenKind === 8 /* NumericLiteral */) { return 4 /* numericLiteral */; } - else if (tokenKind === 8 /* StringLiteral */) { + else if (tokenKind === 9 /* StringLiteral */) { return 6 /* stringLiteral */; } - else if (tokenKind === 9 /* RegularExpressionLiteral */) { + else if (tokenKind === 10 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. return 6 /* stringLiteral */; } @@ -45536,35 +47367,35 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 66 /* Identifier */) { + else if (tokenKind === 67 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 134 /* TypeParameter */: + case 135 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 212 /* InterfaceDeclaration */: + case 213 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 135 /* Parameter */: + case 136 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } @@ -45630,14 +47461,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 14 /* OpenBraceToken */: return 15 /* CloseBraceToken */; - case 16 /* OpenParenToken */: return 17 /* CloseParenToken */; - case 18 /* OpenBracketToken */: return 19 /* CloseBracketToken */; - case 24 /* LessThanToken */: return 26 /* GreaterThanToken */; - case 15 /* CloseBraceToken */: return 14 /* OpenBraceToken */; - case 17 /* CloseParenToken */: return 16 /* OpenParenToken */; - case 19 /* CloseBracketToken */: return 18 /* OpenBracketToken */; - case 26 /* GreaterThanToken */: return 24 /* LessThanToken */; + case 15 /* OpenBraceToken */: return 16 /* CloseBraceToken */; + case 17 /* OpenParenToken */: return 18 /* CloseParenToken */; + case 19 /* OpenBracketToken */: return 20 /* CloseBracketToken */; + case 25 /* LessThanToken */: return 27 /* GreaterThanToken */; + case 16 /* CloseBraceToken */: return 15 /* OpenBraceToken */; + case 18 /* CloseParenToken */: return 17 /* OpenParenToken */; + case 20 /* CloseBracketToken */: return 19 /* OpenBracketToken */; + case 27 /* GreaterThanToken */: return 25 /* LessThanToken */; } return undefined; } @@ -45672,12 +47503,73 @@ var ts; } return []; } + /** + * Checks if position points to a valid position to add JSDoc comments, and if so, + * returns the appropriate template. Otherwise returns an empty string. + * Valid positions are + * - outside of comments, statements, and expressions, and + * - preceding a function declaration. + * + * Hosts should ideally check that: + * - The line is all whitespace up to 'position' before performing the insertion. + * - If the keystroke sequence "/\*\*" induced the call, we also check that the next + * non-whitespace character is '*', which (approximately) indicates whether we added + * the second '*' to complete an existing (JSDoc) comment. + * @param fileName The file in which to perform the check. + * @param position The (character-indexed) position in the file where the check should + * be performed. + */ + function getDocCommentTemplateAtPosition(fileName, position) { + var start = new Date().getTime(); + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + // Check if in a context where we don't want to perform any insertion + if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { + return undefined; + } + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); + var tokenStart = tokenAtPos.getStart(); + if (!tokenAtPos || tokenStart < position) { + return undefined; + } + // TODO: add support for: + // - methods + // - constructors + // - class decls + var containingFunction = ts.getAncestor(tokenAtPos, 211 /* FunctionDeclaration */); + if (!containingFunction || containingFunction.getStart() < position) { + return undefined; + } + var parameters = containingFunction.parameters; + var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); + var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + // TODO: call a helper method instead once PR #4133 gets merged in. + var newLine = host.getNewLine ? host.getNewLine() : "\r\n"; + var docParams = parameters.reduce(function (prev, cur, index) { + return prev + + indentationStr + " * @param " + (cur.name.kind === 67 /* Identifier */ ? cur.name.text : "param" + index) + newLine; + }, ""); + // A doc comment consists of the following + // * The opening comment line + // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) + // * the '@param'-tagged lines + // * TODO: other tags. + // * the closing comment line + // * if the caret was directly in front of the object, then we add an extra line and indentation. + var preamble = "/**" + newLine + + indentationStr + " * "; + var result = preamble + newLine + + docParams + + indentationStr + " */" + + (tokenStart === position ? newLine + indentationStr : ""); + return { newText: result, caretOffset: preamble.length }; + } function getTodoComments(fileName, descriptors) { - // Note: while getting todo comments seems like a syntactic operation, we actually + // Note: while getting todo comments seems like a syntactic operation, we actually // treat it as a semantic operation here. This is because we expect our host to call // this on every single file. If we treat this syntactically, then that will cause // us to populate and throw away the tree in our syntax tree cache for each file. By - // treating this as a semantic operation, we can access any tree without throwing + // treating this as a semantic operation, we can access any tree without throwing // anything away. synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -45701,7 +47593,7 @@ var ts; // 0) The full match for the entire regexp. // 1) The preamble to the message portion. // 2) The message portion. - // 3...N) The descriptor that was matched - by index. 'undefined' for each + // 3...N) The descriptor that was matched - by index. 'undefined' for each // descriptor that didn't match. an actual value if it did match. // // i.e. 'undefined' in position 3 above means TODO(jason) didn't match. @@ -45723,7 +47615,7 @@ var ts; } } ts.Debug.assert(descriptor !== undefined); - // We don't want to match something like 'TODOBY', so we make sure a non + // We don't want to match something like 'TODOBY', so we make sure a non // letter/digit follows the match. if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { continue; @@ -45768,10 +47660,10 @@ var ts; // (?:(TODO\(jason\))|(HACK)) // // Note that the outermost group is *not* a capture group, but the innermost groups - // *are* capture groups. By capturing the inner literals we can determine after + // *are* capture groups. By capturing the inner literals we can determine after // matching which descriptor we are dealing with. var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; - // After matching a descriptor literal, the following regexp matches the rest of the + // After matching a descriptor literal, the following regexp matches the rest of the // text up to the end of the line (or */). var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; var messageRemainder = /(?:.*?)/.source; @@ -45802,7 +47694,7 @@ var ts; var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); // Can only rename an identifier. - if (node && node.kind === 66 /* Identifier */) { + if (node && node.kind === 67 /* Identifier */) { var symbol = typeChecker.getSymbolAtLocation(node); // Only allow a symbol to be renamed if it actually has at least one declaration. if (symbol) { @@ -45882,6 +47774,7 @@ var ts; getFormattingEditsForRange: getFormattingEditsForRange, getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, getEmitOutput: getEmitOutput, getSourceFile: getSourceFile, getProgram: getProgram @@ -45902,17 +47795,17 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 66 /* Identifier */: + case 67 /* Identifier */: nameTable[node.text] = node.text; break; - case 8 /* StringLiteral */: - case 7 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: // We want to store any numbers/strings if they were a name that could be // related to a declaration. So, if we have 'import x = require("something")' // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 229 /* ExternalModuleReference */ || + node.parent.kind === 230 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -45925,29 +47818,29 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 164 /* ElementAccessExpression */ && + node.parent.kind === 165 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier function createClassifier() { - var scanner = ts.createScanner(2 /* Latest */, false); + var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); /// We do not have a full parser support to know when we should parse a regex or not /// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where - /// we have a series of divide operator. this list allows us to be more accurate by ruling out + /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = []; - noRegexTable[66 /* Identifier */] = true; - noRegexTable[8 /* StringLiteral */] = true; - noRegexTable[7 /* NumericLiteral */] = true; - noRegexTable[9 /* RegularExpressionLiteral */] = true; - noRegexTable[94 /* ThisKeyword */] = true; - noRegexTable[39 /* PlusPlusToken */] = true; - noRegexTable[40 /* MinusMinusToken */] = true; - noRegexTable[17 /* CloseParenToken */] = true; - noRegexTable[19 /* CloseBracketToken */] = true; - noRegexTable[15 /* CloseBraceToken */] = true; - noRegexTable[96 /* TrueKeyword */] = true; - noRegexTable[81 /* FalseKeyword */] = true; + noRegexTable[67 /* Identifier */] = true; + noRegexTable[9 /* StringLiteral */] = true; + noRegexTable[8 /* NumericLiteral */] = true; + noRegexTable[10 /* RegularExpressionLiteral */] = true; + noRegexTable[95 /* ThisKeyword */] = true; + noRegexTable[40 /* PlusPlusToken */] = true; + noRegexTable[41 /* MinusMinusToken */] = true; + noRegexTable[18 /* CloseParenToken */] = true; + noRegexTable[20 /* CloseBracketToken */] = true; + noRegexTable[16 /* CloseBraceToken */] = true; + noRegexTable[97 /* TrueKeyword */] = true; + noRegexTable[82 /* FalseKeyword */] = true; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -45972,11 +47865,11 @@ var ts; /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 120 /* GetKeyword */ || - keyword2 === 126 /* SetKeyword */ || - keyword2 === 118 /* ConstructorKeyword */ || - keyword2 === 110 /* StaticKeyword */) { - // Allow things like "public get", "public constructor" and "public static". + if (keyword2 === 121 /* GetKeyword */ || + keyword2 === 127 /* SetKeyword */ || + keyword2 === 119 /* ConstructorKeyword */ || + keyword2 === 111 /* StaticKeyword */) { + // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; } @@ -45994,7 +47887,7 @@ var ts; var lastEnd = 0; for (var i = 0, n = dense.length; i < n; i += 3) { var start = dense[i]; - var length_2 = dense[i + 1]; + var length_3 = dense[i + 1]; var type = dense[i + 2]; // Make a whitespace entry between the last item and this one. if (lastEnd >= 0) { @@ -46003,8 +47896,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: TokenClass.Whitespace }); } } - entries.push({ length: length_2, classification: convertClassification(type) }); - lastEnd = start + length_2; + entries.push({ length: length_3, classification: convertClassification(type) }); + lastEnd = start + length_3; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -46074,7 +47967,7 @@ var ts; offset = 2; // fallthrough case 6 /* InTemplateSubstitutionPosition */: - templateStack.push(11 /* TemplateHead */); + templateStack.push(12 /* TemplateHead */); break; } scanner.setText(text); @@ -46093,83 +47986,83 @@ var ts; // token. So the classification will go back to being an identifier. The moment the user // types again, number will become a keyword, then an identifier, etc. etc. // - // To try to avoid this problem, we avoid classifying contextual keywords as keywords + // To try to avoid this problem, we avoid classifying contextual keywords as keywords // when the user is potentially typing something generic. We just can't do a good enough // job at the lexical level, and so well leave it up to the syntactic classifier to make // the determination. // - // In order to determine if the user is potentially typing something generic, we use a + // In order to determine if the user is potentially typing something generic, we use a // weak heuristic where we track < and > tokens. It's a weak heuristic, but should // work well enough in practice. var angleBracketStack = 0; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 37 /* SlashToken */ || token === 58 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 9 /* RegularExpressionLiteral */) { - token = 9 /* RegularExpressionLiteral */; + if ((token === 38 /* SlashToken */ || token === 59 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 10 /* RegularExpressionLiteral */) { + token = 10 /* RegularExpressionLiteral */; } } - else if (lastNonTriviaToken === 20 /* DotToken */ && isKeyword(token)) { - token = 66 /* Identifier */; + else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { + token = 67 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - // We have two keywords in a row. Only treat the second as a keyword if + // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 66 /* Identifier */; + token = 67 /* Identifier */; } - else if (lastNonTriviaToken === 66 /* Identifier */ && - token === 24 /* LessThanToken */) { - // Could be the start of something generic. Keep track of that by bumping + else if (lastNonTriviaToken === 67 /* Identifier */ && + token === 25 /* LessThanToken */) { + // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } - else if (token === 26 /* GreaterThanToken */ && angleBracketStack > 0) { + else if (token === 27 /* GreaterThanToken */ && angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } - else if (token === 114 /* AnyKeyword */ || - token === 127 /* StringKeyword */ || - token === 125 /* NumberKeyword */ || - token === 117 /* BooleanKeyword */ || - token === 128 /* SymbolKeyword */) { + else if (token === 115 /* AnyKeyword */ || + token === 128 /* StringKeyword */ || + token === 126 /* NumberKeyword */ || + token === 118 /* BooleanKeyword */ || + token === 129 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - // If it looks like we're could be in something generic, don't classify this + // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 66 /* Identifier */; + token = 67 /* Identifier */; } } - else if (token === 11 /* TemplateHead */) { + else if (token === 12 /* TemplateHead */) { templateStack.push(token); } - else if (token === 14 /* OpenBraceToken */) { + else if (token === 15 /* OpenBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 15 /* CloseBraceToken */) { + else if (token === 16 /* CloseBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 11 /* TemplateHead */) { + if (lastTemplateStackToken === 12 /* TemplateHead */) { token = scanner.reScanTemplateToken(); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 13 /* TemplateTail */) { + if (token === 14 /* TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assert(token === 12 /* TemplateMiddle */, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 13 /* TemplateMiddle */, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 14 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 15 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -46184,7 +48077,7 @@ var ts; var end = scanner.getTextPos(); addResult(start, end, classFromKind(token)); if (end >= text.length) { - if (token === 8 /* StringLiteral */) { + if (token === 9 /* StringLiteral */) { // Check to see if we finished up on a multiline string literal. var tokenText = scanner.getTokenText(); if (scanner.isUnterminated()) { @@ -46210,10 +48103,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 13 /* TemplateTail */) { + if (token === 14 /* TemplateTail */) { result.endOfLineState = 5 /* InTemplateMiddleOrTail */; } - else if (token === 10 /* NoSubstitutionTemplateLiteral */) { + else if (token === 11 /* NoSubstitutionTemplateLiteral */) { result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; } else { @@ -46221,7 +48114,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 11 /* TemplateHead */) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12 /* TemplateHead */) { result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; } } @@ -46232,8 +48125,8 @@ var ts; return; } if (start === 0 && offset > 0) { - // We're classifying the first token, and this was a case where we prepended - // text. We should consider the start of this token to be at the start of + // We're classifying the first token, and this was a case where we prepended + // text. We should consider the start of this token to be at the start of // the original text. start += offset; } @@ -46251,42 +48144,42 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 36 /* AsteriskToken */: - case 37 /* SlashToken */: - case 38 /* PercentToken */: - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 41 /* LessThanLessThanToken */: - case 42 /* GreaterThanGreaterThanToken */: - case 43 /* GreaterThanGreaterThanGreaterThanToken */: - case 24 /* LessThanToken */: - case 26 /* GreaterThanToken */: - case 27 /* LessThanEqualsToken */: - case 28 /* GreaterThanEqualsToken */: - case 88 /* InstanceOfKeyword */: - case 87 /* InKeyword */: - case 29 /* EqualsEqualsToken */: - case 30 /* ExclamationEqualsToken */: - case 31 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsEqualsToken */: - case 44 /* AmpersandToken */: - case 46 /* CaretToken */: - case 45 /* BarToken */: - case 49 /* AmpersandAmpersandToken */: - case 50 /* BarBarToken */: - case 64 /* BarEqualsToken */: - case 63 /* AmpersandEqualsToken */: - case 65 /* CaretEqualsToken */: - case 60 /* LessThanLessThanEqualsToken */: - case 61 /* GreaterThanGreaterThanEqualsToken */: - case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 55 /* PlusEqualsToken */: - case 56 /* MinusEqualsToken */: - case 57 /* AsteriskEqualsToken */: - case 58 /* SlashEqualsToken */: - case 59 /* PercentEqualsToken */: - case 54 /* EqualsToken */: - case 23 /* CommaToken */: + case 37 /* AsteriskToken */: + case 38 /* SlashToken */: + case 39 /* PercentToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 42 /* LessThanLessThanToken */: + case 43 /* GreaterThanGreaterThanToken */: + case 44 /* GreaterThanGreaterThanGreaterThanToken */: + case 25 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 28 /* LessThanEqualsToken */: + case 29 /* GreaterThanEqualsToken */: + case 89 /* InstanceOfKeyword */: + case 88 /* InKeyword */: + case 30 /* EqualsEqualsToken */: + case 31 /* ExclamationEqualsToken */: + case 32 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsEqualsToken */: + case 45 /* AmpersandToken */: + case 47 /* CaretToken */: + case 46 /* BarToken */: + case 50 /* AmpersandAmpersandToken */: + case 51 /* BarBarToken */: + case 65 /* BarEqualsToken */: + case 64 /* AmpersandEqualsToken */: + case 66 /* CaretEqualsToken */: + case 61 /* LessThanLessThanEqualsToken */: + case 62 /* GreaterThanGreaterThanEqualsToken */: + case 63 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 56 /* PlusEqualsToken */: + case 57 /* MinusEqualsToken */: + case 58 /* AsteriskEqualsToken */: + case 59 /* SlashEqualsToken */: + case 60 /* PercentEqualsToken */: + case 55 /* EqualsToken */: + case 24 /* CommaToken */: return true; default: return false; @@ -46294,19 +48187,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 34 /* PlusToken */: - case 35 /* MinusToken */: - case 48 /* TildeToken */: - case 47 /* ExclamationToken */: - case 39 /* PlusPlusToken */: - case 40 /* MinusMinusToken */: + case 35 /* PlusToken */: + case 36 /* MinusToken */: + case 49 /* TildeToken */: + case 48 /* ExclamationToken */: + case 40 /* PlusPlusToken */: + case 41 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 67 /* FirstKeyword */ && token <= 131 /* LastKeyword */; + return token >= 68 /* FirstKeyword */ && token <= 132 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -46315,24 +48208,24 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 14 /* FirstPunctuation */ && token <= 65 /* LastPunctuation */) { + else if (token >= 15 /* FirstPunctuation */ && token <= 66 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { - case 7 /* NumericLiteral */: + case 8 /* NumericLiteral */: return 4 /* numericLiteral */; - case 8 /* StringLiteral */: + case 9 /* StringLiteral */: return 6 /* stringLiteral */; - case 9 /* RegularExpressionLiteral */: + case 10 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; - case 6 /* ConflictMarkerTrivia */: + case 7 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: case 2 /* SingleLineCommentTrivia */: return 1 /* comment */; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 66 /* Identifier */: + case 67 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -46364,7 +48257,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 245 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 246 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = -1; proto.end = -1; @@ -46434,159 +48327,159 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ForStatement */) { + if (node.parent.kind === 197 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 178 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { + if (node.parent.kind === 179 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind === 171 /* ArrowFunction */ && node.parent.body === node) { + if (node.parent.kind === 172 /* ArrowFunction */ && node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); } } switch (node.kind) { - case 190 /* VariableStatement */: + case 191 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 208 /* VariableDeclaration */: - case 138 /* PropertyDeclaration */: - case 137 /* PropertySignature */: + case 209 /* VariableDeclaration */: + case 139 /* PropertyDeclaration */: + case 138 /* PropertySignature */: return spanInVariableDeclaration(node); - case 135 /* Parameter */: + case 136 /* Parameter */: return spanInParameterDeclaration(node); - case 210 /* FunctionDeclaration */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 170 /* FunctionExpression */: - case 171 /* ArrowFunction */: + case 211 /* FunctionDeclaration */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 171 /* FunctionExpression */: + case 172 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 216 /* ModuleBlock */: + case 217 /* ModuleBlock */: return spanInBlock(node); - case 241 /* CatchClause */: + case 242 /* CatchClause */: return spanInBlock(node.block); - case 192 /* ExpressionStatement */: + case 193 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 201 /* ReturnStatement */: + case 202 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 195 /* WhileStatement */: + case 196 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 194 /* DoStatement */: + case 195 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 207 /* DebuggerStatement */: + case 208 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 193 /* IfStatement */: + case 194 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 204 /* LabeledStatement */: + case 205 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 200 /* BreakStatement */: - case 199 /* ContinueStatement */: + case 201 /* BreakStatement */: + case 200 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 196 /* ForStatement */: + case 197 /* ForStatement */: return spanInForStatement(node); - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 203 /* SwitchStatement */: + case 204 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 238 /* CaseClause */: - case 239 /* DefaultClause */: + case 239 /* CaseClause */: + case 240 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 206 /* TryStatement */: + case 207 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 205 /* ThrowStatement */: + case 206 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 224 /* ExportAssignment */: + case 225 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 219 /* ImportDeclaration */: + case 220 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 225 /* ExportDeclaration */: + case 226 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 211 /* ClassDeclaration */: - case 214 /* EnumDeclaration */: - case 244 /* EnumMember */: - case 165 /* CallExpression */: - case 166 /* NewExpression */: + case 212 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 245 /* EnumMember */: + case 166 /* CallExpression */: + case 167 /* NewExpression */: // span on complete node return textSpan(node); - case 202 /* WithStatement */: + case 203 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 212 /* InterfaceDeclaration */: - case 213 /* TypeAliasDeclaration */: + case 213 /* InterfaceDeclaration */: + case 214 /* TypeAliasDeclaration */: return undefined; // Tokens: - case 22 /* SemicolonToken */: + case 23 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 23 /* CommaToken */: + case 24 /* CommaToken */: return spanInPreviousNode(node); - case 14 /* OpenBraceToken */: + case 15 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 15 /* CloseBraceToken */: + case 16 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 16 /* OpenParenToken */: + case 17 /* OpenParenToken */: return spanInOpenParenToken(node); - case 17 /* CloseParenToken */: + case 18 /* CloseParenToken */: return spanInCloseParenToken(node); - case 52 /* ColonToken */: + case 53 /* ColonToken */: return spanInColonToken(node); - case 26 /* GreaterThanToken */: - case 24 /* LessThanToken */: + case 27 /* GreaterThanToken */: + case 25 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 101 /* WhileKeyword */: + case 102 /* WhileKeyword */: return spanInWhileKeyword(node); - case 77 /* ElseKeyword */: - case 69 /* CatchKeyword */: - case 82 /* FinallyKeyword */: + case 78 /* ElseKeyword */: + case 70 /* CatchKeyword */: + case 83 /* FinallyKeyword */: return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 242 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 243 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 168 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 169 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -46599,12 +48492,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 197 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 198 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 198 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 199 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 190 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 196 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 191 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 197 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -46658,7 +48551,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 211 /* ClassDeclaration */ && functionDeclaration.kind !== 141 /* Constructor */); + (functionDeclaration.parent.kind === 212 /* ClassDeclaration */ && functionDeclaration.kind !== 142 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -46681,18 +48574,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 215 /* ModuleDeclaration */: + case 216 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 195 /* WhileStatement */: - case 193 /* IfStatement */: - case 197 /* ForInStatement */: - case 198 /* ForOfStatement */: + case 196 /* WhileStatement */: + case 194 /* IfStatement */: + case 198 /* ForInStatement */: + case 199 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 196 /* ForStatement */: + case 197 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -46700,7 +48593,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 209 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 210 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -46720,13 +48613,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 214 /* EnumDeclaration */: + case 215 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 211 /* ClassDeclaration */: + case 212 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -46734,25 +48627,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 216 /* ModuleBlock */: + case 217 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 214 /* EnumDeclaration */: - case 211 /* ClassDeclaration */: + case 215 /* EnumDeclaration */: + case 212 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 189 /* Block */: + case 190 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 241 /* CatchClause */: + case 242 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 217 /* CaseBlock */: + case 218 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -46766,7 +48659,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -46776,17 +48669,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 170 /* FunctionExpression */: - case 210 /* FunctionDeclaration */: - case 171 /* ArrowFunction */: - case 140 /* MethodDeclaration */: - case 139 /* MethodSignature */: - case 142 /* GetAccessor */: - case 143 /* SetAccessor */: - case 141 /* Constructor */: - case 195 /* WhileStatement */: - case 194 /* DoStatement */: - case 196 /* ForStatement */: + case 171 /* FunctionExpression */: + case 211 /* FunctionDeclaration */: + case 172 /* ArrowFunction */: + case 141 /* MethodDeclaration */: + case 140 /* MethodSignature */: + case 143 /* GetAccessor */: + case 144 /* SetAccessor */: + case 142 /* Constructor */: + case 196 /* WhileStatement */: + case 195 /* DoStatement */: + case 197 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -46797,19 +48690,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 242 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 243 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 168 /* TypeAssertionExpression */) { + if (node.parent.kind === 169 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 194 /* DoStatement */) { + if (node.parent.kind === 195 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -46878,9 +48771,21 @@ var ts; })(); var LanguageServiceShimHostAdapter = (function () { function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; this.shimHost = shimHost; this.loggingEnabled = false; this.tracingEnabled = false; + // if shimHost is a COM object then property check will become method call with no arguments. + // 'in' does not have this effect. + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { + var result = ts.lookUp(resolutionsInFile, name); + return result ? { resolvedFileName: result } : undefined; + }); + }; + } } LanguageServiceShimHostAdapter.prototype.log = function (s) { if (this.loggingEnabled) { @@ -46988,10 +48893,26 @@ var ts; function CoreServicesShimHostAdapter(shimHost) { this.shimHost = shimHost; } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension) { - var encoded = this.shimHost.readDirectory(rootDir, extension); + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension, exclude) { + // Wrap the API changes for 1.5 release. This try/catch + // should be removed once TypeScript 1.5 has shipped. + // Also consider removing the optional designation for + // the exclude param at this time. + var encoded; + try { + encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); + } + catch (e) { + encoded = this.shimHost.readDirectory(rootDir, extension); + } return JSON.parse(encoded); }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; return CoreServicesShimHostAdapter; })(); ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; @@ -47098,7 +49019,7 @@ var ts; }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { - var newLine = this.getNewLine(); + var newLine = ts.getNewLineOrDefaultFromHost(this.host); return ts.realizeDiagnostics(diagnostics, newLine); }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { @@ -47131,9 +49052,6 @@ var ts; return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; - LanguageServiceShimObject.prototype.getNewLine = function () { - return this.host.getNewLine ? this.host.getNewLine() : "\r\n"; - }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { @@ -47270,7 +49188,10 @@ var ts; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { - return _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + // workaround for VS document higlighting issue - keep only items from the initial file + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); }); }; /// COMPLETION LISTS @@ -47318,6 +49239,10 @@ var ts; return edits; }); }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount) { @@ -47401,12 +49326,24 @@ var ts; CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + return { + resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); var convertResult = { referencedFiles: [], importedFiles: [], + ambientExternalModules: result.ambientExternalModules, isLibFile: result.isLibFile }; ts.forEach(result.referencedFiles, function (refFile) { @@ -47530,4 +49467,4 @@ var TypeScript; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); /* @internal */ -var toolsVersion = "1.5"; +var toolsVersion = "1.6"; diff --git a/package.json b/package.json index 52dabc79f6e..28f2c1b5755 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "http://typescriptlang.org/", - "version": "1.6.0", + "version": "1.7.0", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ @@ -20,6 +20,7 @@ "url": "https://github.com/Microsoft/TypeScript.git" }, "main": "./lib/typescript.js", + "typings": "./lib/typescript.d.ts", "bin": { "tsc": "./bin/tsc", "tsserver": "./bin/tsserver" @@ -34,7 +35,8 @@ "browserify": "latest", "istanbul": "latest", "mocha-fivemat-progress-reporter": "latest", - "tslint": "latest" + "tslint": "latest", + "tsd": "latest" }, "scripts": { "pretest": "jake tests", @@ -42,12 +44,15 @@ "build": "npm run build:compiler && npm run build:tests", "build:compiler": "jake local", "build:tests": "jake tests", - "clean": "jake clean" + "clean": "jake clean", + "jake": "jake", + "lint": "jake lint", + "setup-hooks": "node scripts/link-hooks.js" }, "browser": { "buffer": false, "fs": false, "os": false, "path": false - } + } } diff --git a/scripts/hooks/post-checkout b/scripts/hooks/post-checkout new file mode 100644 index 00000000000..fb41e4e8652 --- /dev/null +++ b/scripts/hooks/post-checkout @@ -0,0 +1,2 @@ +#!/bin/sh +npm run jake -- generate-diagnostics \ No newline at end of file diff --git a/scripts/importDefinitelyTypedTests.ts b/scripts/importDefinitelyTypedTests.ts deleted file mode 100644 index f33ba1dd525..00000000000 --- a/scripts/importDefinitelyTypedTests.ts +++ /dev/null @@ -1,125 +0,0 @@ -declare var require: any, process: any; -declare var __dirname: any; - -var fs = require("fs"); -var path = require("path"); -var child_process = require('child_process'); - -var tscRoot = path.join(__dirname, "..\\"); -var tscPath = path.join(tscRoot, "built", "instrumented", "tsc.js"); -var rwcTestPath = path.join(tscRoot, "tests", "cases", "rwc", "dt"); -var definitelyTypedRoot = process.argv[2]; - -function fileExtensionIs(path: string, extension: string): boolean { - var pathLen = path.length; - var extLen = extension.length; - return pathLen > extLen && path.substr(pathLen - extLen, extLen).toLocaleLowerCase() === extension.toLocaleLowerCase(); -} - -function copyFileSync(source, destination) { - var text = fs.readFileSync(source); - fs.writeFileSync(destination, text); -} - -function importDefinitelyTypedTest(testCaseName: string, testFiles: string[], responseFile: string ) { - var cmd = "node " + tscPath + " --module commonjs " + testFiles.join(" "); - if (responseFile) cmd += " @" + responseFile; - - var testDirectoryName = testCaseName + "_" + Math.floor((Math.random() * 10000) + 1); - var testDirectoryPath = path.join(process.env["temp"], testDirectoryName); - if (fs.existsSync(testDirectoryPath)) { - throw new Error("Could not create test directory"); - } - fs.mkdirSync(testDirectoryPath); - - child_process.exec(cmd, { - maxBuffer: 1 * 1024 * 1024, - cwd: testDirectoryPath - }, (error, stdout, stderr) => { - console.log("importing " + testCaseName + " ..."); - console.log(cmd); - - if (error) { - console.log("importing " + testCaseName + " ..."); - console.log(cmd); - console.log("==> error " + JSON.stringify(error)); - console.log("==> stdout " + String(stdout)); - console.log("==> stderr " + String(stderr)); - console.log("\r\n"); - return; - } - - // copy generated file to output location - var outputFilePath = path.join(testDirectoryPath, "iocapture0.json"); - var testCasePath = path.join(rwcTestPath, "DefinitelyTyped_" + testCaseName + ".json"); - copyFileSync(outputFilePath, testCasePath); - - //console.log("output generated at: " + outputFilePath); - - if (!fs.existsSync(testCasePath)) { - throw new Error("could not find test case at: " + testCasePath); - } - else { - fs.unlinkSync(outputFilePath); - fs.rmdirSync(testDirectoryPath); - //console.log("testcase generated at: " + testCasePath); - //console.log("Done."); - } - //console.log("\r\n"); - - }) - .on('error', function (error) { - console.log("==> error " + JSON.stringify(error)); - console.log("\r\n"); - }); -} - -function importDefinitelyTypedTests(definitelyTypedRoot: string): void { - fs.readdir(definitelyTypedRoot, (err, subDirectorys) => { - if (err) throw err; - - subDirectorys - .filter(d => ["_infrastructure", "node_modules", ".git"].indexOf(d) < 0) - .filter(i => i.indexOf("sipml") >=0 ) - .filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory()) - .forEach(d => { - var directoryPath = path.join(definitelyTypedRoot, d); - fs.readdir(directoryPath, function (err, files) { - if (err) throw err; - - var tsFiles = []; - var testFiles = []; - var paramFile; - - files - .map(f => path.join(directoryPath, f)) - .forEach(f => { - if (fileExtensionIs(f, ".ts")) tsFiles.push(f); - else if (fileExtensionIs(f, ".tscparams")) paramFile = f; - - if (fileExtensionIs(f, "-tests.ts")) testFiles.push(f); - }); - - if (testFiles.length === 0) { - // no test files but multiple d.ts's, e.g. winjs - var regexp = new RegExp(d + "(([-][0-9])|([\.]d[\.]ts))"); - if (tsFiles.length > 1 && tsFiles.every(t => fileExtensionIs(t, ".d.ts") && regexp.test(t))) { - tsFiles.forEach(filename => { - importDefinitelyTypedTest(path.basename(filename, ".d.ts"), [filename], paramFile); - }); - } - else { - importDefinitelyTypedTest(d, tsFiles, paramFile); - } - } - else { - testFiles.forEach(filename => { - importDefinitelyTypedTest(path.basename(filename, "-tests.ts"), [filename], paramFile); - }); - } - }); - }) - }); -} - -importDefinitelyTypedTests(definitelyTypedRoot); \ No newline at end of file diff --git a/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts new file mode 100644 index 00000000000..1ae3725fff2 --- /dev/null +++ b/scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.ts @@ -0,0 +1,161 @@ +import * as fs from "fs"; +import * as path from "path"; +import * as child_process from "child_process"; + + +interface Map { + [key: string]: T; +} + +declare var process: { + argv: string[]; + env: Map; + exit(exitCode?: number): void; +} + +main(); +function main() { + const [, progName, tscRoot, definitelyTypedRoot] = process.argv; + if (process.argv.length !== 4) { + if (process.argv.length < 2) { + throw "Expected at least 2 argv elements." + } + console.log("Usage:") + console.log(` node ${path.relative(__dirname, progName)} [TypeScript Repo Root] [DefinitelyTyped Repo Root]`); + return; + } + + const tscPath = path.resolve(tscRoot, "built", "local", "tsc.js"); + const rwcTestPath = path.resolve(tscRoot, "internal", "cases", "rwc"); + const resolvedDefinitelyTypedRoot = path.resolve(definitelyTypedRoot); + + console.log(`Resolved TypeScript Compiler Path: '${tscPath}'.`); + console.log(`Resolved TypeScript RWC Path: '${rwcTestPath}'.`); + console.log(`Resolved DefinitelyTyped Repo Root: '${resolvedDefinitelyTypedRoot}'.`); + importDefinitelyTypedTests(tscPath, rwcTestPath, resolvedDefinitelyTypedRoot); +} + +function filePathEndsWith(path: string, endingString: string): boolean { + const pathLen = path.length; + const extLen = endingString.length; + return pathLen > extLen && path.substr(pathLen - extLen, extLen).toLocaleLowerCase() === endingString.toLocaleLowerCase(); +} + +function copyFileSync(source: string, destination: string) { + let text = fs.readFileSync(source); + fs.writeFileSync(destination, text); +} + +function importDefinitelyTypedTest(tscPath: string, rwcTestPath: string, testCaseName: string, testFiles: string[], responseFile: string ) { + let cmd = "node " + tscPath + " --module commonjs " + testFiles.join(" "); + if (responseFile) { + cmd += " @" + responseFile; + } + + let testDirectoryName = testCaseName + "_" + Math.floor((Math.random() * 10000) + 1); + let testDirectoryPath = path.join(process.env["temp"], testDirectoryName); + if (fs.existsSync(testDirectoryPath)) { + throw new Error("Could not create test directory"); + } + fs.mkdirSync(testDirectoryPath); + + child_process.exec(cmd, { + maxBuffer: 1 * 1024 * 1024, + cwd: testDirectoryPath + }, (error, stdout, stderr) => { + console.log("importing " + testCaseName + " ..."); + console.log(cmd); + + if (error) { + console.log("importing " + testCaseName + " ..."); + console.log(cmd); + console.log("==> error " + JSON.stringify(error)); + console.log("==> stdout " + String(stdout)); + console.log("==> stderr " + String(stderr)); + console.log("\r\n"); + return; + } + + // copy generated file to output location + let outputFilePath = path.join(testDirectoryPath, "iocapture0.json"); + let testCasePath = path.join(rwcTestPath, "DefinitelyTyped_" + testCaseName + ".json"); + copyFileSync(outputFilePath, testCasePath); + + //console.log("output generated at: " + outputFilePath); + + if (!fs.existsSync(testCasePath)) { + throw new Error("could not find test case at: " + testCasePath); + } + else { + fs.unlinkSync(outputFilePath); + fs.rmdirSync(testDirectoryPath); + //console.log("testcase generated at: " + testCasePath); + //console.log("Done."); + } + //console.log("\r\n"); + + }) + .on('error', (error: any) => { + console.log("==> error " + JSON.stringify(error)); + console.log("\r\n"); + }); +} + +function importDefinitelyTypedTests(tscPath: string, rwcTestPath: string, definitelyTypedRoot: string): void { + fs.readdir(definitelyTypedRoot, (err, subDirectories) => { + if (err) { + throw err; + } + + // When you just want to test the script out on one or two files, + // just add a line like the following: + // + // .filter(d => d.indexOf("sipml") >= 0 ) + subDirectories + .filter(d => ["_infrastructure", "node_modules", ".git"].indexOf(d) < 0) + .filter(i => fs.statSync(path.join(definitelyTypedRoot, i)).isDirectory()) + .forEach(d => { + const directoryPath = path.join(definitelyTypedRoot, d); + fs.readdir(directoryPath, function (err, files) { + if (err) { + throw err; + } + + let tsFiles: string[] = []; + let testFiles: string[] = []; + let paramFile: string; + + for (const filePath of files.map(f => path.join(directoryPath, f))) { + if (filePathEndsWith(filePath, ".ts")) { + tsFiles.push(filePath); + + if (filePathEndsWith(filePath, "-tests.ts")) { + testFiles.push(filePath); + } + } + else if (filePathEndsWith(filePath, ".tscparams")) { + paramFile = filePath; + } + } + + if (testFiles.length === 0) { + // no test files but multiple d.ts's, e.g. winjs + const regexp = new RegExp(d + "(([-][0-9])|([\.]d[\.]ts))"); + if (tsFiles.length > 1 && tsFiles.every(t => filePathEndsWith(t, ".d.ts") && regexp.test(t))) { + for (const fileName of tsFiles) { + importDefinitelyTypedTest(tscPath, rwcTestPath, path.basename(fileName, ".d.ts"), [fileName], paramFile); + } + } + else { + importDefinitelyTypedTest(tscPath, rwcTestPath, d, tsFiles, paramFile); + } + } + else { + for (const fileName of tsFiles) { + importDefinitelyTypedTest(tscPath, rwcTestPath, path.basename(fileName, "-tests.ts"), [fileName], paramFile); + } + } + }); + }) + }); +} \ No newline at end of file diff --git a/scripts/importDefinitelyTypedTests/tsconfig.json b/scripts/importDefinitelyTypedTests/tsconfig.json new file mode 100644 index 00000000000..dede4572531 --- /dev/null +++ b/scripts/importDefinitelyTypedTests/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "ES5", + "noImplicitAny": true, + "outDir": "./", + "rootDir": ".", + "sourceMap": false + }, + "files": [ + "../typings/node/node.d.ts", + "importDefinitelyTypedTests.ts" + ], + "exclude": [ + ] +} \ No newline at end of file diff --git a/scripts/link-hooks.js b/scripts/link-hooks.js new file mode 100644 index 00000000000..33b5d4fd94f --- /dev/null +++ b/scripts/link-hooks.js @@ -0,0 +1,20 @@ +var fs = require("fs"); +var path = require("path"); + +var hooks = [ + "post-checkout" +]; + +hooks.forEach(function (hook) { + var hookInSourceControl = path.resolve(__dirname, "hooks", hook); + + if (fs.existsSync(hookInSourceControl)) { + var hookInHiddenDirectory = path.resolve(__dirname, "..", ".git", "hooks", hook); + + if (fs.existsSync(hookInHiddenDirectory)) { + fs.unlinkSync(hookInHiddenDirectory); + } + + fs.linkSync(hookInSourceControl, hookInHiddenDirectory); + } +}); \ No newline at end of file diff --git a/scripts/processDiagnosticMessages.ts b/scripts/processDiagnosticMessages.ts index 0a81b993616..1eead82d9fe 100644 --- a/scripts/processDiagnosticMessages.ts +++ b/scripts/processDiagnosticMessages.ts @@ -10,10 +10,6 @@ interface InputDiagnosticMessageTable { [msg: string]: DiagnosticDetails; } -interface IIndexable { - [key: string]: V; -} - function main(): void { var sys = ts.sys; if (sys.args.length < 1) { @@ -25,21 +21,49 @@ function main(): void { var inputFilePath = sys.args[0].replace(/\\/g, "/"); var inputStr = sys.readFile(inputFilePath); - var diagnosticMesages: InputDiagnosticMessageTable = JSON.parse(inputStr); + var diagnosticMessages: InputDiagnosticMessageTable = JSON.parse(inputStr); - var names = Utilities.getObjectKeys(diagnosticMesages); + var names = Utilities.getObjectKeys(diagnosticMessages); var nameMap = buildUniqueNameMap(names); - var infoFileOutput = buildInfoFileOutput(diagnosticMesages, nameMap); - + var infoFileOutput = buildInfoFileOutput(diagnosticMessages, nameMap); + checkForUniqueCodes(names, diagnosticMessages); + // TODO: Fix path joining var inputDirectory = inputFilePath.substr(0,inputFilePath.lastIndexOf("/")); var fileOutputPath = inputDirectory + "/diagnosticInformationMap.generated.ts"; sys.writeFile(fileOutputPath, infoFileOutput); } -function buildUniqueNameMap(names: string[]): IIndexable { - var nameMap: IIndexable = {}; +function checkForUniqueCodes(messages: string[], diagnosticTable: InputDiagnosticMessageTable) { + const originalMessageForCode: string[] = []; + let numConflicts = 0; + + for (const currentMessage of messages) { + const code = diagnosticTable[currentMessage].code; + + if (code in originalMessageForCode) { + const originalMessage = originalMessageForCode[code]; + ts.sys.write("\x1b[91m"); // High intensity red. + ts.sys.write("Error"); + ts.sys.write("\x1b[0m"); // Reset formatting. + ts.sys.write(`: Diagnostic code '${code}' conflicts between "${originalMessage}" and "${currentMessage}".`); + ts.sys.write(ts.sys.newLine + ts.sys.newLine); + + numConflicts++; + } + else { + originalMessageForCode[code] = currentMessage; + } + } + + if (numConflicts > 0) { + throw new Error(`Found ${numConflicts} conflict(s) in diagnostic codes.`); + } +} + +function buildUniqueNameMap(names: string[]): ts.Map { + var nameMap: ts.Map = {}; var uniqueNames = NameGenerator.ensureUniqueness(names, /* isCaseSensitive */ false, /* isFixed */ undefined); @@ -50,7 +74,7 @@ function buildUniqueNameMap(names: string[]): IIndexable { return nameMap; } -function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap: IIndexable): string { +function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap: ts.Map): string { var result = '// \r\n' + '/// \r\n' + @@ -172,7 +196,7 @@ module Utilities { } // Like Object.keys - export function getObjectKeys(obj: any): string[]{ + export function getObjectKeys(obj: any): string[] { var result: string[] = []; for (var name in obj) { diff --git a/scripts/tsd.json b/scripts/tsd.json new file mode 100644 index 00000000000..c2fc88a0b0f --- /dev/null +++ b/scripts/tsd.json @@ -0,0 +1,12 @@ +{ + "version": "v4", + "repo": "borisyankov/DefinitelyTyped", + "ref": "master", + "path": "typings", + "bundle": "typings/tsd.d.ts", + "installed": { + "node/node.d.ts": { + "commit": "5f480287834a2615274eea31574b713e64decf17" + } + } +} diff --git a/scripts/tslint/booleanTriviaRule.ts b/scripts/tslint/booleanTriviaRule.ts new file mode 100644 index 00000000000..be32a870ff4 --- /dev/null +++ b/scripts/tslint/booleanTriviaRule.ts @@ -0,0 +1,50 @@ +/// +/// + + +export class Rule extends Lint.Rules.AbstractRule { + public static FAILURE_STRING_FACTORY = (name: string, currently: string) => `Tag boolean argument as '${name}' (currently '${currently}')`; + + public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { + const program = ts.createProgram([sourceFile.fileName], Lint.createCompilerOptions()); + const checker = program.getTypeChecker(); + return this.applyWithWalker(new BooleanTriviaWalker(checker, program.getSourceFile(sourceFile.fileName), this.getOptions())); + } +} + +class BooleanTriviaWalker extends Lint.RuleWalker { + constructor(private checker: ts.TypeChecker, file: ts.SourceFile, opts: Lint.IOptions) { + super(file, opts); + } + + visitCallExpression(node: ts.CallExpression) { + super.visitCallExpression(node); + if (node.arguments) { + const targetCallSignature = this.checker.getResolvedSignature(node); + if (!!targetCallSignature) { + const targetParameters = targetCallSignature.getParameters(); + const source = this.getSourceFile(); + for (let index = 0; index < targetParameters.length; index++) { + const param = targetParameters[index]; + const arg = node.arguments[index]; + if (!(arg && param)) continue; + + const argType = this.checker.getContextualType(arg); + if (argType && (argType.getFlags() & ts.TypeFlags.Boolean)) { + if (arg.kind !== ts.SyntaxKind.TrueKeyword && arg.kind !== ts.SyntaxKind.FalseKeyword) { + continue; + } + let triviaContent: string; + const ranges = ts.getLeadingCommentRanges(arg.getFullText(), 0); + if (ranges && ranges.length === 1 && ranges[0].kind === ts.SyntaxKind.MultiLineCommentTrivia) { + triviaContent = arg.getFullText().slice(ranges[0].pos + 2, ranges[0].end - 2); //+/-2 to remove /**/ + } + if (triviaContent !== param.getName()) { + this.addFailure(this.createFailure(arg.getStart(source), arg.getWidth(source), Rule.FAILURE_STRING_FACTORY(param.getName(), triviaContent))); + } + } + } + } + } + } +} diff --git a/scripts/tslint/nextLineRule.ts b/scripts/tslint/nextLineRule.ts new file mode 100644 index 00000000000..6d803fc7f88 --- /dev/null +++ b/scripts/tslint/nextLineRule.ts @@ -0,0 +1,61 @@ +/// +/// + +const OPTION_CATCH = "check-catch"; +const OPTION_ELSE = "check-else"; + +export class Rule extends Lint.Rules.AbstractRule { + public static CATCH_FAILURE_STRING = "'catch' should not be on the same line as the preceeding block's curly brace"; + public static ELSE_FAILURE_STRING = "'else' should not be on the same line as the preceeding block's curly brace"; + + public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { + return this.applyWithWalker(new NextLineWalker(sourceFile, this.getOptions())); + } +} + +class NextLineWalker extends Lint.RuleWalker { + public visitIfStatement(node: ts.IfStatement) { + const sourceFile = node.getSourceFile(); + const thenStatement = node.thenStatement; + + const elseStatement = node.elseStatement; + if (!!elseStatement) { + // find the else keyword + const elseKeyword = getFirstChildOfKind(node, ts.SyntaxKind.ElseKeyword); + if (this.hasOption(OPTION_ELSE) && !!elseKeyword) { + const thenStatementEndLoc = sourceFile.getLineAndCharacterOfPosition(thenStatement.getEnd()); + const elseKeywordLoc = sourceFile.getLineAndCharacterOfPosition(elseKeyword.getStart(sourceFile)); + if (thenStatementEndLoc.line === elseKeywordLoc.line) { + const failure = this.createFailure(elseKeyword.getStart(sourceFile), elseKeyword.getWidth(sourceFile), Rule.ELSE_FAILURE_STRING); + this.addFailure(failure); + } + } + } + + super.visitIfStatement(node); + } + + public visitTryStatement(node: ts.TryStatement) { + const sourceFile = node.getSourceFile(); + const catchClause = node.catchClause; + + // "visit" try block + const tryBlock = node.tryBlock; + + if (this.hasOption(OPTION_CATCH) && !!catchClause) { + const tryClosingBrace = tryBlock.getLastToken(sourceFile); + const catchKeyword = catchClause.getFirstToken(sourceFile); + const tryClosingBraceLoc = sourceFile.getLineAndCharacterOfPosition(tryClosingBrace.getEnd()); + const catchKeywordLoc = sourceFile.getLineAndCharacterOfPosition(catchKeyword.getStart(sourceFile)); + if (tryClosingBraceLoc.line === catchKeywordLoc.line) { + const failure = this.createFailure(catchKeyword.getStart(sourceFile), catchKeyword.getWidth(sourceFile), Rule.CATCH_FAILURE_STRING); + this.addFailure(failure); + } + } + super.visitTryStatement(node); + } +} + +function getFirstChildOfKind(node: ts.Node, kind: ts.SyntaxKind) { + return node.getChildren().filter((child) => child.kind === kind)[0]; +} diff --git a/scripts/tslint/noNullRule.ts b/scripts/tslint/noNullRule.ts new file mode 100644 index 00000000000..2a2c5bc3717 --- /dev/null +++ b/scripts/tslint/noNullRule.ts @@ -0,0 +1,20 @@ +/// +/// + + +export class Rule extends Lint.Rules.AbstractRule { + public static FAILURE_STRING = "Don't use the 'null' keyword - use 'undefined' for missing values instead"; + + public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { + return this.applyWithWalker(new NullWalker(sourceFile, this.getOptions())); + } +} + +class NullWalker extends Lint.RuleWalker { + visitNode(node: ts.Node) { + super.visitNode(node); + if (node.kind === ts.SyntaxKind.NullKeyword) { + this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING)); + } + } +} diff --git a/scripts/tslint/tsconfig.json b/scripts/tslint/tsconfig.json new file mode 100644 index 00000000000..db018ce2776 --- /dev/null +++ b/scripts/tslint/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "noImplicitAny": true, + "module": "commonjs", + "outDir": "../../built/local/tslint" + } +} \ No newline at end of file diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 340bf478209..65768332360 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -88,6 +88,7 @@ namespace ts { let container: Node; let blockScopeContainer: Node; let lastContainer: Node; + let seenThisKeyword: boolean; // If this file is an external module, then it is automatically in strict-mode according to // ES6. If it is not an external module, then we'll determine if it is in strict mode or @@ -329,7 +330,14 @@ namespace ts { blockScopeContainer.locals = undefined; } - forEachChild(node, bind); + if (node.kind === SyntaxKind.InterfaceDeclaration) { + seenThisKeyword = false; + forEachChild(node, bind); + node.flags = seenThisKeyword ? node.flags | NodeFlags.ContainsThis : node.flags & ~NodeFlags.ContainsThis; + } + else { + forEachChild(node, bind); + } container = saveContainer; parent = saveParent; @@ -851,6 +859,9 @@ namespace ts { return checkStrictModePrefixUnaryExpression(node); case SyntaxKind.WithStatement: return checkStrictModeWithStatement(node); + case SyntaxKind.ThisKeyword: + seenThisKeyword = true; + return; case SyntaxKind.TypeParameter: return declareSymbolAndAddToSymbolTable(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes); @@ -973,6 +984,10 @@ namespace ts { else { let bindingName = node.name ? node.name.text : "__class"; bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName); + // Add name of class expression into the map for semantic classifier + if (node.name) { + classifiableNames[node.name.text] = node.name.text; + } } let symbol = node.symbol; @@ -1062,4 +1077,4 @@ namespace ts { : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } } -} +} diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 562234a4305..40db300d310 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -38,12 +38,14 @@ namespace ts { let Signature = objectAllocator.getSignatureConstructor(); let typeCount = 0; + let symbolCount = 0; let emptyArray: any[] = []; let emptySymbols: SymbolTable = {}; let compilerOptions = host.getCompilerOptions(); let languageVersion = compilerOptions.target || ScriptTarget.ES3; + let modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None; let emitResolver = createResolver(); @@ -53,7 +55,7 @@ namespace ts { let checker: TypeChecker = { getNodeCount: () => sum(host.getSourceFiles(), "nodeCount"), getIdentifierCount: () => sum(host.getSourceFiles(), "identifierCount"), - getSymbolCount: () => sum(host.getSourceFiles(), "symbolCount"), + getSymbolCount: () => sum(host.getSourceFiles(), "symbolCount") + symbolCount, getTypeCount: () => typeCount, isUndefinedSymbol: symbol => symbol === undefinedSymbol, isArgumentsSymbol: symbol => symbol === argumentsSymbol, @@ -242,6 +244,7 @@ namespace ts { } function createSymbol(flags: SymbolFlags, name: string): Symbol { + symbolCount++; return new Symbol(flags, name); } @@ -388,7 +391,7 @@ namespace ts { return node1.pos <= node2.pos; } - if (!compilerOptions.out) { + if (!compilerOptions.outFile && !compilerOptions.out) { return true; } @@ -947,12 +950,6 @@ namespace ts { return symbol.flags & meaning ? symbol : resolveAlias(symbol); } - function isExternalModuleNameRelative(moduleName: string): boolean { - // TypeScript 1.0 spec (April 2014): 11.2.1 - // An external module name is "relative" if the first term is "." or "..". - return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; - } - function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression): Symbol { if (moduleReferenceExpression.kind !== SyntaxKind.StringLiteral) { return; @@ -965,7 +962,7 @@ namespace ts { // Escape the name in the "require(...)" clause to ensure we find the right symbol. let moduleName = escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) { + if (moduleName === undefined) { return; } let isRelative = isExternalModuleNameRelative(moduleName); @@ -976,8 +973,8 @@ namespace ts { } } - let fileName = getResolvedModuleFileName(getSourceFile(location), moduleReferenceLiteral.text); - let sourceFile = fileName && host.getSourceFile(fileName); + let resolvedModule = getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text); + let sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { return sourceFile.symbol; @@ -1592,6 +1589,7 @@ namespace ts { function buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]) { let globalFlagsToPass = globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike; + let inObjectTypeLiteral = false; return writeType(type, globalFlags); function writeType(type: Type, flags: TypeFormatFlags) { @@ -1602,6 +1600,12 @@ namespace ts { ? "any" : (type).intrinsicName); } + else if (type.flags & TypeFlags.ThisType) { + if (inObjectTypeLiteral) { + writer.reportInaccessibleThisError(); + } + writer.writeKeyword("this"); + } else if (type.flags & TypeFlags.Reference) { writeTypeReference(type, flags); } @@ -1645,11 +1649,10 @@ namespace ts { } } - function writeSymbolTypeReference(symbol: Symbol, typeArguments: Type[], pos: number, end: number) { - // Unnamed function expressions, arrow functions, and unnamed class expressions have reserved names that - // we don't want to display - if (!isReservedMemberName(symbol.name)) { - buildSymbolDisplay(symbol, writer, enclosingDeclaration, SymbolFlags.Type); + function writeSymbolTypeReference(symbol: Symbol, typeArguments: Type[], pos: number, end: number, flags: TypeFormatFlags) { + // Unnamed function expressions and arrow functions have reserved names that we don't want to display + if (symbol.flags & SymbolFlags.Class || !isReservedMemberName(symbol.name)) { + buildSymbolDisplay(symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, flags); } if (pos < end) { writePunctuation(writer, SyntaxKind.LessThanToken); @@ -1664,7 +1667,7 @@ namespace ts { } function writeTypeReference(type: TypeReference, flags: TypeFormatFlags) { - let typeArguments = type.typeArguments; + let typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & TypeFormatFlags.WriteArrayAsGenericType)) { writeType(typeArguments[0], TypeFormatFlags.InElementType); writePunctuation(writer, SyntaxKind.OpenBracketToken); @@ -1688,12 +1691,13 @@ namespace ts { // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent, typeArguments, start, i); + writeSymbolTypeReference(parent, typeArguments, start, i, flags); writePunctuation(writer, SyntaxKind.DotToken); } } } - writeSymbolTypeReference(type.symbol, typeArguments, i, typeArguments.length); + let typeParameterCount = (type.target.typeParameters || emptyArray).length; + writeSymbolTypeReference(type.symbol, typeArguments, i, typeParameterCount, flags); } } @@ -1816,6 +1820,8 @@ namespace ts { } } + let saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; writePunctuation(writer, SyntaxKind.OpenBraceToken); writer.writeLine(); writer.increaseIndent(); @@ -1888,12 +1894,13 @@ namespace ts { } writer.decreaseIndent(); writePunctuation(writer, SyntaxKind.CloseBraceToken); + inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags) { let targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface) { + if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface || targetSymbol.flags & SymbolFlags.TypeAlias) { buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags); } } @@ -2293,10 +2300,17 @@ namespace ts { return type && (type.flags & TypeFlags.Any) !== 0; } + // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been + // assigned by contextual typing. + function getTypeForBindingElementParent(node: VariableLikeDeclaration) { + let symbol = getSymbolOfNode(node); + return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node); + } + // Return the inferred type for a binding element function getTypeForBindingElement(declaration: BindingElement): Type { let pattern = declaration.parent; - let parentType = getTypeForVariableLikeDeclaration(pattern.parent); + let parentType = getTypeForBindingElementParent(pattern.parent); // If parent has the unknown (error) type, then so does this binding element if (parentType === unknownType) { return unknownType; @@ -2318,8 +2332,8 @@ namespace ts { // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. type = getTypeOfPropertyOfType(parentType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || - getIndexTypeOfType(parentType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || + getIndexTypeOfType(parentType, IndexKind.String); if (!type) { error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), declarationNameToString(name)); return unknownType; @@ -2372,7 +2386,7 @@ namespace ts { if (isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } - + // Use type from type annotation if one is present if (declaration.type) { return getTypeFromTypeNode(declaration.type); @@ -2393,12 +2407,12 @@ namespace ts { return type; } } - + // Use the type of the initializer expression if one is present if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - + // If it is a short-hand property assignment, use the type of the identifier if (declaration.kind === SyntaxKind.ShorthandPropertyAssignment) { return checkIdentifier(declaration.name); @@ -2406,7 +2420,7 @@ namespace ts { // If the declaration specifies a binding pattern, use the type implied by the binding pattern if (isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false); } // No type specified and nothing can be inferred @@ -2416,48 +2430,47 @@ namespace ts { // Return the type implied by a binding pattern element. This is the type of the initializer of the element if // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding // pattern. Otherwise, it is the type any. - function getTypeFromBindingElement(element: BindingElement): Type { + function getTypeFromBindingElement(element: BindingElement, includePatternInType?: boolean): Type { if (element.initializer) { return getWidenedType(checkExpressionCached(element.initializer)); } if (isBindingPattern(element.name)) { - return getTypeFromBindingPattern(element.name); + return getTypeFromBindingPattern(element.name, includePatternInType); } return anyType; } // Return the type implied by an object binding pattern - function getTypeFromObjectBindingPattern(pattern: BindingPattern): Type { + function getTypeFromObjectBindingPattern(pattern: BindingPattern, includePatternInType: boolean): Type { let members: SymbolTable = {}; forEach(pattern.elements, e => { let flags = SymbolFlags.Property | SymbolFlags.Transient | (e.initializer ? SymbolFlags.Optional : 0); let name = e.propertyName || e.name; let symbol = createSymbol(flags, name.text); - symbol.type = getTypeFromBindingElement(e); + symbol.type = getTypeFromBindingElement(e, includePatternInType); + symbol.bindingElement = e; members[symbol.name] = symbol; }); - return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + let result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + if (includePatternInType) { + result.pattern = pattern; + } + return result; } // Return the type implied by an array binding pattern - function getTypeFromArrayBindingPattern(pattern: BindingPattern): Type { - let hasSpreadElement: boolean = false; - let elementTypes: Type[] = []; - forEach(pattern.elements, e => { - elementTypes.push(e.kind === SyntaxKind.OmittedExpression || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); - if (e.dotDotDotToken) { - hasSpreadElement = true; - } - }); - if (!elementTypes.length) { + function getTypeFromArrayBindingPattern(pattern: BindingPattern, includePatternInType: boolean): Type { + let elements = pattern.elements; + if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= ScriptTarget.ES6 ? createIterableType(anyType) : anyArrayType; } - else if (hasSpreadElement) { - let unionOfElements = getUnionType(elementTypes); - return languageVersion >= ScriptTarget.ES6 ? createIterableType(unionOfElements) : createArrayType(unionOfElements); - } - // If the pattern has at least one element, and no rest element, then it should imply a tuple type. + let elementTypes = map(elements, e => e.kind === SyntaxKind.OmittedExpression ? anyType : getTypeFromBindingElement(e, includePatternInType)); + if (includePatternInType) { + let result = createNewTupleType(elementTypes); + result.pattern = pattern; + return result; + } return createTupleType(elementTypes); } @@ -2468,10 +2481,10 @@ namespace ts { // used as the contextual type of an initializer associated with the binding pattern. Also, for a destructuring // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. - function getTypeFromBindingPattern(pattern: BindingPattern): Type { + function getTypeFromBindingPattern(pattern: BindingPattern, includePatternInType?: boolean): Type { return pattern.kind === SyntaxKind.ObjectBindingPattern - ? getTypeFromObjectBindingPattern(pattern) - : getTypeFromArrayBindingPattern(pattern); + ? getTypeFromObjectBindingPattern(pattern, includePatternInType) + : getTypeFromArrayBindingPattern(pattern, includePatternInType); } // Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type @@ -2494,10 +2507,10 @@ namespace ts { // tools see the actual type. return declaration.kind !== SyntaxKind.PropertyAssignment ? getWidenedType(type) : type; } - + // Rest parameters default to type any[], other parameters default to type any type = declaration.dotDotDotToken ? anyArrayType : anyType; - + // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { let root = getRootDeclaration(declaration); @@ -2883,6 +2896,31 @@ namespace ts { } } + // Returns true if the interface given by the symbol is free of "this" references. Specifically, the result is + // true if the interface itself contains no references to "this" in its body, if all base types are interfaces, + // and if none of the base interfaces have a "this" type. + function isIndependentInterface(symbol: Symbol): boolean { + for (let declaration of symbol.declarations) { + if (declaration.kind === SyntaxKind.InterfaceDeclaration) { + if (declaration.flags & NodeFlags.ContainsThis) { + return false; + } + let baseTypeNodes = getInterfaceBaseTypeNodes(declaration); + if (baseTypeNodes) { + for (let node of baseTypeNodes) { + if (isSupportedExpressionWithTypeArguments(node)) { + let baseSymbol = resolveEntityName(node.expression, SymbolFlags.Type, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & SymbolFlags.Interface) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + return false; + } + } + } + } + } + } + return true; + } + function getDeclaredTypeOfClassOrInterface(symbol: Symbol): InterfaceType { let links = getSymbolLinks(symbol); if (!links.declaredType) { @@ -2890,7 +2928,12 @@ namespace ts { let type = links.declaredType = createObjectType(kind, symbol); let outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); let localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - if (outerTypeParameters || localTypeParameters) { + // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type + // because it is not feasible to analyze all members to determine if the "this" type escapes the class (in particular, + // property types inferred from initializers and method return types inferred from return statements are very hard + // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of + // "this" references. + if (outerTypeParameters || localTypeParameters || kind === TypeFlags.Class || !isIndependentInterface(symbol)) { type.flags |= TypeFlags.Reference; type.typeParameters = concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -2899,6 +2942,9 @@ namespace ts { (type).instantiations[getTypeListId(type.typeParameters)] = type; (type).target = type; (type).typeArguments = type.typeParameters; + type.thisType = createType(TypeFlags.TypeParameter | TypeFlags.ThisType); + type.thisType.symbol = symbol; + type.thisType.constraint = getTypeWithThisArgument(type); } } return links.declaredType; @@ -2983,6 +3029,82 @@ namespace ts { return unknownType; } + // A type reference is considered independent if each type argument is considered independent. + function isIndependentTypeReference(node: TypeReferenceNode): boolean { + if (node.typeArguments) { + for (let typeNode of node.typeArguments) { + if (!isIndependentType(typeNode)) { + return false; + } + } + } + return true; + } + + // A type is considered independent if it the any, string, number, boolean, symbol, or void keyword, a string + // literal type, an array with an element type that is considered independent, or a type reference that is + // considered independent. + function isIndependentType(node: TypeNode): boolean { + switch (node.kind) { + case SyntaxKind.AnyKeyword: + case SyntaxKind.StringKeyword: + case SyntaxKind.NumberKeyword: + case SyntaxKind.BooleanKeyword: + case SyntaxKind.SymbolKeyword: + case SyntaxKind.VoidKeyword: + case SyntaxKind.StringLiteral: + return true; + case SyntaxKind.ArrayType: + return isIndependentType((node).elementType); + case SyntaxKind.TypeReference: + return isIndependentTypeReference(node); + } + return false; + } + + // A variable-like declaration is considered independent (free of this references) if it has a type annotation + // that specifies an independent type, or if it has no type annotation and no initializer (and thus of type any). + function isIndependentVariableLikeDeclaration(node: VariableLikeDeclaration): boolean { + return node.type && isIndependentType(node.type) || !node.type && !node.initializer; + } + + // A function-like declaration is considered independent (free of this references) if it has a return type + // annotation that is considered independent and if each parameter is considered independent. + function isIndependentFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean { + if (node.kind !== SyntaxKind.Constructor && (!node.type || !isIndependentType(node.type))) { + return false; + } + for (let parameter of node.parameters) { + if (!isIndependentVariableLikeDeclaration(parameter)) { + return false; + } + } + return true; + } + + // Returns true if the class or interface member given by the symbol is free of "this" references. The + // function may return false for symbols that are actually free of "this" references because it is not + // feasible to perform a complete analysis in all cases. In particular, property members with types + // inferred from their initializers and function members with inferred return types are convervatively + // assumed not to be free of "this" references. + function isIndependentMember(symbol: Symbol): boolean { + if (symbol.declarations && symbol.declarations.length === 1) { + let declaration = symbol.declarations[0]; + if (declaration) { + switch (declaration.kind) { + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + return isIndependentVariableLikeDeclaration(declaration); + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.Constructor: + return isIndependentFunctionLikeDeclaration(declaration); + } + } + } + return false; + } + function createSymbolTable(symbols: Symbol[]): SymbolTable { let result: SymbolTable = {}; for (let symbol of symbols) { @@ -2991,10 +3113,12 @@ namespace ts { return result; } - function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper): SymbolTable { + // The mappingThisOnly flag indicates that the only type parameter being mapped is "this". When the flag is true, + // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation. + function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper, mappingThisOnly: boolean): SymbolTable { let result: SymbolTable = {}; for (let symbol of symbols) { - result[symbol.name] = instantiateSymbol(symbol, mapper); + result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } @@ -3027,44 +3151,57 @@ namespace ts { return type; } - function resolveClassOrInterfaceMembers(type: InterfaceType): void { - let target = resolveDeclaredMembers(type); - let members = target.symbol.members; - let callSignatures = target.declaredCallSignatures; - let constructSignatures = target.declaredConstructSignatures; - let stringIndexType = target.declaredStringIndexType; - let numberIndexType = target.declaredNumberIndexType; - let baseTypes = getBaseTypes(target); + function getTypeWithThisArgument(type: ObjectType, thisArgument?: Type) { + if (type.flags & TypeFlags.Reference) { + return createTypeReference((type).target, + concatenate((type).typeArguments, [thisArgument || (type).target.thisType])); + } + return type; + } + + function resolveObjectTypeMembers(type: ObjectType, source: InterfaceTypeWithDeclaredMembers, typeParameters: TypeParameter[], typeArguments: Type[]) { + let mapper = identityMapper; + let members = source.symbol.members; + let callSignatures = source.declaredCallSignatures; + let constructSignatures = source.declaredConstructSignatures; + let stringIndexType = source.declaredStringIndexType; + let numberIndexType = source.declaredNumberIndexType; + if (!rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = createTypeMapper(typeParameters, typeArguments); + members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1); + callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); + constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + stringIndexType = instantiateType(source.declaredStringIndexType, mapper); + numberIndexType = instantiateType(source.declaredNumberIndexType, mapper); + } + let baseTypes = getBaseTypes(source); if (baseTypes.length) { - members = createSymbolTable(target.declaredProperties); + if (members === source.symbol.members) { + members = createSymbolTable(source.declaredProperties); + } + let thisArgument = lastOrUndefined(typeArguments); for (let baseType of baseTypes) { - addInheritedMembers(members, getPropertiesOfObjectType(baseType)); - callSignatures = concatenate(callSignatures, getSignaturesOfType(baseType, SignatureKind.Call)); - constructSignatures = concatenate(constructSignatures, getSignaturesOfType(baseType, SignatureKind.Construct)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, IndexKind.String); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, IndexKind.Number); + let instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); + callSignatures = concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, SignatureKind.Call)); + constructSignatures = concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, SignatureKind.Construct)); + stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, IndexKind.String); + numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, IndexKind.Number); } } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function resolveClassOrInterfaceMembers(type: InterfaceType): void { + resolveObjectTypeMembers(type, resolveDeclaredMembers(type), emptyArray, emptyArray); + } + function resolveTypeReferenceMembers(type: TypeReference): void { - let target = resolveDeclaredMembers(type.target); - let mapper = createTypeMapper(target.typeParameters, type.typeArguments); - let members = createInstantiatedSymbolTable(target.declaredProperties, mapper); - let callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); - let constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - let stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - let numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; - forEach(getBaseTypes(target), baseType => { - let instantiatedBaseType = instantiateType(baseType, mapper); - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); - callSignatures = concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, SignatureKind.Call)); - constructSignatures = concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, SignatureKind.Construct)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, IndexKind.String); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, IndexKind.Number); - }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + let source = resolveDeclaredMembers(type.target); + let typeParameters = concatenate(source.typeParameters, [source.thisType]); + let typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? + type.typeArguments : concatenate(type.typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, typeArguments); } function createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[], parameters: Symbol[], @@ -3119,14 +3256,16 @@ namespace ts { } function resolveTupleTypeMembers(type: TupleType) { - let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); + let arrayElementType = getUnionType(type.elementTypes, /*noSubtypeReduction*/ true); + // Make the tuple type itself the 'this' type by including an extra type argument + let arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); let members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } function findMatchingSignature(signatureList: Signature[], signature: Signature, partialMatch: boolean, ignoreReturnTypes: boolean): Signature { - for (let s of signatureList) { + for (let s of signatureList) { if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { return s; } @@ -3232,7 +3371,7 @@ namespace ts { setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function resolveAnonymousTypeMembers(type: ObjectType) { + function resolveAnonymousTypeMembers(type: AnonymousType) { let symbol = type.symbol; let members: SymbolTable; let callSignatures: Signature[]; @@ -3240,7 +3379,14 @@ namespace ts { let stringIndexType: Type; let numberIndexType: Type; - if (symbol.flags & SymbolFlags.TypeLiteral) { + if (type.target) { + members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); + callSignatures = instantiateList(getSignaturesOfType(type.target, SignatureKind.Call), type.mapper, instantiateSignature); + constructSignatures = instantiateList(getSignaturesOfType(type.target, SignatureKind.Construct), type.mapper, instantiateSignature); + stringIndexType = instantiateType(getIndexTypeOfType(type.target, IndexKind.String), type.mapper); + numberIndexType = instantiateType(getIndexTypeOfType(type.target, IndexKind.Number), type.mapper); + } + else if (symbol.flags & SymbolFlags.TypeLiteral) { members = symbol.members; callSignatures = getSignaturesOfSymbol(members["__call"]); constructSignatures = getSignaturesOfSymbol(members["__new"]); @@ -3278,11 +3424,14 @@ namespace ts { function resolveStructuredTypeMembers(type: ObjectType): ResolvedType { if (!(type).members) { - if (type.flags & (TypeFlags.Class | TypeFlags.Interface)) { + if (type.flags & TypeFlags.Reference) { + resolveTypeReferenceMembers(type); + } + else if (type.flags & (TypeFlags.Class | TypeFlags.Interface)) { resolveClassOrInterfaceMembers(type); } else if (type.flags & TypeFlags.Anonymous) { - resolveAnonymousTypeMembers(type); + resolveAnonymousTypeMembers(type); } else if (type.flags & TypeFlags.Tuple) { resolveTupleTypeMembers(type); @@ -3293,9 +3442,6 @@ namespace ts { else if (type.flags & TypeFlags.Intersection) { resolveIntersectionTypeMembers(type); } - else { - resolveTypeReferenceMembers(type); - } } return type; } @@ -3451,29 +3597,6 @@ namespace ts { return undefined; } - // Check if a property with the given name is known anywhere in the given type. In an object - // type, a property is considered known if the object type is empty, if it has any index - // signatures, or if the property is actually declared in the type. In a union or intersection - // type, a property is considered known if it is known in any constituent type. - function isKnownProperty(type: Type, name: string): boolean { - if (type.flags & TypeFlags.ObjectType && type !== globalObjectType) { - const resolved = resolveStructuredTypeMembers(type); - return !!(resolved.properties.length === 0 || - resolved.stringIndexType || - resolved.numberIndexType || - getPropertyOfType(type, name)); - } - if (type.flags & TypeFlags.UnionOrIntersection) { - for (let t of (type).types) { - if (isKnownProperty(t, name)) { - return true; - } - } - return false; - } - return true; - } - function getSignaturesOfStructuredType(type: Type, kind: SignatureKind): Signature[] { if (type.flags & TypeFlags.StructuredType) { let resolved = resolveStructuredTypeMembers(type); @@ -3784,22 +3907,24 @@ namespace ts { } function getTypeListId(types: Type[]) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - let result = ""; - for (let i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; + if (types) { + switch (types.length) { + case 1: + return "" + types[0].id; + case 2: + return types[0].id + "," + types[1].id; + default: + let result = ""; + for (let i = 0; i < types.length; i++) { + if (i > 0) { + result += ","; + } + result += types[i].id; } - - result += types[i].id; - } - return result; + return result; + } } + return ""; } // This function is used to propagate certain flags when creating new object type references and union types. @@ -3818,7 +3943,7 @@ namespace ts { let id = getTypeListId(typeArguments); let type = target.instantiations[id]; if (!type) { - let flags = TypeFlags.Reference | getPropagatingFlagsOfTypes(typeArguments); + let flags = TypeFlags.Reference | (typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0); type = target.instantiations[id] = createObjectType(flags, target.symbol); type.target = target; type.typeArguments = typeArguments; @@ -3877,8 +4002,8 @@ namespace ts { // Get type from reference to class or interface function getTypeFromClassOrInterfaceReference(node: TypeReferenceNode | ExpressionWithTypeArguments, symbol: Symbol): Type { - let type = getDeclaredTypeOfSymbol(symbol); - let typeParameters = (type).localTypeParameters; + let type = getDeclaredTypeOfSymbol(symbol); + let typeParameters = type.localTypeParameters; if (typeParameters) { if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType), typeParameters.length); @@ -3887,8 +4012,7 @@ namespace ts { // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - return createTypeReference(type, concatenate((type).outerTypeParameters, - map(node.typeArguments, getTypeFromTypeNode))); + return createTypeReference(type, concatenate(type.outerTypeParameters, map(node.typeArguments, getTypeFromTypeNode))); } if (node.typeArguments) { error(node, Diagnostics.Type_0_is_not_generic, typeToString(type)); @@ -4036,7 +4160,7 @@ namespace ts { */ function createTypedPropertyDescriptorType(propertyType: Type): Type { let globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyObjectType + return globalTypedPropertyDescriptorType !== emptyGenericType ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } @@ -4044,20 +4168,20 @@ namespace ts { /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ - function createTypeFromGenericGlobalType(genericGlobalType: GenericType, elementType: Type): Type { - return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, [elementType]) : emptyObjectType; + function createTypeFromGenericGlobalType(genericGlobalType: GenericType, typeArguments: Type[]): Type { + return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } function createIterableType(elementType: Type): Type { - return createTypeFromGenericGlobalType(globalIterableType, elementType); + return createTypeFromGenericGlobalType(globalIterableType, [elementType]); } function createIterableIteratorType(elementType: Type): Type { - return createTypeFromGenericGlobalType(globalIterableIteratorType, elementType); + return createTypeFromGenericGlobalType(globalIterableIteratorType, [elementType]); } function createArrayType(elementType: Type): Type { - return createTypeFromGenericGlobalType(globalArrayType, elementType); + return createTypeFromGenericGlobalType(globalArrayType, [elementType]); } function getTypeFromArrayTypeNode(node: ArrayTypeNode): Type { @@ -4070,11 +4194,12 @@ namespace ts { function createTupleType(elementTypes: Type[]) { let id = getTypeListId(elementTypes); - let type = tupleTypes[id]; - if (!type) { - type = tupleTypes[id] = createObjectType(TypeFlags.Tuple | getPropagatingFlagsOfTypes(elementTypes)); - type.elementTypes = elementTypes; - } + return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); + } + + function createNewTupleType(elementTypes: Type[]) { + let type = createObjectType(TypeFlags.Tuple | getPropagatingFlagsOfTypes(elementTypes)); + type.elementTypes = elementTypes; return type; } @@ -4103,73 +4228,20 @@ namespace ts { } } - function isObjectLiteralTypeDuplicateOf(source: ObjectType, target: ObjectType): boolean { - let sourceProperties = getPropertiesOfObjectType(source); - let targetProperties = getPropertiesOfObjectType(target); - if (sourceProperties.length !== targetProperties.length) { - return false; - } - for (let sourceProp of sourceProperties) { - let targetProp = getPropertyOfObjectType(target, sourceProp.name); - if (!targetProp || - getDeclarationFlagsFromSymbol(targetProp) & (NodeFlags.Private | NodeFlags.Protected) || - !isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) { - return false; - } - } - return true; - } - - function isTupleTypeDuplicateOf(source: TupleType, target: TupleType): boolean { - let sourceTypes = source.elementTypes; - let targetTypes = target.elementTypes; - if (sourceTypes.length !== targetTypes.length) { - return false; - } - for (var i = 0; i < sourceTypes.length; i++) { - if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) { - return false; - } - } - return true; - } - - // Returns true if the source type is a duplicate of the target type. A source type is a duplicate of - // a target type if the the two are identical, with the exception that the source type may have null or - // undefined in places where the target type doesn't. This is by design an asymmetric relationship. - function isTypeDuplicateOf(source: Type, target: Type): boolean { - if (source === target) { - return true; - } - if (source.flags & TypeFlags.Undefined || source.flags & TypeFlags.Null && !(target.flags & TypeFlags.Undefined)) { - return true; - } - if (source.flags & TypeFlags.ObjectLiteral && target.flags & TypeFlags.ObjectType) { - return isObjectLiteralTypeDuplicateOf(source, target); - } - if (isArrayType(source) && isArrayType(target)) { - return isTypeDuplicateOf((source).typeArguments[0], (target).typeArguments[0]); - } - if (isTupleType(source) && isTupleType(target)) { - return isTupleTypeDuplicateOf(source, target); - } - return isTypeIdenticalTo(source, target); - } - - function isTypeDuplicateOfSomeType(candidate: Type, types: Type[]): boolean { - for (let type of types) { - if (candidate !== type && isTypeDuplicateOf(candidate, type)) { + function isSubtypeOfAny(candidate: Type, types: Type[]): boolean { + for (let i = 0, len = types.length; i < len; i++) { + if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { return true; } } return false; } - function removeDuplicateTypes(types: Type[]) { + function removeSubtypes(types: Type[]) { let i = types.length; while (i > 0) { i--; - if (isTypeDuplicateOfSomeType(types[i], types)) { + if (isSubtypeOfAny(types[i], types)) { types.splice(i, 1); } } @@ -4194,12 +4266,14 @@ namespace ts { } } - // We always deduplicate the constituent type set based on object identity, but we'll also deduplicate - // based on the structure of the types unless the noDeduplication flag is true, which is the case when - // creating a union type from a type node and when instantiating a union type. In both of those cases, - // structural deduplication has to be deferred to properly support recursive union types. For example, - // a type of the form "type Item = string | (() => Item)" cannot be deduplicated during its declaration. - function getUnionType(types: Type[], noDeduplication?: boolean): Type { + // We reduce the constituent type set to only include types that aren't subtypes of other types, unless + // the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on + // object identity. Subtype reduction is possible only when union types are known not to circularly + // reference themselves (as is the case with union types created by expression constructs such as array + // literals and the || and ?: operators). Named types can circularly reference themselves and therefore + // cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is + // a named type that circularly references itself. + function getUnionType(types: Type[], noSubtypeReduction?: boolean): Type { if (types.length === 0) { return emptyObjectType; } @@ -4208,12 +4282,12 @@ namespace ts { if (containsTypeAny(typeSet)) { return anyType; } - if (noDeduplication) { + if (noSubtypeReduction) { removeAllButLast(typeSet, undefinedType); removeAllButLast(typeSet, nullType); } else { - removeDuplicateTypes(typeSet); + removeSubtypes(typeSet); } if (typeSet.length === 1) { return typeSet[0]; @@ -4230,7 +4304,7 @@ namespace ts { function getTypeFromUnionTypeNode(node: UnionTypeNode): Type { let links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noDeduplication*/ true); + links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true); } return links.resolvedType; } @@ -4296,6 +4370,26 @@ namespace ts { return links.resolvedType; } + function getThisType(node: TypeNode): Type { + let container = getThisContainer(node, /*includeArrowFunctions*/ false); + let parent = container && container.parent; + if (parent && (isClassLike(parent) || parent.kind === SyntaxKind.InterfaceDeclaration)) { + if (!(container.flags & NodeFlags.Static)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; + } + } + error(node, Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); + return unknownType; + } + + function getTypeFromThisTypeNode(node: TypeNode): Type { + let links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getThisType(node); + } + return links.resolvedType; + } + function getTypeFromTypeNode(node: TypeNode): Type { switch (node.kind) { case SyntaxKind.AnyKeyword: @@ -4310,6 +4404,8 @@ namespace ts { return esSymbolType; case SyntaxKind.VoidKeyword: return voidType; + case SyntaxKind.ThisKeyword: + return getTypeFromThisTypeNode(node); case SyntaxKind.StringLiteral: return getTypeFromStringLiteral(node); case SyntaxKind.TypeReference: @@ -4412,7 +4508,7 @@ namespace ts { } return t; }; - + mapper.context = context; return mapper; } @@ -4454,7 +4550,7 @@ namespace ts { } let result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), - signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, + instantiateType(signature.resolvedReturnType, mapper), freshTypePredicate, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); result.target = signature; @@ -4486,28 +4582,32 @@ namespace ts { return result; } - function instantiateAnonymousType(type: ObjectType, mapper: TypeMapper): ObjectType { + function instantiateAnonymousType(type: AnonymousType, mapper: TypeMapper): ObjectType { + if (mapper.instantiations) { + let cachedType = mapper.instantiations[type.id]; + if (cachedType) { + return cachedType; + } + } + else { + mapper.instantiations = []; + } // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it - let result = createObjectType(TypeFlags.Anonymous | TypeFlags.Instantiated, type.symbol); - result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); - result.members = createSymbolTable(result.properties); - result.callSignatures = instantiateList(getSignaturesOfType(type, SignatureKind.Call), mapper, instantiateSignature); - result.constructSignatures = instantiateList(getSignaturesOfType(type, SignatureKind.Construct), mapper, instantiateSignature); - let stringIndexType = getIndexTypeOfType(type, IndexKind.String); - let numberIndexType = getIndexTypeOfType(type, IndexKind.Number); - if (stringIndexType) result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper); + let result = createObjectType(TypeFlags.Anonymous | TypeFlags.Instantiated, type.symbol); + result.target = type; + result.mapper = mapper; + mapper.instantiations[type.id] = result; return result; } function instantiateType(type: Type, mapper: TypeMapper): Type { - if (mapper !== identityMapper) { + if (type && mapper !== identityMapper) { if (type.flags & TypeFlags.TypeParameter) { return mapper(type); } if (type.flags & TypeFlags.Anonymous) { return type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) ? - instantiateAnonymousType(type, mapper) : type; + instantiateAnonymousType(type, mapper) : type; } if (type.flags & TypeFlags.Reference) { return createTypeReference((type).target, instantiateList((type).typeArguments, mapper, instantiateType)); @@ -4516,7 +4616,7 @@ namespace ts { return createTupleType(instantiateList((type).elementTypes, mapper, instantiateType)); } if (type.flags & TypeFlags.Union) { - return getUnionType(instantiateList((type).types, mapper, instantiateType), /*noDeduplication*/ true); + return getUnionType(instantiateList((type).types, mapper, instantiateType), /*noSubtypeReduction*/ true); } if (type.flags & TypeFlags.Intersection) { return getIntersectionType(instantiateList((type).types, mapper, instantiateType)); @@ -4612,7 +4712,7 @@ namespace ts { * @param target The right-hand-side of the relation. * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. * Used as both to determine which checks are performed and as a cache of previously computed results. - * @param errorNode The node upon which all errors will be reported, if defined. + * @param errorNode The suggested node upon which all errors will be reported, if defined. This may or may not be the actual node used. * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. * @param containingMessageChain A chain of errors to prepend any new errors found. */ @@ -4704,7 +4804,9 @@ namespace ts { // and intersection types are further deconstructed on the target side, we don't want to // make the check again (as it might fail for a partial target type). Therefore we obtain // the regular source type and proceed with that. - source = getRegularTypeOfObjectLiteral(source); + if (target.flags & TypeFlags.UnionOrIntersection) { + source = getRegularTypeOfObjectLiteral(source); + } } let saveErrorInfo = errorInfo; @@ -4752,7 +4854,7 @@ namespace ts { else { if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (source).target === (target).target) { // We have type references to same target type, see if relationship holds for all type arguments - if (result = typesRelatedTo((source).typeArguments, (target).typeArguments, reportErrors)) { + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; } } @@ -4783,7 +4885,7 @@ namespace ts { if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType) { if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (source).target === (target).target) { // We have type references to same target type, see if all type arguments are identical - if (result = typesRelatedTo((source).typeArguments, (target).typeArguments, /*reportErrors*/ false)) { + if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) { return result; } } @@ -4803,11 +4905,41 @@ namespace ts { return Ternary.False; } + // Check if a property with the given name is known anywhere in the given type. In an object type, a property + // is considered known if the object type is empty and the check is for assignability, if the object type has + // index signatures, or if the property is actually declared in the object type. In a union or intersection + // type, a property is considered known if it is known in any constituent type. + function isKnownProperty(type: Type, name: string): boolean { + if (type.flags & TypeFlags.ObjectType) { + const resolved = resolveStructuredTypeMembers(type); + if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) || + resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) { + return true; + } + return false; + } + if (type.flags & TypeFlags.UnionOrIntersection) { + for (let t of (type).types) { + if (isKnownProperty(t, name)) { + return true; + } + } + return false; + } + return true; + } + function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean { for (let prop of getPropertiesOfObjectType(source)) { if (!isKnownProperty(target, prop.name)) { if (reportErrors) { - reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); + // We know *exactly* where things went wrong when comparing the types. + // Use this property as the error node as this will be more helpful in + // reasoning about what went wrong. + errorNode = prop.valueDeclaration; + reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, + symbolToString(prop), + typeToString(target)); } return true; } @@ -4875,9 +5007,14 @@ namespace ts { return result; } - function typesRelatedTo(sources: Type[], targets: Type[], reportErrors: boolean): Ternary { + function typeArgumentsRelatedTo(source: TypeReference, target: TypeReference, reportErrors: boolean): Ternary { + let sources = source.typeArguments || emptyArray; + let targets = target.typeArguments || emptyArray; + if (sources.length !== targets.length && relation === identityRelation) { + return Ternary.False; + } let result = Ternary.True; - for (let i = 0, len = sources.length; i < len; i++) { + for (let i = 0; i < targets.length; i++) { let related = isRelatedTo(sources[i], targets[i], reportErrors); if (!related) { return Ternary.False; @@ -5104,7 +5241,7 @@ namespace ts { if (kind === SignatureKind.Construct) { // Only want to compare the construct signatures for abstractness guarantees. - + // Because the "abstractness" of a class is the same across all construct signatures // (internally we are checking the corresponding declaration), it is enough to perform // the check and report an error once over all pairs of source and target construct signatures. @@ -5145,8 +5282,8 @@ namespace ts { function abstractSignatureRelatedTo(source: Type, sourceSig: Signature, target: Type, targetSig: Signature) { if (sourceSig && targetSig) { - let sourceDecl = source.symbol && getDeclarationOfKind(source.symbol, SyntaxKind.ClassDeclaration); - let targetDecl = target.symbol && getDeclarationOfKind(target.symbol, SyntaxKind.ClassDeclaration); + let sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol); + let targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol); if (!sourceDecl) { // If the source object isn't itself a class declaration, it can be freely assigned, regardless @@ -5160,8 +5297,8 @@ namespace ts { let sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); let targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); - let sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getDeclarationOfKind(sourceReturnType.symbol, SyntaxKind.ClassDeclaration); - let targetReturnDecl = targetReturnType && targetReturnType.symbol && getDeclarationOfKind(targetReturnType.symbol, SyntaxKind.ClassDeclaration); + let sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); + let targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); let sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & NodeFlags.Abstract; let targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & NodeFlags.Abstract; @@ -5545,6 +5682,7 @@ namespace ts { regularType.constructSignatures = (type).constructSignatures; regularType.stringIndexType = (type).stringIndexType; regularType.numberIndexType = (type).numberIndexType; + (type).regularType = regularType; } return regularType; } @@ -5584,7 +5722,7 @@ namespace ts { return getWidenedTypeOfObjectLiteral(type); } if (type.flags & TypeFlags.Union) { - return getUnionType(map((type).types, getWidenedType)); + return getUnionType(map((type).types, getWidenedType), /*noSubtypeReduction*/ true); } if (isArrayType(type)) { return createArrayType(getWidenedType((type).typeArguments[0])); @@ -5775,9 +5913,10 @@ namespace ts { } else if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (source).target === (target).target) { // If source and target are references to the same generic type, infer from type arguments - let sourceTypes = (source).typeArguments; - let targetTypes = (target).typeArguments; - for (let i = 0; i < sourceTypes.length; i++) { + let sourceTypes = (source).typeArguments || emptyArray; + let targetTypes = (target).typeArguments || emptyArray; + let count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; + for (let i = 0; i < count; i++) { inferFromTypes(sourceTypes[i], targetTypes[i]); } } @@ -6272,7 +6411,7 @@ namespace ts { return getUnionType(assignableConstituents); } } - + if (isTypeAssignableTo(narrowedTypeCandidate, originalType)) { // Narrow to the target type if it's assignable to the current type return narrowedTypeCandidate; @@ -6479,7 +6618,7 @@ namespace ts { if (isClassLike(container.parent)) { let symbol = getSymbolOfNode(container.parent); - return container.flags & NodeFlags.Static ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); + return container.flags & NodeFlags.Static ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol)).thisType; } return anyType; } @@ -6499,46 +6638,46 @@ namespace ts { let classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); let baseClassType = classType && getBaseTypes(classType)[0]; - let container = getSuperContainer(node, /*includeFunctions*/ true); + let container = getSuperContainer(node, /*includeFunctions*/ true); let needToCaptureLexicalThis = false; - if (!isCallExpression) { + if (!isCallExpression) { // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting while (container && container.kind === SyntaxKind.ArrowFunction) { container = getSuperContainer(container, /*includeFunctions*/ true); needToCaptureLexicalThis = languageVersion < ScriptTarget.ES6; } } - + let canUseSuperExpression = isLegalUsageOfSuperExpression(container); let nodeCheckFlag: NodeCheckFlags = 0; - + // always set NodeCheckFlags for 'super' expression node - if (canUseSuperExpression) { + if (canUseSuperExpression) { if ((container.flags & NodeFlags.Static) || isCallExpression) { nodeCheckFlag = NodeCheckFlags.SuperStatic; } else { nodeCheckFlag = NodeCheckFlags.SuperInstance; } - + getNodeLinks(node).flags |= nodeCheckFlag; - + if (needToCaptureLexicalThis) { // call expressions are allowed only in constructors so they should always capture correct 'this' // super property access expressions can also appear in arrow functions - // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); - } + } } - + if (!baseClassType) { if (!classDeclaration || !getClassExtendsHeritageClauseElement(classDeclaration)) { error(node, Diagnostics.super_can_only_be_referenced_in_a_derived_class); } - return unknownType; + return unknownType; } - + if (!canUseSuperExpression) { if (container && container.kind === SyntaxKind.ComputedPropertyName) { error(node, Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); @@ -6549,20 +6688,20 @@ namespace ts { else { error(node, Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); } - + return unknownType; } - + if (container.kind === SyntaxKind.Constructor && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } - + return nodeCheckFlag === NodeCheckFlags.SuperStatic ? getBaseConstructorTypeOfClass(classType) : baseClassType; - + function isLegalUsageOfSuperExpression(container: Node): boolean { if (!container) { return false; @@ -6598,15 +6737,15 @@ namespace ts { } } } - + return false; - } + } } // Return contextual type of parameter or undefined if no contextual type is available function getContextuallyTypedParameterType(parameter: ParameterDeclaration): Type { - if (isFunctionExpressionOrArrowFunction(parameter.parent)) { - let func = parameter.parent; + let func = parameter.parent; + if (isFunctionExpressionOrArrowFunction(func) || isObjectLiteralMethod(func)) { if (isContextSensitive(func)) { let contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -6647,7 +6786,7 @@ namespace ts { } } if (isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name); + return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true); } } return undefined; @@ -6938,7 +7077,7 @@ namespace ts { } } - function isFunctionExpressionOrArrowFunction(node: Node): boolean { + function isFunctionExpressionOrArrowFunction(node: Node): node is FunctionExpression { return node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.ArrowFunction; } @@ -6957,8 +7096,8 @@ namespace ts { function getContextualSignature(node: FunctionExpression | MethodDeclaration): Signature { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); let type = isObjectLiteralMethod(node) - ? getContextualTypeForObjectLiteralMethod(node) - : getContextualType(node); + ? getContextualTypeForObjectLiteralMethod(node) + : getContextualType(node); if (!type) { return undefined; } @@ -7043,11 +7182,13 @@ namespace ts { return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } + function hasDefaultValue(node: BindingElement | Expression): boolean { + return (node.kind === SyntaxKind.BindingElement && !!(node).initializer) || + (node.kind === SyntaxKind.BinaryExpression && (node).operatorToken.kind === SyntaxKind.EqualsToken); + } + function checkArrayLiteral(node: ArrayLiteralExpression, contextualMapper?: TypeMapper): Type { let elements = node.elements; - if (!elements.length) { - return createArrayType(undefinedType); - } let hasSpreadElement = false; let elementTypes: Type[] = []; let inDestructuringPattern = isAssignmentTarget(node); @@ -7079,12 +7220,39 @@ namespace ts { hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElementExpression; } if (!hasSpreadElement) { + // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such + // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". + if (inDestructuringPattern && elementTypes.length) { + let type = createNewTupleType(elementTypes); + type.pattern = node; + return type; + } let contextualType = getContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) { - return createTupleType(elementTypes); + if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { + let pattern = contextualType.pattern; + // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting + // tuple type with the corresponding binding or assignment element types to make the lengths equal. + if (pattern && (pattern.kind === SyntaxKind.ArrayBindingPattern || pattern.kind === SyntaxKind.ArrayLiteralExpression)) { + let patternElements = (pattern).elements; + for (let i = elementTypes.length; i < patternElements.length; i++) { + let patternElement = patternElements[i]; + if (hasDefaultValue(patternElement)) { + elementTypes.push((contextualType).elementTypes[i]); + } + else { + if (patternElement.kind !== SyntaxKind.OmittedExpression) { + error(patternElement, Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + elementTypes.push(unknownType); + } + } + } + if (elementTypes.length) { + return createTupleType(elementTypes); + } } } - return createArrayType(getUnionType(elementTypes)); + return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType); } function isNumericName(name: DeclarationName): boolean { @@ -7151,7 +7319,10 @@ namespace ts { let propertiesTable: SymbolTable = {}; let propertiesArray: Symbol[] = []; let contextualType = getContextualType(node); - let typeFlags: TypeFlags; + let contextualTypeHasPattern = contextualType && contextualType.pattern && + (contextualType.pattern.kind === SyntaxKind.ObjectBindingPattern || contextualType.pattern.kind === SyntaxKind.ObjectLiteralExpression); + let inDestructuringPattern = isAssignmentTarget(node); + let typeFlags: TypeFlags = 0; for (let memberDecl of node.properties) { let member = memberDecl.symbol; @@ -7171,6 +7342,25 @@ namespace ts { } typeFlags |= type.flags; let prop = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name); + if (inDestructuringPattern) { + // If object literal is an assignment pattern and if the assignment pattern specifies a default value + // for the property, make the property optional. + if (memberDecl.kind === SyntaxKind.PropertyAssignment && hasDefaultValue((memberDecl).initializer)) { + prop.flags |= SymbolFlags.Optional; + } + } + else if (contextualTypeHasPattern) { + // If object literal is contextually typed by the implied type of a binding pattern, and if the + // binding pattern specifies a default value for the property, make the property optional. + let impliedProp = getPropertyOfType(contextualType, member.name); + if (impliedProp) { + prop.flags |= impliedProp.flags & SymbolFlags.Optional; + } + else if (!compilerOptions.suppressExcessPropertyErrors) { + error(memberDecl.name, Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, + symbolToString(member), typeToString(contextualType)); + } + } prop.declarations = member.declarations; prop.parent = member.parent; if (member.valueDeclaration) { @@ -7197,10 +7387,29 @@ namespace ts { propertiesArray.push(member); } + // If object literal is contextually typed by the implied type of a binding pattern, augment the result + // type with those properties for which the binding pattern specifies a default value. + if (contextualTypeHasPattern) { + for (let prop of getPropertiesOfType(contextualType)) { + if (!hasProperty(propertiesTable, prop.name)) { + if (!(prop.flags & SymbolFlags.Optional)) { + error(prop.valueDeclaration || (prop).bindingElement, + Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); + } + propertiesTable[prop.name] = prop; + propertiesArray.push(prop); + } + } + } + let stringIndexType = getIndexType(IndexKind.String); let numberIndexType = getIndexType(IndexKind.Number); let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= TypeFlags.ObjectLiteral | TypeFlags.FreshObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.PropagatingFlags); + let freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshObjectLiteral; + result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags); + if (inDestructuringPattern) { + result.pattern = node; + } return result; function getIndexType(kind: IndexKind) { @@ -7314,7 +7523,7 @@ namespace ts { // Maybe there's a string indexer? let indexerType = getIndexTypeOfType(elementAttributesType, IndexKind.String); if (indexerType) { - correspondingPropType = indexerType + correspondingPropType = indexerType; } else { // If there's no corresponding property with this name, error @@ -7382,7 +7591,8 @@ namespace ts { if (!links.resolvedSymbol) { if (isJsxIntrinsicIdentifier(node.tagName)) { links.resolvedSymbol = lookupIntrinsicTag(node); - } else { + } + else { links.resolvedSymbol = lookupClassTag(node); } } @@ -7422,7 +7632,9 @@ namespace ts { // Look up the value in the current scope if (valueSymbol && valueSymbol !== unknownSymbol) { links.jsxFlags |= JsxFlags.ClassElement; - getSymbolLinks(valueSymbol).referenced = true; + if (valueSymbol.flags & SymbolFlags.Alias) { + markAliasSymbolAsReferenced(valueSymbol); + } } return valueSymbol || unknownSymbol; @@ -7796,7 +8008,7 @@ namespace ts { let prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text) { - error(right, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(right), typeToString(type)); + error(right, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(right), typeToString(type.flags & TypeFlags.ThisType ? apparentType : type)); } return unknownType; } @@ -7804,7 +8016,7 @@ namespace ts { getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & SymbolFlags.Class) { - checkClassPropertyAccess(node, left, type, prop); + checkClassPropertyAccess(node, left, apparentType, prop); } return getTypeOfSymbol(prop); } @@ -8006,9 +8218,9 @@ namespace ts { function reorderCandidates(signatures: Signature[], result: Signature[]): void { let lastParent: Node; let lastSymbol: Symbol; - let cutoffIndex: number = 0; + let cutoffIndex = 0; let index: number; - let specializedIndex: number = -1; + let specializedIndex = -1; let spliceIndex: number; Debug.assert(!result.length); for (let signature of signatures) { @@ -8355,6 +8567,12 @@ namespace ts { case SyntaxKind.SetAccessor: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) + + // If we are emitting decorators for ES3, we will only pass two arguments. + if (languageVersion === ScriptTarget.ES3) { + return 2; + } + // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; @@ -8912,7 +9130,7 @@ namespace ts { // Note, only class declarations can be declared abstract. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - let valueDecl = expressionType.symbol && getDeclarationOfKind(expressionType.symbol, SyntaxKind.ClassDeclaration); + let valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); if (valueDecl && valueDecl.flags & NodeFlags.Abstract) { error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name)); return resolveErrorCall(node); @@ -9123,10 +9341,24 @@ namespace ts { } } + // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push + // the destructured type into the contained binding elements. + function assignBindingElementTypes(node: VariableLikeDeclaration) { + if (isBindingPattern(node.name)) { + for (let element of (node.name).elements) { + if (element.kind !== SyntaxKind.OmittedExpression) { + getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); + assignBindingElementTypes(element); + } + } + } + } + function assignTypeToParameterAndFixTypeParameters(parameter: Symbol, contextualType: Type, mapper: TypeMapper) { let links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); + assignBindingElementTypes(parameter.valueDeclaration); } else if (isInferentialContext(mapper)) { // Even if the parameter already has a type, it might be because it was given a type while @@ -9165,7 +9397,7 @@ namespace ts { function createPromiseType(promisedType: Type): Type { // creates a `Promise` type where `T` is the promisedType argument let globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyObjectType) { + if (globalPromiseType !== emptyGenericType) { // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type promisedType = getAwaitedType(promisedType); return createTypeReference(globalPromiseType, [promisedType]); @@ -10593,7 +10825,7 @@ namespace ts { } if (!superCallStatement) { error(node, Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); - } + } else { // In such a required super call, it is a compile-time error for argument expressions to reference this. markThisReferencesAsErrors(superCallStatement.expression); @@ -11032,7 +11264,7 @@ namespace ts { // Spaces for anyting not declared a 'default export'. let nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces; - + let commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces; let commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces; @@ -11040,7 +11272,7 @@ namespace ts { // declaration spaces for exported and non-exported declarations intersect for (let d of symbol.declarations) { let declarationSpaces = getDeclarationSpaces(d); - + // Only error on the declarations that conributed to the intersecting spaces. if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { error(d.name, Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, declarationNameToString(d.name)); @@ -11384,9 +11616,16 @@ namespace ts { // serialize the type metadata. if (node && node.kind === SyntaxKind.TypeReference) { let root = getFirstIdentifier((node).typeName); - let rootSymbol = resolveName(root, root.text, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); - if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); + let meaning = root.parent.kind === SyntaxKind.TypeReference ? SymbolFlags.Type : SymbolFlags.Namespace; + // Resolve type so we know which symbol is referenced + let rootSymbol = resolveName(root, root.text, meaning | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + // Resolved symbol is alias + if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias) { + let aliasTarget = resolveAlias(rootSymbol); + // If alias has value symbol - mark alias as referenced + if (aliasTarget.flags & SymbolFlags.Value && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); + } } } } @@ -11860,7 +12099,7 @@ namespace ts { function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node: Node) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && node.parent.kind === SyntaxKind.ObjectLiteralExpression){ + if (node.modifiers && node.parent.kind === SyntaxKind.ObjectLiteralExpression) { if (isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); @@ -12587,6 +12826,7 @@ namespace ts { checkExportsOnMergedDeclarations(node); let symbol = getSymbolOfNode(node); let type = getDeclaredTypeOfSymbol(symbol); + let typeWithThis = getTypeWithThisArgument(type); let staticType = getTypeOfSymbol(symbol); let baseTypeNode = getClassExtendsHeritageClauseElement(node); @@ -12596,6 +12836,7 @@ namespace ts { if (baseTypes.length && produceDiagnostics) { let baseType = baseTypes[0]; let staticBaseType = getBaseConstructorTypeOfClass(type); + checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { forEach(baseTypeNode.typeArguments, checkSourceElement); for (let constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments)) { @@ -12604,7 +12845,7 @@ namespace ts { } } } - checkTypeAssignableTo(type, baseType, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); @@ -12624,7 +12865,7 @@ namespace ts { let implementedTypeNodes = getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - forEach(implementedTypeNodes, typeRefNode => { + for (let typeRefNode of implementedTypeNodes) { if (!isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -12634,14 +12875,14 @@ namespace ts { if (t !== unknownType) { let declaredType = (t.flags & TypeFlags.Reference) ? (t).target : t; if (declaredType.flags & (TypeFlags.Class | TypeFlags.Interface)) { - checkTypeAssignableTo(type, t, node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1); + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1); } else { error(typeRefNode, Diagnostics.A_class_may_only_implement_another_class_or_interface); } } } - }); + } } if (produceDiagnostics) { @@ -12656,6 +12897,10 @@ namespace ts { return s.flags & SymbolFlags.Instantiated ? getSymbolLinks(s).target : s; } + function getClassLikeDeclarationOfSymbol(symbol: Symbol): Declaration { + return forEach(symbol.declarations, d => isClassLike(d) ? d : undefined); + } + function checkKindsOfPropertyMemberOverrides(type: InterfaceType, baseType: ObjectType): void { // TypeScript 1.0 spec (April 2014): 8.2.3 @@ -12693,14 +12938,20 @@ namespace ts { if (derived === base) { // derived class inherits base without override/redeclaration - let derivedClassDecl = getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration); + let derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if ( baseDeclarationFlags & NodeFlags.Abstract && (!derivedClassDecl || !(derivedClassDecl.flags & NodeFlags.Abstract))) { - error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, - typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + if (baseDeclarationFlags & NodeFlags.Abstract && (!derivedClassDecl || !(derivedClassDecl.flags & NodeFlags.Abstract))) { + if (derivedClassDecl.kind === SyntaxKind.ClassExpression) { + error(derivedClassDecl, Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, + symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, + typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } } } else { @@ -12791,7 +13042,7 @@ namespace ts { let ok = true; for (let base of baseTypes) { - let properties = getPropertiesOfObjectType(base); + let properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); for (let prop of properties) { if (!hasProperty(seen, prop.name)) { seen[prop.name] = { prop: prop, containingType: base }; @@ -12836,11 +13087,12 @@ namespace ts { // Only check this symbol once if (node === firstInterfaceDecl) { let type = getDeclaredTypeOfSymbol(symbol); + let typeWithThis = getTypeWithThisArgument(type); // run subsequent checks only if first set succeeded if (checkInheritedPropertiesAreIdentical(type, node.name)) { - forEach(getBaseTypes(type), baseType => { - checkTypeAssignableTo(type, baseType, node.name, Diagnostics.Interface_0_incorrectly_extends_interface_1); - }); + for (let baseType of getBaseTypes(type)) { + checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, Diagnostics.Interface_0_incorrectly_extends_interface_1); + } checkIndexConstraints(type); } } @@ -12883,26 +13135,41 @@ namespace ts { if (!(nodeLinks.flags & NodeCheckFlags.EnumValuesComputed)) { let enumSymbol = getSymbolOfNode(node); let enumType = getDeclaredTypeOfSymbol(enumSymbol); - let autoValue = 0; + let autoValue = 0; // set to undefined when enum member is non-constant let ambient = isInAmbientContext(node); let enumIsConst = isConst(node); - forEach(node.members, member => { - if (member.name.kind !== SyntaxKind.ComputedPropertyName && isNumericLiteralName((member.name).text)) { + for (const member of node.members) { + if (member.name.kind === SyntaxKind.ComputedPropertyName) { + error(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums); + } + else if (isNumericLiteralName((member.name).text)) { error(member.name, Diagnostics.An_enum_member_cannot_have_a_numeric_name); } + + const previousEnumMemberIsNonConstant = autoValue === undefined; + let initializer = member.initializer; if (initializer) { autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient); } else if (ambient && !enumIsConst) { + // In ambient enum declarations that specify no const modifier, enum member declarations + // that omit a value are considered computed members (as opposed to having auto-incremented values assigned). autoValue = undefined; } + else if (previousEnumMemberIsNonConstant) { + // If the member declaration specifies no value, the member is considered a constant enum member. + // If the member is the first member in the enum declaration, it is assigned the value zero. + // Otherwise, it is assigned the value of the immediately preceding member plus one, + // and an error occurs if the immediately preceding member is not a constant enum member + error(member.name, Diagnostics.Enum_member_must_have_initializer); + } if (autoValue !== undefined) { getNodeLinks(member).enumMemberValue = autoValue++; } - }); + } nodeLinks.flags |= NodeCheckFlags.EnumValuesComputed; } @@ -12918,11 +13185,11 @@ namespace ts { if (enumIsConst) { error(initializer, Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); } - else if (!ambient) { + else if (ambient) { + error(initializer, Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); + } + else { // Only here do we need to check that the initializer is assignable to the enum type. - // If it is a constant value (not undefined), it is syntactically constrained to be a number. - // Also, we do not need to check this for ambients because there is already - // a syntax error if it is not a constant. checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); } } @@ -13046,7 +13313,7 @@ namespace ts { // illegal case: forward reference if (!isDefinedBefore(propertyDecl, member)) { reportError = false; - error(e, Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums); + error(e, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return undefined; } @@ -13062,7 +13329,7 @@ namespace ts { } // Grammar checking - checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node); + checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); @@ -13195,7 +13462,7 @@ namespace ts { // Checks for ambient external modules. if (isAmbientExternalModule) { if (!isGlobalSourceFile(node.parent)) { - error(node.name, Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules); + error(node.name, Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces); } if (isExternalModuleNameRelative(node.name.text)) { error(node.name, Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name); @@ -13220,7 +13487,7 @@ namespace ts { Debug.assert(node.kind === SyntaxKind.Identifier); return node; } - + function checkExternalImportOrExportDeclaration(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): boolean { let moduleName = getExternalModuleName(node); if (!nodeIsMissing(moduleName) && moduleName.kind !== SyntaxKind.StringLiteral) { @@ -13322,9 +13589,9 @@ namespace ts { } } else { - if (languageVersion >= ScriptTarget.ES6 && !isInAmbientContext(node)) { + if (modulekind === ModuleKind.ES6 && !isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above - grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); + grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -13399,11 +13666,11 @@ namespace ts { checkExternalModuleExports(container); if (node.isExportEquals && !isInAmbientContext(node)) { - if (languageVersion >= ScriptTarget.ES6) { - // export assignment is deprecated in es6 or above - grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); + if (modulekind === ModuleKind.ES6) { + // export assignment is not supported in es6 modules + grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_modules_Consider_using_export_default_or_another_module_format_instead); } - else if (compilerOptions.module === ModuleKind.System) { + else if (modulekind === ModuleKind.System) { // system modules does not support export assignment grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } @@ -13599,7 +13866,7 @@ namespace ts { forEach(node.decorators, checkFunctionAndClassExpressionBodies); forEach((node).parameters, checkFunctionAndClassExpressionBodies); if (isObjectLiteralMethod(node)) { - checkFunctionExpressionOrObjectLiteralMethodBody(node); + checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; case SyntaxKind.Constructor: @@ -13665,6 +13932,8 @@ namespace ts { case SyntaxKind.VariableDeclaration: case SyntaxKind.VariableDeclarationList: case SyntaxKind.ClassDeclaration: + case SyntaxKind.HeritageClause: + case SyntaxKind.ExpressionWithTypeArguments: case SyntaxKind.EnumDeclaration: case SyntaxKind.EnumMember: case SyntaxKind.ExportAssignment: @@ -13846,6 +14115,10 @@ namespace ts { break; } + if (introducesArgumentsExoticObject(location)) { + copySymbol(argumentsSymbol, meaning); + } + memberFlags = location.flags; location = location.parent; } @@ -13960,7 +14233,21 @@ namespace ts { } if (isHeritageClauseElementIdentifier(entityName)) { - let meaning = entityName.parent.kind === SyntaxKind.ExpressionWithTypeArguments ? SymbolFlags.Type : SymbolFlags.Namespace; + let meaning = SymbolFlags.None; + + // In an interface or class, we're definitely interested in a type. + if (entityName.parent.kind === SyntaxKind.ExpressionWithTypeArguments) { + meaning = SymbolFlags.Type; + + // In a class 'extends' clause we are also looking for a value. + if (isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + meaning |= SymbolFlags.Value; + } + } + else { + meaning = SymbolFlags.Namespace; + } + meaning |= SymbolFlags.Alias; return resolveEntityName(entityName, meaning); } @@ -14052,7 +14339,7 @@ namespace ts { case SyntaxKind.ThisKeyword: case SyntaxKind.SuperKeyword: - let type = checkExpression(node); + let type = isExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; case SyntaxKind.ConstructorKeyword: @@ -14191,7 +14478,10 @@ namespace ts { let symbols: Symbol[] = []; let name = symbol.name; forEach(getSymbolLinks(symbol).containingType.types, t => { - symbols.push(getPropertyOfType(t, name)); + let symbol = getPropertyOfType(t, name); + if (symbol) { + symbols.push(symbol); + } }); return symbols; } @@ -14314,9 +14604,9 @@ namespace ts { } // const enums and modules that contain only const enums are not considered values from the emit perespective // unless 'preserveConstEnums' option is set to true - return target !== unknownSymbol && - target && - target.flags & SymbolFlags.Value && + return target !== unknownSymbol && + target && + target.flags & SymbolFlags.Value && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } @@ -14387,7 +14677,7 @@ namespace ts { function isFunctionType(type: Type): boolean { return type.flags & TypeFlags.ObjectType && getSignaturesOfType(type, SignatureKind.Call).length > 0; } - + function getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind { // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. let valueSymbol = resolveEntityName(typeName, SymbolFlags.Value, /*ignoreErrors*/ true); @@ -14398,6 +14688,10 @@ namespace ts { // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. let typeSymbol = resolveEntityName(typeName, SymbolFlags.Type, /*ignoreErrors*/ true); + // We might not be able to resolve type symbol so use unknown type in that case (eg error case) + if (!typeSymbol) { + return TypeReferenceSerializationKind.ObjectType; + } let type = getDeclaredTypeOfSymbol(typeSymbol); if (type === unknownType) { return TypeReferenceSerializationKind.Unknown; @@ -14604,7 +14898,7 @@ namespace ts { function createInstantiatedPromiseLikeType(): ObjectType { let promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyObjectType) { + if (promiseLikeType !== emptyGenericType) { return createTypeReference(promiseLikeType, [anyType]); } @@ -14632,9 +14926,6 @@ namespace ts { if (!nodeCanBeDecorated(node)) { return grammarErrorOnFirstToken(node, Diagnostics.Decorators_are_not_valid_here); } - else if (languageVersion < ScriptTarget.ES5) { - return grammarErrorOnFirstToken(node, Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); - } else if (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor) { let accessors = getAllAccessorDeclarations((node.parent).members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { @@ -15549,40 +15840,6 @@ namespace ts { return false; } - function checkGrammarEnumDeclaration(enumDecl: EnumDeclaration): boolean { - let enumIsConst = (enumDecl.flags & NodeFlags.Const) !== 0; - - let hasError = false; - - // skip checks below for const enums - they allow arbitrary initializers as long as they can be evaluated to constant expressions. - // since all values are known in compile time - it is not necessary to check that constant enum section precedes computed enum members. - if (!enumIsConst) { - let inConstantEnumMemberSection = true; - let inAmbientContext = isInAmbientContext(enumDecl); - for (let node of enumDecl.members) { - // Do not use hasDynamicName here, because that returns false for well known symbols. - // We want to perform checkComputedPropertyName for all computed properties, including - // well known symbols. - if (node.name.kind === SyntaxKind.ComputedPropertyName) { - hasError = grammarErrorOnNode(node.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (inAmbientContext) { - if (node.initializer && !isIntegerLiteral(node.initializer)) { - hasError = grammarErrorOnNode(node.name, Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; - } - } - else if (node.initializer) { - inConstantEnumMemberSection = isIntegerLiteral(node.initializer); - } - else if (!inConstantEnumMemberSection) { - hasError = grammarErrorOnNode(node.name, Diagnostics.Enum_member_must_have_initializer) || hasError; - } - } - } - - return hasError; - } - function hasParseDiagnostics(sourceFile: SourceFile): boolean { return sourceFile.parseDiagnostics.length > 0; } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 5d7c1bc1690..f84118b5322 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -41,6 +41,11 @@ namespace ts { type: "boolean", description: Diagnostics.Print_this_message, }, + { + name: "init", + type: "boolean", + description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, + }, { name: "inlineSourceMap", type: "boolean", @@ -82,10 +87,11 @@ namespace ts { "amd": ModuleKind.AMD, "system": ModuleKind.System, "umd": ModuleKind.UMD, + "es6": ModuleKind.ES6, }, - description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_or_umd, + description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6, paramType: Diagnostics.KIND, - error: Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_or_umd + error: Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6 }, { name: "newLine", @@ -131,6 +137,13 @@ namespace ts { { name: "out", type: "string", + isFilePath: false, // This is intentionally broken to support compatability with existing tsconfig files + // for correct behaviour, please use outFile + paramType: Diagnostics.FILE, + }, + { + name: "outFile", + type: "string", isFilePath: true, description: Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: Diagnostics.FILE, @@ -183,6 +196,12 @@ namespace ts { description: Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, paramType: Diagnostics.LOCATION, }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", @@ -229,22 +248,50 @@ namespace ts { type: "boolean", experimental: true, description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: { + "node": ModuleResolutionKind.NodeJs, + "classic": ModuleResolutionKind.Classic + }, + description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + error: Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic, } ]; - export function parseCommandLine(commandLine: string[]): ParsedCommandLine { - let options: CompilerOptions = {}; - let fileNames: string[] = []; - let errors: Diagnostic[] = []; - let shortOptionNames: Map = {}; - let optionNameMap: Map = {}; + /* @internal */ + export interface OptionNameMap { + optionNameMap: Map; + shortOptionNames: Map; + } + let optionNameMapCache: OptionNameMap; + /* @internal */ + export function getOptionNameMap(): OptionNameMap { + if (optionNameMapCache) { + return optionNameMapCache; + } + + let optionNameMap: Map = {}; + let shortOptionNames: Map = {}; forEach(optionDeclarations, option => { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { shortOptionNames[option.shortName] = option.name; } }); + + optionNameMapCache = { optionNameMap, shortOptionNames }; + return optionNameMapCache; + } + + export function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine { + let options: CompilerOptions = {}; + let fileNames: string[] = []; + let errors: Diagnostic[] = []; + let { optionNameMap, shortOptionNames } = getOptionNameMap(); + parseStrings(commandLine); return { options, @@ -293,7 +340,7 @@ namespace ts { options[opt.name] = map[key]; } else { - errors.push(createCompilerDiagnostic(opt.error)); + errors.push(createCompilerDiagnostic((opt).error)); } } } @@ -308,7 +355,7 @@ namespace ts { } function parseResponseFile(fileName: string) { - let text = sys.readFile(fileName); + let text = readFile ? readFile(fileName) : sys.readFile(fileName); if (!text) { errors.push(createCompilerDiagnostic(Diagnostics.File_0_not_found, fileName)); @@ -345,10 +392,10 @@ namespace ts { * Read tsconfig.json file * @param fileName The path to the config file */ - export function readConfigFile(fileName: string): { config?: any; error?: Diagnostic } { + export function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; error?: Diagnostic } { let text = ""; try { - text = sys.readFile(fileName); + text = readFile(fileName); } catch (e) { return { error: createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; @@ -406,7 +453,7 @@ namespace ts { value = optType[key]; } else { - errors.push(createCompilerDiagnostic(opt.error)); + errors.push(createCompilerDiagnostic((opt).error)); value = 0; } } @@ -434,7 +481,7 @@ namespace ts { fileNames = map(json["files"], s => combinePaths(basePath, s)); } else { - errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); } } else { @@ -461,4 +508,4 @@ namespace ts { return fileNames; } } -} +} diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 5fc9335073c..ce59c3b3bc6 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -52,7 +52,7 @@ namespace ts { function normalizeKey(key: string) { return getCanonicalFileName(normalizeSlashes(key)); } - + function clear() { files = {}; } @@ -117,7 +117,7 @@ namespace ts { return count; } - export function filter(array: T[], f: (x: T) => boolean): T[]{ + export function filter(array: T[], f: (x: T) => boolean): T[] { let result: T[]; if (array) { result = []; @@ -130,7 +130,7 @@ namespace ts { return result; } - export function map(array: T[], f: (x: T) => U): U[]{ + export function map(array: T[], f: (x: T) => U): U[] { let result: U[]; if (array) { result = []; @@ -148,7 +148,7 @@ namespace ts { return array1.concat(array2); } - export function deduplicate(array: T[]): T[]{ + export function deduplicate(array: T[]): T[] { let result: T[]; if (array) { result = []; @@ -287,14 +287,14 @@ namespace ts { return result; } - export function extend(first: Map, second: Map): Map { - let result: Map = {}; + export function extend(first: Map, second: Map): Map { + let result: Map = {}; for (let id in first) { - result[id] = first[id]; + (result as any)[id] = first[id]; } for (let id in second) { if (!hasProperty(result, id)) { - result[id] = second[id]; + (result as any)[id] = second[id]; } } return result; @@ -486,7 +486,7 @@ namespace ts { return text1 ? Comparison.GreaterThan : Comparison.LessThan; } - export function sortAndDeduplicateDiagnostics(diagnostics: Diagnostic[]): Diagnostic[]{ + export function sortAndDeduplicateDiagnostics(diagnostics: Diagnostic[]): Diagnostic[] { return deduplicateSortedDiagnostics(diagnostics.sort(compareDiagnostics)); } @@ -795,7 +795,7 @@ namespace ts { VeryAggressive = 3, } - export module Debug { + export namespace Debug { let currentAssertionLevel = AssertionLevel.None; export function shouldAssert(level: AssertionLevel): boolean { diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index a490ba39a46..00085f16086 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -52,6 +52,7 @@ namespace ts { let enclosingDeclaration: Node; let currentSourceFile: SourceFile; let reportedDeclarationError = false; + let errorNameNode: DeclarationName; let emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments; let emit = compilerOptions.stripInternal ? stripInternal : emitNode; @@ -152,6 +153,7 @@ namespace ts { function createAndSetNewTextWriterWithSymbolWriter(): EmitTextWriterWithSymbolWriter { let writer = createTextWriter(newLine); writer.trackSymbol = trackSymbol; + writer.reportInaccessibleThisError = reportInaccessibleThisError; writer.writeKeyword = writer.write; writer.writeOperator = writer.write; writer.writePunctuation = writer.write; @@ -178,9 +180,11 @@ namespace ts { let nodeToCheck: Node; if (declaration.kind === SyntaxKind.VariableDeclaration) { nodeToCheck = declaration.parent.parent; - } else if (declaration.kind === SyntaxKind.NamedImports || declaration.kind === SyntaxKind.ImportSpecifier || declaration.kind === SyntaxKind.ImportClause) { + } + else if (declaration.kind === SyntaxKind.NamedImports || declaration.kind === SyntaxKind.ImportSpecifier || declaration.kind === SyntaxKind.ImportClause) { Debug.fail("We should be getting ImportDeclaration instead to write"); - } else { + } + else { nodeToCheck = declaration; } @@ -257,6 +261,13 @@ namespace ts { handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); } + function reportInaccessibleThisError() { + if (errorNameNode) { + diagnostics.push(createDiagnosticForNode(errorNameNode, Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary, + declarationNameToString(errorNameNode))); + } + } + function writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, type: TypeNode, getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); @@ -265,7 +276,9 @@ namespace ts { emitType(type); } else { + errorNameNode = declaration.name; resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer); + errorNameNode = undefined; } } @@ -277,7 +290,9 @@ namespace ts { emitType(signature.type); } else { + errorNameNode = signature.name; resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer); + errorNameNode = undefined; } } @@ -326,6 +341,7 @@ namespace ts { case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: case SyntaxKind.VoidKeyword: + case SyntaxKind.ThisKeyword: case SyntaxKind.StringLiteral: return writeTextOfNode(currentSourceFile, type); case SyntaxKind.ExpressionWithTypeArguments: @@ -896,6 +912,9 @@ namespace ts { if (isSupportedExpressionWithTypeArguments(node)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } + else if (!isImplementsList && node.expression.kind === SyntaxKind.NullKeyword) { + write("null"); + } function getHeritageClauseVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic { let diagnosticMessage: DiagnosticMessage; @@ -1065,7 +1084,7 @@ namespace ts { // emitted: declare var c: number; // instead of declare var c:number, ; let elements: Node[] = []; for (let element of bindingPattern.elements) { - if (element.kind !== SyntaxKind.OmittedExpression){ + if (element.kind !== SyntaxKind.OmittedExpression) { elements.push(element); } } @@ -1574,7 +1593,7 @@ namespace ts { ? referencedFile.fileName // Declaration file, use declaration file name : shouldEmitToOwnFile(referencedFile, compilerOptions) ? getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file - : removeFileExtension(compilerOptions.out) + ".d.ts"; // Global out file + : removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; // Global out file declFileName = getRelativePathToDirectoryOrUrl( getDirectoryPath(normalizeSlashes(jsFilePath)), diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts deleted file mode 100644 index 4fdb2221762..00000000000 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ /dev/null @@ -1,622 +0,0 @@ -// -/// -/* @internal */ -namespace ts { - export var Diagnostics = { - Unterminated_string_literal: { code: 1002, category: DiagnosticCategory.Error, key: "Unterminated string literal." }, - Identifier_expected: { code: 1003, category: DiagnosticCategory.Error, key: "Identifier expected." }, - _0_expected: { code: 1005, category: DiagnosticCategory.Error, key: "'{0}' expected." }, - A_file_cannot_have_a_reference_to_itself: { code: 1006, category: DiagnosticCategory.Error, key: "A file cannot have a reference to itself." }, - Trailing_comma_not_allowed: { code: 1009, category: DiagnosticCategory.Error, key: "Trailing comma not allowed." }, - Asterisk_Slash_expected: { code: 1010, category: DiagnosticCategory.Error, key: "'*/' expected." }, - Unexpected_token: { code: 1012, category: DiagnosticCategory.Error, key: "Unexpected token." }, - A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: DiagnosticCategory.Error, key: "A rest parameter must be last in a parameter list." }, - Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: DiagnosticCategory.Error, key: "Parameter cannot have question mark and initializer." }, - A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: DiagnosticCategory.Error, key: "A required parameter cannot follow an optional parameter." }, - An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: DiagnosticCategory.Error, key: "An index signature cannot have a rest parameter." }, - An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: DiagnosticCategory.Error, key: "An index signature parameter cannot have an accessibility modifier." }, - An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: DiagnosticCategory.Error, key: "An index signature parameter cannot have a question mark." }, - An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer." }, - An_index_signature_must_have_a_type_annotation: { code: 1021, category: DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, - An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, - An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, - Accessibility_modifier_already_seen: { code: 1028, category: DiagnosticCategory.Error, key: "Accessibility modifier already seen." }, - _0_modifier_must_precede_1_modifier: { code: 1029, category: DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." }, - _0_modifier_already_seen: { code: 1030, category: DiagnosticCategory.Error, key: "'{0}' modifier already seen." }, - _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." }, - super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, - Only_ambient_modules_can_use_quoted_names: { code: 1035, category: DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." }, - Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, - Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, - _0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used in an ambient context." }, - _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a class declaration." }, - _0_modifier_cannot_be_used_here: { code: 1042, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used here." }, - _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a data property." }, - _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, - A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an interface declaration." }, - A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, - A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, - A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, - A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter." }, - A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter." }, - A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, - A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, - A_get_accessor_cannot_have_parameters: { code: 1054, category: DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, - Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: DiagnosticCategory.Error, key: "Type '{0}' is not a valid async function return type." }, - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, - An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: DiagnosticCategory.Error, key: "An async function or method must have a valid awaitable return type." }, - Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: DiagnosticCategory.Error, key: "Operand for 'await' does not have a valid callable 'then' member." }, - Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: DiagnosticCategory.Error, key: "Return expression in async function does not have a valid callable 'then' member." }, - Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: DiagnosticCategory.Error, key: "Expression body for async arrow function does not have a valid callable 'then' member." }, - Enum_member_must_have_initializer: { code: 1061, category: DiagnosticCategory.Error, key: "Enum member must have initializer." }, - _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: DiagnosticCategory.Error, key: "{0} is referenced directly or indirectly in the fulfillment callback of its own 'then' method." }, - An_export_assignment_cannot_be_used_in_a_namespace: { code: 1063, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in a namespace." }, - Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." }, - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, - A_0_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an import declaration." }, - Invalid_reference_directive_syntax: { code: 1084, category: DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, - An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." }, - _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a constructor declaration." }, - _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a parameter." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...in' statement." }, - Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: DiagnosticCategory.Error, key: "Type parameters cannot appear on a constructor declaration." }, - Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: DiagnosticCategory.Error, key: "Type annotation cannot appear on a constructor declaration." }, - An_accessor_cannot_have_type_parameters: { code: 1094, category: DiagnosticCategory.Error, key: "An accessor cannot have type parameters." }, - A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have a return type annotation." }, - An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: DiagnosticCategory.Error, key: "An index signature must have exactly one parameter." }, - _0_list_cannot_be_empty: { code: 1097, category: DiagnosticCategory.Error, key: "'{0}' list cannot be empty." }, - Type_parameter_list_cannot_be_empty: { code: 1098, category: DiagnosticCategory.Error, key: "Type parameter list cannot be empty." }, - Type_argument_list_cannot_be_empty: { code: 1099, category: DiagnosticCategory.Error, key: "Type argument list cannot be empty." }, - Invalid_use_of_0_in_strict_mode: { code: 1100, category: DiagnosticCategory.Error, key: "Invalid use of '{0}' in strict mode." }, - with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in strict mode." }, - delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: DiagnosticCategory.Error, key: "'delete' cannot be called on an identifier in strict mode." }, - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: DiagnosticCategory.Error, key: "A 'continue' statement can only be used within an enclosing iteration statement." }, - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: DiagnosticCategory.Error, key: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, - Jump_target_cannot_cross_function_boundary: { code: 1107, category: DiagnosticCategory.Error, key: "Jump target cannot cross function boundary." }, - A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: DiagnosticCategory.Error, key: "A 'return' statement can only be used within a function body." }, - Expression_expected: { code: 1109, category: DiagnosticCategory.Error, key: "Expression expected." }, - Type_expected: { code: 1110, category: DiagnosticCategory.Error, key: "Type expected." }, - A_class_member_cannot_be_declared_optional: { code: 1112, category: DiagnosticCategory.Error, key: "A class member cannot be declared optional." }, - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, - Duplicate_label_0: { code: 1114, category: DiagnosticCategory.Error, key: "Duplicate label '{0}'" }, - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: DiagnosticCategory.Error, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: DiagnosticCategory.Error, key: "A 'break' statement can only jump to a label of an enclosing statement." }, - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: DiagnosticCategory.Error, key: "An object literal cannot have multiple properties with the same name in strict mode." }, - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: DiagnosticCategory.Error, key: "An object literal cannot have multiple get/set accessors with the same name." }, - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name." }, - An_export_assignment_cannot_have_modifiers: { code: 1120, category: DiagnosticCategory.Error, key: "An export assignment cannot have modifiers." }, - Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: DiagnosticCategory.Error, key: "Octal literals are not allowed in strict mode." }, - A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: DiagnosticCategory.Error, key: "A tuple type element list cannot be empty." }, - Variable_declaration_list_cannot_be_empty: { code: 1123, category: DiagnosticCategory.Error, key: "Variable declaration list cannot be empty." }, - Digit_expected: { code: 1124, category: DiagnosticCategory.Error, key: "Digit expected." }, - Hexadecimal_digit_expected: { code: 1125, category: DiagnosticCategory.Error, key: "Hexadecimal digit expected." }, - Unexpected_end_of_text: { code: 1126, category: DiagnosticCategory.Error, key: "Unexpected end of text." }, - Invalid_character: { code: 1127, category: DiagnosticCategory.Error, key: "Invalid character." }, - Declaration_or_statement_expected: { code: 1128, category: DiagnosticCategory.Error, key: "Declaration or statement expected." }, - Statement_expected: { code: 1129, category: DiagnosticCategory.Error, key: "Statement expected." }, - case_or_default_expected: { code: 1130, category: DiagnosticCategory.Error, key: "'case' or 'default' expected." }, - Property_or_signature_expected: { code: 1131, category: DiagnosticCategory.Error, key: "Property or signature expected." }, - Enum_member_expected: { code: 1132, category: DiagnosticCategory.Error, key: "Enum member expected." }, - Variable_declaration_expected: { code: 1134, category: DiagnosticCategory.Error, key: "Variable declaration expected." }, - Argument_expression_expected: { code: 1135, category: DiagnosticCategory.Error, key: "Argument expression expected." }, - Property_assignment_expected: { code: 1136, category: DiagnosticCategory.Error, key: "Property assignment expected." }, - Expression_or_comma_expected: { code: 1137, category: DiagnosticCategory.Error, key: "Expression or comma expected." }, - Parameter_declaration_expected: { code: 1138, category: DiagnosticCategory.Error, key: "Parameter declaration expected." }, - Type_parameter_declaration_expected: { code: 1139, category: DiagnosticCategory.Error, key: "Type parameter declaration expected." }, - Type_argument_expected: { code: 1140, category: DiagnosticCategory.Error, key: "Type argument expected." }, - String_literal_expected: { code: 1141, category: DiagnosticCategory.Error, key: "String literal expected." }, - Line_break_not_permitted_here: { code: 1142, category: DiagnosticCategory.Error, key: "Line break not permitted here." }, - or_expected: { code: 1144, category: DiagnosticCategory.Error, key: "'{' or ';' expected." }, - Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members." }, - Declaration_expected: { code: 1146, category: DiagnosticCategory.Error, key: "Declaration expected." }, - Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: DiagnosticCategory.Error, key: "Import declarations in a namespace cannot reference a module." }, - Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." }, - File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, - const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, - const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, - let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, - Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." }, - Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." }, - An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." }, - A_yield_expression_is_only_allowed_in_a_generator_body: { code: 1163, category: DiagnosticCategory.Error, key: "A 'yield' expression is only allowed in a generator body." }, - Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, - A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, - A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." }, - A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, - A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: DiagnosticCategory.Error, key: "A comma expression is not allowed in a computed property name." }, - extends_clause_already_seen: { code: 1172, category: DiagnosticCategory.Error, key: "'extends' clause already seen." }, - extends_clause_must_precede_implements_clause: { code: 1173, category: DiagnosticCategory.Error, key: "'extends' clause must precede 'implements' clause." }, - Classes_can_only_extend_a_single_class: { code: 1174, category: DiagnosticCategory.Error, key: "Classes can only extend a single class." }, - implements_clause_already_seen: { code: 1175, category: DiagnosticCategory.Error, key: "'implements' clause already seen." }, - Interface_declaration_cannot_have_implements_clause: { code: 1176, category: DiagnosticCategory.Error, key: "Interface declaration cannot have 'implements' clause." }, - Binary_digit_expected: { code: 1177, category: DiagnosticCategory.Error, key: "Binary digit expected." }, - Octal_digit_expected: { code: 1178, category: DiagnosticCategory.Error, key: "Octal digit expected." }, - Unexpected_token_expected: { code: 1179, category: DiagnosticCategory.Error, key: "Unexpected token. '{' expected." }, - Property_destructuring_pattern_expected: { code: 1180, category: DiagnosticCategory.Error, key: "Property destructuring pattern expected." }, - Array_element_destructuring_pattern_expected: { code: 1181, category: DiagnosticCategory.Error, key: "Array element destructuring pattern expected." }, - A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." }, - An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." }, - Modifiers_cannot_appear_here: { code: 1184, category: DiagnosticCategory.Error, key: "Modifiers cannot appear here." }, - Merge_conflict_marker_encountered: { code: 1185, category: DiagnosticCategory.Error, key: "Merge conflict marker encountered." }, - A_rest_element_cannot_have_an_initializer: { code: 1186, category: DiagnosticCategory.Error, key: "A rest element cannot have an initializer." }, - A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: DiagnosticCategory.Error, key: "A parameter property may not be a binding pattern." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...of' statement." }, - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: DiagnosticCategory.Error, key: "The variable declaration of a 'for...in' statement cannot have an initializer." }, - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: DiagnosticCategory.Error, key: "The variable declaration of a 'for...of' statement cannot have an initializer." }, - An_import_declaration_cannot_have_modifiers: { code: 1191, category: DiagnosticCategory.Error, key: "An import declaration cannot have modifiers." }, - Module_0_has_no_default_export: { code: 1192, category: DiagnosticCategory.Error, key: "Module '{0}' has no default export." }, - An_export_declaration_cannot_have_modifiers: { code: 1193, category: DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." }, - Export_declarations_are_not_permitted_in_a_namespace: { code: 1194, category: DiagnosticCategory.Error, key: "Export declarations are not permitted in a namespace." }, - Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: DiagnosticCategory.Error, key: "Catch clause variable name must be an identifier." }, - Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: DiagnosticCategory.Error, key: "Catch clause variable cannot have a type annotation." }, - Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." }, - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." }, - Unterminated_Unicode_escape_sequence: { code: 1199, category: DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." }, - Line_terminator_not_permitted_before_arrow: { code: 1200, category: DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." }, - Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." }, - Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." }, - Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher: { code: 1204, category: DiagnosticCategory.Error, key: "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher." }, - Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." }, - Decorators_are_not_valid_here: { code: 1206, category: DiagnosticCategory.Error, key: "Decorators are not valid here." }, - Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." }, - Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, - Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, - A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." }, - Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: DiagnosticCategory.Error, key: "Invalid use of '{0}'. Modules are automatically in strict mode." }, - Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." }, - Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." }, - Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." }, - An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." }, - _0_tag_already_specified: { code: 1223, category: DiagnosticCategory.Error, key: "'{0}' tag already specified." }, - Signature_0_must_have_a_type_predicate: { code: 1224, category: DiagnosticCategory.Error, key: "Signature '{0}' must have a type predicate." }, - Cannot_find_parameter_0: { code: 1225, category: DiagnosticCategory.Error, key: "Cannot find parameter '{0}'." }, - Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: DiagnosticCategory.Error, key: "Type predicate '{0}' is not assignable to '{1}'." }, - Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: DiagnosticCategory.Error, key: "Parameter '{0}' is not in the same position as parameter '{1}'." }, - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: DiagnosticCategory.Error, key: "A type predicate is only allowed in return type position for functions and methods." }, - A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: DiagnosticCategory.Error, key: "A type predicate cannot reference a rest parameter." }, - A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: DiagnosticCategory.Error, key: "A type predicate cannot reference element '{0}' in a binding pattern." }, - An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: DiagnosticCategory.Error, key: "An export assignment can only be used in a module." }, - An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: DiagnosticCategory.Error, key: "An import declaration can only be used in a namespace or module." }, - An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: DiagnosticCategory.Error, key: "An export declaration can only be used in a module." }, - An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." }, - A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." }, - Experimental_support_for_async_functions_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalAsyncFunctions_to_remove_this_warning: { code: 1236, category: DiagnosticCategory.Error, key: "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning." }, - with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, - Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, - The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." }, - The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." }, - Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." }, - Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, - Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, - Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, - abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: DiagnosticCategory.Error, key: "'abstract' modifier can only appear on a class or method declaration." }, - _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, - Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, - Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, - Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, - Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, - Circular_definition_of_import_alias_0: { code: 2303, category: DiagnosticCategory.Error, key: "Circular definition of import alias '{0}'." }, - Cannot_find_name_0: { code: 2304, category: DiagnosticCategory.Error, key: "Cannot find name '{0}'." }, - Module_0_has_no_exported_member_1: { code: 2305, category: DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, - File_0_is_not_a_module: { code: 2306, category: DiagnosticCategory.Error, key: "File '{0}' is not a module." }, - Cannot_find_module_0: { code: 2307, category: DiagnosticCategory.Error, key: "Cannot find module '{0}'." }, - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, - Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, - A_class_may_only_extend_another_class: { code: 2311, category: DiagnosticCategory.Error, key: "A class may only extend another class." }, - An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: DiagnosticCategory.Error, key: "An interface may only extend a class or another interface." }, - Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: { code: 2313, category: DiagnosticCategory.Error, key: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list." }, - Generic_type_0_requires_1_type_argument_s: { code: 2314, category: DiagnosticCategory.Error, key: "Generic type '{0}' requires {1} type argument(s)." }, - Type_0_is_not_generic: { code: 2315, category: DiagnosticCategory.Error, key: "Type '{0}' is not generic." }, - Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: DiagnosticCategory.Error, key: "Global type '{0}' must be a class or interface type." }, - Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: DiagnosticCategory.Error, key: "Global type '{0}' must have {1} type parameter(s)." }, - Cannot_find_global_type_0: { code: 2318, category: DiagnosticCategory.Error, key: "Cannot find global type '{0}'." }, - Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: DiagnosticCategory.Error, key: "Named property '{0}' of types '{1}' and '{2}' are not identical." }, - Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: DiagnosticCategory.Error, key: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, - Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: DiagnosticCategory.Error, key: "Excessive stack depth comparing types '{0}' and '{1}'." }, - Type_0_is_not_assignable_to_type_1: { code: 2322, category: DiagnosticCategory.Error, key: "Type '{0}' is not assignable to type '{1}'." }, - Property_0_is_missing_in_type_1: { code: 2324, category: DiagnosticCategory.Error, key: "Property '{0}' is missing in type '{1}'." }, - Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: DiagnosticCategory.Error, key: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, - Types_of_property_0_are_incompatible: { code: 2326, category: DiagnosticCategory.Error, key: "Types of property '{0}' are incompatible." }, - Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: DiagnosticCategory.Error, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, - Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible." }, - Index_signature_is_missing_in_type_0: { code: 2329, category: DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, - Index_signatures_are_incompatible: { code: 2330, category: DiagnosticCategory.Error, key: "Index signatures are incompatible." }, - this_cannot_be_referenced_in_a_module_or_namespace_body: { code: 2331, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in a module or namespace body." }, - this_cannot_be_referenced_in_current_location: { code: 2332, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in current location." }, - this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in constructor arguments." }, - this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, - super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." }, - super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, - Property_0_does_not_exist_on_type_1: { code: 2339, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, - Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, - Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, - Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." }, - Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: DiagnosticCategory.Error, key: "Untyped function calls may not accept type arguments." }, - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: DiagnosticCategory.Error, key: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: DiagnosticCategory.Error, key: "Cannot invoke an expression whose type lacks a call signature." }, - Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." }, - Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, - Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, - Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, - No_best_common_type_exists_among_return_expressions: { code: 2354, category: DiagnosticCategory.Error, key: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: DiagnosticCategory.Error, key: "The operand of an increment or decrement operator must be a variable, property or indexer." }, - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: DiagnosticCategory.Error, key: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: DiagnosticCategory.Error, key: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: DiagnosticCategory.Error, key: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: DiagnosticCategory.Error, key: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: DiagnosticCategory.Error, key: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: DiagnosticCategory.Error, key: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: DiagnosticCategory.Error, key: "Invalid left-hand side of assignment expression." }, - Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: DiagnosticCategory.Error, key: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, - Type_parameter_name_cannot_be_0: { code: 2368, category: DiagnosticCategory.Error, key: "Type parameter name cannot be '{0}'" }, - A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: DiagnosticCategory.Error, key: "A parameter property is only allowed in a constructor implementation." }, - A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: DiagnosticCategory.Error, key: "A rest parameter must be of an array type." }, - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: DiagnosticCategory.Error, key: "A parameter initializer is only allowed in a function or constructor implementation." }, - Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: DiagnosticCategory.Error, key: "Parameter '{0}' cannot be referenced in its initializer." }, - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: DiagnosticCategory.Error, key: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, - Duplicate_string_index_signature: { code: 2374, category: DiagnosticCategory.Error, key: "Duplicate string index signature." }, - Duplicate_number_index_signature: { code: 2375, category: DiagnosticCategory.Error, key: "Duplicate number index signature." }, - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: DiagnosticCategory.Error, key: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, - Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: DiagnosticCategory.Error, key: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: DiagnosticCategory.Error, key: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, - Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: DiagnosticCategory.Error, key: "Getter and setter accessors do not agree in visibility." }, - get_and_set_accessor_must_have_the_same_type: { code: 2380, category: DiagnosticCategory.Error, key: "'get' and 'set' accessor must have the same type." }, - A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: DiagnosticCategory.Error, key: "A signature with an implementation cannot use a string literal type." }, - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: DiagnosticCategory.Error, key: "Specialized overload signature is not assignable to any non-specialized signature." }, - Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: DiagnosticCategory.Error, key: "Overload signatures must all be exported or not exported." }, - Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: DiagnosticCategory.Error, key: "Overload signatures must all be ambient or non-ambient." }, - Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: DiagnosticCategory.Error, key: "Overload signatures must all be public, private or protected." }, - Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: DiagnosticCategory.Error, key: "Overload signatures must all be optional or required." }, - Function_overload_must_be_static: { code: 2387, category: DiagnosticCategory.Error, key: "Function overload must be static." }, - Function_overload_must_not_be_static: { code: 2388, category: DiagnosticCategory.Error, key: "Function overload must not be static." }, - Function_implementation_name_must_be_0: { code: 2389, category: DiagnosticCategory.Error, key: "Function implementation name must be '{0}'." }, - Constructor_implementation_is_missing: { code: 2390, category: DiagnosticCategory.Error, key: "Constructor implementation is missing." }, - Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: DiagnosticCategory.Error, key: "Function implementation is missing or not immediately following the declaration." }, - Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." }, - Duplicate_function_implementation: { code: 2393, category: DiagnosticCategory.Error, key: "Duplicate function implementation." }, - Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: DiagnosticCategory.Error, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: DiagnosticCategory.Error, key: "Individual declarations in merged declaration '{0}' must be all exported or all local." }, - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: DiagnosticCategory.Error, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: DiagnosticCategory.Error, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: DiagnosticCategory.Error, key: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: DiagnosticCategory.Error, key: "Expression resolves to '_super' that compiler uses to capture base class reference." }, - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: DiagnosticCategory.Error, key: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, - The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, - The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, - Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...in' statement." }, - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: DiagnosticCategory.Error, key: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, - Setters_cannot_return_a_value: { code: 2408, category: DiagnosticCategory.Error, key: "Setters cannot return a value." }, - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: DiagnosticCategory.Error, key: "Return type of constructor signature must be assignable to the instance type of the class" }, - All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: DiagnosticCategory.Error, key: "All symbols within a 'with' block will be resolved to 'any'." }, - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: DiagnosticCategory.Error, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, - Class_name_cannot_be_0: { code: 2414, category: DiagnosticCategory.Error, key: "Class name cannot be '{0}'" }, - Class_0_incorrectly_extends_base_class_1: { code: 2415, category: DiagnosticCategory.Error, key: "Class '{0}' incorrectly extends base class '{1}'." }, - Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: DiagnosticCategory.Error, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, - Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: DiagnosticCategory.Error, key: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, - Class_0_incorrectly_implements_interface_1: { code: 2420, category: DiagnosticCategory.Error, key: "Class '{0}' incorrectly implements interface '{1}'." }, - A_class_may_only_implement_another_class_or_interface: { code: 2422, category: DiagnosticCategory.Error, key: "A class may only implement another class or interface." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: DiagnosticCategory.Error, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: DiagnosticCategory.Error, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: DiagnosticCategory.Error, key: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: DiagnosticCategory.Error, key: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, - Interface_name_cannot_be_0: { code: 2427, category: DiagnosticCategory.Error, key: "Interface name cannot be '{0}'" }, - All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: DiagnosticCategory.Error, key: "All declarations of an interface must have identical type parameters." }, - Interface_0_incorrectly_extends_interface_1: { code: 2430, category: DiagnosticCategory.Error, key: "Interface '{0}' incorrectly extends interface '{1}'." }, - Enum_name_cannot_be_0: { code: 2431, category: DiagnosticCategory.Error, key: "Enum name cannot be '{0}'" }, - In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: DiagnosticCategory.Error, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: DiagnosticCategory.Error, key: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: DiagnosticCategory.Error, key: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_modules_cannot_be_nested_in_other_modules: { code: 2435, category: DiagnosticCategory.Error, key: "Ambient modules cannot be nested in other modules." }, - Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: DiagnosticCategory.Error, key: "Ambient module declaration cannot specify relative module name." }, - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" }, - Import_name_cannot_be_0: { code: 2438, category: DiagnosticCategory.Error, key: "Import name cannot be '{0}'" }, - Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: DiagnosticCategory.Error, key: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, - Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" }, - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, - Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: DiagnosticCategory.Error, key: "Types have separate declarations of a private property '{0}'." }, - Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: DiagnosticCategory.Error, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, - Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: DiagnosticCategory.Error, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, - Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, - The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: DiagnosticCategory.Error, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, - Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: DiagnosticCategory.Error, key: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: DiagnosticCategory.Error, key: "The operand of an increment or decrement operator cannot be a constant." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: DiagnosticCategory.Error, key: "Left-hand side of assignment expression cannot be a constant." }, - Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: DiagnosticCategory.Error, key: "Cannot redeclare block-scoped variable '{0}'." }, - An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: DiagnosticCategory.Error, key: "An enum member cannot have a numeric name." }, - The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: DiagnosticCategory.Error, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, - Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: DiagnosticCategory.Error, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, - Type_alias_0_circularly_references_itself: { code: 2456, category: DiagnosticCategory.Error, key: "Type alias '{0}' circularly references itself." }, - Type_alias_name_cannot_be_0: { code: 2457, category: DiagnosticCategory.Error, key: "Type alias name cannot be '{0}'" }, - An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: DiagnosticCategory.Error, key: "An AMD module cannot have multiple name assignments." }, - Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}' and no string index signature." }, - Type_0_has_no_property_1: { code: 2460, category: DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}'." }, - Type_0_is_not_an_array_type: { code: 2461, category: DiagnosticCategory.Error, key: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: DiagnosticCategory.Error, key: "A rest element must be last in an array destructuring pattern" }, - A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: DiagnosticCategory.Error, key: "A binding pattern parameter cannot be optional in an implementation signature." }, - A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: DiagnosticCategory.Error, key: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, - this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in a computed property name." }, - super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: DiagnosticCategory.Error, key: "'super' cannot be referenced in a computed property name." }, - A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: DiagnosticCategory.Error, key: "A computed property name cannot reference a type parameter from its containing type." }, - Cannot_find_global_value_0: { code: 2468, category: DiagnosticCategory.Error, key: "Cannot find global value '{0}'." }, - The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: DiagnosticCategory.Error, key: "The '{0}' operator cannot be applied to type 'symbol'." }, - Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: DiagnosticCategory.Error, key: "'Symbol' reference does not refer to the global Symbol constructor object." }, - A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: DiagnosticCategory.Error, key: "A computed property name of the form '{0}' must be of type 'symbol'." }, - Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { code: 2472, category: DiagnosticCategory.Error, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher." }, - Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." }, - In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression." }, - const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, - A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: DiagnosticCategory.Error, key: "A const enum member can only be accessed using a string literal." }, - const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." }, - const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, - Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." }, - let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, - Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, - The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, - Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: DiagnosticCategory.Error, key: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." }, - Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." }, - Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, - An_iterator_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "An iterator must have a 'next()' method." }, - The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, - Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" }, - Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: DiagnosticCategory.Error, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, - Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, - Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." }, - The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { code: 2496, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression." }, - Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: DiagnosticCategory.Error, key: "Module '{0}' resolves to a non-module entity and cannot be imported using this construct." }, - Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: DiagnosticCategory.Error, key: "Module '{0}' uses 'export =' and cannot be used with 'export *'." }, - An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." }, - A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." }, - A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." }, - _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own type annotation." }, - Cannot_find_namespace_0: { code: 2503, category: DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." }, - No_best_common_type_exists_among_yield_expressions: { code: 2504, category: DiagnosticCategory.Error, key: "No best common type exists among yield expressions." }, - A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." }, - _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own base expression." }, - Type_0_is_not_a_constructor_function_type: { code: 2507, category: DiagnosticCategory.Error, key: "Type '{0}' is not a constructor function type." }, - No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, - Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, - Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, - Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, - Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: DiagnosticCategory.Error, key: "Overload signatures must all be abstract or not abstract." }, - Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, - Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, - Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, - All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, - Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: DiagnosticCategory.Error, key: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, - Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2518, category: DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." }, - Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, - Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, - The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, - yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." }, - await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." }, - JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, - The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, - JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, - Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: DiagnosticCategory.Error, key: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, - JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: DiagnosticCategory.Error, key: "JSX element type '{0}' does not have any construct or call signatures." }, - JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: DiagnosticCategory.Error, key: "JSX element type '{0}' is not a constructor function for JSX elements." }, - Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: DiagnosticCategory.Error, key: "Property '{0}' of JSX spread attribute is not assignable to target property." }, - JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, - The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, - Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, - A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." }, - Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, - Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, - Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, - Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, - Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: DiagnosticCategory.Error, key: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: DiagnosticCategory.Error, key: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: DiagnosticCategory.Error, key: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, - Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, - Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, - Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using private name '{1}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using private name '{1}'." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using private name '{1}'." }, - Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, - Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using private name '{0}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using private name '{0}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using private name '{0}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using private name '{0}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using private name '{0}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using private name '{0}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using private name '{0}'." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, - Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: DiagnosticCategory.Error, key: "Return type of exported function has or is using private name '{0}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using private name '{1}'." }, - Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using private name '{1}'." }, - Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: DiagnosticCategory.Error, key: "Default export of the module has or is using private name '{0}'." }, - Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher: { code: 4091, category: DiagnosticCategory.Error, key: "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher." }, - The_current_host_does_not_support_the_0_option: { code: 5001, category: DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." }, - Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, - Cannot_read_file_0_Colon_1: { code: 5012, category: DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, - Unsupported_file_encoding: { code: 5013, category: DiagnosticCategory.Error, key: "Unsupported file encoding." }, - Failed_to_parse_file_0_Colon_1: { code: 5014, category: DiagnosticCategory.Error, key: "Failed to parse file '{0}': {1}." }, - Unknown_compiler_option_0: { code: 5023, category: DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." }, - Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." }, - Could_not_write_file_0_Colon_1: { code: 5033, category: DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option." }, - Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." }, - Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." }, - Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." }, - Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." }, - Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." }, - Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." }, - Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, - Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, - Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, - Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, - Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, - Concatenate_and_emit_output_to_single_file: { code: 6001, category: DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, - Generates_corresponding_d_ts_file: { code: 6002, category: DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, - Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, - Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, - Watch_input_files: { code: 6005, category: DiagnosticCategory.Message, key: "Watch input files." }, - Redirect_output_structure_to_the_directory: { code: 6006, category: DiagnosticCategory.Message, key: "Redirect output structure to the directory." }, - Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: DiagnosticCategory.Message, key: "Do not erase const enum declarations in generated code." }, - Do_not_emit_outputs_if_any_errors_were_reported: { code: 6008, category: DiagnosticCategory.Message, key: "Do not emit outputs if any errors were reported." }, - Do_not_emit_comments_to_output: { code: 6009, category: DiagnosticCategory.Message, key: "Do not emit comments to output." }, - Do_not_emit_outputs: { code: 6010, category: DiagnosticCategory.Message, key: "Do not emit outputs." }, - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_amd_system_or_umd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'" }, - Print_this_message: { code: 6017, category: DiagnosticCategory.Message, key: "Print this message." }, - Print_the_compiler_s_version: { code: 6019, category: DiagnosticCategory.Message, key: "Print the compiler's version." }, - Compile_the_project_in_the_given_directory: { code: 6020, category: DiagnosticCategory.Message, key: "Compile the project in the given directory." }, - Syntax_Colon_0: { code: 6023, category: DiagnosticCategory.Message, key: "Syntax: {0}" }, - options: { code: 6024, category: DiagnosticCategory.Message, key: "options" }, - file: { code: 6025, category: DiagnosticCategory.Message, key: "file" }, - Examples_Colon_0: { code: 6026, category: DiagnosticCategory.Message, key: "Examples: {0}" }, - Options_Colon: { code: 6027, category: DiagnosticCategory.Message, key: "Options:" }, - Version_0: { code: 6029, category: DiagnosticCategory.Message, key: "Version {0}" }, - Insert_command_line_options_and_files_from_a_file: { code: 6030, category: DiagnosticCategory.Message, key: "Insert command line options and files from a file." }, - File_change_detected_Starting_incremental_compilation: { code: 6032, category: DiagnosticCategory.Message, key: "File change detected. Starting incremental compilation..." }, - KIND: { code: 6034, category: DiagnosticCategory.Message, key: "KIND" }, - FILE: { code: 6035, category: DiagnosticCategory.Message, key: "FILE" }, - VERSION: { code: 6036, category: DiagnosticCategory.Message, key: "VERSION" }, - LOCATION: { code: 6037, category: DiagnosticCategory.Message, key: "LOCATION" }, - DIRECTORY: { code: 6038, category: DiagnosticCategory.Message, key: "DIRECTORY" }, - Compilation_complete_Watching_for_file_changes: { code: 6042, category: DiagnosticCategory.Message, key: "Compilation complete. Watching for file changes." }, - Generates_corresponding_map_file: { code: 6043, category: DiagnosticCategory.Message, key: "Generates corresponding '.map' file." }, - Compiler_option_0_expects_an_argument: { code: 6044, category: DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." }, - Unterminated_quoted_string_in_response_file_0: { code: 6045, category: DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_amd_system_or_umd: { code: 6046, category: DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'." }, - Argument_for_target_option_must_be_ES3_ES5_or_ES6: { code: 6047, category: DiagnosticCategory.Error, key: "Argument for '--target' option must be 'ES3', 'ES5', or 'ES6'." }, - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: DiagnosticCategory.Error, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, - Unsupported_locale_0: { code: 6049, category: DiagnosticCategory.Error, key: "Unsupported locale '{0}'." }, - Unable_to_open_file_0: { code: 6050, category: DiagnosticCategory.Error, key: "Unable to open file '{0}'." }, - Corrupted_locale_file_0: { code: 6051, category: DiagnosticCategory.Error, key: "Corrupted locale file {0}." }, - Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: DiagnosticCategory.Message, key: "Raise error on expressions and declarations with an implied 'any' type." }, - File_0_not_found: { code: 6053, category: DiagnosticCategory.Error, key: "File '{0}' not found." }, - File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, - Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, - Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, - Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, - File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, - Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, - NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" }, - Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, - Specify_diagnostic_printing_style_Colon_simple_default_or_pretty: { code: 6063, category: DiagnosticCategory.Message, key: "Specify diagnostic printing style: 'simple' (default) or 'pretty'." }, - Argument_for_diagnosticStyle_must_be_simple_or_pretty: { code: 6064, category: DiagnosticCategory.Error, key: "Argument for '--diagnosticStyle' must be 'simple' or 'pretty'." }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, - Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, - Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, - Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, - Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, - Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." }, - Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." }, - Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, - Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, - Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, - new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: DiagnosticCategory.Error, key: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, - _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: DiagnosticCategory.Error, key: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: DiagnosticCategory.Error, key: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, - Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: DiagnosticCategory.Error, key: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: DiagnosticCategory.Error, key: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, - Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: DiagnosticCategory.Error, key: "Index signature of object type implicitly has an 'any' type." }, - Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: DiagnosticCategory.Error, key: "Object literal's property '{0}' implicitly has an '{1}' type." }, - Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, - Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer." }, - _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, - You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." }, - You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, - import_can_only_be_used_in_a_ts_file: { code: 8002, category: DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." }, - export_can_only_be_used_in_a_ts_file: { code: 8003, category: DiagnosticCategory.Error, key: "'export=' can only be used in a .ts file." }, - type_parameter_declarations_can_only_be_used_in_a_ts_file: { code: 8004, category: DiagnosticCategory.Error, key: "'type parameter declarations' can only be used in a .ts file." }, - implements_clauses_can_only_be_used_in_a_ts_file: { code: 8005, category: DiagnosticCategory.Error, key: "'implements clauses' can only be used in a .ts file." }, - interface_declarations_can_only_be_used_in_a_ts_file: { code: 8006, category: DiagnosticCategory.Error, key: "'interface declarations' can only be used in a .ts file." }, - module_declarations_can_only_be_used_in_a_ts_file: { code: 8007, category: DiagnosticCategory.Error, key: "'module declarations' can only be used in a .ts file." }, - type_aliases_can_only_be_used_in_a_ts_file: { code: 8008, category: DiagnosticCategory.Error, key: "'type aliases' can only be used in a .ts file." }, - _0_can_only_be_used_in_a_ts_file: { code: 8009, category: DiagnosticCategory.Error, key: "'{0}' can only be used in a .ts file." }, - types_can_only_be_used_in_a_ts_file: { code: 8010, category: DiagnosticCategory.Error, key: "'types' can only be used in a .ts file." }, - type_arguments_can_only_be_used_in_a_ts_file: { code: 8011, category: DiagnosticCategory.Error, key: "'type arguments' can only be used in a .ts file." }, - parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: DiagnosticCategory.Error, key: "'parameter modifiers' can only be used in a .ts file." }, - property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." }, - enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." }, - type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, - Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, - class_expressions_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'class' expressions are not currently supported." }, - JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: DiagnosticCategory.Error, key: "JSX attributes must only be assigned a non-empty 'expression'." }, - JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, - Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, - JSX_attribute_expected: { code: 17003, category: DiagnosticCategory.Error, key: "JSX attribute expected." }, - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }, - }; -} \ No newline at end of file diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4a7280f5fda..03d890bffa1 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -161,7 +161,7 @@ }, "Type '{0}' is not a valid async function return type.": { "category": "Error", - "code": 1055 + "code": 1055 }, "Accessors are only available when targeting ECMAScript 5 and higher.": { "category": "Error", @@ -195,7 +195,7 @@ "category": "Error", "code": 1063 }, - "Ambient enum elements can only have integer literal initializers.": { + "In ambient enum declarations member initializer must be constant expression.": { "category": "Error", "code": 1066 }, @@ -549,7 +549,7 @@ }, "An implementation cannot be declared in ambient contexts.": { "category": "Error", - "code": 1184 + "code": 1183 }, "Modifiers cannot appear here.": { "category": "Error", @@ -619,22 +619,18 @@ "category": "Error", "code": 1200 }, - "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead.": { + "Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead.": { "category": "Error", "code": 1202 }, - "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.": { + "Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead.": { "category": "Error", "code": 1203 }, - "Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher.": { + "Cannot compile modules into 'es6' when targeting 'ES5' or lower.": { "category": "Error", "code": 1204 }, - "Decorators are only available when targeting ECMAScript 5 and higher.": { - "category": "Error", - "code": 1205 - }, "Decorators are not valid here.": { "category": "Error", "code": 1206 @@ -747,24 +743,6 @@ "category": "Error", "code": 1235 }, - "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning.": { - "category": "Error", - "code": 1236 - }, - - - "'with' statements are not allowed in an async function block.": { - "category": "Error", - "code": 1300 - }, - "'await' expression is only allowed within an async function.": { - "category": "Error", - "code": 1308 - }, - "Async functions are only available when targeting ECMAScript 6 and higher.": { - "category": "Error", - "code": 1311 - }, "The return type of a property decorator function must be either 'void' or 'any'.": { "category": "Error", "code": 1236 @@ -805,6 +783,23 @@ "category": "Error", "code": 1245 }, + "Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning.": { + "category": "Error", + "code": 1246 + }, + + "'with' statements are not allowed in an async function block.": { + "category": "Error", + "code": 1300 + }, + "'await' expression is only allowed within an async function.": { + "category": "Error", + "code": 1308 + }, + "Async functions are only available when targeting ECMAScript 6 and higher.": { + "category": "Error", + "code": 1311 + }, "Duplicate identifier '{0}'.": { "category": "Error", "code": 2300 @@ -965,7 +960,7 @@ "category": "Error", "code": 2341 }, - "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.": { + "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.": { "category": "Error", "code": 2342 }, @@ -1301,7 +1296,7 @@ "category": "Error", "code": 2434 }, - "Ambient modules cannot be nested in other modules.": { + "Ambient modules cannot be nested in other modules or namespaces.": { "category": "Error", "code": 2435 }, @@ -1649,6 +1644,18 @@ "category": "Error", "code": 2524 }, + "Initializer provides no value for this binding element and the binding element has no default value.": { + "category": "Error", + "code": 2525 + }, + "A 'this' type is available only in a non-static member of a class or interface.": { + "category": "Error", + "code": 2526 + }, + "The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary.": { + "category": "Error", + "code": 2527 + }, "JSX element attributes type '{0}' must be an object type.": { "category": "Error", "code": 2600 @@ -1689,14 +1696,30 @@ "category": "Error", "code": 2650 }, - "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.": { + "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.": { "category": "Error", "code": 2651 - }, + }, "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead.": { "category": "Error", "code": 2652 }, + "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'.": { + "category": "Error", + "code": 2653 + }, + "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition.": { + "category": "Error", + "code": 2654 + }, + "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition.": { + "category": "Error", + "code": 2655 + }, + "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition.": { + "category": "Error", + "code": 2656 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 @@ -2013,58 +2036,30 @@ "category": "Error", "code": 5033 }, - "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option.": { - "category": "Error", - "code": 5038 - }, - "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option.": { - "category": "Error", - "code": 5039 - }, - "Option 'noEmit' cannot be specified with option 'out' or 'outDir'.": { - "category": "Error", - "code": 5040 - }, - "Option 'noEmit' cannot be specified with option 'declaration'.": { - "category": "Error", - "code": 5041 - }, "Option 'project' cannot be mixed with source files on a command line.": { "category": "Error", "code": 5042 }, - "Option 'declaration' cannot be specified with option 'isolatedModules'.": { - "category": "Error", - "code": 5044 - }, - "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'.": { - "category": "Error", - "code": 5045 - }, - "Option 'out' cannot be specified with option 'isolatedModules'.": { - "category": "Error", - "code": 5046 - }, "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher.": { "category": "Error", "code": 5047 }, - "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.": { - "category": "Error", - "code": 5048 - }, - "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'.": { - "category": "Error", - "code": 5049 - }, - "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'.": { - "category": "Error", - "code": 5050 - }, "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": { "category": "Error", "code": 5051 }, + "Option '{0}' cannot be specified without specifying option '{1}'.": { + "category": "Error", + "code": 5052 + }, + "Option '{0}' cannot be specified with option '{1}'.": { + "category": "Error", + "code": 5053 + }, + "A 'tsconfig.json' file is already defined at: '{0}'.": { + "category": "Error", + "code": 5054 + }, "Concatenate and emit output to single file.": { "category": "Message", @@ -2110,7 +2105,7 @@ "category": "Message", "code": 6015 }, - "Specify module code generation: 'commonjs', 'amd', 'system' or 'umd'": { + "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'": { "category": "Message", "code": 6016 }, @@ -2194,7 +2189,7 @@ "category": "Error", "code": 6045 }, - "Argument for '--module' option must be 'commonjs', 'amd', 'system' or 'umd'.": { + "Argument for '--module' option must be 'commonjs', 'amd', 'system', 'umd', or 'es6'.": { "category": "Error", "code": 6046 }, @@ -2258,13 +2253,9 @@ "category": "Error", "code": 6062 }, - "Specify diagnostic printing style: 'simple' (default) or 'pretty'.": { - "category": "Message", - "code": 6063 - }, - "Argument for '--diagnosticStyle' must be 'simple' or 'pretty'.": { + "Argument for '--moduleResolution' option must be 'node' or 'classic'.": { "category": "Error", - "code": 6064 + "code": 6063 }, "Specify JSX code generation: 'preserve' or 'react'": { @@ -2275,10 +2266,6 @@ "category": "Message", "code": 6081 }, - "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified.": { - "category": "Error", - "code": 6064 - }, "Enables experimental support for ES7 decorators.": { "category": "Message", "code": 6065 @@ -2295,6 +2282,30 @@ "category": "Message", "code": 6068 }, + "Specifies module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6).": { + "category": "Message", + "code": 6069 + }, + "Initializes a TypeScript project and creates a tsconfig.json file.": { + "category": "Message", + "code": 6070 + }, + "Successfully created a tsconfig.json file.": { + "category": "Message", + "code": 6071 + }, + "Suppress excess property checks for object literals.": { + "category": "Message", + "code": 6072 + }, + "Specify diagnostic printing style: 'simple' (default) or 'pretty'.": { + "category": "Message", + "code": 6073 + }, + "Argument for '--diagnosticStyle' must be 'simple' or 'pretty'.": { + "category": "Error", + "code": 6074 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a6e9b22ddee..71187b20960 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -7,6 +7,264 @@ namespace ts { return isExternalModule(sourceFile) || isDeclarationFile(sourceFile); } + type DependencyGroup = Array; + + let entities: Map = { + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; + // Flags enum to track count of temp variables and a few dedicated names const enum TempFlags { Auto = 0x00000000, // No preferred name @@ -27,12 +285,10 @@ var __extends = (this && this.__extends) || function (d, b) { // emit output for the __decorate helper function const decorateHelper = ` var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; };`; // emit output for the __metadata helper function @@ -64,6 +320,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let compilerOptions = host.getCompilerOptions(); let languageVersion = compilerOptions.target || ScriptTarget.ES3; + let modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None; let sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; let diagnostics: Diagnostic[] = []; let newLine = host.getNewLine(); @@ -78,18 +335,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } }); - if (compilerOptions.out) { - emitFile(compilerOptions.out); + if (compilerOptions.outFile || compilerOptions.out) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } else { // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); + let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } - else if (!isDeclarationFile(targetSourceFile) && compilerOptions.out) { - emitFile(compilerOptions.out); + else if (!isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) { + emitFile(compilerOptions.outFile || compilerOptions.out); } } @@ -124,11 +381,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitJavaScript(jsFilePath: string, root?: SourceFile) { let writer = createTextWriter(newLine); - let write = writer.write; - let writeTextOfNode = writer.writeTextOfNode; - let writeLine = writer.writeLine; - let increaseIndent = writer.increaseIndent; - let decreaseIndent = writer.decreaseIndent; + let { write, writeTextOfNode, writeLine, increaseIndent, decreaseIndent } = writer; let currentSourceFile: SourceFile; // name of an exporter function if file is a System external module @@ -190,6 +443,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi /** Sourcemap data that will get encoded */ let sourceMapData: SourceMapData; + /** If removeComments is true, no leading-comments needed to be emitted **/ + let emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos: number) { } : emitLeadingCommentsOfPositionWorker; + + let moduleEmitDelegates: Map<(node: SourceFile) => void> = { + [ModuleKind.ES6]: emitES6Module, + [ModuleKind.AMD]: emitAMDModule, + [ModuleKind.System]: emitSystemModule, + [ModuleKind.UMD]: emitUMDModule, + [ModuleKind.CommonJS]: emitCommonJSModule, + }; + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); } @@ -687,7 +951,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } } - + function emitNodeWithCommentsAndWithSourcemap(node: Node) { emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap); } @@ -1181,9 +1445,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitJsxElement(openingNode: JsxOpeningLikeElement, children?: JsxChild[]) { + let syntheticReactRef = createSynthesizedNode(SyntaxKind.Identifier); + syntheticReactRef.text = "React"; + syntheticReactRef.parent = openingNode; + // Call React.createElement(tag, ... emitLeadingComments(openingNode); - write("React.createElement("); + emitExpressionIdentifier(syntheticReactRef); + write(".createElement("); emitTagName(openingNode.tagName); write(", "); @@ -1197,7 +1466,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // a call to React.__spread let attrs = openingNode.attributes; if (forEach(attrs, attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) { - write("React.__spread("); + emitExpressionIdentifier(syntheticReactRef); + write(".__spread("); let haveOpenedObjectLiteral = false; for (let i = 0; i < attrs.length; i++) { @@ -1290,8 +1560,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function jsxEmitPreserve(node: JsxElement|JsxSelfClosingElement) { function emitJsxAttribute(node: JsxAttribute) { emit(node.name); - write("="); - emit(node.initializer); + if (node.initializer) { + write("="); + emit(node.initializer); + } } function emitJsxSpreadAttribute(node: JsxSpreadAttribute) { @@ -1378,7 +1650,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // // The emit for the decorated computed property decorator is: // - // Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); + // __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)); // if (nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { @@ -1418,6 +1690,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let parent = node.parent; switch (parent.kind) { case SyntaxKind.ArrayLiteralExpression: + case SyntaxKind.AsExpression: case SyntaxKind.BinaryExpression: case SyntaxKind.CallExpression: case SyntaxKind.CaseClause: @@ -1486,7 +1759,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (container) { if (container.kind === SyntaxKind.SourceFile) { // Identifier references module export - if (languageVersion < ScriptTarget.ES6 && compilerOptions.module !== ModuleKind.System) { + if (modulekind !== ModuleKind.ES6 && modulekind !== ModuleKind.System) { write("exports."); } } @@ -1496,7 +1769,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("."); } } - else if (languageVersion < ScriptTarget.ES6) { + else if (modulekind !== ModuleKind.ES6) { let declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { if (declaration.kind === SyntaxKind.ImportClause) { @@ -1508,8 +1781,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else if (declaration.kind === SyntaxKind.ImportSpecifier) { // Identifier references named import write(getGeneratedNameForNode(declaration.parent.parent.parent)); - write("."); - writeTextOfNode(currentSourceFile, (declaration).propertyName || (declaration).name); + let name = (declaration).propertyName || (declaration).name; + let identifier = getSourceTextOfNodeFromSourceFile(currentSourceFile, name); + if (languageVersion === ScriptTarget.ES3 && identifier === "default") { + write(`["default"]`); + } + else { + write("."); + write(identifier); + } return; } } @@ -1519,7 +1799,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return; } } - writeTextOfNode(currentSourceFile, node); + + if (nodeIsSynthesized(node)) { + write(node.text); + } + else { + writeTextOfNode(currentSourceFile, node); + } } function isNameOfNestedRedeclaration(node: Identifier) { @@ -1546,6 +1832,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else if (isNameOfNestedRedeclaration(node)) { write(getGeneratedNameForNode(node)); } + else if (nodeIsSynthesized(node)) { + write(node.text); + } else { writeTextOfNode(currentSourceFile, node); } @@ -2036,15 +2325,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } return false; } - + function tryGetConstEnumValue(node: Node): number { if (compilerOptions.isolatedModules) { return undefined; } - - return node.kind === SyntaxKind.PropertyAccessExpression || node.kind === SyntaxKind.ElementAccessExpression + + return node.kind === SyntaxKind.PropertyAccessExpression || node.kind === SyntaxKind.ElementAccessExpression ? resolver.getConstantValue(node) - : undefined + : undefined; } // Returns 'true' if the code was actually indented, false otherwise. @@ -2105,7 +2394,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } - + function emitQualifiedName(node: QualifiedName) { emit(node.left); write("."); @@ -2128,12 +2417,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else { emitEntityNameAsExpression(node.left, /*useFallback*/ false); } - + write("."); emit(node.right); } - - function emitEntityNameAsExpression(node: EntityName, useFallback: boolean) { + + function emitEntityNameAsExpression(node: EntityName, useFallback: boolean) { switch (node.kind) { case SyntaxKind.Identifier: if (useFallback) { @@ -2141,10 +2430,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitExpressionIdentifier(node); write(" !== 'undefined' && "); } - + emitExpressionIdentifier(node); break; - + case SyntaxKind.QualifiedName: emitQualifiedNameAsExpression(node, useFallback); break; @@ -2341,7 +2630,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi operand.kind !== SyntaxKind.PostfixUnaryExpression && operand.kind !== SyntaxKind.NewExpression && !(operand.kind === SyntaxKind.CallExpression && node.parent.kind === SyntaxKind.NewExpression) && - !(operand.kind === SyntaxKind.FunctionExpression && node.parent.kind === SyntaxKind.CallExpression)) { + !(operand.kind === SyntaxKind.FunctionExpression && node.parent.kind === SyntaxKind.CallExpression) && + !(operand.kind === SyntaxKind.NumericLiteral && node.parent.kind === SyntaxKind.PropertyAccessExpression)) { emit(operand); return; } @@ -3032,7 +3322,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(getGeneratedNameForNode(container)); write("."); } - else if (languageVersion < ScriptTarget.ES6 && compilerOptions.module !== ModuleKind.System) { + else if (modulekind !== ModuleKind.ES6 && modulekind !== ModuleKind.System) { write("exports."); } } @@ -3052,10 +3342,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (node.parent.kind === SyntaxKind.SourceFile) { Debug.assert(!!(node.flags & NodeFlags.Default) || node.kind === SyntaxKind.ExportAssignment); // only allow export default at a source file level - if (compilerOptions.module === ModuleKind.CommonJS || compilerOptions.module === ModuleKind.AMD || compilerOptions.module === ModuleKind.UMD) { + if (modulekind === ModuleKind.CommonJS || modulekind === ModuleKind.AMD || modulekind === ModuleKind.UMD) { if (!currentSourceFile.symbol.exports["___esModule"]) { if (languageVersion === ScriptTarget.ES5) { - // default value of configurable, enumerable, writable are `false`. + // default value of configurable, enumerable, writable are `false`. write("Object.defineProperty(exports, \"__esModule\", { value: true });"); writeLine(); } @@ -3074,7 +3364,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitStart(node); // emit call to exporter only for top level nodes - if (compilerOptions.module === ModuleKind.System && node.parent === currentSourceFile) { + if (modulekind === ModuleKind.System && node.parent === currentSourceFile) { // emit export default as // export("default", ) write(`${exportFunctionForFile}("`); @@ -3110,10 +3400,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitExportMemberAssignments(name: Identifier) { - if (compilerOptions.module === ModuleKind.System) { + if (modulekind === ModuleKind.System) { return; } - + if (!exportEquals && exportSpecifiers && hasProperty(exportSpecifiers, name.text)) { for (let specifier of exportSpecifiers[name.text]) { writeLine(); @@ -3128,10 +3418,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } } - + function emitExportSpecifierInSystemModule(specifier: ExportSpecifier): void { - Debug.assert(compilerOptions.module === ModuleKind.System); - + Debug.assert(modulekind === ModuleKind.System); + + if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier) ) { + return; + } + writeLine(); emitStart(specifier.name); write(`${exportFunctionForFile}("`); @@ -3199,22 +3493,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } - function ensureIdentifier(expr: Expression): Expression { - if (expr.kind !== SyntaxKind.Identifier) { - let identifier = createTempVariable(TempFlags.Auto); - if (!canDefineTempVariablesInPlace) { - recordTempDeclaration(identifier); - } - emitAssignment(identifier, expr); - expr = identifier; + /** + * Ensures that there exists a declared identifier whose value holds the given expression. + * This function is useful to ensure that the expression's value can be read from in subsequent expressions. + * Unless 'reuseIdentifierExpressions' is false, 'expr' will be returned if it is just an identifier. + * + * @param expr the expression whose value needs to be bound. + * @param reuseIdentifierExpressions true if identifier expressions can simply be returned; + * false if it is necessary to always emit an identifier. + */ + function ensureIdentifier(expr: Expression, reuseIdentifierExpressions: boolean): Expression { + if (expr.kind === SyntaxKind.Identifier && reuseIdentifierExpressions) { + return expr; } - return expr; + + let identifier = createTempVariable(TempFlags.Auto); + if (!canDefineTempVariablesInPlace) { + recordTempDeclaration(identifier); + } + emitAssignment(identifier, expr); + return identifier; } function createDefaultValueCheck(value: Expression, defaultValue: Expression): Expression { // The value expression will be evaluated twice, so for anything but a simple identifier // we need to generate a temporary variable - value = ensureIdentifier(value); + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); // Return the expression 'value === void 0 ? defaultValue : value' let equals = createSynthesizedNode(SyntaxKind.BinaryExpression); equals.left = value; @@ -3265,7 +3569,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (properties.length !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. - value = ensureIdentifier(value); + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); } for (let p of properties) { if (p.kind === SyntaxKind.PropertyAssignment || p.kind === SyntaxKind.ShorthandPropertyAssignment) { @@ -3280,7 +3584,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (elements.length !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. - value = ensureIdentifier(value); + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); } for (let i = 0; i < elements.length; i++) { let e = elements[i]; @@ -3325,7 +3629,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (root.parent.kind !== SyntaxKind.ParenthesizedExpression) { write("("); } - value = ensureIdentifier(value); + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); emitDestructuringAssignment(target, value); write(", "); emit(value); @@ -3335,7 +3639,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } - function emitBindingElement(target: BindingElement, value: Expression) { + function emitBindingElement(target: BindingElement | VariableDeclaration, value: Expression) { if (target.initializer) { // Combine value and initializer value = value ? createDefaultValueCheck(value, target.initializer) : target.initializer; @@ -3345,14 +3649,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi value = createVoidZero(); } if (isBindingPattern(target.name)) { - let pattern = target.name; - let elements = pattern.elements; - if (elements.length !== 1) { - // For anything but a single element destructuring we need to generate a temporary - // to ensure value is evaluated exactly once. - value = ensureIdentifier(value); + const pattern = target.name; + const elements = pattern.elements; + const numElements = elements.length; + + if (numElements !== 1) { + // For anything other than a single-element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. Additionally, if we have zero elements + // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, + // so in that case, we'll intentionally create that temporary. + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0); } - for (let i = 0; i < elements.length; i++) { + + for (let i = 0; i < numElements; i++) { let element = elements[i]; if (pattern.kind === SyntaxKind.ObjectBindingPattern) { // Rewrite element to a declaration with an initializer that fetches property @@ -3364,7 +3673,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } - else if (i === elements.length - 1) { + else if (i === numElements - 1) { emitBindingElement(element, createSliceCall(value, i)); } } @@ -3448,7 +3757,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function isES6ExportedDeclaration(node: Node) { return !!(node.flags & NodeFlags.Export) && - languageVersion >= ScriptTarget.ES6 && + modulekind === ModuleKind.ES6 && node.parent.kind === SyntaxKind.SourceFile; } @@ -3655,7 +3964,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitFunctionDeclaration(node: FunctionLikeDeclaration) { if (nodeIsMissing(node.body)) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } // TODO (yuisu) : we should not have special cases to condition emitting comments @@ -4132,7 +4441,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } else if (member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) { if (!(member).body) { - return emitOnlyPinnedOrTripleSlashComments(member); + return emitCommentsOnNotEmittedNode(member); } writeLine(); @@ -4199,7 +4508,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitMemberFunctionsForES6AndHigher(node: ClassLikeDeclaration) { for (let member of node.members) { if ((member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) && !(member).body) { - emitOnlyPinnedOrTripleSlashComments(member); + emitCommentsOnNotEmittedNode(member); } else if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.GetAccessor || @@ -4256,7 +4565,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // Emit the constructor overload pinned comments forEach(node.members, member => { if (member.kind === SyntaxKind.Constructor && !(member).body) { - emitOnlyPinnedOrTripleSlashComments(member); + emitCommentsOnNotEmittedNode(member); } // Check if there is any non-static property assignment if (member.kind === SyntaxKind.PropertyDeclaration && (member).initializer && (member.flags & NodeFlags.Static) === 0) { @@ -4311,7 +4620,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (ctor) { // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). - startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); + startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); emitDetachedComments(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); @@ -4396,7 +4705,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // // let C = class { // }; - // Object.defineProperty(C, "name", { value: "C", configurable: true }); // C = __decorate([dec], C); // // * For an exported class declaration: @@ -4408,7 +4716,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // // export let C = class { // }; - // Object.defineProperty(C, "name", { value: "C", configurable: true }); // C = __decorate([dec], C); // // * For a default export of a class declaration with a name: @@ -4420,7 +4727,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // // let C = class { // } - // Object.defineProperty(C, "name", { value: "C", configurable: true }); // C = __decorate([dec], C); // export default C; // @@ -4477,8 +4783,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("class"); - // check if this is an "export default class" as it may not have a name. Do not emit the name if the class is decorated. - if ((node.name || !(node.flags & NodeFlags.Default)) && !thisNodeIsDecorated) { + // emit name if + // - node has a name + // - this is default export and target is not ES6 (for ES6 `export default` does not need to be compiled downlevel) + if ((node.name || (node.flags & NodeFlags.Default && languageVersion < ScriptTarget.ES6)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -4746,21 +5054,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // // The emit for a method is: // - // Object.defineProperty(C.prototype, "method", - // __decorate([ - // dec, - // __param(0, dec2), - // __metadata("design:type", Function), - // __metadata("design:paramtypes", [Object]), - // __metadata("design:returntype", void 0) - // ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + // __decorate([ + // dec, + // __param(0, dec2), + // __metadata("design:type", Function), + // __metadata("design:paramtypes", [Object]), + // __metadata("design:returntype", void 0) + // ], C.prototype, "method", undefined); // // The emit for an accessor is: // - // Object.defineProperty(C.prototype, "accessor", - // __decorate([ - // dec - // ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); + // __decorate([ + // dec + // ], C.prototype, "accessor", undefined); // // The emit for a property is: // @@ -4771,18 +5077,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi writeLine(); emitStart(member); - if (member.kind !== SyntaxKind.PropertyDeclaration) { - write("Object.defineProperty("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(","); - increaseIndent(); - writeLine(); - } - write("__decorate(["); increaseIndent(); writeLine(); @@ -4806,15 +5100,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== SyntaxKind.PropertyDeclaration) { - write(", Object.getOwnPropertyDescriptor("); - emitStart(member.name); - emitClassMemberPrefix(node, member); - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write("))"); - decreaseIndent(); + if (languageVersion > ScriptTarget.ES3) { + if (member.kind !== SyntaxKind.PropertyDeclaration) { + // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly. + // We have this extra argument here so that we can inject an explicit property descriptor at a later date. + write(", null"); + } + else { + // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it + // should not invoke `Object.getOwnPropertyDescriptor`. + write(", void 0"); + } } write(");"); @@ -4883,7 +5179,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } return false; } - + /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ function emitSerializedTypeOfNode(node: Node) { // serialization of the type of a declaration uses the following rules: @@ -4894,100 +5190,98 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. // * The serialized type of any other FunctionLikeDeclaration is "Function". // * The serialized type of any other node is "void 0". - // + // // For rules on serializing type annotations, see `serializeTypeNode`. switch (node.kind) { case SyntaxKind.ClassDeclaration: write("Function"); return; - - case SyntaxKind.PropertyDeclaration: + + case SyntaxKind.PropertyDeclaration: emitSerializedTypeNode((node).type); return; - - case SyntaxKind.Parameter: + + case SyntaxKind.Parameter: emitSerializedTypeNode((node).type); return; - - case SyntaxKind.GetAccessor: + + case SyntaxKind.GetAccessor: emitSerializedTypeNode((node).type); return; - - case SyntaxKind.SetAccessor: + + case SyntaxKind.SetAccessor: emitSerializedTypeNode(getSetAccessorTypeAnnotationNode(node)); return; - + } - + if (isFunctionLike(node)) { write("Function"); return; } - + write("void 0"); } - + function emitSerializedTypeNode(node: TypeNode) { - if (!node) { - return; + if (node) { + + switch (node.kind) { + case SyntaxKind.VoidKeyword: + write("void 0"); + return; + + case SyntaxKind.ParenthesizedType: + emitSerializedTypeNode((node).type); + return; + + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + write("Function"); + return; + + case SyntaxKind.ArrayType: + case SyntaxKind.TupleType: + write("Array"); + return; + + case SyntaxKind.TypePredicate: + case SyntaxKind.BooleanKeyword: + write("Boolean"); + return; + + case SyntaxKind.StringKeyword: + case SyntaxKind.StringLiteral: + write("String"); + return; + + case SyntaxKind.NumberKeyword: + write("Number"); + return; + + case SyntaxKind.SymbolKeyword: + write("Symbol"); + return; + + case SyntaxKind.TypeReference: + emitSerializedTypeReferenceNode(node); + return; + + case SyntaxKind.TypeQuery: + case SyntaxKind.TypeLiteral: + case SyntaxKind.UnionType: + case SyntaxKind.IntersectionType: + case SyntaxKind.AnyKeyword: + break; + + default: + Debug.fail("Cannot serialize unexpected type node."); + break; + } } - - switch (node.kind) { - case SyntaxKind.VoidKeyword: - write("void 0"); - return; - - case SyntaxKind.ParenthesizedType: - emitSerializedTypeNode((node).type); - return; - - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - write("Function"); - return; - - case SyntaxKind.ArrayType: - case SyntaxKind.TupleType: - write("Array"); - return; - - case SyntaxKind.TypePredicate: - case SyntaxKind.BooleanKeyword: - write("Boolean"); - return; - - case SyntaxKind.StringKeyword: - case SyntaxKind.StringLiteral: - write("String"); - return; - - case SyntaxKind.NumberKeyword: - write("Number"); - return; - - case SyntaxKind.SymbolKeyword: - write("Symbol"); - return; - - case SyntaxKind.TypeReference: - emitSerializedTypeReferenceNode(node); - return; - - case SyntaxKind.TypeQuery: - case SyntaxKind.TypeLiteral: - case SyntaxKind.UnionType: - case SyntaxKind.IntersectionType: - case SyntaxKind.AnyKeyword: - break; - - default: - Debug.fail("Cannot serialize unexpected type node."); - break; - } - write("Object"); } - + /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ function emitSerializedTypeReferenceNode(node: TypeReferenceNode) { let location: Node = node.parent; @@ -5015,27 +5309,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi case TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: emitEntityNameAsExpression(typeName, /*useFallback*/ false); break; - + case TypeReferenceSerializationKind.VoidType: write("void 0"); break; - + case TypeReferenceSerializationKind.BooleanType: write("Boolean"); break; - + case TypeReferenceSerializationKind.NumberLikeType: write("Number"); break; - + case TypeReferenceSerializationKind.StringLikeType: write("String"); break; - + case TypeReferenceSerializationKind.ArrayLikeType: write("Array"); break; - + case TypeReferenceSerializationKind.ESSymbolType: if (languageVersion < ScriptTarget.ES6) { write("typeof Symbol === 'function' ? Symbol : Object"); @@ -5044,24 +5338,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("Symbol"); } break; - + case TypeReferenceSerializationKind.TypeWithCallSignature: write("Function"); break; - + case TypeReferenceSerializationKind.ObjectType: write("Object"); break; } } - + /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ function emitSerializedParameterTypesOfNode(node: Node) { // serialization of parameter types uses the following rules: // // * If the declaration is a class, the parameters of the first constructor with a body are used. // * If the declaration is function-like and has a body, the parameters of the function are used. - // + // // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. if (node) { let valueDeclaration: FunctionLikeDeclaration; @@ -5071,7 +5365,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else if (isFunctionLike(node) && nodeIsPresent((node).body)) { valueDeclaration = node; } - + if (valueDeclaration) { const parameters = valueDeclaration.parameters; const parameterCount = parameters.length; @@ -5080,7 +5374,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (i > 0) { write(", "); } - + if (parameters[i].dotDotDotToken) { let parameterType = parameters[i].type; if (parameterType.kind === SyntaxKind.ArrayType) { @@ -5092,7 +5386,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else { parameterType = undefined; } - + emitSerializedTypeNode(parameterType); } else { @@ -5103,18 +5397,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } } - + /** Serializes the return type of function. Used by the __metadata decorator for a method. */ function emitSerializedReturnTypeOfNode(node: Node): string | string[] { if (node && isFunctionLike(node) && (node).type) { emitSerializedTypeNode((node).type); return; } - + write("void 0"); } - - + + function emitSerializedTypeMetadata(node: Declaration, writeComma: boolean): number { // This method emits the serialized type metadata for a decorator target. // The caller should have already tested whether the node has decorators. @@ -5131,7 +5425,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi argumentsWritten++; } if (shouldEmitParamTypesMetadata(node)) { - debugger; if (writeComma || argumentsWritten) { write(", "); } @@ -5145,7 +5438,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (writeComma || argumentsWritten) { write(", "); } - + writeLine(); write("__metadata('design:returntype', "); emitSerializedReturnTypeOfNode(node); @@ -5153,12 +5446,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi argumentsWritten++; } } - + return argumentsWritten; } - + function emitInterfaceDeclaration(node: InterfaceDeclaration) { - emitOnlyPinnedOrTripleSlashComments(node); + emitCommentsOnNotEmittedNode(node); } function shouldEmitEnumDeclaration(node: EnumDeclaration) { @@ -5217,7 +5510,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(";"); } if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile) { - if (compilerOptions.module === ModuleKind.System && (node.flags & NodeFlags.Export)) { + if (modulekind === ModuleKind.System && (node.flags & NodeFlags.Export)) { // write the call to exporter for enum writeLine(); write(`${exportFunctionForFile}("`); @@ -5280,7 +5573,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let shouldEmit = shouldEmitModuleDeclaration(node); if (!shouldEmit) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } let hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node); let emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node); @@ -5339,7 +5632,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === SyntaxKind.Identifier && node.parent === currentSourceFile) { - if (compilerOptions.module === ModuleKind.System && (node.flags & NodeFlags.Export)) { + if (modulekind === ModuleKind.System && (node.flags & NodeFlags.Export)) { writeLine(); write(`${exportFunctionForFile}("`); emitDeclarationName(node); @@ -5350,14 +5643,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitExportMemberAssignments(node.name); } } - + /* * Some bundlers (SystemJS builder) sometimes want to rename dependencies. * Here we check if alternative name was provided for a given moduleName and return it if possible. */ function tryRenameExternalModule(moduleName: LiteralExpression): string { if (currentSourceFile.renamedDependencies && hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) { - return `"${currentSourceFile.renamedDependencies[moduleName.text]}"` + return `"${currentSourceFile.renamedDependencies[moduleName.text]}"`; } return undefined; } @@ -5403,7 +5696,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitImportDeclaration(node: ImportDeclaration) { - if (languageVersion < ScriptTarget.ES6) { + if (modulekind !== ModuleKind.ES6) { return emitExternalImportDeclaration(node); } @@ -5454,7 +5747,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi let isExportedImport = node.kind === SyntaxKind.ImportEqualsDeclaration && (node.flags & NodeFlags.Export) !== 0; let namespaceDeclaration = getNamespaceDeclarationNode(node); - if (compilerOptions.module !== ModuleKind.AMD) { + if (modulekind !== ModuleKind.AMD) { emitLeadingComments(node); emitStart(node); if (namespaceDeclaration && !isDefaultImport(node)) { @@ -5522,18 +5815,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi (!isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) { emitLeadingComments(node); emitStart(node); - + // variable declaration for import-equals declaration can be hoisted in system modules // in this case 'var' should be omitted and emit should contain only initialization let variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true); - + // is it top level export import v = a.b.c in system module? // if yes - it needs to be rewritten as exporter('v', v = a.b.c) let isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true); - + if (!variableDeclarationIsHoisted) { Debug.assert(!isExported); - + if (isES6ExportedDeclaration(node)) { write("export "); write("var "); @@ -5542,8 +5835,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("var "); } } - - + + if (isExported) { write(`${exportFunctionForFile}("`); emitNodeWithoutSourceMap(node.name); @@ -5557,8 +5850,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (isExported) { write(")"); } - - write(";"); + + write(";"); emitEnd(node); emitExportImportAssignments(node); emitTrailingComments(node); @@ -5566,15 +5859,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitExportDeclaration(node: ExportDeclaration) { - Debug.assert(compilerOptions.module !== ModuleKind.System); + Debug.assert(modulekind !== ModuleKind.System); - if (languageVersion < ScriptTarget.ES6) { + if (modulekind !== ModuleKind.ES6) { if (node.moduleSpecifier && (!node.exportClause || resolver.isValueAliasDeclaration(node))) { emitStart(node); let generatedName = getGeneratedNameForNode(node); if (node.exportClause) { // export { x, y, ... } from "foo" - if (compilerOptions.module !== ModuleKind.AMD) { + if (modulekind !== ModuleKind.AMD) { write("var "); write(generatedName); write(" = "); @@ -5601,7 +5894,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // export * from "foo" writeLine(); write("__export("); - if (compilerOptions.module !== ModuleKind.AMD) { + if (modulekind !== ModuleKind.AMD) { emitRequire(getExternalModuleName(node)); } else { @@ -5634,7 +5927,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitExportOrImportSpecifierList(specifiers: ImportOrExportSpecifier[], shouldEmit: (node: Node) => boolean) { - Debug.assert(languageVersion >= ScriptTarget.ES6); + Debug.assert(modulekind === ModuleKind.ES6); let needsComma = false; for (let specifier of specifiers) { @@ -5654,7 +5947,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitExportAssignment(node: ExportAssignment) { if (!node.isExportEquals && resolver.isValueAliasDeclaration(node)) { - if (languageVersion >= ScriptTarget.ES6) { + if (modulekind === ModuleKind.ES6) { writeLine(); emitStart(node); write("export default "); @@ -5669,7 +5962,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else { writeLine(); emitStart(node); - if (compilerOptions.module === ModuleKind.System) { + if (modulekind === ModuleKind.System) { write(`${exportFunctionForFile}("default",`); emit(node.expression); write(")"); @@ -5679,7 +5972,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitContainingModuleName(node); if (languageVersion === ScriptTarget.ES3) { write("[\"default\"] = "); - } else { + } + else { write(".default = "); } emit(node.expression); @@ -5772,7 +6066,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function getExternalModuleNameText(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): string { let moduleName = getExternalModuleName(importNode); if (moduleName.kind === SyntaxKind.StringLiteral) { - return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); + return tryRenameExternalModule(moduleName) || getLiteralText(moduleName); } return undefined; @@ -6080,12 +6374,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } return; } - - if (isInternalModuleImportEqualsDeclaration(node)) { + + if (isInternalModuleImportEqualsDeclaration(node) && resolver.isValueAliasDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; } - + hoistedVars.push(node.name); return; } @@ -6115,7 +6409,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function isCurrentFileSystemExternalModule() { - return compilerOptions.module === ModuleKind.System && isExternalModule(currentSourceFile); + return modulekind === ModuleKind.System && isExternalModule(currentSourceFile); } function emitSystemModuleBody(node: SourceFile, dependencyGroups: DependencyGroup[], startIndex: number): void { @@ -6174,7 +6468,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitSetters(exportStarFunction: string, dependencyGroups: DependencyGroup[]) { write("setters:["); - + for (let i = 0; i < dependencyGroups.length; ++i) { if (i !== 0) { write(","); @@ -6182,17 +6476,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi writeLine(); increaseIndent(); - + let group = dependencyGroups[i]; - + // derive a unique name for parameter from the first named entry in the group let parameterName = makeUniqueName(forEach(group, getLocalNameForExternalImport) || ""); write(`function (${parameterName}) {`); increaseIndent(); - - for(let entry of group) { + + for (let entry of group) { let importVariableName = getLocalNameForExternalImport(entry) || ""; - + switch (entry.kind) { case SyntaxKind.ImportDeclaration: if (!(entry).importClause) { @@ -6228,7 +6522,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(","); writeLine(); } - + let e = (entry).exportClause.elements[i]; write(`"`); emitNodeWithCommentsAndWithoutSourcemap(e.name); @@ -6238,7 +6532,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } decreaseIndent(); writeLine(); - write("});") + write("});"); } else { writeLine(); @@ -6273,7 +6567,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // - import declarations are not emitted since they are already handled in setters // - export declarations with module specifiers are not emitted since they were already written in setters // - export declarations without module specifiers are emitted preserving the order - case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionDeclaration: case SyntaxKind.ImportDeclaration: continue; case SyntaxKind.ExportDeclaration: @@ -6293,16 +6587,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi default: writeLine(); emit(statement); - } + } } decreaseIndent(); writeLine(); write("}"); // execute } - - type DependencyGroup = Array; - - function emitSystemModule(node: SourceFile, startIndex: number): void { + + function emitSystemModule(node: SourceFile): void { collectExternalModuleInfo(node); // System modules has the following shape // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) @@ -6321,7 +6613,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(`"${node.moduleName}", `); } write("["); - + let groupIndices: Map = {}; let dependencyGroups: DependencyGroup[] = []; @@ -6341,12 +6633,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (i !== 0) { write(", "); } - + write(text); } write(`], function(${exportFunctionForFile}) {`); writeLine(); increaseIndent(); + let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitSystemModuleBody(node, dependencyGroups, startIndex); @@ -6355,19 +6648,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("});"); } - function emitAMDDependencies(node: SourceFile, includeNonAmdDependencies: boolean) { - // An AMD define function has the following shape: - // define(id?, dependencies?, factory); - // - // This has the shape of - // define(name, ["module1", "module2"], function (module1Alias) { - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // `import "module"` or `` - // we need to add modules without alias names to the end of the dependencies list + interface AMDDependencyNames { + aliasedModuleNames: string[]; + unaliasedModuleNames: string[]; + importAliasNames: string[]; + } + function getAMDDependencyNames(node: SourceFile, includeNonAmdDependencies: boolean): AMDDependencyNames { // names of modules with corresponding parameter in the factory function let aliasedModuleNames: string[] = []; // names of modules with no corresponding parameters in factory function @@ -6402,6 +6689,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } + return { aliasedModuleNames, unaliasedModuleNames, importAliasNames }; + } + + function emitAMDDependencies(node: SourceFile, includeNonAmdDependencies: boolean) { + // An AMD define function has the following shape: + // define(id?, dependencies?, factory); + // + // This has the shape of + // define(name, ["module1", "module2"], function (module1Alias) { + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // `import "module"` or `` + // we need to add modules without alias names to the end of the dependencies list + + let dependencyNames = getAMDDependencyNames(node, includeNonAmdDependencies); + emitAMDDependencyList(dependencyNames); + write(", "); + emitAMDFactoryHeader(dependencyNames); + } + + function emitAMDDependencyList({ aliasedModuleNames, unaliasedModuleNames }: AMDDependencyNames) { write("[\"require\", \"exports\""); if (aliasedModuleNames.length) { write(", "); @@ -6411,14 +6721,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write(", "); write(unaliasedModuleNames.join(", ")); } - write("], function (require, exports"); + write("]"); + } + + function emitAMDFactoryHeader({ importAliasNames }: AMDDependencyNames) { + write("function (require, exports"); if (importAliasNames.length) { write(", "); write(importAliasNames.join(", ")); } + write(") {"); } - function emitAMDModule(node: SourceFile, startIndex: number) { + function emitAMDModule(node: SourceFile) { emitEmitHelpers(node); collectExternalModuleInfo(node); @@ -6428,8 +6743,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("\"" + node.moduleName + "\", "); } emitAMDDependencies(node, /*includeNonAmdDependencies*/ true); - write(") {"); increaseIndent(); + let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -6440,7 +6755,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("});"); } - function emitCommonJSModule(node: SourceFile, startIndex: number) { + function emitCommonJSModule(node: SourceFile) { + let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); emitEmitHelpers(node); collectExternalModuleInfo(node); emitExportStarHelper(); @@ -6450,22 +6766,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitExportEquals(/*emitAsReturn*/ false); } - function emitUMDModule(node: SourceFile, startIndex: number) { + function emitUMDModule(node: SourceFile) { emitEmitHelpers(node); collectExternalModuleInfo(node); + let dependencyNames = getAMDDependencyNames(node, /*includeNonAmdDependencies*/ false); + // Module is detected first to support Browserify users that load into a browser with an AMD loader - writeLines(`(function (deps, factory) { + writeLines(`(function (factory) { if (typeof module === 'object' && typeof module.exports === 'object') { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === 'function' && define.amd) { - define(deps, factory); - } + define(`); + emitAMDDependencyList(dependencyNames); + write(", factory);"); + writeLines(` } })(`); - emitAMDDependencies(node, false); - write(") {"); + emitAMDFactoryHeader(dependencyNames); increaseIndent(); + let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true); emitExportStarHelper(); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -6476,11 +6796,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi write("});"); } - function emitES6Module(node: SourceFile, startIndex: number) { + function emitES6Module(node: SourceFile) { externalImports = undefined; exportSpecifiers = undefined; exportEquals = undefined; hasExportStars = false; + let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); emitEmitHelpers(node); emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); @@ -6513,9 +6834,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } - function trimReactWhitespace(node: JsxText): string { + function trimReactWhitespaceAndApplyEntities(node: JsxText): string { let result: string = undefined; - let text = getTextOfNode(node); + let text = getTextOfNode(node, /*includeTrivia*/ true); let firstNonWhitespace = 0; let lastNonWhitespace = -1; @@ -6538,19 +6859,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } } + if (firstNonWhitespace !== -1) { let part = text.substr(firstNonWhitespace); result = (result ? result + "\" + ' ' + \"" : "") + part; } + if (result) { + // Replace entities like   + result = result.replace(/&(\w+);/g, function(s: any, m: string) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); + } + return result; } function getTextToEmit(node: JsxText) { switch (compilerOptions.jsx) { case JsxEmit.React: - let text = trimReactWhitespace(node); - if (text.length === 0) { + let text = trimReactWhitespaceAndApplyEntities(node); + if (text === undefined || text.length === 0) { return undefined; } else { @@ -6558,7 +6892,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } case JsxEmit.Preserve: default: - return getTextOfNode(node, true); + return getTextOfNode(node, /*includeTrivia*/ true); } } @@ -6566,13 +6900,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi switch (compilerOptions.jsx) { case JsxEmit.React: write("\""); - write(trimReactWhitespace(node)); + write(trimReactWhitespaceAndApplyEntities(node)); write("\""); break; case JsxEmit.Preserve: default: // Emit JSX-preserve as default when no --jsx flag is specified - writer.writeLiteral(getTextOfNode(node, true)); + writer.writeLiteral(getTextOfNode(node, /*includeTrivia*/ true)); break; } } @@ -6656,27 +6990,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emitShebang(); emitDetachedComments(node); - // emit prologue directives prior to __extends - let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); - if (isExternalModule(node) || compilerOptions.isolatedModules) { - if (languageVersion >= ScriptTarget.ES6) { - emitES6Module(node, startIndex); - } - else if (compilerOptions.module === ModuleKind.AMD) { - emitAMDModule(node, startIndex); - } - else if (compilerOptions.module === ModuleKind.System) { - emitSystemModule(node, startIndex); - } - else if (compilerOptions.module === ModuleKind.UMD) { - emitUMDModule(node, startIndex); - } - else { - emitCommonJSModule(node, startIndex); - } + let emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[ModuleKind.CommonJS]; + emitModule(node); } else { + // emit prologue directives prior to __extends + let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); externalImports = undefined; exportSpecifiers = undefined; exportEquals = undefined; @@ -6697,7 +7017,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitNodeConsideringCommentsOption(node: Node, emitNodeConsideringSourcemap: (node: Node) => void): void { if (node) { if (node.flags & NodeFlags.Ambient) { - return emitOnlyPinnedOrTripleSlashComments(node); + return emitCommentsOnNotEmittedNode(node); } if (isSpecializedCommentHandling(node)) { @@ -6964,22 +7284,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi return leadingComments; } - /** - * Removes all but the pinned or triple slash comments. - * @param ranges The array to be filtered - * @param onlyPinnedOrTripleSlashComments whether the filtering should be performed. - */ - function filterComments(ranges: CommentRange[], onlyPinnedOrTripleSlashComments: boolean): CommentRange[] { - // If we're removing comments, then we want to strip out all but the pinned or - // triple slash comments. - if (ranges && onlyPinnedOrTripleSlashComments) { - ranges = filter(ranges, isPinnedOrTripleSlashComment); - if (ranges.length === 0) { - return undefined; - } - } + function isPinnedComments(comment: CommentRange) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk && + currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation; + } - return ranges; + /** + * Determine if the given comment is a triple-slash + * + * @return true if the comment is a triple-slash comment else false + **/ + function isTripleSlashComment(comment: CommentRange) { + // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text + // so that we don't end up computing comment string and doing match for all // comments + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash && + comment.pos + 2 < comment.end && + currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.slash) { + let textSubStr = currentSourceFile.text.substring(comment.pos, comment.end); + return textSubStr.match(fullTripleSlashReferencePathRegEx) || + textSubStr.match(fullTripleSlashAMDReferencePathRegEx) ? + true : false; + } + return false; } function getLeadingCommentsToEmit(node: Node) { @@ -7007,28 +7333,53 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } - function emitOnlyPinnedOrTripleSlashComments(node: Node) { - emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ true); + /** + * Emit comments associated with node that will not be emitted into JS file + */ + function emitCommentsOnNotEmittedNode(node: Node) { + emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false); } function emitLeadingComments(node: Node) { - return emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); + return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true); } - function emitLeadingCommentsWorker(node: Node, onlyPinnedOrTripleSlashComments: boolean) { - // If the caller only wants pinned or triple slash comments, then always filter - // down to that set. Otherwise, filter based on the current compiler options. - let leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments); + function emitLeadingCommentsWorker(node: Node, isEmittedNode: boolean) { + if (compilerOptions.removeComments) { + return; + } + + let leadingComments: CommentRange[]; + if (isEmittedNode) { + leadingComments = getLeadingCommentsToEmit(node); + } + else { + // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node, + // unless it is a triple slash comment at the top of the file. + // For Example: + // /// + // declare var x; + // /// + // interface F {} + // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted + if (node.pos === 0) { + leadingComments = filter(getLeadingCommentsToEmit(node), isTripleSlashComment); + } + } emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); + emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment); } function emitTrailingComments(node: Node) { + if (compilerOptions.removeComments) { + return; + } + // Emit the trailing comments only if the parent's end doesn't match - let trailingComments = filterComments(getTrailingCommentsToEmit(node), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); + let trailingComments = getTrailingCommentsToEmit(node); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment); @@ -7040,13 +7391,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi * ^ => pos; the function will emit "comment1" in the emitJS */ function emitTrailingCommentsOfPosition(pos: number) { - let trailingComments = filterComments(getTrailingCommentRanges(currentSourceFile.text, pos), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments); + if (compilerOptions.removeComments) { + return; + } + + let trailingComments = getTrailingCommentRanges(currentSourceFile.text, pos); // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/ emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); } - function emitLeadingCommentsOfPosition(pos: number) { + function emitLeadingCommentsOfPositionWorker(pos: number) { + if (compilerOptions.removeComments) { + return; + } + let leadingComments: CommentRange[]; if (hasDetachedComments(pos)) { // get comments without detached comments @@ -7057,7 +7416,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi leadingComments = getLeadingCommentRanges(currentSourceFile.text, pos); } - leadingComments = filterComments(leadingComments, compilerOptions.removeComments); emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space @@ -7065,7 +7423,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitDetachedComments(node: TextRange) { - let leadingComments = getLeadingCommentRanges(currentSourceFile.text, node.pos); + let leadingComments: CommentRange[]; + if (compilerOptions.removeComments) { + // removeComments is true, only reserve pinned comment at the top of file + // For example: + // /*! Pinned Comment */ + // + // var x = 10; + if (node.pos === 0) { + leadingComments = filter(getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + } + } + else { + // removeComments is false, just get detached as normal and bypass the process to filter comment + leadingComments = getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { let detachedComments: CommentRange[] = []; let lastComment: CommentRange; @@ -7108,27 +7481,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } } - + function emitShebang() { let shebang = getShebang(currentSourceFile.text); if (shebang) { write(shebang); } } - - function isPinnedOrTripleSlashComment(comment: CommentRange) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation; - } - // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text - // so that we don't end up computing comment string and doing match for all // comments - else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash && - comment.pos + 2 < comment.end && - currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.slash && - currentSourceFile.text.substring(comment.pos, comment.end).match(fullTripleSlashReferencePathRegEx)) { - return true; - } - } } function emitFile(jsFilePath: string, sourceFile?: SourceFile) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index def08e81758..dcdaec98318 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -425,7 +425,7 @@ namespace ts { // Implement the parser as a singleton module. We do this for perf reasons because creating // parser instances can actually be expensive enough to impact us on projects with many source // files. - module Parser { + namespace Parser { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. const scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true); @@ -518,7 +518,7 @@ namespace ts { // // Note: any errors at the end of the file that do not precede a regular node, should get // attached to the EOF token. - let parseErrorBeforeNextFinishedNode: boolean = false; + let parseErrorBeforeNextFinishedNode = false; export function parseSourceFile(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean): SourceFile { initializeState(fileName, _sourceText, languageVersion, _syntaxCursor); @@ -856,7 +856,7 @@ namespace ts { let saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; // Note: it is not actually necessary to save/restore the context flags here. That's - // because the saving/restorating of these flags happens naturally through the recursive + // because the saving/restoring of these flags happens naturally through the recursive // descent nature of our parser. However, we still store this here just so we can // assert that that invariant holds. let saveContextFlags = contextFlags; @@ -1058,11 +1058,11 @@ namespace ts { } function parseIdentifierName(): Identifier { - return createIdentifier(isIdentifierOrKeyword()); + return createIdentifier(tokenIsIdentifierOrKeyword(token)); } function isLiteralPropertyName(): boolean { - return isIdentifierOrKeyword() || + return tokenIsIdentifierOrKeyword(token) || token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral; } @@ -1086,7 +1086,7 @@ namespace ts { } function isSimplePropertyName() { - return token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral || isIdentifierOrKeyword(); + return token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral || tokenIsIdentifierOrKeyword(token); } function parseComputedPropertyName(): ComputedPropertyName { @@ -1124,7 +1124,15 @@ namespace ts { if (token === SyntaxKind.DefaultKeyword) { return nextTokenIsClassOrFunction(); } + if (token === SyntaxKind.StaticKeyword) { + nextToken(); + return canFollowModifier(); + } + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return false; + } return canFollowModifier(); } @@ -1213,9 +1221,9 @@ namespace ts { case ParsingContext.HeritageClauses: return isHeritageClause(); case ParsingContext.ImportOrExportSpecifiers: - return isIdentifierOrKeyword(); + return tokenIsIdentifierOrKeyword(token); case ParsingContext.JsxAttributes: - return isIdentifierOrKeyword() || token === SyntaxKind.OpenBraceToken; + return tokenIsIdentifierOrKeyword(token) || token === SyntaxKind.OpenBraceToken; case ParsingContext.JsxChildren: return true; case ParsingContext.JSDocFunctionParameters: @@ -1254,7 +1262,7 @@ namespace ts { function nextTokenIsIdentifierOrKeyword() { nextToken(); - return isIdentifierOrKeyword(); + return tokenIsIdentifierOrKeyword(token); } function isHeritageClauseExtendsOrImplementsKeyword(): boolean { @@ -1824,7 +1832,7 @@ namespace ts { // the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword". // In the first case though, ASI will not take effect because there is not a // line terminator after the identifier or keyword. - if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { + if (scanner.hasPrecedingLineBreak() && tokenIsIdentifierOrKeyword(token)) { let matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { @@ -2282,7 +2290,7 @@ namespace ts { } } - if (isIdentifierOrKeyword()) { + if (tokenIsIdentifierOrKeyword(token)) { return parsePropertyOrMethodSignature(); } } @@ -2360,6 +2368,7 @@ namespace ts { let node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); case SyntaxKind.VoidKeyword: + case SyntaxKind.ThisKeyword: return parseTokenNode(); case SyntaxKind.TypeOfKeyword: return parseTypeQuery(); @@ -2382,6 +2391,7 @@ namespace ts { case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: case SyntaxKind.VoidKeyword: + case SyntaxKind.ThisKeyword: case SyntaxKind.TypeOfKeyword: case SyntaxKind.OpenBraceToken: case SyntaxKind.OpenBracketToken: @@ -3938,7 +3948,8 @@ namespace ts { forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(SyntaxKind.CloseParenToken); forOrForInOrForOfStatement = forOfStatement; - } else { + } + else { let forStatement = createNode(SyntaxKind.ForStatement, pos); forStatement.initializer = initializer; parseExpected(SyntaxKind.SemicolonToken); @@ -4101,13 +4112,9 @@ namespace ts { } } - function isIdentifierOrKeyword() { - return token >= SyntaxKind.Identifier; - } - function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); - return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); + return tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { @@ -4117,7 +4124,7 @@ namespace ts { function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); - return (isIdentifierOrKeyword() || token === SyntaxKind.NumericLiteral) && !scanner.hasPrecedingLineBreak(); + return (tokenIsIdentifierOrKeyword(token) || token === SyntaxKind.NumericLiteral) && !scanner.hasPrecedingLineBreak(); } function isDeclaration(): boolean { @@ -4158,8 +4165,12 @@ namespace ts { case SyntaxKind.ModuleKeyword: case SyntaxKind.NamespaceKeyword: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); + case SyntaxKind.AbstractKeyword: case SyntaxKind.AsyncKeyword: case SyntaxKind.DeclareKeyword: + case SyntaxKind.PrivateKeyword: + case SyntaxKind.ProtectedKeyword: + case SyntaxKind.PublicKeyword: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { @@ -4170,7 +4181,7 @@ namespace ts { case SyntaxKind.ImportKeyword: nextToken(); return token === SyntaxKind.StringLiteral || token === SyntaxKind.AsteriskToken || - token === SyntaxKind.OpenBraceToken || isIdentifierOrKeyword(); + token === SyntaxKind.OpenBraceToken || tokenIsIdentifierOrKeyword(token); case SyntaxKind.ExportKeyword: nextToken(); if (token === SyntaxKind.EqualsToken || token === SyntaxKind.AsteriskToken || @@ -4179,11 +4190,7 @@ namespace ts { } continue; - case SyntaxKind.PublicKeyword: - case SyntaxKind.PrivateKeyword: - case SyntaxKind.ProtectedKeyword: case SyntaxKind.StaticKeyword: - case SyntaxKind.AbstractKeyword: nextToken(); continue; default: @@ -4777,7 +4784,7 @@ namespace ts { // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name - if (isIdentifierOrKeyword() || + if (tokenIsIdentifierOrKeyword(token) || token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral || token === SyntaxKind.AsteriskToken || @@ -4813,7 +4820,7 @@ namespace ts { node.decorators = decorators; setModifiers(node, modifiers); parseExpected(SyntaxKind.ClassKeyword); - node.name = parseOptionalIdentifier(); + node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); @@ -4830,6 +4837,21 @@ namespace ts { return finishNode(node); } + function parseNameOfClassDeclarationOrExpression(): Identifier { + // implements is a future reserved word so + // 'class implements' might mean either + // - class expression with omitted name, 'implements' starts heritage clause + // - class with name 'implements' + // 'isImplementsClause' helps to disambiguate between these two cases + return isIdentifier() && !isImplementsClause() + ? parseIdentifier() + : undefined; + } + + function isImplementsClause() { + return token === SyntaxKind.ImplementsKeyword && lookAhead(nextTokenIsIdentifierOrKeyword); + } + function parseHeritageClauses(isClassHeritageClause: boolean): NodeArray { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } @@ -4941,12 +4963,15 @@ namespace ts { function parseModuleOrNamespaceDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray, flags: NodeFlags): ModuleDeclaration { let node = createNode(SyntaxKind.ModuleDeclaration, fullStart); + // If we are parsing a dotted namespace name, we want to + // propagate the 'Namespace' flag across the names if set. + let namespaceFlag = flags & NodeFlags.Namespace; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(SyntaxKind.DotToken) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.Export) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.Export | namespaceFlag) : parseModuleBlock(); return finishNode(node); } @@ -5301,7 +5326,7 @@ namespace ts { Unknown } - export module JSDocParser { + export namespace JSDocParser { export function isJSDocType() { switch (token) { case SyntaxKind.AsteriskToken: @@ -5317,7 +5342,7 @@ namespace ts { return true; } - return isIdentifierOrKeyword(); + return tokenIsIdentifierOrKeyword(token); } export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number) { @@ -5831,7 +5856,6 @@ namespace ts { if (!name) { parseErrorAtPosition(pos, 0, Diagnostics.Identifier_expected); - return undefined; } let preName: Identifier, postName: Identifier; @@ -5947,7 +5971,7 @@ namespace ts { } } - module IncrementalParser { + namespace IncrementalParser { export function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks: boolean): SourceFile { aggressiveChecks = aggressiveChecks || Debug.shouldAssert(AssertionLevel.Aggressive); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index ceb4e5fb033..c6d3a245a8d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1,5 +1,6 @@ /// /// +/// namespace ts { /* @internal */ export let programTime = 0; @@ -8,10 +9,10 @@ namespace ts { /* @internal */ export let ioWriteTime = 0; /** The version of the TypeScript compiler release */ - + let emptyArray: any[] = []; - - export const version = "1.6.0"; + + export const version = "1.7.0"; export function findConfigFile(searchPath: string): string { let fileName = "tsconfig.json"; @@ -28,25 +29,138 @@ namespace ts { } return undefined; } - + export function resolveTripleslashReference(moduleName: string, containingFile: string): string { let basePath = getDirectoryPath(containingFile); let referencedFileName = isRootedDiskPath(moduleName) ? moduleName : combinePaths(basePath, moduleName); return normalizePath(referencedFileName); } - - export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule { - // TODO: use different resolution strategy based on compiler options - return legacyNameResolver(moduleName, containingFile, compilerOptions, host); + + export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations { + let moduleResolution = compilerOptions.moduleResolution !== undefined + ? compilerOptions.moduleResolution + : compilerOptions.module === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic; + + switch (moduleResolution) { + case ModuleResolutionKind.NodeJs: return nodeModuleNameResolver(moduleName, containingFile, host); + case ModuleResolutionKind.Classic: return classicNameResolver(moduleName, containingFile, compilerOptions, host); + } } - function legacyNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule { - - // module names that contain '!' are used to reference resources and are not resolved to actual files on disk - if (moduleName.indexOf('!') != -1) { - return { resolvedFileName: undefined, failedLookupLocations: [] }; + export function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations { + let containingDirectory = getDirectoryPath(containingFile); + + if (getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) { + let failedLookupLocations: string[] = []; + let candidate = normalizePath(combinePaths(containingDirectory, moduleName)); + let resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + + if (resolvedFileName) { + return { resolvedModule: { resolvedFileName }, failedLookupLocations }; + } + + resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host); + return resolvedFileName + ? { resolvedModule: { resolvedFileName }, failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations }; } - + else { + return loadModuleFromNodeModules(moduleName, containingDirectory, host); + } + } + + function loadNodeModuleFromFile(candidate: string, loadOnlyDts: boolean, failedLookupLocation: string[], host: ModuleResolutionHost): string { + if (loadOnlyDts) { + return tryLoad(".d.ts"); + } + else { + return forEach(supportedExtensions, tryLoad); + } + + function tryLoad(ext: string): string { + let fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext; + if (host.fileExists(fileName)) { + return fileName; + } + else { + failedLookupLocation.push(fileName); + return undefined; + } + } + } + + function loadNodeModuleFromDirectory(candidate: string, loadOnlyDts: boolean, failedLookupLocation: string[], host: ModuleResolutionHost): string { + let packageJsonPath = combinePaths(candidate, "package.json"); + if (host.fileExists(packageJsonPath)) { + + let jsonContent: { typings?: string }; + + try { + let jsonText = host.readFile(packageJsonPath); + jsonContent = jsonText ? <{ typings?: string }>JSON.parse(jsonText) : { typings: undefined }; + } + catch (e) { + // gracefully handle if readFile fails or returns not JSON + jsonContent = { typings: undefined }; + } + + if (jsonContent.typings) { + let result = loadNodeModuleFromFile(normalizePath(combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host); + if (result) { + return result; + } + } + } + else { + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocation.push(packageJsonPath); + } + + return loadNodeModuleFromFile(combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host); + } + + function loadModuleFromNodeModules(moduleName: string, directory: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations { + let failedLookupLocations: string[] = []; + directory = normalizeSlashes(directory); + while (true) { + let baseName = getBaseFileName(directory); + if (baseName !== "node_modules") { + let nodeModulesFolder = combinePaths(directory, "node_modules"); + let candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName)); + let result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations }; + } + + result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host); + if (result) { + return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations }; + } + } + + let parentPath = getDirectoryPath(directory); + if (parentPath === directory) { + break; + } + + directory = parentPath; + } + + return { resolvedModule: undefined, failedLookupLocations }; + } + + function nameStartsWithDotSlashOrDotDotSlash(name: string) { + let i = name.lastIndexOf("./", 1); + return i === 0 || (i === 1 && name.charCodeAt(0) === CharacterCodes.dot); + } + + export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations { + + // module names that contain '!' are used to reference resources and are not resolved to actual files on disk + if (moduleName.indexOf("!") != -1) { + return { resolvedModule: undefined, failedLookupLocations: [] }; + } + let searchPath = getDirectoryPath(containingFile); let searchName: string; @@ -61,7 +175,7 @@ namespace ts { // 'logical not' handles both undefined and None cases return undefined; } - + let candidate = searchName + extension; if (host.fileExists(candidate)) { return candidate; @@ -82,9 +196,21 @@ namespace ts { searchPath = parentPath; } - return { resolvedFileName: referencedSourceFile, failedLookupLocations }; + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations }; } + /* @internal */ + export const defaultInitCompilerOptions: CompilerOptions = { + module: ModuleKind.CommonJS, + target: ScriptTarget.ES3, + noImplicitAny: false, + outDir: "built", + rootDir: ".", + sourceMap: false, + }; + export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost { let currentDirectory: string; let existingDirectories: Map = {}; @@ -151,8 +277,7 @@ namespace ts { } const newLine = getNewLineCharacter(options); - - + return { getSourceFile, getDefaultLibFileName: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), getDefaultLibFileName(options)), @@ -208,7 +333,8 @@ namespace ts { export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program { let program: Program; let files: SourceFile[] = []; - let diagnostics = createDiagnosticCollection(); + let fileProcessingDiagnostics = createDiagnosticCollection(); + let programDiagnostics = createDiagnosticCollection(); let commonSourceDirectory: string; let diagnosticsProducingTypeChecker: TypeChecker; @@ -220,36 +346,26 @@ namespace ts { let start = new Date().getTime(); host = host || createCompilerHost(options); - - // initialize resolveModuleNameWorker only if noResolve is false - let resolveModuleNamesWorker: (moduleNames: string[], containingFile: string) => string[]; - if (!options.noResolve) { - resolveModuleNamesWorker = host.resolveModuleNames; - if (!resolveModuleNamesWorker) { - resolveModuleNamesWorker = (moduleNames, containingFile) => { - return map(moduleNames, moduleName => { - let moduleResolution = resolveModuleName(moduleName, containingFile, options, host); - return moduleResolution.resolvedFileName; - }); - } - } - } + + const resolveModuleNamesWorker = host.resolveModuleNames + ? ((moduleNames: string[], containingFile: string) => host.resolveModuleNames(moduleNames, containingFile)) + : ((moduleNames: string[], containingFile: string) => map(moduleNames, moduleName => resolveModuleName(moduleName, containingFile, options, host).resolvedModule)); let filesByName = createFileMap(fileName => host.getCanonicalFileName(fileName)); - + if (oldProgram) { // check properties that can affect structure of the program or module resolution strategy // if any of these properties has changed - structure cannot be reused let oldOptions = oldProgram.getCompilerOptions(); - if ((oldOptions.module !== options.module) || - (oldOptions.noResolve !== options.noResolve) || - (oldOptions.target !== options.target) || + if ((oldOptions.module !== options.module) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || (oldOptions.noLib !== options.noLib) || (oldOptions.jsx !== options.jsx)) { oldProgram = undefined; } } - + if (!tryReuseStructureFromOldProgram()) { forEach(rootNames, name => processRootFile(name, false)); // Do not process the default library if: @@ -288,6 +404,7 @@ namespace ts { getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(), getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(), getTypeCount: () => getDiagnosticsProducingTypeChecker().getTypeCount(), + getFileProcessingDiagnostics: () => fileProcessingDiagnostics }; return program; @@ -309,7 +426,7 @@ namespace ts { if (!oldProgram) { return false; } - + Debug.assert(!oldProgram.structureIsReused); // there is an old program, check if we can reuse its structure @@ -317,16 +434,17 @@ namespace ts { if (!arrayIsEqualTo(oldRootNames, rootNames)) { return false; } - + // check if program source files has changed in the way that can affect structure of the program let newSourceFiles: SourceFile[] = []; + let modifiedSourceFiles: SourceFile[] = []; for (let oldSourceFile of oldProgram.getSourceFiles()) { let newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target); if (!newSourceFile) { return false; } - if (oldSourceFile !== newSourceFile) { + if (oldSourceFile !== newSourceFile) { if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed // this will affect if default library is injected into the list of files @@ -338,46 +456,58 @@ namespace ts { // tripleslash references has changed return false; } - + // check imports - collectExternalModuleReferences(newSourceFile); + collectExternalModuleReferences(newSourceFile); if (!arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { // imports has changed return false; } - + if (resolveModuleNamesWorker) { let moduleNames = map(newSourceFile.imports, name => name.text); let resolutions = resolveModuleNamesWorker(moduleNames, newSourceFile.fileName); // ensure that module resolution results are still correct for (let i = 0; i < moduleNames.length; ++i) { - let oldResolution = getResolvedModuleFileName(oldSourceFile, moduleNames[i]); - if (oldResolution !== resolutions[i]) { + let newResolution = resolutions[i]; + let oldResolution = getResolvedModule(oldSourceFile, moduleNames[i]); + let resolutionChanged = oldResolution + ? !newResolution || + oldResolution.resolvedFileName !== newResolution.resolvedFileName || + !!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport + : newResolution; + + if (resolutionChanged) { return false; - } + } } } // pass the cache of module resolutions from the old source file newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + modifiedSourceFiles.push(newSourceFile); } else { // file has no changes - use it as is newSourceFile = oldSourceFile; } - + // if file has passed all checks it should be safe to reuse it newSourceFiles.push(newSourceFile); } - + // update fileName -> file mapping for (let file of newSourceFiles) { filesByName.set(file.fileName, file); } - + files = newSourceFiles; - + fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); + + for (let modifiedFile of modifiedSourceFiles) { + fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + } oldProgram.structureIsReused = true; - + return true; } @@ -423,7 +553,7 @@ namespace ts { // This is because in the -out scenario all files need to be emitted, and therefore all // files need to be type checked. And the way to specify that all files need to be type // checked is to not pass the file to getEmitResolver. - let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); + let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); let start = new Date().getTime(); @@ -437,7 +567,9 @@ namespace ts { } function getSourceFile(fileName: string) { - return filesByName.get(fileName); + // first try to use file name as is to find file + // then try to convert relative file name to absolute and use it to retrieve source file + return filesByName.get(fileName) || filesByName.get(getNormalizedAbsolutePath(fileName, host.getCurrentDirectory())); } function getDiagnosticsHelper( @@ -505,9 +637,10 @@ namespace ts { Debug.assert(!!sourceFile.bindDiagnostics); let bindDiagnostics = sourceFile.bindDiagnostics; let checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); - let programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); + let fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); + let programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); + return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); }); } @@ -524,7 +657,8 @@ namespace ts { function getOptionsDiagnostics(): Diagnostic[] { let allDiagnostics: Diagnostic[] = []; - addRange(allDiagnostics, diagnostics.getGlobalDiagnostics()); + addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); + addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); return sortAndDeduplicateDiagnostics(allDiagnostics); } @@ -540,23 +674,29 @@ namespace ts { function processRootFile(fileName: string, isDefaultLib: boolean) { processSourceFile(normalizePath(fileName), isDefaultLib); - } - + } + function fileReferenceIsEqualTo(a: FileReference, b: FileReference): boolean { return a.fileName === b.fileName; } - + function moduleNameIsEqualTo(a: LiteralExpression, b: LiteralExpression): boolean { return a.text === b.text; } - + function collectExternalModuleReferences(file: SourceFile): void { if (file.imports) { return; } - + let imports: LiteralExpression[]; for (let node of file.statements) { + collect(node, /* allowRelativeModuleNames */ true); + } + + file.imports = imports || emptyArray; + + function collect(node: Node, allowRelativeModuleNames: boolean): void { switch (node.kind) { case SyntaxKind.ImportDeclaration: case SyntaxKind.ImportEqualsDeclaration: @@ -569,7 +709,9 @@ namespace ts { break; } - (imports || (imports = [])).push(moduleNameExpr); + if (allowRelativeModuleNames || !isExternalModuleNameRelative((moduleNameExpr).text)) { + (imports || (imports = [])).push(moduleNameExpr); + } break; case SyntaxKind.ModuleDeclaration: if ((node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) { @@ -579,23 +721,15 @@ namespace ts { // The StringLiteral must specify a top - level external module name. // Relative external module names are not permitted forEachChild((node).body, node => { - if (isExternalModuleImportEqualsDeclaration(node) && - getExternalModuleImportEqualsDeclarationExpression(node).kind === SyntaxKind.StringLiteral) { - let moduleName = getExternalModuleImportEqualsDeclarationExpression(node); - // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules - // only through top - level external module names. Relative external module names are not permitted. - if (moduleName) { - (imports || (imports = [])).push(moduleName); - } - } + // TypeScript 1.0 spec (April 2014): 12.1.6 + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // only through top - level external module names. Relative external module names are not permitted. + collect(node, /* allowRelativeModuleNames */ false); }); } break; } } - - file.imports = imports || emptyArray; } function processSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) { @@ -632,73 +766,78 @@ namespace ts { if (diagnostic) { if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { - diagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...diagnosticArgument)); + fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...diagnosticArgument)); } else { - diagnostics.add(createCompilerDiagnostic(diagnostic, ...diagnosticArgument)); + fileProcessingDiagnostics.add(createCompilerDiagnostic(diagnostic, ...diagnosticArgument)); } } } // Get source file from normalized fileName function findSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile { - let canonicalName = host.getCanonicalFileName(normalizeSlashes(fileName)); - if (filesByName.contains(canonicalName)) { + if (filesByName.contains(fileName)) { // We've already looked for this file, use cached result - return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false); + return getSourceFileFromCache(fileName, /*useAbsolutePath*/ false); } - else { - let normalizedAbsolutePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - let canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (filesByName.contains(canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true); - } - - // We haven't looked for this file, do so now and cache result - let file = host.getSourceFile(fileName, options.target, hostErrorMessage => { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - diagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, - Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }); - filesByName.set(canonicalName, file); - if (file) { - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - - // Set the source file for normalized absolute path - filesByName.set(canonicalAbsolutePath, file); - - if (!options.noResolve) { - let basePath = getDirectoryPath(fileName); - processReferencedFiles(file, basePath); - processImportedModules(file, basePath); - } - if (isDefaultLib) { - file.isDefaultLib = true; - files.unshift(file); - } - else { - files.push(file); - } - } + let normalizedAbsolutePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + if (filesByName.contains(normalizedAbsolutePath)) { + const file = getSourceFileFromCache(normalizedAbsolutePath, /*useAbsolutePath*/ true); + // we don't have resolution for this relative file name but the match was found by absolute file name + // store resolution for relative name as well + filesByName.set(fileName, file); return file; } - function getSourceFileFromCache(fileName: string, canonicalName: string, useAbsolutePath: boolean): SourceFile { - let file = filesByName.get(canonicalName); + // We haven't looked for this file, do so now and cache result + let file = host.getSourceFile(fileName, options.target, hostErrorMessage => { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, + Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + else { + fileProcessingDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + }); + + filesByName.set(fileName, file); + if (file) { + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + + // Set the source file for normalized absolute path + filesByName.set(normalizedAbsolutePath, file); + + let basePath = getDirectoryPath(fileName); + if (!options.noResolve) { + processReferencedFiles(file, basePath); + } + + // always process imported modules to record module name resolutions + processImportedModules(file, basePath); + + if (isDefaultLib) { + file.isDefaultLib = true; + files.unshift(file); + } + else { + files.push(file); + } + } + + return file; + + function getSourceFileFromCache(fileName: string, useAbsolutePath: boolean): SourceFile { + let file = filesByName.get(fileName); if (file && host.useCaseSensitiveFileNames()) { let sourceFileName = useAbsolutePath ? getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName; - if (canonicalName !== sourceFileName) { + if (normalizeSlashes(fileName) !== normalizeSlashes(sourceFileName)) { if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - diagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, + fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } else { - diagnostics.add(createCompilerDiagnostic(Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); + fileProcessingDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName)); } } } @@ -712,22 +851,34 @@ namespace ts { processSourceFile(referencedFileName, /* isDefaultLib */ false, file, ref.pos, ref.end); }); } - - function processImportedModules(file: SourceFile, basePath: string) { - collectExternalModuleReferences(file); - if (file.imports.length) { + + function processImportedModules(file: SourceFile, basePath: string) { + collectExternalModuleReferences(file); + if (file.imports.length) { file.resolvedModules = {}; - let oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName); - let moduleNames = map(file.imports, name => name.text); let resolutions = resolveModuleNamesWorker(moduleNames, file.fileName); for (let i = 0; i < file.imports.length; ++i) { let resolution = resolutions[i]; - setResolvedModuleName(file, moduleNames[i], resolution); - if (resolution) { - findModuleSourceFile(resolution, file.imports[i]); + setResolvedModule(file, moduleNames[i], resolution); + if (resolution && !options.noResolve) { + const importedFile = findModuleSourceFile(resolution.resolvedFileName, file.imports[i]); + if (importedFile && resolution.isExternalLibraryImport) { + if (!isExternalModule(importedFile)) { + let 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 (!fileExtensionIs(importedFile.fileName, ".d.ts")) { + let start = getTokenPosOfNode(file.imports[i], file); + fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition)); + } + else if (importedFile.referencedFiles.length) { + let 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)); + } + } } - } + } } else { // no imports - drop cached module resolutions @@ -736,7 +887,7 @@ namespace ts { return; function findModuleSourceFile(fileName: string, nameLiteral: Expression) { - return findSourceFile(fileName, /* isDefaultLib */ false, file, nameLiteral.pos, nameLiteral.end); + return findSourceFile(fileName, /* isDefaultLib */ false, file, skipTrivia(file.text, nameLiteral.pos), nameLiteral.end); } } @@ -761,7 +912,7 @@ namespace ts { for (let i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { if (commonPathComponents[i] !== sourcePathComponents[i]) { if (i === 0) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); return; } @@ -790,7 +941,7 @@ namespace ts { if (!isDeclarationFile(sourceFile)) { let absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); allFilesBelongToPath = false; } } @@ -803,71 +954,80 @@ namespace ts { function verifyCompilerOptions() { if (options.isolatedModules) { if (options.declaration) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); } if (options.noEmitOnError) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); } if (options.out) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + + if (options.outFile) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); } } if (options.inlineSourceMap) { if (options.sourceMap) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); } if (options.mapRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); } if (options.sourceRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap")); } } if (options.inlineSources) { if (!options.sourceMap && !options.inlineSourceMap) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); } } + if (options.out && options.outFile) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); + } + if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { // Error to specify --mapRoot or --sourceRoot without mapSourceFiles if (options.mapRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } if (options.sourceRoot) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap")); } return; } let languageVersion = options.target || ScriptTarget.ES3; + let outFile = options.outFile || options.out; let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined); if (options.isolatedModules) { if (!options.module && languageVersion < ScriptTarget.ES6) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher)); } let firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined); if (firstNonExternalModuleSourceFile) { let span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - diagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); + programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); - diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); + programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } - // Cannot specify module gen target when in es6 or above - if (options.module && languageVersion >= ScriptTarget.ES6) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher)); + // Cannot specify module gen target of es6 when below es6 + if (options.module === ModuleKind.ES6 && languageVersion < ScriptTarget.ES6) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower)); } // there has to be common source directory if user specified --outdir || --sourceRoot @@ -875,7 +1035,7 @@ namespace ts { if (options.outDir || // there is --outDir specified options.sourceRoot || // there is --sourceRoot specified (options.mapRoot && // there is --mapRoot specified and there would be multiple js files generated - (!options.out || firstExternalModuleSourceFile !== undefined))) { + (!outFile || firstExternalModuleSourceFile !== undefined))) { if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { // If a rootDir is specified and is valid use it as the commonSourceDirectory @@ -895,23 +1055,31 @@ namespace ts { } if (options.noEmit) { - if (options.out || options.outDir) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir)); + if (options.out) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out")); + } + + if (options.outFile) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile")); + } + + if (options.outDir) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir")); } if (options.declaration) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration")); } } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } if (options.experimentalAsyncFunctions && options.target !== ScriptTarget.ES6) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); } } } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 2f73c9c8820..ee4dea04f09 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -6,6 +6,11 @@ namespace ts { (message: DiagnosticMessage, length: number): void; } + /* @internal */ + export function tokenIsIdentifierOrKeyword(token: SyntaxKind): boolean { + return token >= SyntaxKind.Identifier; + } + export interface Scanner { getStartPos(): number; getToken(): SyntaxKind; @@ -219,7 +224,7 @@ namespace ts { } // Perform binary search in one of the Unicode range maps - let lo: number = 0; + let lo = 0; let hi: number = map.length; let mid: number; @@ -472,7 +477,7 @@ namespace ts { break; case CharacterCodes.hash: - if (isShebangTrivia(text, pos)) { + if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); continue; } @@ -652,7 +657,7 @@ namespace ts { export function getTrailingCommentRanges(text: string, pos: number): CommentRange[] { return getCommentRanges(text, pos, /*trailing*/ true); } - + /** Optionally, get the shebang */ export function getShebang(text: string): string { return shebangTriviaRegex.test(text) @@ -734,18 +739,6 @@ namespace ts { } } - function isIdentifierStart(ch: number): boolean { - return ch >= CharacterCodes.A && ch <= CharacterCodes.Z || ch >= CharacterCodes.a && ch <= CharacterCodes.z || - ch === CharacterCodes.$ || ch === CharacterCodes._ || - ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierStart(ch, languageVersion); - } - - function isIdentifierPart(ch: number): boolean { - return ch >= CharacterCodes.A && ch <= CharacterCodes.Z || ch >= CharacterCodes.a && ch <= CharacterCodes.z || - ch >= CharacterCodes._0 && ch <= CharacterCodes._9 || ch === CharacterCodes.$ || ch === CharacterCodes._ || - ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion); - } - function scanNumber(): number { let start = pos; while (isDigit(text.charCodeAt(pos))) pos++; @@ -1059,12 +1052,12 @@ namespace ts { let start = pos; while (pos < end) { let ch = text.charCodeAt(pos); - if (isIdentifierPart(ch)) { + if (isIdentifierPart(ch, languageVersion)) { pos++; } else if (ch === CharacterCodes.backslash) { ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch))) { + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } result += text.substring(start, pos); @@ -1368,7 +1361,9 @@ namespace ts { if (text.charCodeAt(pos + 1) === CharacterCodes.equals) { return pos += 2, token = SyntaxKind.LessThanEqualsToken; } - if (text.charCodeAt(pos + 1) === CharacterCodes.slash && languageVariant === LanguageVariant.JSX) { + if (languageVariant === LanguageVariant.JSX && + text.charCodeAt(pos + 1) === CharacterCodes.slash && + text.charCodeAt(pos + 2) !== CharacterCodes.asterisk) { return pos += 2, token = SyntaxKind.LessThanSlashToken; } return pos++, token = SyntaxKind.LessThanToken; @@ -1434,7 +1429,7 @@ namespace ts { return pos++, token = SyntaxKind.AtToken; case CharacterCodes.backslash: let cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); @@ -1442,9 +1437,9 @@ namespace ts { error(Diagnostics.Invalid_character); return pos++, token = SyntaxKind.Unknown; default: - if (isIdentifierStart(ch)) { + if (isIdentifierStart(ch, languageVersion)) { pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos))) pos++; + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) pos++; tokenValue = text.substring(tokenPos, pos); if (ch === CharacterCodes.backslash) { tokenValue += scanIdentifierParts(); @@ -1531,7 +1526,7 @@ namespace ts { p++; } - while (p < end && isIdentifierPart(text.charCodeAt(p))) { + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { p++; } pos = p; @@ -1590,11 +1585,11 @@ namespace ts { // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes function scanJsxIdentifier(): SyntaxKind { - if (token === SyntaxKind.Identifier) { + if (tokenIsIdentifierOrKeyword(token)) { let firstCharPosition = pos; while (pos < end) { let ch = text.charCodeAt(pos); - if (ch === CharacterCodes.minus || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + if (ch === CharacterCodes.minus || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { pos++; } else { diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index c68f48dfbfb..c50291e60b8 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -9,7 +9,7 @@ namespace ts { writesToTty?(): boolean; readFile(path: string, encoding?: string): string; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; - watchFile?(path: string, callback: (path: string) => void): FileWatcher; + watchFile?(path: string, callback: (path: string, removed: boolean) => void): FileWatcher; resolvePath(path: string): string; fileExists(path: string): boolean; directoryExists(path: string): boolean; @@ -30,8 +30,8 @@ namespace ts { declare var process: any; declare var global: any; declare var __filename: string; - declare var Buffer: { - new (str: string, encoding?: string): any; + declare var Buffer: { + new (str: string, encoding?: string): any; }; declare class Enumerator { @@ -117,7 +117,7 @@ namespace ts { return path.toLowerCase(); } - function getNames(collection: any): string[]{ + function getNames(collection: any): string[] { let result: string[] = []; for (let e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { result.push(e.item().Name); @@ -287,11 +287,16 @@ namespace ts { }; function fileChanged(curr: any, prev: any) { + // mtime.getTime() equals 0 if file was removed + if (curr.mtime.getTime() === 0) { + callback(fileName, /* removed */ true); + return; + } if (+curr.mtime <= +prev.mtime) { return; } - callback(fileName); + callback(fileName, /* removed */ false); } }, resolvePath: function (path: string): string { diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index ae1a7cda220..5222ca2fccf 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -179,6 +179,19 @@ namespace ts { sys.write(output); } + function reportWatchDiagnostic(diagnostic: Diagnostic) { + let output = new Date().toLocaleTimeString() + " - "; + + if (diagnostic.file) { + let loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); + output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `; + } + + output += `${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`; + + sys.write(output); + } + function padLeft(s: string, length: number) { while (s.length < length) { s = " " + s; @@ -236,6 +249,11 @@ namespace ts { return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } + if (commandLine.options.init) { + writeConfigFile(commandLine.options, commandLine.fileNames); + return sys.exit(ExitStatus.Success); + } + if (commandLine.options.version) { reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, ts.version)); return sys.exit(ExitStatus.Success); @@ -288,9 +306,9 @@ namespace ts { if (!cachedProgram) { if (configFileName) { - let result = readConfigFile(configFileName); + let result = readConfigFile(configFileName, sys.readFile); if (result.error) { - reportDiagnostic(result.error); + reportWatchDiagnostic(result.error); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } @@ -323,7 +341,7 @@ namespace ts { } setCachedProgram(compileResult.program); - reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); + reportWatchDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); } function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) { @@ -339,7 +357,7 @@ namespace ts { let sourceFile = hostGetSourceFile(fileName, languageVersion, onError); if (sourceFile && compilerOptions.watch) { // Attach a file watcher - sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, () => sourceFileChanged(sourceFile)); + sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, (fileName, removed) => sourceFileChanged(sourceFile, removed)); } return sourceFile; } @@ -361,9 +379,15 @@ namespace ts { } // If a source file changes, mark it as unwatched and start the recompilation timer - function sourceFileChanged(sourceFile: SourceFile) { + function sourceFileChanged(sourceFile: SourceFile, removed: boolean) { sourceFile.fileWatcher.close(); sourceFile.fileWatcher = undefined; + if (removed) { + let index = rootFileNames.indexOf(sourceFile.fileName); + if (index >= 0) { + rootFileNames.splice(index, 1); + } + } startTimer(); } @@ -385,7 +409,7 @@ namespace ts { function recompile() { timerHandle = undefined; - reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation)); + reportWatchDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation)); performCompilation(); } } @@ -437,7 +461,7 @@ namespace ts { function compileProgram(): ExitStatus { let diagnostics: Diagnostic[]; - + // First get and report any syntactic errors. diagnostics = program.getSyntacticDiagnostics(); @@ -570,6 +594,70 @@ namespace ts { return Array(paddingLength + 1).join(" "); } } + + function writeConfigFile(options: CompilerOptions, fileNames: string[]) { + let currentDirectory = sys.getCurrentDirectory(); + let file = combinePaths(currentDirectory, "tsconfig.json"); + if (sys.fileExists(file)) { + reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file)); + } + else { + let compilerOptions = extend(options, defaultInitCompilerOptions); + let configurations: any = { + compilerOptions: serializeCompilerOptions(compilerOptions), + exclude: ["node_modules"] + }; + + if (fileNames && fileNames.length) { + // only set the files property if we have at least one file + configurations.files = fileNames; + } + + sys.writeFile(file, JSON.stringify(configurations, undefined, 4)); + reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file)); + } + + return; + + function serializeCompilerOptions(options: CompilerOptions): Map { + let result: Map = {}; + let optionsNameMap = getOptionNameMap().optionNameMap; + + for (let name in options) { + if (hasProperty(options, name)) { + let value = options[name]; + switch (name) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + let optionDefinition = optionsNameMap[name.toLowerCase()]; + if (optionDefinition) { + if (typeof optionDefinition.type === "string") { + // string, number or boolean + result[name] = value; + } + else { + // Enum + let typeMap = >optionDefinition.type; + for (let key in typeMap) { + if (hasProperty(typeMap, key)) { + if (typeMap[key] === value) + result[name] = key; + } + } + } + } + break; + } + } + } + return result; + } + } } ts.executeCommandLine(ts.sys.args); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 01a791237ad..48a31c417b7 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -376,6 +376,7 @@ namespace ts { OctalLiteral = 0x00010000, // Octal numeric literal Namespace = 0x00020000, // Namespace declaration ExportContext = 0x00040000, // Export context (initialized by binding) + ContainsThis = 0x00080000, // Interface contains references to "this" Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async, AccessibilityModifier = Public | Private | Protected, @@ -1244,7 +1245,7 @@ namespace ts { moduleName: string; referencedFiles: FileReference[]; languageVariant: LanguageVariant; - + // this map is used by transpiler to supply alternative names for dependencies (i.e. in case of bundling) /* @internal */ renamedDependencies?: Map; @@ -1284,7 +1285,7 @@ namespace ts { // Stores a mapping 'external module reference text' -> 'resolved file name' | undefined // It is used to resolve module names in the checker. // Content of this fiels should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead - /* @internal */ resolvedModules: Map; + /* @internal */ resolvedModules: Map; /* @internal */ imports: LiteralExpression[]; } @@ -1312,12 +1313,12 @@ namespace ts { } export interface Program extends ScriptReferenceHost { - + /** * Get a list of root file names that were passed to a 'createProgram' */ - getRootFileNames(): string[] - + getRootFileNames(): string[]; + /** * Get a list of files in the program */ @@ -1359,6 +1360,7 @@ namespace ts { /* @internal */ getSymbolCount(): number; /* @internal */ getTypeCount(): number; + /* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection; // For testing purposes only. /* @internal */ structureIsReused?: boolean; } @@ -1411,6 +1413,7 @@ namespace ts { /* @internal */ sourceMaps: SourceMapData[]; // Array of sourceMapData if compiler emitted sourcemaps } + /* @internal */ export interface TypeCheckerHost { getCompilerOptions(): CompilerOptions; @@ -1494,6 +1497,7 @@ namespace ts { // declaration emitter to help determine if it should patch up the final declaration file // with import statements it previously saw (but chose not to emit). trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; + reportInaccessibleThisError(): void; } export const enum TypeFormatFlags { @@ -1551,8 +1555,8 @@ namespace ts { export interface SymbolAccessiblityResult extends SymbolVisibilityResult { errorModuleName?: string; // If the symbol is not visible from module, module's name } - - /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator + + /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator * metadata */ /* @internal */ export enum TypeReferenceSerializationKind { @@ -1596,7 +1600,7 @@ namespace ts { getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; getBlockScopedVariableId(node: Identifier): number; getReferencedValueDeclaration(reference: Identifier): Declaration; - getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind; + getTypeReferenceSerializationKind(typeName: EntityName): TypeReferenceSerializationKind; isOptionalParameter(node: ParameterDeclaration): boolean; } @@ -1713,6 +1717,7 @@ namespace ts { resolvedExports?: SymbolTable; // Resolved exports of module exportsChecked?: boolean; // True if exports of external module have been checked isNestedRedeclaration?: boolean; // True if symbol is block scoped redeclaration + bindingElement?: BindingElement; // Binding element associated with property symbol } /* @internal */ @@ -1794,6 +1799,7 @@ namespace ts { /* @internal */ ContainsAnyFunctionType = 0x00800000, // Type is or contains object literal type ESSymbol = 0x01000000, // Type of symbol primitive introduced in ES6 + ThisType = 0x02000000, // This type /* @internal */ Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null, @@ -1810,11 +1816,14 @@ namespace ts { PropagatingFlags = ContainsUndefinedOrNull | ContainsObjectLiteral | ContainsAnyFunctionType } + export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; + // Properties common to all types export interface Type { - flags: TypeFlags; // Flags - /* @internal */ id: number; // Unique ID - symbol?: Symbol; // Symbol associated with type (if any) + flags: TypeFlags; // Flags + /* @internal */ id: number; // Unique ID + symbol?: Symbol; // Symbol associated with type (if any) + pattern?: DestructuringPattern; // Destructuring pattern represented by type (if any) } /* @internal */ @@ -1836,6 +1845,7 @@ namespace ts { typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic) outerTypeParameters: TypeParameter[]; // Outer type parameters (undefined if none) localTypeParameters: TypeParameter[]; // Local type parameters (undefined if none) + thisType: TypeParameter; // The "this" type (undefined if none) /* @internal */ resolvedBaseConstructorType?: Type; // Resolved base constructor type of class /* @internal */ @@ -1850,10 +1860,17 @@ namespace ts { declaredNumberIndexType: Type; // Declared numeric index type } - // Type references (TypeFlags.Reference) + // Type references (TypeFlags.Reference). When a class or interface has type parameters or + // a "this" type, references to the class or interface are made using type references. The + // typeArguments property specififes the types to substitute for the type parameters of the + // class or interface and optionally includes an extra element that specifies the type to + // substitute for "this" in the resulting instantiation. When no extra argument is present, + // the type reference itself is substituted for "this". The typeArguments property is undefined + // if the class or interface has no type parameters and the reference isn't specifying an + // explicit "this" argument. export interface TypeReference extends ObjectType { target: GenericType; // Type reference target - typeArguments: Type[]; // Type reference type arguments + typeArguments: Type[]; // Type reference type arguments (undefined if none) } // Generic class and interface types @@ -1863,8 +1880,7 @@ namespace ts { } export interface TupleType extends ObjectType { - elementTypes: Type[]; // Element types - baseArrayType: TypeReference; // Array where T is best common type of element types + elementTypes: Type[]; // Element types } export interface UnionOrIntersectionType extends Type { @@ -1879,6 +1895,13 @@ namespace ts { export interface IntersectionType extends UnionOrIntersectionType { } + /* @internal */ + // An instantiated anonymous type has a target and a mapper + export interface AnonymousType extends ObjectType { + target?: AnonymousType; // Instantiation target + mapper?: TypeMapper; // Instantiation mapper + } + /* @internal */ // Resolved object, union, or intersection type export interface ResolvedType extends ObjectType, UnionOrIntersectionType { @@ -1952,6 +1975,7 @@ namespace ts { /* @internal */ export interface TypeMapper { (t: TypeParameter): Type; + instantiations?: Type[]; // Cache of instantiations created using this type mapper. context?: InferenceContext; // The inference context this mapper was created from. // Only inference mappers have this set (in createInferenceMapper). // The identity mapper and regular instantiation mappers do not need it. @@ -2009,6 +2033,11 @@ namespace ts { Message, } + export const enum ModuleResolutionKind { + Classic = 1, + NodeJs = 2 + } + export interface CompilerOptions { allowNonTsExtensions?: boolean; charset?: string; @@ -2016,6 +2045,7 @@ namespace ts { diagnostics?: boolean; emitBOM?: boolean; help?: boolean; + init?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; jsx?: JsxEmit; @@ -2032,6 +2062,7 @@ namespace ts { noLib?: boolean; noResolve?: boolean; out?: string; + outFile?: string; outDir?: string; preserveConstEnums?: boolean; project?: string; @@ -2039,6 +2070,7 @@ namespace ts { rootDir?: string; sourceMap?: boolean; sourceRoot?: string; + suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; version?: boolean; @@ -2047,6 +2079,7 @@ namespace ts { experimentalDecorators?: boolean; experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; + moduleResolution?: ModuleResolutionKind; /* @internal */ stripInternal?: boolean; // Skip checking lib.d.ts to help speed up tests. @@ -2061,6 +2094,7 @@ namespace ts { AMD = 2, UMD = 3, System = 4, + ES6 = 5, } export const enum JsxEmit { @@ -2107,17 +2141,30 @@ namespace ts { } /* @internal */ - export interface CommandLineOption { + export interface CommandLineOptionBase { name: string; type: string | Map; // "string", "number", "boolean", or an object literal mapping named values to actual values isFilePath?: boolean; // True if option value is a path or fileName shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help' description?: DiagnosticMessage; // The message describing what the command line switch does paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter - error?: DiagnosticMessage; // The error given when the argument does not fit a customized 'type' experimental?: boolean; } + /* @internal */ + export interface CommandLineOptionOfPrimitiveType extends CommandLineOptionBase { + type: string; // "string" | "number" | "boolean" + } + + /* @internal */ + export interface CommandLineOptionOfCustomType extends CommandLineOptionBase { + type: Map; // an object literal mapping named values to actual values + error: DiagnosticMessage; // The error given when the argument does not fit a customized 'type' + } + + /* @internal */ + export type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType; + /* @internal */ export const enum CharacterCodes { nullCharacter = 0, @@ -2253,21 +2300,30 @@ namespace ts { byteOrderMark = 0xFEFF, tab = 0x09, // \t verticalTab = 0x0B, // \v - } - + } + export interface ModuleResolutionHost { fileExists(fileName: string): boolean; // readFile function is used to read arbitrary text files on disk, i.e. when resolution procedure needs the content of 'package.json' // to determine location of bundled typings for node module readFile(fileName: string): string; } - + export interface ResolvedModule { resolvedFileName: string; + /* + * Denotes if 'resolvedFileName' is isExternalLibraryImport and thus should be proper external module: + * - be a .d.ts file + * - use top level imports\exports + * - don't use tripleslash references + */ + isExternalLibraryImport?: boolean; + } + + export interface ResolvedModuleWithFailedLookupLocations { + resolvedModule: ResolvedModule; failedLookupLocations: string[]; } - - export type ModuleNameResolver = (moduleName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost) => ResolvedModule; export interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; @@ -2278,7 +2334,7 @@ namespace ts { getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; - + /* * CompilerHost must either implement resolveModuleNames (in case if it wants to be completely in charge of * module name resolution) or provide implementation for methods from ModuleResolutionHost (in this case compiler @@ -2286,7 +2342,7 @@ namespace ts { * If resolveModuleNames is implemented then implementation for members from ModuleResolutionHost can be just * 'throw new Error("NotImplemented")' */ - resolveModuleNames?(moduleNames: string[], containingFile: string): string[]; + resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; } export interface TextSpan { @@ -2317,5 +2373,7 @@ namespace ts { // operation caused diagnostics to be returned by storing and comparing the return value // of this method before/after the operation is performed. getModificationCount(): number; + + /* @internal */ reattachFileDiagnostics(newFile: SourceFile): void; } } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index a33419ae810..5127b98ab3a 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1,4 +1,5 @@ /// +/// /* @internal */ namespace ts { @@ -64,7 +65,8 @@ namespace ts { increaseIndent: () => { }, decreaseIndent: () => { }, clear: () => str = "", - trackSymbol: () => { } + trackSymbol: () => { }, + reportInaccessibleThisError: () => { } }; } @@ -97,22 +99,22 @@ namespace ts { } return true; - } - - export function hasResolvedModuleName(sourceFile: SourceFile, moduleNameText: string): boolean { + } + + export function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean { return sourceFile.resolvedModules && hasProperty(sourceFile.resolvedModules, moduleNameText); } - export function getResolvedModuleFileName(sourceFile: SourceFile, moduleNameText: string): string { - return hasResolvedModuleName(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModule { + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; } - export function setResolvedModuleName(sourceFile: SourceFile, moduleNameText: string, resolvedFileName: string): void { + export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModule): void { if (!sourceFile.resolvedModules) { sourceFile.resolvedModules = {}; } - sourceFile.resolvedModules[moduleNameText] = resolvedFileName; + sourceFile.resolvedModules[moduleNameText] = resolvedModule; } // Returns true if this node contains a parse error anywhere underneath it. @@ -164,16 +166,16 @@ namespace ts { return node.pos; } - // Returns true if this node is missing from the actual source code. 'missing' is different - // from 'undefined/defined'. When a node is undefined (which can happen for optional nodes - // in the tree), it is definitel missing. HOwever, a node may be defined, but still be + // Returns true if this node is missing from the actual source code. A 'missing' node is different + // from 'undefined/defined'. When a node is undefined (which can happen for optional nodes + // in the tree), it is definitely missing. However, a node may be defined, but still be // missing. This happens whenever the parser knows it needs to parse something, but can't - // get anything in the source code that it expects at that location. For example: + // get anything in the source code that it expects at that location. For example: // // let a: ; // // Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source - // code). So the parser will attempt to parse out a type, and will create an actual node. + // code). So the parser will attempt to parse out a type, and will create an actual node. // However, this node will be 'missing' in the sense that no actual source-code/tokens are // contained within it. export function nodeIsMissing(node: Node) { @@ -240,7 +242,7 @@ namespace ts { // Make an identifier from an external module name by extracting the string after the last "/" and replacing // all non-alphanumeric characters with underscores export function makeIdentifierFromModuleName(moduleName: string): string { - return getBaseFileName(moduleName).replace(/\W/g, "_"); + return getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); } export function isBlockOrCatchScoped(declaration: Declaration) { @@ -420,7 +422,10 @@ namespace ts { } export function getJsDocComments(node: Node, sourceFileOfNode: SourceFile) { - let commentRanges = (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) ? concatenate(getTrailingCommentRanges(sourceFileOfNode.text, node.pos), getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : getLeadingCommentRangesOfNode(node, sourceFileOfNode); + let commentRanges = (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.TypeParameter) ? + concatenate(getTrailingCommentRanges(sourceFileOfNode.text, node.pos), + getLeadingCommentRanges(sourceFileOfNode.text, node.pos)) : + getLeadingCommentRangesOfNode(node, sourceFileOfNode); return filter(commentRanges, isJsDocComment); function isJsDocComment(comment: CommentRange) { @@ -432,6 +437,7 @@ namespace ts { } export let fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + export let fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; export function isTypeNode(node: Node): boolean { if (SyntaxKind.FirstTypeNode <= node.kind && node.kind <= SyntaxKind.LastTypeNode) { @@ -463,13 +469,12 @@ namespace ts { else if (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node) { node = node.parent; } - // fall through - case SyntaxKind.QualifiedName: - case SyntaxKind.PropertyAccessExpression: // At this point, node is either a qualified name or an identifier Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccessExpression, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); - + case SyntaxKind.QualifiedName: + case SyntaxKind.PropertyAccessExpression: + case SyntaxKind.ThisKeyword: let parent = node.parent; if (parent.kind === SyntaxKind.TypeQuery) { return false; @@ -608,15 +613,15 @@ namespace ts { return false; } - export function isAccessor(node: Node): boolean { + export function isAccessor(node: Node): node is AccessorDeclaration { return node && (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor); } - export function isClassLike(node: Node): boolean { + export function isClassLike(node: Node): node is ClassLikeDeclaration { return node && (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression); } - export function isFunctionLike(node: Node): boolean { + export function isFunctionLike(node: Node): node is FunctionLikeDeclaration { if (node) { switch (node.kind) { case SyntaxKind.Constructor: @@ -638,11 +643,25 @@ namespace ts { return false; } + export function introducesArgumentsExoticObject(node: Node) { + switch (node.kind) { + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + case SyntaxKind.Constructor: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + return true; + } + return false; + } + export function isFunctionBlock(node: Node) { return node && node.kind === SyntaxKind.Block && isFunctionLike(node.parent); } - export function isObjectLiteralMethod(node: Node) { + export function isObjectLiteralMethod(node: Node): node is MethodDeclaration { return node && node.kind === SyntaxKind.MethodDeclaration && node.parent.kind === SyntaxKind.ObjectLiteralExpression; } @@ -714,6 +733,9 @@ namespace ts { case SyntaxKind.Constructor: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.IndexSignature: case SyntaxKind.EnumDeclaration: case SyntaxKind.SourceFile: return node; @@ -876,7 +898,6 @@ namespace ts { export function isExpression(node: Node): boolean { switch (node.kind) { - case SyntaxKind.ThisKeyword: case SyntaxKind.SuperKeyword: case SyntaxKind.NullKeyword: case SyntaxKind.TrueKeyword: @@ -909,6 +930,7 @@ namespace ts { case SyntaxKind.JsxElement: case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.YieldExpression: + case SyntaxKind.AwaitExpression: return true; case SyntaxKind.QualifiedName: while (node.parent.kind === SyntaxKind.QualifiedName) { @@ -922,6 +944,7 @@ namespace ts { // fall through case SyntaxKind.NumericLiteral: case SyntaxKind.StringLiteral: + case SyntaxKind.ThisKeyword: let parent = node.parent; switch (parent.kind) { case SyntaxKind.VariableDeclaration: @@ -961,6 +984,8 @@ namespace ts { case SyntaxKind.ComputedPropertyName: return node === (parent).expression; case SyntaxKind.Decorator: + case SyntaxKind.JsxExpression: + case SyntaxKind.JsxSpreadAttribute: return true; case SyntaxKind.ExpressionWithTypeArguments: return (parent).expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); @@ -973,6 +998,12 @@ namespace ts { return false; } + export function isExternalModuleNameRelative(moduleName: string): boolean { + // TypeScript 1.0 spec (April 2014): 11.2.1 + // An external module name is "relative" if the first term is "." or "..". + return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; + } + export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) { let moduleState = getModuleInstanceState(node); return moduleState === ModuleInstanceState.Instantiated || @@ -1489,13 +1520,24 @@ namespace ts { add, getGlobalDiagnostics, getDiagnostics, - getModificationCount + getModificationCount, + reattachFileDiagnostics }; function getModificationCount() { return modificationCount; } + function reattachFileDiagnostics(newFile: SourceFile): void { + if (!hasProperty(fileDiagnostics, newFile.fileName)) { + return; + } + + for (let diagnostic of fileDiagnostics[newFile.fileName]) { + diagnostic.file = newFile; + } + } + function add(diagnostic: Diagnostic): void { let diagnostics: Diagnostic[]; if (diagnostic.file) { @@ -1749,7 +1791,7 @@ namespace ts { export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean { if (!isDeclarationFile(sourceFile)) { - if ((isExternalModule(sourceFile) || !compilerOptions.out)) { + if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) { // 1. in-browser single file compilation scenario // 2. non .js file return compilerOptions.isolatedModules || !fileExtensionIs(sourceFile.fileName, ".js"); diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 87e22e08cfa..108c6f4518a 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -1,6 +1,7 @@ /// /// /// +/* tslint:disable:no-null */ const enum CompilerTestType { Conformance, @@ -32,7 +33,8 @@ class CompilerBaselineRunner extends RunnerBase { } else if (testType === CompilerTestType.Test262) { this.testSuiteName = "test262"; - } else { + } + else { this.testSuiteName = "compiler"; // default to this for historical reasons } this.basePath += "/" + this.testSuiteName; @@ -44,10 +46,10 @@ class CompilerBaselineRunner extends RunnerBase { // Everything declared here should be cleared out in the "after" callback. let justName: string; let content: string; - let testCaseContent: { settings: Harness.TestCaseParser.CompilerSetting[]; testUnitData: Harness.TestCaseParser.TestUnitData[]; }; + let testCaseContent: { settings: Harness.TestCaseParser.CompilerSettings; testUnitData: Harness.TestCaseParser.TestUnitData[]; }; let units: Harness.TestCaseParser.TestUnitData[]; - let tcSettings: Harness.TestCaseParser.CompilerSetting[]; + let tcSettings: Harness.TestCaseParser.CompilerSettings; let lastUnit: Harness.TestCaseParser.TestUnitData; let rootDir: string; @@ -61,15 +63,12 @@ class CompilerBaselineRunner extends RunnerBase { let otherFiles: { unitName: string; content: string }[]; let harnessCompiler: Harness.Compiler.HarnessCompiler; - let createNewInstance = false; - before(() => { justName = fileName.replace(/^.*[\\\/]/, ""); // strips the fileName from the path. content = Harness.IO.readFile(fileName); testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, fileName); units = testCaseContent.testUnitData; tcSettings = testCaseContent.settings; - createNewInstance = false; lastUnit = units[units.length - 1]; rootDir = lastUnit.originalFilePath.indexOf("conformance") === -1 ? "tests/cases/compiler/" : lastUnit.originalFilePath.substring(0, lastUnit.originalFilePath.lastIndexOf("/")) + "/"; harnessCompiler = Harness.Compiler.getCompiler(); @@ -85,7 +84,8 @@ class CompilerBaselineRunner extends RunnerBase { otherFiles.push({ unitName: rootDir + unit.name, content: unit.content }); } }); - } else { + } + else { toBeCompiled = units.map(unit => { return { unitName: rootDir + unit.name, content: unit.content }; }); @@ -100,27 +100,6 @@ class CompilerBaselineRunner extends RunnerBase { }); }); - beforeEach(() => { - /* The compiler doesn't handle certain flags flipping during a single compilation setting. Tests on these flags will need - a fresh compiler instance for themselves and then create a fresh one for the next test. Would be nice to get dev fixes - eventually to remove this limitation. */ - for (let i = 0; i < tcSettings.length; ++i) { - // noImplicitAny is passed to getCompiler, but target is just passed in the settings blob to setCompilerSettings - if (!createNewInstance && (tcSettings[i].flag == "noimplicitany" || tcSettings[i].flag === "target")) { - harnessCompiler = Harness.Compiler.getCompiler(); - harnessCompiler.setCompilerSettings(tcSettings); - createNewInstance = true; - } - } - }); - - afterEach(() => { - if (createNewInstance) { - harnessCompiler = Harness.Compiler.getCompiler(); - createNewInstance = false; - } - }); - after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Therefore we have to clean out large objects after the test is done. @@ -217,7 +196,8 @@ class CompilerBaselineRunner extends RunnerBase { if (jsCode.length > 0) { return tsCode + "\r\n\r\n" + jsCode; - } else { + } + else { return null; } }); @@ -402,10 +382,6 @@ class CompilerBaselineRunner extends RunnerBase { else { this.tests.forEach(test => this.checkTestCodeOutput(test)); } - - describe("Cleanup after compiler baselines", () => { - let harnessCompiler = Harness.Compiler.getCompiler(); - }); }); } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 1d2ad83d98a..a846077a85f 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -18,8 +18,9 @@ /// /// /// +/* tslint:disable:no-null */ -module FourSlash { +namespace FourSlash { ts.disableIncrementalParsing = false; // Represents a parsed source file with metadata @@ -29,13 +30,13 @@ module FourSlash { fileName: string; version: number; // File-specific options (name/value pairs) - fileOptions: { [index: string]: string; }; + fileOptions: Harness.TestCaseParser.CompilerSettings; } // Represents a set of parsed source files and options export interface FourSlashData { // Global options (name/value pairs) - globalOptions: { [index: string]: string; }; + globalOptions: Harness.TestCaseParser.CompilerSettings; files: FourSlashFile[]; @@ -117,70 +118,17 @@ module FourSlash { // Add cases into convertGlobalOptionsToCompilationsSettings function for the compiler to acknowledge such option from meta data let metadataOptionNames = { baselineFile: "BaselineFile", - declaration: "declaration", emitThisFile: "emitThisFile", // This flag is used for testing getEmitOutput feature. It allows test-cases to indicate what file to be output in multiple files project fileName: "Filename", - mapRoot: "mapRoot", - module: "module", - out: "out", - outDir: "outDir", - sourceMap: "sourceMap", - sourceRoot: "sourceRoot", - allowNonTsExtensions: "allowNonTsExtensions", resolveReference: "ResolveReference", // This flag is used to specify entry file for resolve file references. The flag is only allow once per test file }; // List of allowed metadata names let fileMetadataNames = [metadataOptionNames.fileName, metadataOptionNames.emitThisFile, metadataOptionNames.resolveReference]; - let globalMetadataNames = [metadataOptionNames.allowNonTsExtensions, metadataOptionNames.baselineFile, metadataOptionNames.declaration, - metadataOptionNames.mapRoot, metadataOptionNames.module, metadataOptionNames.out, - metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot]; - function convertGlobalOptionsToCompilerOptions(globalOptions: { [idx: string]: string }): ts.CompilerOptions { + function convertGlobalOptionsToCompilerOptions(globalOptions: Harness.TestCaseParser.CompilerSettings): ts.CompilerOptions { let settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 }; - // Convert all property in globalOptions into ts.CompilationSettings - for (let prop in globalOptions) { - if (globalOptions.hasOwnProperty(prop)) { - switch (prop) { - case metadataOptionNames.allowNonTsExtensions: - settings.allowNonTsExtensions = globalOptions[prop] === "true"; - break; - case metadataOptionNames.declaration: - settings.declaration = globalOptions[prop] === "true"; - break; - case metadataOptionNames.mapRoot: - settings.mapRoot = globalOptions[prop]; - break; - case metadataOptionNames.module: - // create appropriate external module target for CompilationSettings - switch (globalOptions[prop]) { - case "AMD": - settings.module = ts.ModuleKind.AMD; - break; - case "CommonJS": - settings.module = ts.ModuleKind.CommonJS; - break; - default: - ts.Debug.assert(globalOptions[prop] === undefined || globalOptions[prop] === "None"); - settings.module = ts.ModuleKind.None; - break; - } - break; - case metadataOptionNames.out: - settings.out = globalOptions[prop]; - break; - case metadataOptionNames.outDir: - settings.outDir = globalOptions[prop]; - break; - case metadataOptionNames.sourceMap: - settings.sourceMap = globalOptions[prop] === "true"; - break; - case metadataOptionNames.sourceRoot: - settings.sourceRoot = globalOptions[prop]; - break; - } - } - } + Harness.Compiler.setCompilerOptionsFromHarnessSetting(globalOptions, settings); return settings; } @@ -209,7 +157,7 @@ module FourSlash { return true; } - public setCancelled(numberOfCalls: number = 0): void { + public setCancelled(numberOfCalls = 0): void { ts.Debug.assert(numberOfCalls >= 0); this.numberOfCallsBeforeCancellation = numberOfCalls; } @@ -311,7 +259,8 @@ module FourSlash { this.inputFiles[file.fileName] = file.content; if (!startResolveFileRef && file.fileOptions[metadataOptionNames.resolveReference] === "true") { startResolveFileRef = file; - } else if (startResolveFileRef) { + } + else if (startResolveFileRef) { // If entry point for resolving file references is already specified, report duplication error throw new Error("There exists a Fourslash file which has resolveReference flag specified; remove duplicated resolveReference flag"); } @@ -358,7 +307,7 @@ module FourSlash { this.formatCodeOptions = { IndentSize: 4, TabSize: 4, - NewLineCharacter: ts.sys.newLine, + NewLineCharacter: Harness.IO.newLine(), ConvertTabsToSpaces: true, InsertSpaceAfterCommaDelimiter: true, InsertSpaceAfterSemicolonInForStatements: true, @@ -414,7 +363,8 @@ module FourSlash { this.currentCaretPosition = Math.min(this.currentCaretPosition, this.getFileContent(this.activeFile.fileName).length); if (count > 0) { this.scenarioActions.push(``); - } else { + } + else { this.scenarioActions.push(``); } } @@ -489,7 +439,8 @@ module FourSlash { predicate = function (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { return ((errorMinChar >= startPos) && (errorLimChar >= startPos)) ? true : false; }; - } else { + } + else { predicate = function (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { return ((errorMinChar <= startPos) && (errorLimChar <= startPos)) ? true : false; }; @@ -529,14 +480,15 @@ module FourSlash { private printErrorLog(expectErrors: boolean, errors: ts.Diagnostic[]) { if (expectErrors) { Harness.IO.log("Expected error not found. Error list is:"); - } else { + } + else { Harness.IO.log("Unexpected error(s) found. Error list is:"); } errors.forEach(function (error: ts.Diagnostic) { Harness.IO.log(" minChar: " + error.start + ", limChar: " + (error.start + error.length) + - ", message: " + ts.flattenDiagnosticMessageText(error.messageText, ts.sys.newLine) + "\n"); + ", message: " + ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine()) + "\n"); }); } @@ -602,10 +554,12 @@ module FourSlash { if (negative) { this.verifyMemberListIsEmpty(false); return; - } else { + } + else { this.scenarioActions.push(""); } - } else { + } + else { this.scenarioActions.push(""); this.scenarioActions.push(``); } @@ -648,14 +602,16 @@ module FourSlash { public verifyMemberListIsEmpty(negative: boolean) { if (negative) { this.scenarioActions.push(""); - } else { + } + else { this.scenarioActions.push(""); } let members = this.getMemberListAtCaret(); if ((!members || members.entries.length === 0) && negative) { this.raiseError("Member list is empty at Caret"); - } else if ((members && members.entries.length !== 0) && !negative) { + } + else if ((members && members.entries.length !== 0) && !negative) { let errorMsg = "\n" + "Member List contains: [" + members.entries[0].name; for (let i = 1; i < members.entries.length; i++) { @@ -692,7 +648,8 @@ module FourSlash { if ((completions && !completions.isNewIdentifierLocation) && !negative) { this.raiseError("Expected builder completion entry"); - } else if ((completions && completions.isNewIdentifierLocation) && negative) { + } + else if ((completions && completions.isNewIdentifierLocation) && negative) { this.raiseError("Un-expected builder completion entry"); } } @@ -804,7 +761,7 @@ module FourSlash { this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${JSON.stringify(missingItem)} in the returned list: (${JSON.stringify(references)})`); } - public verifyReferencesCountIs(count: number, localFilesOnly: boolean = true) { + public verifyReferencesCountIs(count: number, localFilesOnly = true) { this.taoInvalidReason = "verifyReferences NYI"; let references = this.getReferencesAtCaret(); @@ -885,7 +842,8 @@ module FourSlash { if (expectedDocumentation != undefined) { assert.notEqual(actualQuickInfoDocumentation, expectedDocumentation, this.messageAtLastKnownMarker("quick info doc comment")); } - } else { + } + else { if (expectedText !== undefined) { assert.equal(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text")); } @@ -1067,7 +1025,8 @@ module FourSlash { if (!actual) { this.raiseError("Expected signature help to be present, but it wasn't"); } - } else { + } + else { if (actual) { this.raiseError(`Expected no signature help, but got "${JSON.stringify(actual)}"`); } @@ -1247,21 +1206,21 @@ module FourSlash { emitFiles.forEach(emitFile => { let emitOutput = this.languageService.getEmitOutput(emitFile.fileName); // Print emitOutputStatus in readable format - resultString += "EmitSkipped: " + emitOutput.emitSkipped + ts.sys.newLine; + resultString += "EmitSkipped: " + emitOutput.emitSkipped + Harness.IO.newLine(); if (emitOutput.emitSkipped) { - resultString += "Diagnostics:" + ts.sys.newLine; + resultString += "Diagnostics:" + Harness.IO.newLine(); let diagnostics = ts.getPreEmitDiagnostics(this.languageService.getProgram()); for (let i = 0, n = diagnostics.length; i < n; i++) { - resultString += " " + diagnostics[0].messageText + ts.sys.newLine; + resultString += " " + diagnostics[0].messageText + Harness.IO.newLine(); } } emitOutput.outputFiles.forEach((outputFile, idx, array) => { - let fileName = "FileName : " + outputFile.name + ts.sys.newLine; + let fileName = "FileName : " + outputFile.name + Harness.IO.newLine(); resultString = resultString + fileName + outputFile.text; }); - resultString += ts.sys.newLine; + resultString += Harness.IO.newLine(); }); return resultString; @@ -1298,7 +1257,7 @@ module FourSlash { Harness.IO.log( "start: " + err.start + ", length: " + err.length + - ", message: " + ts.flattenDiagnosticMessageText(err.messageText, ts.sys.newLine)); + ", message: " + ts.flattenDiagnosticMessageText(err.messageText, Harness.IO.newLine())); }); } } @@ -1424,7 +1383,8 @@ module FourSlash { public type(text: string) { if (text === "") { this.taoInvalidReason = "Test used empty-insert workaround."; - } else { + } + else { this.scenarioActions.push(``); } @@ -1451,7 +1411,8 @@ module FourSlash { if (ch === "(" || ch === ",") { /* Signature help*/ this.languageService.getSignatureHelpItems(this.activeFile.fileName, offset); - } else if (prevChar === " " && /A-Za-z_/.test(ch)) { + } + else if (prevChar === " " && /A-Za-z_/.test(ch)) { /* Completions */ this.languageService.getCompletionsAtPosition(this.activeFile.fileName, offset); } @@ -1600,7 +1561,8 @@ module FourSlash { if (marker.position < limChar) { // Marker is inside the edit - mark it as invalidated (?) marker.position = -1; - } else { + } + else { // Move marker back/forward by the appropriate amount marker.position += (minChar - limChar) + text.length; } @@ -1621,7 +1583,8 @@ module FourSlash { public goToDefinition(definitionIndex: number) { if (definitionIndex === 0) { this.scenarioActions.push(""); - } else { + } + else { this.taoInvalidReason = "GoToDefinition not supported for non-zero definition indices"; } @@ -1703,7 +1666,8 @@ module FourSlash { if (negative) { assert.notEqual(actualDefinitionName, expectedName, this.messageAtLastKnownMarker("Definition Info Name")); assert.notEqual(actualDefinitionContainerName, expectedContainerName, this.messageAtLastKnownMarker("Definition Info Container Name")); - } else { + } + else { assert.equal(actualDefinitionName, expectedName, this.messageAtLastKnownMarker("Definition Info Name")); assert.equal(actualDefinitionContainerName, expectedContainerName, this.messageAtLastKnownMarker("Definition Info Container Name")); } @@ -1872,9 +1836,9 @@ module FourSlash { } function jsonMismatchString() { - return ts.sys.newLine + - "expected: '" + ts.sys.newLine + JSON.stringify(expected, (k, v) => v, 2) + "'" + ts.sys.newLine + - "actual: '" + ts.sys.newLine + JSON.stringify(actual, (k, v) => v, 2) + "'"; + return Harness.IO.newLine() + + "expected: '" + Harness.IO.newLine() + JSON.stringify(expected, (k, v) => v, 2) + "'" + Harness.IO.newLine() + + "actual: '" + Harness.IO.newLine() + JSON.stringify(actual, (k, v) => v, 2) + "'"; } } @@ -1950,26 +1914,33 @@ module FourSlash { if (expected === undefined) { if (actual) { - this.raiseError(name + ' failed - expected no template but got {newText: \"' + actual.newText + '\" caretOffset: ' + actual.caretOffset + '}'); + this.raiseError(name + " failed - expected no template but got {newText: \"" + actual.newText + "\" caretOffset: " + actual.caretOffset + "}"); } return; } else { if (actual === undefined) { - this.raiseError(name + ' failed - expected the template {newText: \"' + actual.newText + '\" caretOffset: ' + actual.caretOffset + '} but got nothing instead'); + this.raiseError(name + " failed - expected the template {newText: \"" + actual.newText + "\" caretOffset: " + actual.caretOffset + "} but got nothing instead"); } if (actual.newText !== expected.newText) { - this.raiseError(name + ' failed - expected insertion:\n' + expected.newText + '\nactual insertion:\n' + actual.newText); + this.raiseError(name + " failed - expected insertion:\n" + this.clarifyNewlines(expected.newText) + "\nactual insertion:\n" + this.clarifyNewlines(actual.newText)); } if (actual.caretOffset !== expected.caretOffset) { - this.raiseError(name + ' failed - expected caretOffset: ' + expected.caretOffset + ',\nactual caretOffset:' + actual.caretOffset); + this.raiseError(name + " failed - expected caretOffset: " + expected.caretOffset + ",\nactual caretOffset:" + actual.caretOffset); } } } + private clarifyNewlines(str: string) { + return str.replace(/\r?\n/g, lineEnding => { + const representation = lineEnding === "\r\n" ? "CRLF" : "LF"; + return "# - " + representation + lineEnding; + }); + } + public verifyMatchingBracePosition(bracePosition: number, expectedMatchPosition: number) { this.taoInvalidReason = "verifyMatchingBracePosition NYI"; @@ -1982,9 +1953,11 @@ module FourSlash { let actualMatchPosition = -1; if (bracePosition === actual[0].start) { actualMatchPosition = actual[1].start; - } else if (bracePosition === actual[1].start) { + } + else if (bracePosition === actual[1].start) { actualMatchPosition = actual[0].start; - } else { + } + else { this.raiseError(`verifyMatchingBracePosition failed - could not find the brace position: ${bracePosition} in the returned list: (${actual[0].start},${ts.textSpanEnd(actual[0])}) and (${actual[1].start},${ts.textSpanEnd(actual[1])})`); } @@ -2154,7 +2127,7 @@ module FourSlash { let occurrences = this.getOccurrencesAtCurrentPosition(); if (!occurrences || occurrences.length === 0) { - this.raiseError('verifyOccurrencesAtPositionListContains failed - found 0 references, expected at least one.'); + this.raiseError("verifyOccurrencesAtPositionListContains failed - found 0 references, expected at least one."); } for (let occurrence of occurrences) { @@ -2186,12 +2159,12 @@ module FourSlash { } public verifyDocumentHighlightsAtPositionListContains(fileName: string, start: number, end: number, fileNamesToSearch: string[], kind?: string) { - this.taoInvalidReason = 'verifyDocumentHighlightsAtPositionListContains NYI'; + this.taoInvalidReason = "verifyDocumentHighlightsAtPositionListContains NYI"; let documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNamesToSearch); if (!documentHighlights || documentHighlights.length === 0) { - this.raiseError('verifyDocumentHighlightsAtPositionListContains failed - found 0 highlights, expected at least one.'); + this.raiseError("verifyDocumentHighlightsAtPositionListContains failed - found 0 highlights, expected at least one."); } for (let documentHighlight of documentHighlights) { @@ -2214,15 +2187,15 @@ module FourSlash { } public verifyDocumentHighlightsAtPositionListCount(expectedCount: number, fileNamesToSearch: string[]) { - this.taoInvalidReason = 'verifyDocumentHighlightsAtPositionListCount NYI'; + this.taoInvalidReason = "verifyDocumentHighlightsAtPositionListCount NYI"; let documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNamesToSearch); - let actualCount = documentHighlights - ? documentHighlights.reduce((currentCount, { highlightSpans }) => currentCount + highlightSpans.length, 0) + let actualCount = documentHighlights + ? documentHighlights.reduce((currentCount, { highlightSpans }) => currentCount + highlightSpans.length, 0) : 0; if (expectedCount !== actualCount) { - this.raiseError('verifyDocumentHighlightsAtPositionListCount failed - actual: ' + actualCount + ', expected:' + expectedCount); + this.raiseError("verifyDocumentHighlightsAtPositionListCount failed - actual: " + actualCount + ", expected:" + expectedCount); } } @@ -2296,10 +2269,12 @@ module FourSlash { let index = indexOrName; if (index >= this.testData.files.length) { throw new Error(`File index (${index}) in openFile was out of range. There are only ${this.testData.files.length} files in this test.`); - } else { + } + else { result = this.testData.files[index]; } - } else if (typeof indexOrName === "string") { + } + else if (typeof indexOrName === "string") { let name = indexOrName; // names are stored in the compiler with this relative path, this allows people to use goTo.file on just the fileName @@ -2322,7 +2297,8 @@ module FourSlash { if (!foundIt) { throw new Error(`No test file named "${name}" exists. Available file names are: ${availableNames.join(", ")}`); } - } else { + } + else { throw new Error("Unknown argument type"); } @@ -2340,7 +2316,8 @@ module FourSlash { let markerNames: string[] = []; for (let m in this.testData.markerPositions) markerNames.push(m); throw new Error(`Unknown marker "${markerName}" Available markers: ${markerNames.map(m => "\"" + m + "\"").join(", ")}`); - } else { + } + else { return markerPos; } } @@ -2383,7 +2360,7 @@ module FourSlash { let host = Harness.Compiler.createCompilerHost([{ unitName: Harness.Compiler.fourslashFileName, content: undefined }], (fn, contents) => fourslashJsOutput = contents, ts.ScriptTarget.Latest, - ts.sys.useCaseSensitiveFileNames); + Harness.IO.useCaseSensitiveFileNames()); let program = ts.createProgram([Harness.Compiler.fourslashFileName], { noResolve: true, target: ts.ScriptTarget.ES3 }, host); @@ -2405,16 +2382,16 @@ module FourSlash { ], (fn, contents) => result = contents, ts.ScriptTarget.Latest, - ts.sys.useCaseSensitiveFileNames); + Harness.IO.useCaseSensitiveFileNames()); - let program = ts.createProgram([Harness.Compiler.fourslashFileName, fileName], { out: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host); + let program = ts.createProgram([Harness.Compiler.fourslashFileName, fileName], { outFile: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host); let sourceFile = host.getSourceFile(fileName, ts.ScriptTarget.ES3); let diagnostics = ts.getPreEmitDiagnostics(program, sourceFile); if (diagnostics.length > 0) { throw new Error(`Error compiling ${fileName}: ` + - diagnostics.map(e => ts.flattenDiagnosticMessageText(e.messageText, ts.sys.newLine)).join("\r\n")); + diagnostics.map(e => ts.flattenDiagnosticMessageText(e.messageText, Harness.IO.newLine())).join("\r\n")); } program.emit(sourceFile); @@ -2485,22 +2462,28 @@ module FourSlash { // Append to the current subfile content, inserting a newline needed if (currentFileContent === null) { currentFileContent = ""; - } else { + } + else { // End-of-line currentFileContent = currentFileContent + "\n"; } currentFileContent = currentFileContent + line.substr(4); - } else if (line.substr(0, 2) === "//") { + } + else if (line.substr(0, 2) === "//") { // Comment line, check for global/file @options and record them let match = optionRegex.exec(line.substr(2)); if (match) { - let globalMetadataNamesIndex = globalMetadataNames.indexOf(match[1]); let fileMetadataNamesIndex = fileMetadataNames.indexOf(match[1]); - if (globalMetadataNamesIndex === -1) { - if (fileMetadataNamesIndex === -1) { - throw new Error(`Unrecognized metadata name "${match[1]}". Available global metadata names are: ${globalMetadataNames.join(", ")}; file metadata names are: ${fileMetadataNames.join(", ")}`); - } else if (fileMetadataNamesIndex === fileMetadataNames.indexOf(metadataOptionNames.fileName)) { + if (fileMetadataNamesIndex === -1) { + // Check if the match is already existed in the global options + if (globalOptions[match[1]] !== undefined) { + throw new Error("Global Option : '" + match[1] + "' is already existed"); + } + globalOptions[match[1]] = match[2]; + } + else { + if (fileMetadataNamesIndex === fileMetadataNames.indexOf(metadataOptionNames.fileName)) { // Found an @FileName directive, if this is not the first then create a new subfile if (currentFileContent) { let file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges); @@ -2517,23 +2500,20 @@ module FourSlash { currentFileName = basePath + "/" + match[2]; currentFileOptions[match[1]] = match[2]; - } else { + } + else { // Add other fileMetadata flag currentFileOptions[match[1]] = match[2]; } - } else { - // Check if the match is already existed in the global options - if (globalOptions[match[1]] !== undefined) { - throw new Error("Global Option : '" + match[1] + "' is already existed"); - } - globalOptions[match[1]] = match[2]; } } // TODO: should be '==='? - } else if (line == "" || lineLength === 0) { + } + else if (line == "" || lineLength === 0) { // Previously blank lines between fourslash content caused it to be considered as 2 files, // Remove this behavior since it just causes errors now - } else { + } + else { // Empty line or code line, terminate current subfile if there is one if (currentFileContent) { let file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges); @@ -2603,7 +2583,8 @@ module FourSlash { try { // Attempt to parse the marker value as JSON markerValue = JSON.parse("{ " + text + " }"); - } catch (e) { + } + catch (e) { reportError(fileName, location.sourceLine, location.sourceColumn, "Unable to parse marker text " + e.message); } @@ -2639,7 +2620,8 @@ module FourSlash { let message = "Marker '" + name + "' is duplicated in the source file contents."; reportError(marker.fileName, location.sourceLine, location.sourceColumn, message); return null; - } else { + } + else { markerMap[name] = marker; markers.push(marker); return marker; @@ -2653,7 +2635,7 @@ module FourSlash { let validMarkerChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz$1234567890_"; /// The file content (minus metacharacters) so far - let output: string = ""; + let output = ""; /// The current marker (or maybe multi-line comment?) we're parsing, possibly let openMarker: ILocationInformation = null; @@ -2665,22 +2647,23 @@ module FourSlash { let localRanges: Range[] = []; /// The latest position of the start of an unflushed plain text area - let lastNormalCharPosition: number = 0; + let lastNormalCharPosition = 0; /// The total number of metacharacters removed from the file (so far) - let difference: number = 0; + let difference = 0; /// The fourslash file state object we are generating let state: State = State.none; /// Current position data - let line: number = 1; - let column: number = 1; + let line = 1; + let column = 1; let flush = (lastSafeCharIndex: number) => { if (lastSafeCharIndex === undefined) { output = output + content.substr(lastNormalCharPosition); - } else { + } + else { output = output + content.substr(lastNormalCharPosition, lastSafeCharIndex - lastNormalCharPosition); } }; @@ -2703,7 +2686,8 @@ module FourSlash { flush(i - 1); lastNormalCharPosition = i + 1; difference += 2; - } else if (previousChar === "|" && currentChar === "]") { + } + else if (previousChar === "|" && currentChar === "]") { // found a range end let rangeStart = openRanges.pop(); if (!rangeStart) { @@ -2722,7 +2706,8 @@ module FourSlash { flush(i - 1); lastNormalCharPosition = i + 1; difference += 2; - } else if (previousChar === "/" && currentChar === "*") { + } + else if (previousChar === "/" && currentChar === "*") { // found a possible marker start state = State.inSlashStarMarker; openMarker = { @@ -2731,7 +2716,8 @@ module FourSlash { sourceLine: line, sourceColumn: column, }; - } else if (previousChar === "{" && currentChar === "|") { + } + else if (previousChar === "{" && currentChar === "|") { // found an object marker start state = State.inObjectMarker; openMarker = { @@ -2784,10 +2770,12 @@ module FourSlash { // Reset the state openMarker = null; state = State.none; - } else if (validMarkerChars.indexOf(currentChar) < 0) { + } + else if (validMarkerChars.indexOf(currentChar) < 0) { if (currentChar === "*" && i < content.length - 1 && content.charAt(i + 1) === "/") { // The marker is about to be closed, ignore the 'invalid' char - } else { + } + else { // We've hit a non-valid marker character, so we were actually in a block comment // Bail out the text we've gathered so far back into the output flush(i); @@ -2803,7 +2791,8 @@ module FourSlash { if (currentChar === "\n" && previousChar === "\r") { // Ignore trailing \n after a \r continue; - } else if (currentChar === "\n" || currentChar === "\r") { + } + else if (currentChar === "\n" || currentChar === "\r") { line++; column = 1; continue; diff --git a/src/harness/fourslashRunner.ts b/src/harness/fourslashRunner.ts index d30a30d88e3..867c0d5a4d6 100644 --- a/src/harness/fourslashRunner.ts +++ b/src/harness/fourslashRunner.ts @@ -1,6 +1,7 @@ /// /// /// +/* tslint:disable:no-null */ const enum FourSlashTestType { Native, @@ -25,8 +26,8 @@ class FourSlashRunner extends RunnerBase { this.testSuiteName = "fourslash-shims"; break; case FourSlashTestType.ShimsWithPreprocess: - this.basePath = 'tests/cases/fourslash/shims-pp'; - this.testSuiteName = 'fourslash-shims-pp'; + this.basePath = "tests/cases/fourslash/shims-pp"; + this.testSuiteName = "fourslash-shims-pp"; break; case FourSlashTestType.Server: this.basePath = "tests/cases/fourslash/server"; @@ -87,7 +88,8 @@ class FourSlashRunner extends RunnerBase { FourSlash.xmlData.forEach(xml => { if (xml.invalidReason !== null) { lines.push(""); - } else { + } + else { lines.push(" "); xml.actions.forEach(action => { lines.push(" " + action); diff --git a/src/harness/harness.ts b/src/harness/harness.ts index a0366c0c40b..a37b647a124 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -23,10 +23,10 @@ /// /// /// +/* tslint:disable:no-null */ // Block scoped definitions work poorly for global variables, temporarily enable var /* tslint:disable:no-var-keyword */ -var Buffer: BufferConstructor = require("buffer").Buffer; // this will work in the browser via browserify var _chai: typeof chai = require("chai"); @@ -36,7 +36,7 @@ declare var __dirname: string; // Node-specific var global = Function("return this").call(null); /* tslint:enable:no-var-keyword */ -module Utils { +namespace Utils { // Setup some globals based on the current environment export const enum ExecutionEnvironment { Node, @@ -58,6 +58,14 @@ module Utils { export let currentExecutionEnvironment = getExecutionEnvironment(); + const Buffer: BufferConstructor = currentExecutionEnvironment !== ExecutionEnvironment.Browser + ? require("buffer").Buffer + : undefined; + + export function encodeString(s: string): string { + return Buffer ? (new Buffer(s)).toString("utf8") : s; + } + export function evalFile(fileContents: string, fileName: string, nodeContext?: any) { let environment = getExecutionEnvironment(); switch (environment) { @@ -69,7 +77,8 @@ module Utils { let vm = require("vm"); if (nodeContext) { vm.runInNewContext(fileContents, nodeContext, fileName); - } else { + } + else { vm.runInThisContext(fileContents, fileName); } break; @@ -102,7 +111,7 @@ module Utils { let content: string = undefined; try { - content = ts.sys.readFile(Harness.userSpecifiedRoot + path); + content = Harness.IO.readFile(Harness.userSpecifiedRoot + path); } catch (err) { return undefined; @@ -119,7 +128,8 @@ module Utils { let cachedResult = cache[key]; if (cachedResult) { return cachedResult; - } else { + } + else { return cache[key] = f.apply(this, arguments); } }); @@ -190,7 +200,7 @@ module Utils { return { start: diagnostic.start, length: diagnostic.length, - messageText: ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine), + messageText: ts.flattenDiagnosticMessageText(diagnostic.messageText, Harness.IO.newLine()), category: (ts).DiagnosticCategory[diagnostic.category], code: diagnostic.code }; @@ -323,8 +333,8 @@ module Utils { assert.equal(d1.start, d2.start, "d1.start !== d2.start"); assert.equal(d1.length, d2.length, "d1.length !== d2.length"); assert.equal( - ts.flattenDiagnosticMessageText(d1.messageText, ts.sys.newLine), - ts.flattenDiagnosticMessageText(d2.messageText, ts.sys.newLine), "d1.messageText !== d2.messageText"); + ts.flattenDiagnosticMessageText(d1.messageText, Harness.IO.newLine()), + ts.flattenDiagnosticMessageText(d2.messageText, Harness.IO.newLine()), "d1.messageText !== d2.messageText"); assert.equal(d1.category, d2.category, "d1.category !== d2.category"); assert.equal(d1.code, d2.code, "d1.code !== d2.code"); } @@ -389,7 +399,7 @@ module Utils { } } -module Harness.Path { +namespace Harness.Path { export function getFileName(fullPath: string) { return fullPath.replace(/^.*[\\\/]/, ""); } @@ -402,8 +412,12 @@ module Harness.Path { } } -module Harness { +namespace Harness { export interface IO { + newLine(): string; + getCurrentDirectory(): string; + useCaseSensitiveFileNames(): boolean; + resolvePath(path: string): string; readFile(path: string): string; writeFile(path: string, contents: string): void; directoryName(path: string): string; @@ -414,10 +428,17 @@ module Harness { listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[]; log(text: string): void; getMemoryUsage?(): number; + args(): string[]; + getExecutingFilePath(): string; + exit(exitCode?: number): void; + readDirectory(path: string, extension?: string, exclude?: string[]): string[]; } export var IO: IO; - module IOImpl { + // harness always uses one kind of new line + const harnessNewLine = "\r\n"; + + namespace IOImpl { declare class Enumerator { public atEnd(): boolean; public moveNext(): boolean; @@ -425,20 +446,30 @@ module Harness { constructor(o: any); } - export module CScript { + export namespace CScript { let fso: any; if (global.ActiveXObject) { fso = new global.ActiveXObject("Scripting.FileSystemObject"); - } else { + } + else { fso = {}; } - export let readFile: typeof IO.readFile = ts.sys.readFile; - export let writeFile: typeof IO.writeFile = ts.sys.writeFile; - export let directoryName: typeof IO.directoryName = fso.GetParentFolderName; - export let directoryExists: typeof IO.directoryExists = fso.FolderExists; - export let fileExists: typeof IO.fileExists = fso.FileExists; - export let log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine; + export const args = () => ts.sys.args; + export const getExecutingFilePath = () => ts.sys.getExecutingFilePath(); + export const exit = (exitCode: number) => ts.sys.exit(exitCode); + export const resolvePath = (path: string) => ts.sys.resolvePath(path); + export const getCurrentDirectory = () => ts.sys.getCurrentDirectory(); + export const newLine = () => harnessNewLine; + export const useCaseSensitiveFileNames = () => ts.sys.useCaseSensitiveFileNames; + + export const readFile: typeof IO.readFile = path => ts.sys.readFile(path); + export const writeFile: typeof IO.writeFile = (path, content) => ts.sys.writeFile(path, content); + export const directoryName: typeof IO.directoryName = fso.GetParentFolderName; + export const directoryExists: typeof IO.directoryExists = fso.FolderExists; + export const fileExists: typeof IO.fileExists = fso.FileExists; + export const log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine; + export const readDirectory: typeof IO.readDirectory = (path, extension, exclude) => ts.sys.readDirectory(path, extension, exclude); export function createDirectory(path: string) { if (directoryExists(path)) { @@ -484,20 +515,31 @@ module Harness { }; } - export module Node { + export namespace Node { declare let require: any; let fs: any, pathModule: any; if (require) { fs = require("fs"); pathModule = require("path"); - } else { + } + else { fs = pathModule = {}; } - export let readFile: typeof IO.readFile = ts.sys.readFile; - export let writeFile: typeof IO.writeFile = ts.sys.writeFile; - export let fileExists: typeof IO.fileExists = fs.existsSync; - export let log: typeof IO.log = s => console.log(s); + export const resolvePath = (path: string) => ts.sys.resolvePath(path); + export const getCurrentDirectory = () => ts.sys.getCurrentDirectory(); + export const newLine = () => harnessNewLine; + export const useCaseSensitiveFileNames = () => ts.sys.useCaseSensitiveFileNames; + export const args = () => ts.sys.args; + export const getExecutingFilePath = () => ts.sys.getExecutingFilePath(); + export const exit = (exitCode: number) => ts.sys.exit(exitCode); + + export const readFile: typeof IO.readFile = path => ts.sys.readFile(path); + export const writeFile: typeof IO.writeFile = (path, content) => ts.sys.writeFile(path, content); + export const fileExists: typeof IO.fileExists = fs.existsSync; + export const log: typeof IO.log = s => console.log(s); + + export const readDirectory: typeof IO.readDirectory = (path, extension, exclude) => ts.sys.readDirectory(path, extension, exclude); export function createDirectory(path: string) { if (!directoryExists(path)) { @@ -508,7 +550,8 @@ module Harness { export function deleteFile(path: string) { try { fs.unlinkSync(path); - } catch (e) { + } + catch (e) { } } @@ -522,7 +565,8 @@ module Harness { // Node will just continue to repeat the root path, rather than return null if (dirPath === path) { dirPath = null; - } else { + } + else { return dirPath; } } @@ -559,15 +603,20 @@ module Harness { }; } - export module Network { + export namespace Network { let serverRoot = "http://localhost:8888/"; - // Unused? - let newLine = "\r\n"; - let currentDirectory = () => ""; - let supportsCodePage = () => false; + export const newLine = () => harnessNewLine; + export const useCaseSensitiveFileNames = () => false; + export const getCurrentDirectory = () => ""; + export const args = () => []; + export const getExecutingFilePath = () => ""; + export const exit = (exitCode: number) => {}; - module Http { + let supportsCodePage = () => false; + export let log = (s: string) => console.log(s); + + namespace Http { function waitForXHR(xhr: XMLHttpRequest) { while (xhr.readyState !== 4) { } return { status: xhr.status, responseText: xhr.responseText }; @@ -616,6 +665,7 @@ module Harness { xhr.send(contents); } catch (e) { + log(`XHR Error: ${e}`); return { status: 500, responseText: null }; } @@ -641,10 +691,12 @@ module Harness { if (dirPath.match(/localhost:\d+$/) || dirPath.match(/localhost:\d+\/$/)) { dirPath = null; // path + fileName - } else if (dirPath.indexOf(".") === -1) { + } + else if (dirPath.indexOf(".") === -1) { dirPath = dirPath.substring(0, dirPath.lastIndexOf("/")); // path - } else { + } + else { // strip any trailing slash if (dirPath.match(/.*\/$/)) { dirPath = dirPath.substring(0, dirPath.length - 2); @@ -655,6 +707,7 @@ module Harness { return dirPath; } export let directoryName: typeof IO.directoryName = Utils.memoize(directoryNameImpl); + export const resolvePath = (path: string) => directoryName(path); export function fileExists(path: string): boolean { let response = Http.getFileFromServerSync(serverRoot + path); @@ -667,7 +720,8 @@ module Harness { let results = response.responseText.split(","); if (spec) { return results.filter(file => spec.test(file)); - } else { + } + else { return results; } } @@ -677,13 +731,12 @@ module Harness { }; export let listFiles = Utils.memoize(_listFilesImpl); - export let log = (s: string) => console.log(s); - export function readFile(file: string) { let response = Http.getFileFromServerSync(serverRoot + file); if (response.status === 200) { return response.responseText; - } else { + } + else { return null; } } @@ -691,6 +744,10 @@ module Harness { export function writeFile(path: string, contents: string) { Http.writeToServerSync(serverRoot + path, "WRITE", contents); } + + export function readDirectory(path: string, extension?: string, exclude?: string[]) { + return listFiles(path).filter(f => !extension || ts.fileExtensionIs(f, extension)); + } } } @@ -707,7 +764,7 @@ module Harness { } } -module Harness { +namespace Harness { let tcServicesFileName = "typescriptServices.js"; export let libFolder: string; @@ -738,7 +795,7 @@ module Harness { export let lightMode = false; /** Functionality for compiling TypeScript code */ - export module Compiler { + export namespace Compiler { /** Aggregate various writes into a single array of lines. Useful for passing to the * TypeScript compiler to fill with source code or errors. */ @@ -812,12 +869,12 @@ module Harness { } export function createSourceFileAndAssertInvariants( - fileName: string, - sourceText: string, - languageVersion: ts.ScriptTarget) { + fileName: string, + sourceText: string, + languageVersion: ts.ScriptTarget) { // We'll only assert inletiants outside of light mode. const shouldAssertInvariants = !Harness.lightMode; - + // Only set the parent nodes if we're asserting inletiants. We don't need them otherwise. let result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldAssertInvariants); @@ -840,17 +897,17 @@ module Harness { export let fourslashSourceFile: ts.SourceFile; export function getCanonicalFileName(fileName: string): string { - return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return Harness.IO.useCaseSensitiveFileNames() ? fileName : fileName.toLowerCase(); } export function createCompilerHost( - inputFiles: { unitName: string; content: string; }[], - writeFile: (fn: string, contents: string, writeByteOrderMark: boolean) => void, - scriptTarget: ts.ScriptTarget, - useCaseSensitiveFileNames: boolean, - // the currentDirectory is needed for rwcRunner to passed in specified current directory to compiler host - currentDirectory?: string, - newLineKind?: ts.NewLineKind): ts.CompilerHost { + inputFiles: { unitName: string; content: string; }[], + writeFile: (fn: string, contents: string, writeByteOrderMark: boolean) => void, + scriptTarget: ts.ScriptTarget, + useCaseSensitiveFileNames: boolean, + // the currentDirectory is needed for rwcRunner to passed in specified current directory to compiler host + currentDirectory?: string, + newLineKind?: ts.NewLineKind): ts.CompilerHost { // Local get canonical file name function, that depends on passed in parameter for useCaseSensitiveFileNames function getCanonicalFileName(fileName: string): string { @@ -858,7 +915,7 @@ module Harness { } let filemap: { [fileName: string]: ts.SourceFile; } = {}; - let getCurrentDirectory = currentDirectory === undefined ? ts.sys.getCurrentDirectory : () => currentDirectory; + let getCurrentDirectory = currentDirectory === undefined ? Harness.IO.getCurrentDirectory : () => currentDirectory; // Register input files function register(file: { unitName: string; content: string; }) { @@ -868,7 +925,7 @@ module Harness { } }; inputFiles.forEach(register); - + function getSourceFile(fn: string, languageVersion: ts.ScriptTarget) { fn = ts.normalizePath(fn); if (Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(fn))) { @@ -895,7 +952,7 @@ module Harness { let newLine = newLineKind === ts.NewLineKind.CarriageReturnLineFeed ? carriageReturnLineFeed : newLineKind === ts.NewLineKind.LineFeed ? lineFeed : - ts.sys.newLine; + Harness.IO.newLine(); return { getCurrentDirectory, @@ -910,16 +967,79 @@ module Harness { }; } + interface HarnessOptions { + useCaseSensitiveFileNames?: boolean; + includeBuiltFile?: string; + baselineFile?: string; + } + + // Additional options not already in ts.optionDeclarations + const harnessOptionDeclarations: ts.CommandLineOption[] = [ + { name: "allowNonTsExtensions", type: "boolean" }, + { name: "useCaseSensitiveFileNames", type: "boolean" }, + { name: "baselineFile", type: "string" }, + { name: "includeBuiltFile", type: "string" }, + { name: "fileName", type: "string" }, + { name: "noErrorTruncation", type: "boolean" } + ]; + + let optionsIndex: ts.Map; + function getCommandLineOption(name: string): ts.CommandLineOption { + if (!optionsIndex) { + optionsIndex = {}; + let optionDeclarations = harnessOptionDeclarations.concat(ts.optionDeclarations); + for (let option of optionDeclarations) { + optionsIndex[option.name.toLowerCase()] = option; + } + } + return ts.lookUp(optionsIndex, name.toLowerCase()); + } + + export function setCompilerOptionsFromHarnessSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnessOptions): void { + for (let name in settings) { + if (settings.hasOwnProperty(name)) { + let value = settings[name]; + if (value === undefined) { + throw new Error(`Cannot have undefined value for compiler option '${name}'.`); + } + let option = getCommandLineOption(name); + if (option) { + switch (option.type) { + case "boolean": + options[option.name] = value.toLowerCase() === "true"; + break; + case "string": + options[option.name] = value; + break; + // If not a primitive, the possible types are specified in what is effectively a map of options. + default: + let map = >option.type; + let key = value.toLowerCase(); + if (ts.hasProperty(map, key)) { + options[option.name] = map[key]; + } + else { + throw new Error(`Unknown value '${value}' for compiler option '${name}'.`); + } + } + } + else { + throw new Error(`Unknown compiler option '${name}'.`); + } + } + } + } + export class HarnessCompiler { private inputFiles: { unitName: string; content: string }[] = []; private compileOptions: ts.CompilerOptions; - private settings: Harness.TestCaseParser.CompilerSetting[] = []; + private settings: Harness.TestCaseParser.CompilerSettings = {}; private lastErrors: ts.Diagnostic[]; public reset() { this.inputFiles = []; - this.settings = []; + this.settings = {}; this.lastErrors = []; } @@ -927,11 +1047,7 @@ module Harness { return this.lastErrors; } - public setCompilerSettingsFromOptions(tcSettings: ts.CompilerOptions) { - this.settings = Object.keys(tcSettings).map(k => ({ flag: k, value: (tcSettings)[k] })); - } - - public setCompilerSettings(tcSettings: Harness.TestCaseParser.CompilerSetting[]) { + public setCompilerSettings(tcSettings: Harness.TestCaseParser.CompilerSettings) { this.settings = tcSettings; } @@ -967,7 +1083,7 @@ module Harness { otherFiles: { unitName: string; content: string }[], onComplete: (result: CompilerResult, program: ts.Program) => void, settingsCallback?: (settings: ts.CompilerOptions) => void, - options?: ts.CompilerOptions, + options?: ts.CompilerOptions & HarnessOptions, // Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file currentDirectory?: string) { @@ -976,20 +1092,26 @@ module Harness { options.module = options.module || ts.ModuleKind.None; options.newLine = options.newLine || ts.NewLineKind.CarriageReturnLineFeed; options.noErrorTruncation = true; + options.skipDefaultLibCheck = true; if (settingsCallback) { settingsCallback(null); } let newLine = "\r\n"; - options.skipDefaultLibCheck = true; + + // Parse settings + setCompilerOptionsFromHarnessSetting(this.settings, options); // Files from built\local that are requested by test "@includeBuiltFiles" to be in the context. // Treat them as library files, so include them in build, but not in baselines. let includeBuiltFiles: { unitName: string; content: string }[] = []; + if (options.includeBuiltFile) { + let builtFileName = libFolder + options.includeBuiltFile; + includeBuiltFiles.push({ unitName: builtFileName, content: normalizeLineEndings(IO.readFile(builtFileName), newLine) }); + } - let useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames; - this.settings.forEach(setCompilerOptionForSetting); + let useCaseSensitiveFileNames = options.useCaseSensitiveFileNames !== undefined ? options.useCaseSensitiveFileNames : Harness.IO.useCaseSensitiveFileNames(); let fileOutputs: GeneratedFile[] = []; @@ -1006,186 +1128,10 @@ module Harness { let errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); this.lastErrors = errors; - let result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps); + let result = new CompilerResult(fileOutputs, errors, program, Harness.IO.getCurrentDirectory(), emitResult.sourceMaps); onComplete(result, program); - // reset what newline means in case the last test changed it - ts.sys.newLine = newLine; return options; - - function setCompilerOptionForSetting(setting: Harness.TestCaseParser.CompilerSetting) { - switch (setting.flag.toLowerCase()) { - // "fileName", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve" - case "module": - case "modulegentarget": - if (typeof setting.value === "string") { - if (setting.value.toLowerCase() === "amd") { - options.module = ts.ModuleKind.AMD; - } else if (setting.value.toLowerCase() === "umd") { - options.module = ts.ModuleKind.UMD; - } else if (setting.value.toLowerCase() === "commonjs") { - options.module = ts.ModuleKind.CommonJS; - } else if (setting.value.toLowerCase() === "system") { - options.module = ts.ModuleKind.System; - } else if (setting.value.toLowerCase() === "unspecified") { - options.module = ts.ModuleKind.None; - } else { - throw new Error("Unknown module type " + setting.value); - } - } else { - options.module = setting.value; - } - break; - - case "target": - case "codegentarget": - if (typeof setting.value === "string") { - if (setting.value.toLowerCase() === "es3") { - options.target = ts.ScriptTarget.ES3; - } else if (setting.value.toLowerCase() === "es5") { - options.target = ts.ScriptTarget.ES5; - } else if (setting.value.toLowerCase() === "es6") { - options.target = ts.ScriptTarget.ES6; - } else { - throw new Error("Unknown compile target " + setting.value); - } - } else { - options.target = setting.value; - } - break; - - case "experimentaldecorators": - options.experimentalDecorators = setting.value === "true"; - break; - - case "emitdecoratormetadata": - options.emitDecoratorMetadata = setting.value === "true"; - break; - - case "experimentalasyncfunctions": - options.experimentalAsyncFunctions = setting.value === "true"; - break; - - case "noemithelpers": - options.noEmitHelpers = setting.value === "true"; - break; - - case "noemitonerror": - options.noEmitOnError = setting.value === "true"; - break; - - case "noresolve": - options.noResolve = setting.value === "true"; - break; - - case "noimplicitany": - options.noImplicitAny = setting.value === "true"; - break; - - case "nolib": - options.noLib = setting.value === "true"; - break; - - case "out": - case "outfileoption": - options.out = setting.value; - break; - - case "outdiroption": - case "outdir": - options.outDir = setting.value; - break; - - case "skipdefaultlibcheck": - options.skipDefaultLibCheck = setting.value === "true"; - break; - - case "sourceroot": - options.sourceRoot = setting.value; - break; - - case "maproot": - options.mapRoot = setting.value; - break; - - case "sourcemap": - options.sourceMap = setting.value === "true"; - break; - - case "declaration": - options.declaration = setting.value === "true"; - break; - - case "newline": - if (setting.value.toLowerCase() === "crlf") { - options.newLine = ts.NewLineKind.CarriageReturnLineFeed; - } - else if (setting.value.toLowerCase() === "lf") { - options.newLine = ts.NewLineKind.LineFeed; - } - else { - throw new Error("Unknown option for newLine: " + setting.value); - } - break; - - case "comments": - options.removeComments = setting.value === "false"; - break; - - case "stripinternal": - options.stripInternal = setting.value === "true"; - - case "usecasesensitivefilenames": - useCaseSensitiveFileNames = setting.value === "true"; - break; - - case "filename": - // Not supported yet - break; - - case "emitbom": - options.emitBOM = setting.value === "true"; - break; - - case "errortruncation": - options.noErrorTruncation = setting.value === "false"; - break; - - case "preserveconstenums": - options.preserveConstEnums = setting.value === "true"; - break; - - case "isolatedmodules": - options.isolatedModules = setting.value === "true"; - break; - - case "suppressimplicitanyindexerrors": - options.suppressImplicitAnyIndexErrors = setting.value === "true"; - break; - - case "includebuiltfile": - let builtFileName = libFolder + setting.value; - includeBuiltFiles.push({ unitName: builtFileName, content: normalizeLineEndings(IO.readFile(builtFileName), newLine) }); - break; - - case "inlinesourcemap": - options.inlineSourceMap = setting.value === "true"; - break; - - case "inlinesources": - options.inlineSources = setting.value === "true"; - break; - - case "jsx": - options.jsx = setting.value.toLowerCase() === "react" ? ts.JsxEmit.React : - setting.value.toLowerCase() === "preserve" ? ts.JsxEmit.Preserve : - ts.JsxEmit.None; - break; - - default: - throw new Error("Unsupported compiler setting " + setting.flag); - } - } } public compileDeclarationFiles(inputFiles: { unitName: string; content: string; }[], @@ -1229,7 +1175,8 @@ module Harness { assert(sourceFile, "Program has no source file with name '" + fileName + "'"); // Is this file going to be emitted separately let sourceFileName: string; - if (ts.isExternalModule(sourceFile) || !options.out) { + let outFile = options.outFile || options.out; + if (ts.isExternalModule(sourceFile) || !outFile) { if (options.outDir) { let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, result.currentDirectoryForProgram); sourceFilePath = sourceFilePath.replace(result.program.getCommonSourceDirectory(), ""); @@ -1241,7 +1188,7 @@ module Harness { } else { // Goes to single --out file - sourceFileName = options.out; + sourceFileName = outFile; } let dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts"; @@ -1273,7 +1220,7 @@ module Harness { errorOutput += diagnostic.file.fileName + "(" + (lineAndCharacter.line + 1) + "," + (lineAndCharacter.character + 1) + "): "; } - errorOutput += ts.DiagnosticCategory[diagnostic.category].toLowerCase() + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + ts.sys.newLine; + errorOutput += ts.DiagnosticCategory[diagnostic.category].toLowerCase() + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, Harness.IO.newLine()) + Harness.IO.newLine(); }); return errorOutput; @@ -1282,11 +1229,11 @@ module Harness { export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: ts.Diagnostic[]) { diagnostics.sort(ts.compareDiagnostics); let outputLines: string[] = []; - // Count up all the errors we find so we don't miss any - let totalErrorsReported = 0; + // Count up all errors that were found in files other than lib.d.ts so we don't miss any + let totalErrorsReportedInNonLibraryFiles = 0; function outputErrorText(error: ts.Diagnostic) { - let message = ts.flattenDiagnosticMessageText(error.messageText, ts.sys.newLine); + let message = ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine()); let errLines = RunnerBase.removeFullPaths(message) .split("\n") @@ -1295,7 +1242,14 @@ module Harness { .map(s => "!!! " + ts.DiagnosticCategory[error.category].toLowerCase() + " TS" + error.code + ": " + s); errLines.forEach(e => outputLines.push(e)); - totalErrorsReported++; + // do not count errors from lib.d.ts here, they are computed separately as numLibraryDiagnostics + // if lib.d.ts is explicitly included in input files and there are some errors in it (i.e. because of duplicate identifiers) + // then they will be added twice thus triggering 'total errors' assertion with condition + // 'totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length + + if (!error.file || !isLibraryFile(error.file.fileName)) { + totalErrorsReportedInNonLibraryFiles++; + } } // Report global errors @@ -1336,7 +1290,8 @@ module Harness { // On the last line of the file, fake the next line start number so that we handle errors on the last character of the file correctly if (lineIndex === lines.length - 1) { nextLineStart = inputFile.content.length; - } else { + } + else { nextLineStart = lineStarts[lineIndex + 1]; } // Emit this line from the original file @@ -1380,10 +1335,10 @@ module Harness { }); // Verify we didn't miss any errors in total - assert.equal(totalErrorsReported + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors"); + assert.equal(totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors"); return minimalDiagnosticsToString(diagnostics) + - ts.sys.newLine + ts.sys.newLine + outputLines.join("\r\n"); + Harness.IO.newLine() + Harness.IO.newLine() + outputLines.join("\r\n"); } export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): string { @@ -1400,7 +1355,7 @@ module Harness { // FileName header + content result += "/*====== " + outputFile.fileName + " ======*/\r\n"; - + result += outputFile.code; } @@ -1500,11 +1455,10 @@ module Harness { } } - export module TestCaseParser { + export namespace TestCaseParser { /** all the necessary information to set the right compiler settings */ - export interface CompilerSetting { - flag: string; - value: string; + export interface CompilerSettings { + [name: string]: string; } /** All the necessary information to turn a multi file test into useful units for later compilation */ @@ -1519,30 +1473,19 @@ module Harness { // Regex for parsing options in the format "@Alpha: Value of any sort" let optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines - // List of allowed metadata names - let fileMetadataNames = ["filename", "comments", "declaration", "module", - "nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror", - "noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom", - "errortruncation", "usecasesensitivefilenames", "preserveconstenums", - "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal", - "isolatedmodules", "inlinesourcemap", "maproot", "sourceroot", - "inlinesources", "emitdecoratormetadata", "experimentaldecorators", - "skipdefaultlibcheck", "jsx"]; - - function extractCompilerSettings(content: string): CompilerSetting[] { - - let opts: CompilerSetting[] = []; + function extractCompilerSettings(content: string): CompilerSettings { + let opts: CompilerSettings = {}; let match: RegExpExecArray; while ((match = optionRegex.exec(content)) != null) { - opts.push({ flag: match[1], value: match[2] }); + opts[match[1]] = match[2]; } return opts; } /** Given a test file containing // @FileName directives, return an array of named units of code to be added to an existing compiler instance */ - export function makeUnitsFromTest(code: string, fileName: string): { settings: CompilerSetting[]; testUnitData: TestUnitData[]; } { + export function makeUnitsFromTest(code: string, fileName: string): { settings: CompilerSettings; testUnitData: TestUnitData[]; } { let settings = extractCompilerSettings(code); // List of all the subfiles we've parsed out @@ -1565,7 +1508,8 @@ module Harness { let metaDataName = testMetaData[1].toLowerCase(); if (metaDataName === "filename") { currentFileOptions[testMetaData[1]] = testMetaData[2]; - } else { + } + else { continue; } @@ -1586,16 +1530,19 @@ module Harness { currentFileOptions = {}; currentFileName = testMetaData[2]; refs = []; - } else { + } + else { // First metadata marker in the file currentFileName = testMetaData[2]; } - } else { + } + else { // Subfile content line // Append to the current subfile content, inserting a newline needed if (currentFileContent === null) { currentFileContent = ""; - } else { + } + else { // End-of-line currentFileContent = currentFileContent + "\n"; } @@ -1621,7 +1568,7 @@ module Harness { } /** Support class for baseline files */ - export module Baseline { + export namespace Baseline { export interface BaselineOptions { Subfolder?: string; @@ -1649,7 +1596,8 @@ module Harness { function baselinePath(fileName: string, type: string, baselineFolder: string, subfolder?: string) { if (subfolder !== undefined) { return Harness.userSpecifiedRoot + baselineFolder + "/" + subfolder + "/" + type + "/" + fileName; - } else { + } + else { return Harness.userSpecifiedRoot + baselineFolder + "/" + type + "/" + fileName; } } @@ -1719,7 +1667,7 @@ module Harness { } function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string, descriptionForDescribe: string) { - let encoded_actual = (new Buffer(actual)).toString("utf8"); + let encoded_actual = Utils.encodeString(actual); if (expected != encoded_actual) { // Overwrite & issue error let errMsg = "The baseline file " + relativeFileName + " has changed"; @@ -1741,7 +1689,8 @@ module Harness { actual = generateActual(actualFileName, generateContent); let comparison = compareToBaseline(actual, relativeFileName, opts); writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, descriptionForDescribe); - } else { + } + else { actual = generateActual(actualFileName, generateContent); let comparison = compareToBaseline(actual, relativeFileName, opts); @@ -1758,11 +1707,11 @@ module Harness { return filePath.indexOf(Harness.libFolder) === 0; } - export function getDefaultLibraryFile(): { unitName: string, content: string } { - let libFile = Harness.userSpecifiedRoot + Harness.libFolder + "/" + "lib.d.ts"; + export function getDefaultLibraryFile(io: Harness.IO): { unitName: string, content: string } { + let libFile = Harness.userSpecifiedRoot + Harness.libFolder + "lib.d.ts"; return { unitName: libFile, - content: IO.readFile(libFile) + content: io.readFile(libFile) }; } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index f228bc862d8..dfde2bd1c08 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -3,11 +3,11 @@ /// /// -module Harness.LanguageService { +namespace Harness.LanguageService { export class ScriptInfo { public version: number = 1; public editRanges: { length: number; textChangeRange: ts.TextChangeRange; }[] = []; - public lineMap: number[] = null; + public lineMap: number[] = undefined; constructor(public fileName: string, public content: string) { this.setContent(content); @@ -95,8 +95,8 @@ module Harness.LanguageService { let oldShim = oldScript; let range = this.scriptSnapshot.getChangeRange(oldShim.scriptSnapshot); - if (range === null) { - return null; + if (range === undefined) { + return undefined; } return JSON.stringify({ span: { start: range.span.start, length: range.span.length }, newLength: range.newLength }); @@ -118,11 +118,11 @@ module Harness.LanguageService { getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo; } - export class LanguageServiceAdapterHost { + export class LanguageServiceAdapterHost { protected fileNameToScript: ts.Map = {}; - + constructor(protected cancellationToken = DefaultHostCancellationToken.Instance, - protected settings = ts.getDefaultCompilerOptions()) { + protected settings = ts.getDefaultCompilerOptions()) { } public getNewLine(): string { @@ -145,7 +145,7 @@ module Harness.LanguageService { public editScript(fileName: string, start: number, end: number, newText: string) { let script = this.getScriptInfo(fileName); - if (script !== null) { + if (script !== undefined) { script.editContent(start, end, newText); return; } @@ -169,7 +169,7 @@ module Harness.LanguageService { } /// Native adapter - class NativeLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceHost { + class NativeLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceHost { getCompilationSettings() { return this.settings; } getCancellationToken() { return this.cancellationToken; } getCurrentDirectory(): string { return ""; } @@ -191,7 +191,7 @@ module Harness.LanguageService { export class NativeLanugageServiceAdapter implements LanguageServiceAdapter { private host: NativeLanguageServiceHost; - constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { + constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { this.host = new NativeLanguageServiceHost(cancellationToken, options); } getHost() { return this.host; } @@ -204,14 +204,14 @@ module Harness.LanguageService { class ShimLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceShimHost, ts.CoreServicesShimHost { private nativeHost: NativeLanguageServiceHost; - public getModuleResolutionsForFile: (fileName: string)=> string; + public getModuleResolutionsForFile: (fileName: string) => string; constructor(preprocessToResolve: boolean, cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { super(cancellationToken, options); this.nativeHost = new NativeLanguageServiceHost(cancellationToken, options); if (preprocessToResolve) { - let compilerOptions = this.nativeHost.getCompilationSettings() + let compilerOptions = this.nativeHost.getCompilationSettings(); let moduleResolutionHost: ts.ModuleResolutionHost = { fileExists: fileName => this.getScriptInfo(fileName) !== undefined, readFile: fileName => { @@ -225,12 +225,12 @@ module Harness.LanguageService { let imports: ts.Map = {}; for (let module of preprocessInfo.importedFiles) { let resolutionInfo = ts.resolveModuleName(module.fileName, fileName, compilerOptions, moduleResolutionHost); - if (resolutionInfo.resolvedFileName) { - imports[module.fileName] = resolutionInfo.resolvedFileName; + if (resolutionInfo.resolvedModule) { + imports[module.fileName] = resolutionInfo.resolvedModule.resolvedFileName; } } return JSON.stringify(imports); - } + }; } } @@ -247,7 +247,7 @@ module Harness.LanguageService { getScriptFileNames(): string { return JSON.stringify(this.nativeHost.getScriptFileNames()); } getScriptSnapshot(fileName: string): ts.ScriptSnapshotShim { let nativeScriptSnapshot = this.nativeHost.getScriptSnapshot(fileName); - return nativeScriptSnapshot && new ScriptSnapshotProxy(nativeScriptSnapshot); + return nativeScriptSnapshot && new ScriptSnapshotProxy(nativeScriptSnapshot); } getScriptVersion(fileName: string): string { return this.nativeHost.getScriptVersion(fileName); } getLocalizedDiagnosticMessages(): string { return JSON.stringify({}); } @@ -255,17 +255,17 @@ module Harness.LanguageService { readDirectory(rootDir: string, extension: string): string { throw new Error("NYI"); } - fileExists(fileName: string) { return this.getScriptInfo(fileName) !== undefined; } - readFile(fileName: string) { + fileExists(fileName: string) { return this.getScriptInfo(fileName) !== undefined; } + readFile(fileName: string) { let snapshot = this.nativeHost.getScriptSnapshot(fileName); return snapshot && snapshot.getText(0, snapshot.getLength()); - } + } log(s: string): void { this.nativeHost.log(s); } trace(s: string): void { this.nativeHost.trace(s); } error(s: string): void { this.nativeHost.error(s); } } - class ClassifierShimProxy implements ts.Classifier { + class ClassifierShimProxy implements ts.Classifier { constructor(private shim: ts.ClassifierShim) { } getEncodedLexicalClassifications(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.Classifications { @@ -302,7 +302,7 @@ module Harness.LanguageService { if (parsedResult.error) { throw new Error("Language Service Shim Error: " + JSON.stringify(parsedResult.error)); } - else if (parsedResult.canceled) { + else if (parsedResult.canceled) { throw new ts.OperationCanceledException(); } return parsedResult.result; @@ -369,7 +369,7 @@ module Harness.LanguageService { getDefinitionAtPosition(fileName: string, position: number): ts.DefinitionInfo[] { return unwrapJSONCallResult(this.shim.getDefinitionAtPosition(fileName, position)); } - getTypeDefinitionAtPosition(fileName: string, position: number): ts.DefinitionInfo[]{ + getTypeDefinitionAtPosition(fileName: string, position: number): ts.DefinitionInfo[] { return unwrapJSONCallResult(this.shim.getTypeDefinitionAtPosition(fileName, position)); } getReferencesAtPosition(fileName: string, position: number): ts.ReferenceEntry[] { @@ -474,19 +474,19 @@ module Harness.LanguageService { } // Server adapter - class SessionClientHost extends NativeLanguageServiceHost implements ts.server.SessionClientHost { + class SessionClientHost extends NativeLanguageServiceHost implements ts.server.SessionClientHost { private client: ts.server.SessionClient; constructor(cancellationToken: ts.HostCancellationToken, settings: ts.CompilerOptions) { super(cancellationToken, settings); } - onMessage(message: string): void { - + onMessage(message: string): void { + } - writeMessage(message: string): void { - + writeMessage(message: string): void { + } setClient(client: ts.server.SessionClient) { @@ -504,7 +504,7 @@ module Harness.LanguageService { } } - class SessionServerHost implements ts.server.ServerHost, ts.server.Logger { + class SessionServerHost implements ts.server.ServerHost, ts.server.Logger { args: string[] = []; newLine: string; useCaseSensitiveFileNames: boolean = false; @@ -513,23 +513,23 @@ module Harness.LanguageService { this.newLine = this.host.getNewLine(); } - onMessage(message: string): void { - + onMessage(message: string): void { + } writeMessage(message: string): void { } - write(message: string): void { + write(message: string): void { this.writeMessage(message); } readFile(fileName: string): string { - if (fileName.indexOf(Harness.Compiler.defaultLibFileName) >= 0) { + if (fileName.indexOf(Harness.Compiler.defaultLibFileName) >= 0) { fileName = Harness.Compiler.defaultLibFileName; } - + let snapshot = this.host.getScriptSnapshot(fileName); return snapshot && snapshot.getText(0, snapshot.getLength()); } @@ -567,8 +567,8 @@ module Harness.LanguageService { readDirectory(path: string, extension?: string): string[] { throw new Error("Not implemented Yet."); } - - watchFile(fileName: string, callback: (fileName: string) => void): ts.FileWatcher { + + watchFile(fileName: string, callback: (fileName: string) => void): ts.FileWatcher { return { close() { } }; } @@ -582,7 +582,7 @@ module Harness.LanguageService { msg(message: string) { return this.host.log(message); } - + loggingEnabled() { return true; } @@ -602,7 +602,7 @@ module Harness.LanguageService { startGroup(): void { } } - + export class ServerLanugageServiceAdapter implements LanguageServiceAdapter { private host: SessionClientHost; private client: ts.server.SessionClient; diff --git a/src/harness/instrumenter.ts b/src/harness/instrumenter.ts index 1c9b9af78d2..b1b1750b8a8 100644 --- a/src/harness/instrumenter.ts +++ b/src/harness/instrumenter.ts @@ -3,11 +3,15 @@ var fs: any = require('fs'); var path: any = require('path'); function instrumentForRecording(fn: string, tscPath: string) { - instrument(tscPath, 'ts.sys = Playback.wrapSystem(ts.sys); ts.sys.startRecord("' + fn + '");', 'ts.sys.endRecord();'); + instrument(tscPath, ` +ts.sys = Playback.wrapSystem(ts.sys); +ts.sys.startRecord("${ fn }");`, `ts.sys.endRecord();`); } function instrumentForReplay(logFilename: string, tscPath: string) { - instrument(tscPath, 'ts.sys = Playback.wrapSystem(ts.sys); ts.sys.startReplay("' + logFilename + '");'); + instrument(tscPath, ` +ts.sys = Playback.wrapSystem(ts.sys); +ts.sys.startReplay("${ logFilename }");`); } function instrument(tscPath: string, prepareCode: string, cleanupCode: string = '') { diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index db82a47d362..d60756edf19 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -1,6 +1,7 @@ /// /// /// +/* tslint:disable:no-null */ interface FileInformation { contents: string; @@ -59,6 +60,12 @@ interface IOLog { path: string; result?: string; }[]; + directoriesRead: { + path: string, + extension: string, + exclude: string[], + result: string[] + }[]; } interface PlaybackControl { @@ -70,7 +77,7 @@ interface PlaybackControl { endRecord(): void; } -module Playback { +namespace Playback { let recordLog: IOLog = undefined; let replayLog: IOLog = undefined; let recordLogFileNameBase = ""; @@ -89,10 +96,12 @@ module Playback { run.reset = () => { lookup = null; }; - + return run; } + export interface PlaybackIO extends Harness.IO, PlaybackControl { } + export interface PlaybackSystem extends ts.System, PlaybackControl { } function createEmptyLog(): IOLog { @@ -101,6 +110,7 @@ module Playback { arguments: [], currentDirectory: "", filesRead: [], + directoriesRead: [], filesWritten: [], filesDeleted: [], filesAppended: [], @@ -114,8 +124,10 @@ module Playback { }; } - function initWrapper(wrapper: PlaybackControl, underlying: T) { - Object.keys(underlying).forEach(prop => { + function initWrapper(wrapper: PlaybackSystem, underlying: ts.System): void; + function initWrapper(wrapper: PlaybackIO, underlying: Harness.IO): void; + function initWrapper(wrapper: PlaybackSystem | PlaybackIO, underlying: ts.System | Harness.IO): void { + ts.forEach(Object.keys(underlying), prop => { (wrapper)[prop] = (underlying)[prop]; }); @@ -135,6 +147,93 @@ module Playback { wrapper.startRecord = (fileNameBase) => { recordLogFileNameBase = fileNameBase; recordLog = createEmptyLog(); + + if (typeof underlying.args !== "function") { + recordLog.arguments = underlying.args; + } + }; + + wrapper.startReplayFromFile = logFn => { + wrapper.startReplayFromString(underlying.readFile(logFn)); + }; + wrapper.endRecord = () => { + if (recordLog !== undefined) { + let i = 0; + let fn = () => recordLogFileNameBase + i + ".json"; + while (underlying.fileExists(fn())) i++; + underlying.writeFile(fn(), JSON.stringify(recordLog)); + recordLog = undefined; + } + }; + + wrapper.fileExists = recordReplay(wrapper.fileExists, underlying)( + path => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path }), + memoize(path => { + // If we read from the file, it must exist + if (findResultByPath(wrapper, replayLog.filesRead, path, null) !== null) { + return true; + } + else { + return findResultByFields(replayLog.fileExists, { path }, false); + } + }) + ); + + wrapper.getExecutingFilePath = () => { + if (replayLog !== undefined) { + return replayLog.executingPath; + } + else if (recordLog !== undefined) { + return recordLog.executingPath = underlying.getExecutingFilePath(); + } + else { + return underlying.getExecutingFilePath(); + } + }; + + wrapper.getCurrentDirectory = () => { + if (replayLog !== undefined) { + return replayLog.currentDirectory || ""; + } + else if (recordLog !== undefined) { + return recordLog.currentDirectory = underlying.getCurrentDirectory(); + } + else { + return underlying.getCurrentDirectory(); + } + }; + + wrapper.resolvePath = recordReplay(wrapper.resolvePath, underlying)( + path => callAndRecord(underlying.resolvePath(path), recordLog.pathsResolved, { path }), + memoize(path => findResultByFields(replayLog.pathsResolved, { path }, !ts.isRootedDiskPath(ts.normalizeSlashes(path)) && replayLog.currentDirectory ? replayLog.currentDirectory + "/" + path : ts.normalizeSlashes(path)))); + + wrapper.readFile = recordReplay(wrapper.readFile, underlying)( + path => { + let result = underlying.readFile(path); + let logEntry = { path, codepage: 0, result: { contents: result, codepage: 0 } }; + recordLog.filesRead.push(logEntry); + return result; + }, + memoize(path => findResultByPath(wrapper, replayLog.filesRead, path).contents)); + + wrapper.readDirectory = recordReplay(wrapper.readDirectory, underlying)( + (path, extension, exclude) => { + let result = (underlying).readDirectory(path, extension, exclude); + let logEntry = { path, extension, exclude, result }; + recordLog.directoriesRead.push(logEntry); + return result; + }, + (path, extension, exclude) => findResultByPath(wrapper, replayLog.directoriesRead.filter(d => d.extension === extension && ts.arrayIsEqualTo(d.exclude, exclude)), path)); + + wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)( + (path, contents) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }), + (path, contents) => noOpReplay("writeFile")); + + wrapper.exit = (exitCode) => { + if (recordLog !== undefined) { + wrapper.endRecord(); + } + underlying.exit(exitCode); }; } @@ -143,9 +242,11 @@ module Playback { return (function () { if (replayLog !== undefined) { return replay.apply(undefined, arguments); - } else if (recordLog !== undefined) { + } + else if (recordLog !== undefined) { return record.apply(undefined, arguments); - } else { + } + else { return original.apply(underlying, arguments); } }); @@ -169,7 +270,8 @@ module Playback { if (results.length === 0) { if (defaultValue !== undefined) { return defaultValue; - } else { + } + else { throw new Error("No matching result in log array for: " + JSON.stringify(expectedFields)); } } @@ -177,7 +279,7 @@ module Playback { } function findResultByPath(wrapper: { resolvePath(s: string): string }, logArray: { path: string; result?: T }[], expectedPath: string, defaultValue?: T): T { - let normalizedName = ts.normalizeSlashes(expectedPath).toLowerCase(); + let normalizedName = ts.normalizePath(expectedPath).toLowerCase(); // Try to find the result through normal fileName for (let i = 0; i < logArray.length; i++) { if (ts.normalizeSlashes(logArray[i].path).toLowerCase() === normalizedName) { @@ -193,10 +295,12 @@ module Playback { } } } + // If we got here, we didn't find a match if (defaultValue === undefined) { throw new Error("No matching result in log array for path: " + expectedPath); - } else { + } + else { return defaultValue; } } @@ -214,7 +318,8 @@ module Playback { } if (pathEquivCache.hasOwnProperty(key)) { return pathEquivCache[key]; - } else { + } + else { return pathEquivCache[key] = check(); } } @@ -223,91 +328,22 @@ module Playback { // console.log("Swallowed write operation during replay: " + name); } - export function wrapSystem(underlying: ts.System): PlaybackSystem { - let wrapper: PlaybackSystem = {}; + export function wrapIO(underlying: Harness.IO): PlaybackIO { + let wrapper: PlaybackIO = {}; initWrapper(wrapper, underlying); - wrapper.startReplayFromFile = logFn => { - wrapper.startReplayFromString(underlying.readFile(logFn)); - }; - wrapper.endRecord = () => { - if (recordLog !== undefined) { - let i = 0; - let fn = () => recordLogFileNameBase + i + ".json"; - while (underlying.fileExists(fn())) i++; - underlying.writeFile(fn(), JSON.stringify(recordLog)); - recordLog = undefined; - } - }; - - Object.defineProperty(wrapper, "args", { - get() { - if (replayLog !== undefined) { - return replayLog.arguments; - } else if (recordLog !== undefined) { - recordLog.arguments = underlying.args; - } - return underlying.args; - } - }); - - - wrapper.fileExists = recordReplay(wrapper.fileExists, underlying)( - (path) => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path: path }), - memoize((path) => { - // If we read from the file, it must exist - if (findResultByPath(wrapper, replayLog.filesRead, path, null) !== null) { - return true; - } else { - return findResultByFields(replayLog.fileExists, { path: path }, false); - } - }) - ); - - wrapper.getExecutingFilePath = () => { - if (replayLog !== undefined) { - return replayLog.executingPath; - } else if (recordLog !== undefined) { - return recordLog.executingPath = underlying.getExecutingFilePath(); - } else { - return underlying.getExecutingFilePath(); - } - }; - - wrapper.getCurrentDirectory = () => { - if (replayLog !== undefined) { - return replayLog.currentDirectory || ""; - } else if (recordLog !== undefined) { - return recordLog.currentDirectory = underlying.getCurrentDirectory(); - } else { - return underlying.getCurrentDirectory(); - } - }; - - wrapper.resolvePath = recordReplay(wrapper.resolvePath, underlying)( - (path) => callAndRecord(underlying.resolvePath(path), recordLog.pathsResolved, { path: path }), - memoize((path) => findResultByFields(replayLog.pathsResolved, { path: path }, !ts.isRootedDiskPath(ts.normalizeSlashes(path)) && replayLog.currentDirectory ? replayLog.currentDirectory + "/" + path : ts.normalizeSlashes(path)))); - - wrapper.readFile = recordReplay(wrapper.readFile, underlying)( - (path) => { - let result = underlying.readFile(path); - let logEntry = { path: path, codepage: 0, result: { contents: result, codepage: 0 } }; - recordLog.filesRead.push(logEntry); - return result; - }, - memoize((path) => findResultByPath(wrapper, replayLog.filesRead, path).contents)); - - wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)( - (path, contents) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path: path, contents: contents, bom: false }), - (path, contents) => noOpReplay("writeFile")); - - wrapper.exit = (exitCode) => { - if (recordLog !== undefined) { - wrapper.endRecord(); - } - underlying.exit(exitCode); - }; + wrapper.directoryName = (path): string => { throw new Error("NotSupported"); }; + wrapper.createDirectory = (path): void => { throw new Error("NotSupported"); }; + wrapper.directoryExists = (path): boolean => { throw new Error("NotSupported"); }; + wrapper.deleteFile = (path): void => { throw new Error("NotSupported"); }; + wrapper.listFiles = (path, filter, options): string[] => { throw new Error("NotSupported"); }; return wrapper; } + + export function wrapSystem(underlying: ts.System): PlaybackSystem { + let wrapper: PlaybackSystem = {}; + initWrapper(wrapper, underlying); + return wrapper; + } } \ No newline at end of file diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 1790956755a..862e446352d 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -1,5 +1,6 @@ /// /// +/* tslint:disable:no-null */ // Test case is json of below type in tests/cases/project/ interface ProjectRunnerTestCase { @@ -62,7 +63,7 @@ class ProjectRunner extends RunnerBase { let testFileText: string = null; try { - testFileText = ts.sys.readFile(testCaseFileName); + testFileText = Harness.IO.readFile(testCaseFileName); } catch (e) { assert(false, "Unable to open testcase file: " + testCaseFileName + ": " + e.message); @@ -98,7 +99,7 @@ class ProjectRunner extends RunnerBase { } function cleanProjectUrl(url: string) { - let diskProjectPath = ts.normalizeSlashes(ts.sys.resolvePath(testCase.projectRoot)); + let diskProjectPath = ts.normalizeSlashes(Harness.IO.resolvePath(testCase.projectRoot)); let projectRootUrl = "file:///" + diskProjectPath; let normalizedProjectRoot = ts.normalizeSlashes(testCase.projectRoot); diskProjectPath = diskProjectPath.substr(0, diskProjectPath.lastIndexOf(normalizedProjectRoot)); @@ -122,7 +123,7 @@ class ProjectRunner extends RunnerBase { } function getCurrentDirectory() { - return ts.sys.resolvePath(testCase.projectRoot); + return Harness.IO.resolvePath(testCase.projectRoot); } function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: () => string[], @@ -158,11 +159,12 @@ class ProjectRunner extends RunnerBase { return { declaration: !!testCase.declaration, sourceMap: !!testCase.sourceMap, - out: testCase.out, + outFile: testCase.out, outDir: testCase.outDir, - mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? ts.sys.resolvePath(testCase.mapRoot) : testCase.mapRoot, - sourceRoot: testCase.resolveSourceRoot && testCase.sourceRoot ? ts.sys.resolvePath(testCase.sourceRoot) : testCase.sourceRoot, + mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? Harness.IO.resolvePath(testCase.mapRoot) : testCase.mapRoot, + sourceRoot: testCase.resolveSourceRoot && testCase.sourceRoot ? Harness.IO.resolvePath(testCase.sourceRoot) : testCase.sourceRoot, module: moduleKind, + moduleResolution: ts.ModuleResolutionKind.Classic, // currently all tests use classic module resolution kind, this will change in the future noResolve: testCase.noResolve, rootDir: testCase.rootDir }; @@ -190,15 +192,15 @@ class ProjectRunner extends RunnerBase { writeFile, getCurrentDirectory, getCanonicalFileName: Harness.Compiler.getCanonicalFileName, - useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames, - getNewLine: () => ts.sys.newLine, + useCaseSensitiveFileNames: () => Harness.IO.useCaseSensitiveFileNames(), + getNewLine: () => Harness.IO.newLine(), fileExists: fileName => getSourceFile(fileName, ts.ScriptTarget.ES5) !== undefined, readFile: fileName => Harness.IO.readFile(fileName) }; } } - function batchCompilerProjectTestCase(moduleKind: ts.ModuleKind): BatchCompileProjectTestCaseResult{ + function batchCompilerProjectTestCase(moduleKind: ts.ModuleKind): BatchCompileProjectTestCaseResult { let nonSubfolderDiskFiles = 0; let outputFiles: BatchCompileProjectTestCaseEmittedFile[] = []; @@ -216,7 +218,7 @@ class ProjectRunner extends RunnerBase { function getSourceFileText(fileName: string): string { let text: string = undefined; try { - text = ts.sys.readFile(ts.isRootedDiskPath(fileName) + text = Harness.IO.readFile(ts.isRootedDiskPath(fileName) ? fileName : ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName)); } @@ -263,14 +265,14 @@ class ProjectRunner extends RunnerBase { // Actual writing of file as in tc.ts function ensureDirectoryStructure(directoryname: string) { if (directoryname) { - if (!ts.sys.directoryExists(directoryname)) { + if (!Harness.IO.directoryExists(directoryname)) { ensureDirectoryStructure(ts.getDirectoryPath(directoryname)); - ts.sys.createDirectory(directoryname); + Harness.IO.createDirectory(directoryname); } } } ensureDirectoryStructure(ts.getDirectoryPath(ts.normalizePath(outputFilePath))); - ts.sys.writeFile(outputFilePath, data, writeByteOrderMark); + Harness.IO.writeFile(outputFilePath, data); outputFiles.push({ emittedFileName: fileName, code: data, fileName: diskRelativeName, writeByteOrderMark: writeByteOrderMark }); } @@ -299,7 +301,7 @@ class ProjectRunner extends RunnerBase { allInputFiles.unshift(findOutpuDtsFile(outputDtsFileName)); } else { - let outputDtsFileName = ts.removeFileExtension(compilerOptions.out) + ".d.ts"; + let outputDtsFileName = ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; let outputDtsFile = findOutpuDtsFile(outputDtsFileName); if (!ts.contains(allInputFiles, outputDtsFile)) { allInputFiles.unshift(outputDtsFile); @@ -391,7 +393,7 @@ class ProjectRunner extends RunnerBase { Harness.Baseline.runBaseline("Baseline of emitted result (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => { try { - return ts.sys.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind)); + return Harness.IO.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind)); } catch (e) { return undefined; diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 3d97938011c..366355520a2 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -20,8 +20,10 @@ /// /// +/* tslint:disable:no-null */ + let runners: RunnerBase[] = []; -let iterations: number = 1; +let iterations = 1; function runTests(runners: RunnerBase[]) { for (let i = iterations; i > 0; i--) { @@ -68,10 +70,10 @@ if (testConfigFile !== "") { case "fourslash-shims": runners.push(new FourSlashRunner(FourSlashTestType.Shims)); break; - case 'fourslash-shims-pp': + case "fourslash-shims-pp": runners.push(new FourSlashRunner(FourSlashTestType.ShimsWithPreprocess)); break; - case 'fourslash-server': + case "fourslash-server": runners.push(new FourSlashRunner(FourSlashTestType.Server)); break; case "fourslash-generated": @@ -106,6 +108,4 @@ if (runners.length === 0) { // runners.push(new GeneratedFourslashRunner()); } -ts.sys.newLine = "\r\n"; - runTests(runners); diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts index afe757ea829..7469325475a 100644 --- a/src/harness/runnerbase.ts +++ b/src/harness/runnerbase.ts @@ -25,12 +25,12 @@ abstract class RunnerBase { let fixedPath = path; // full paths either start with a drive letter or / for *nix, shouldn't have \ in the path at this point - let fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.tsx?/g; + let fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.tsx?/g; let fullPathList = fixedPath.match(fullPath); if (fullPathList) { fullPathList.forEach((match: string) => fixedPath = fixedPath.replace(match, Harness.Path.getFileName(match))); } - + // when running in the browser the 'full path' is the host name, shows up in error baselines let localHost = /http:\/localhost:\d+/g; fixedPath = fixedPath.replace(localHost, ""); diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index d8b52ec2e39..3027afae9dc 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -2,23 +2,29 @@ /// /// /// +/* tslint:disable:no-null */ -module RWC { - function runWithIOLog(ioLog: IOLog, fn: () => void) { - let oldSys = ts.sys; +namespace RWC { + function runWithIOLog(ioLog: IOLog, fn: (oldIO: Harness.IO) => void) { + let oldIO = Harness.IO; - let wrappedSys = Playback.wrapSystem(ts.sys); - wrappedSys.startReplayFromData(ioLog); - ts.sys = wrappedSys; + let wrappedIO = Playback.wrapIO(oldIO); + wrappedIO.startReplayFromData(ioLog); + Harness.IO = wrappedIO; try { - fn(); + fn(oldIO); } finally { - wrappedSys.endReplay(); - ts.sys = oldSys; + wrappedIO.endReplay(); + Harness.IO = oldIO; } } + function isTsConfigFile(file: { path: string }): boolean { + const tsConfigFileName = "tsconfig.json"; + return file.path.substr(file.path.length - tsConfigFileName.length).toLowerCase() === tsConfigFileName; + } + export function runRWCTest(jsonPath: string) { describe("Testing a RWC project: " + jsonPath, () => { let inputFiles: { unitName: string; content: string; }[] = []; @@ -32,7 +38,6 @@ module RWC { let baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2]; let currentDirectory: string; let useCustomLibraryFile: boolean; - after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Therefore we have to clean out large objects after the test is done. @@ -57,7 +62,7 @@ module RWC { currentDirectory = ioLog.currentDirectory; useCustomLibraryFile = ioLog.useCustomLibraryFile; runWithIOLog(ioLog, () => { - opts = ts.parseCommandLine(ioLog.arguments); + opts = ts.parseCommandLine(ioLog.arguments, fileName => Harness.IO.readFile(fileName)); assert.equal(opts.errors.length, 0); // To provide test coverage of output javascript file, @@ -65,28 +70,43 @@ module RWC { opts.options.noEmitOnError = false; }); - runWithIOLog(ioLog, () => { + runWithIOLog(ioLog, oldIO => { harnessCompiler.reset(); + let fileNames = opts.fileNames; + + let tsconfigFile = ts.forEach(ioLog.filesRead, f => isTsConfigFile(f) ? f : undefined); + if (tsconfigFile) { + let tsconfigFileContents = getHarnessCompilerInputUnit(tsconfigFile.path); + let parsedTsconfigFileContents = ts.parseConfigFileText(tsconfigFile.path, tsconfigFileContents.content); + let configParseResult = ts.parseConfigFile(parsedTsconfigFileContents.config, Harness.IO, ts.getDirectoryPath(tsconfigFile.path)); + fileNames = configParseResult.fileNames; + opts.options = ts.extend(opts.options, configParseResult.options); + } + // Load the files - ts.forEach(opts.fileNames, fileName => { + for (let fileName of fileNames) { inputFiles.push(getHarnessCompilerInputUnit(fileName)); - }); + } // Add files to compilation let isInInputList = (resolvedPath: string) => (inputFile: { unitName: string; content: string; }) => inputFile.unitName === resolvedPath; for (let fileRead of ioLog.filesRead) { // Check if the file is already added into the set of input files. - const resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path)); + const resolvedPath = ts.normalizeSlashes(Harness.IO.resolvePath(fileRead.path)); let inInputList = ts.forEach(inputFiles, isInInputList(resolvedPath)); + if (isTsConfigFile(fileRead)) { + continue; + } + if (!Harness.isLibraryFile(fileRead.path)) { if (inInputList) { continue; } otherFiles.push(getHarnessCompilerInputUnit(fileRead.path)); } - else if (!opts.options.noLib && Harness.isLibraryFile(fileRead.path)){ + else if (!opts.options.noLib && Harness.isLibraryFile(fileRead.path)) { if (!inInputList) { // If useCustomLibraryFile is true, we will use lib.d.ts from json object // otherwise use the lib.d.ts from built/local @@ -97,7 +117,8 @@ module RWC { inputFiles.push(getHarnessCompilerInputUnit(fileRead.path)); } else { - inputFiles.push(Harness.getDefaultLibraryFile()); + // set the flag to put default library to the beginning of the list + inputFiles.unshift(Harness.getDefaultLibraryFile(oldIO)); } } } @@ -118,13 +139,13 @@ module RWC { }); function getHarnessCompilerInputUnit(fileName: string) { - let unitName = ts.normalizeSlashes(ts.sys.resolvePath(fileName)); + let unitName = ts.normalizeSlashes(Harness.IO.resolvePath(fileName)); let content: string = null; try { - content = ts.sys.readFile(unitName); + content = Harness.IO.readFile(unitName); } catch (e) { - content = ts.sys.readFile(fileName); + content = Harness.IO.readFile(fileName); } return { unitName, content }; } @@ -187,7 +208,7 @@ module RWC { } return Harness.Compiler.minimalDiagnosticsToString(declFileCompilationResult.declResult.errors) + - ts.sys.newLine + ts.sys.newLine + + Harness.IO.newLine() + Harness.IO.newLine() + Harness.Compiler.getErrorBaseline(declFileCompilationResult.declInputFiles.concat(declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors); }, false, baselineOpts); } diff --git a/src/harness/sourceMapRecorder.ts b/src/harness/sourceMapRecorder.ts index 55ca9ea9651..dcdc59a2a40 100644 --- a/src/harness/sourceMapRecorder.ts +++ b/src/harness/sourceMapRecorder.ts @@ -15,14 +15,14 @@ /// -module Harness.SourceMapRecoder { +namespace Harness.SourceMapRecoder { interface SourceMapSpanWithDecodeErrors { sourceMapSpan: ts.SourceMapSpan; decodeErrors: string[]; } - module SourceMapDecoder { + namespace SourceMapDecoder { let sourceMapMappings: string; let sourceMapNames: string[]; let decodingIndex: number; @@ -202,7 +202,7 @@ module Harness.SourceMapRecoder { } } - module SourceMapSpanWriter { + namespace SourceMapSpanWriter { let sourceMapRecoder: Compiler.WriterAggregator; let sourceMapSources: string[]; let sourceMapNames: string[]; @@ -442,7 +442,7 @@ module Harness.SourceMapRecoder { for (let i = 0; i < sourceMapDataList.length; i++) { let sourceMapData = sourceMapDataList[i]; - let prevSourceFile: ts.SourceFile = null; + let prevSourceFile: ts.SourceFile; SourceMapSpanWriter.intializeSourceMapSpanWriter(sourceMapRecoder, sourceMapData, jsFiles[i]); for (let j = 0; j < sourceMapData.sourceMapDecodedMappings.length; j++) { diff --git a/src/harness/test262Runner.ts b/src/harness/test262Runner.ts index d9bbd55e7a3..491c71a5839 100644 --- a/src/harness/test262Runner.ts +++ b/src/harness/test262Runner.ts @@ -1,5 +1,6 @@ /// /// +/* tslint:disable:no-null */ class Test262BaselineRunner extends RunnerBase { private static basePath = "internal/cases/test262"; diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index 442921ca5a4..7259ff5081c 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -316,31 +316,31 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A string that represents the regular expression. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: string, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. + * @param searchValue A string that represents the regular expression. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ replace(searchValue: RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. @@ -1182,3 +1182,2644 @@ interface PromiseLike { then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; } + +interface ArrayLike { + length: number; + [n: number]: T; +} + + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; + + /** + * Returns a section of an ArrayBuffer. + */ + slice(begin:number, end?:number): ArrayBuffer; +} + +interface ArrayBufferConstructor { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; + isView(arg: any): boolean; +} +declare var ArrayBuffer: ArrayBufferConstructor; + +interface ArrayBufferView { + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; +} + +interface DataView { + buffer: ArrayBuffer; + byteLength: number; + byteOffset: number; + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian?: boolean): number; + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; +} + +interface DataViewConstructor { + new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; +} +declare var DataView: DataViewConstructor; + +/** + * 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 { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Int8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Int8Array; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} +interface Int8ArrayConstructor { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: ArrayLike): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + +} +declare var Int8Array: Int8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint8Array; + + /** + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ArrayConstructor { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: ArrayLike): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + +} +declare var Uint8Array: Uint8ArrayConstructor; + +/** + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8ClampedArray { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint8ClampedArray; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint8ClampedArray; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8ClampedArray, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint8ClampedArray; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint8ClampedArray; + + /** + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8ClampedArray; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint8ClampedArrayConstructor { + prototype: Uint8ClampedArray; + new (length: number): Uint8ClampedArray; + new (array: ArrayLike): Uint8ClampedArray; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint8ClampedArray; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; +} +declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; + +/** + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Int16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Int16Array; + + /** + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int16ArrayConstructor { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: ArrayLike): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + +} +declare var Int16Array: Int16ArrayConstructor; + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint16Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint16Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint16Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint16Array; + + /** + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint16ArrayConstructor { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: ArrayLike): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint16Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + +} +declare var Uint16Array: Uint16ArrayConstructor; +/** + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Int32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Int32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Int32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Int32Array; + + /** + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Int32ArrayConstructor { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: ArrayLike): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Int32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; +} +declare var Int32Array: Int32ArrayConstructor; + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Uint32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Uint32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Uint32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Uint32Array; + + /** + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Uint32ArrayConstructor { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: ArrayLike): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Uint32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; +} +declare var Uint32Array: Uint32ArrayConstructor; + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ +interface Float32Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Float32Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float32Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float32Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Float32Array; + + /** + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float32ArrayConstructor { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: ArrayLike): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float32Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + +} +declare var Float32Array: Float32ArrayConstructor; + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ +interface Float64Array { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The ArrayBuffer instance referenced by the array. + */ + buffer: ArrayBuffer; + + /** + * The length in bytes of the array. + */ + byteLength: number; + + /** + * The offset in bytes of the array. + */ + byteOffset: number; + + /** + * 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 + * 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; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * 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 + * length+end. + */ + fill(value: number, start?: number, end?: number): Float64Array; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; + + /** + * 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 + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + + /** + * 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 + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: number) => boolean, thisArg?: any): number; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + indexOf(searchElement: number, fromIndex?: number): number; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + + /** + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ + lastIndexOf(searchElement: number, fromIndex?: number): number; + + /** + * The length of the array. + */ + length: number; + + /** + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; + + /** + * Reverses the elements in an Array. + */ + reverse(): Float64Array; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: ArrayLike, offset?: number): void; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): Float64Array; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + + /** + * 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: number, b: number) => number): Float64Array; + + /** + * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; + + /** + * Converts a number to a string by using the current locale. + */ + toLocaleString(): string; + + /** + * Returns a string representation of an array. + */ + toString(): string; + + [index: number]: number; +} + +interface Float64ArrayConstructor { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: ArrayLike): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ + of(...items: number[]): Float64Array; + + /** + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ + from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; +} +declare var Float64Array: Float64ArrayConstructor; diff --git a/src/lib/dom.es6.d.ts b/src/lib/dom.es6.d.ts index 8702201bb9e..e83b8531011 100644 --- a/src/lib/dom.es6.d.ts +++ b/src/lib/dom.es6.d.ts @@ -8,4 +8,4 @@ interface NodeList { interface NodeListOf { [Symbol.iterator](): IterableIterator -} \ No newline at end of file +} diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index 8eec72f1a4c..e34ce36633f 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -202,8 +202,8 @@ interface AnalyserNode extends AudioNode { smoothingTimeConstant: number; getByteFrequencyData(array: Uint8Array): void; getByteTimeDomainData(array: Uint8Array): void; - getFloatFrequencyData(array: any): void; - getFloatTimeDomainData(array: any): void; + getFloatFrequencyData(array: Float32Array): void; + getFloatTimeDomainData(array: Float32Array): void; } declare var AnalyserNode: { @@ -290,7 +290,7 @@ interface AudioBuffer { length: number; numberOfChannels: number; sampleRate: number; - getChannelData(channel: number): any; + getChannelData(channel: number): Float32Array; } declare var AudioBuffer: { @@ -334,7 +334,7 @@ interface AudioContext extends EventTarget { createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; createOscillator(): OscillatorNode; createPanner(): PannerNode; - createPeriodicWave(real: any, imag: any): PeriodicWave; + createPeriodicWave(real: Float32Array, imag: Float32Array): PeriodicWave; createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; createStereoPanner(): StereoPannerNode; createWaveShaper(): WaveShaperNode; @@ -392,7 +392,7 @@ interface AudioParam { linearRampToValueAtTime(value: number, endTime: number): void; setTargetAtTime(target: number, startTime: number, timeConstant: number): void; setValueAtTime(value: number, startTime: number): void; - setValueCurveAtTime(values: any, startTime: number, duration: number): void; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): void; } declare var AudioParam: { @@ -468,7 +468,7 @@ interface BiquadFilterNode extends AudioNode { frequency: AudioParam; gain: AudioParam; type: string; - getFrequencyResponse(frequencyHz: any, magResponse: any, phaseResponse: any): void; + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; } declare var BiquadFilterNode: { @@ -2459,7 +2459,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. * @param replace Specifies whether the existing entry for the document is replaced in the history list. */ - open(url?: string, name?: string, features?: string, replace?: boolean): Document | Window; + open(url?: string, name?: string, features?: string, replace?: boolean): Document; /** * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. * @param commandId Specifies a command identifier. @@ -2916,6 +2916,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec webkitMatchesSelector(selectors: string): boolean; webkitRequestFullScreen(): void; webkitRequestFullscreen(): void; + getElementsByClassName(classNames: string): NodeListOf; addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -3030,7 +3031,7 @@ interface File extends Blob { declare var File: { prototype: File; - new(): File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; } interface FileList { @@ -3903,7 +3904,6 @@ interface HTMLElement extends Element { contains(child: HTMLElement): boolean; dragDrop(): boolean; focus(): void; - getElementsByClassName(classNames: string): NodeListOf; insertAdjacentElement(position: string, insertedElement: Element): Element; insertAdjacentHTML(where: string, html: string): void; insertAdjacentText(where: string, text: string): void; @@ -6865,7 +6865,7 @@ interface IDBDatabase extends EventTarget { createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6986,7 +6986,7 @@ interface IDBTransaction extends EventTarget { READ_ONLY: string; READ_WRITE: string; VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -7016,11 +7016,14 @@ interface ImageData { width: number; } -declare var ImageData: { +interface ImageDataConstructor { prototype: ImageData; - new(): ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +declare var ImageData: ImageDataConstructor; + interface KeyboardEvent extends UIEvent { altKey: boolean; char: string; @@ -7703,7 +7706,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -8445,7 +8448,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface Range { @@ -10890,7 +10893,7 @@ declare var WEBGL_depth_texture: { } interface WaveShaperNode extends AudioNode { - curve: any; + curve: Float32Array; oversample: string; } @@ -11077,34 +11080,34 @@ interface WebGLRenderingContext { texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; uniform1f(location: WebGLUniformLocation, x: number): void; - uniform1fv(location: WebGLUniformLocation, v: any): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; uniform1i(location: WebGLUniformLocation, x: number): void; uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; uniform2f(location: WebGLUniformLocation, x: number, y: number): void; - uniform2fv(location: WebGLUniformLocation, v: any): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; uniform2i(location: WebGLUniformLocation, x: number, y: number): void; uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; - uniform3fv(location: WebGLUniformLocation, v: any): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; - uniform4fv(location: WebGLUniformLocation, v: any): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; - uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; - uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: any): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; useProgram(program: WebGLProgram): void; validateProgram(program: WebGLProgram): void; vertexAttrib1f(indx: number, x: number): void; - vertexAttrib1fv(indx: number, values: any): void; + vertexAttrib1fv(indx: number, values: Float32Array): void; vertexAttrib2f(indx: number, x: number, y: number): void; - vertexAttrib2fv(indx: number, values: any): void; + vertexAttrib2fv(indx: number, values: Float32Array): void; vertexAttrib3f(indx: number, x: number, y: number, z: number): void; - vertexAttrib3fv(indx: number, values: any): void; + vertexAttrib3fv(indx: number, values: Float32Array): void; vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; - vertexAttrib4fv(indx: number, values: any): void; + vertexAttrib4fv(indx: number, values: Float32Array): void; vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; viewport(x: number, y: number, width: number, height: number): void; ACTIVE_ATTRIBUTES: number; @@ -12169,7 +12172,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { LOADING: number; OPENED: number; UNSENT: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -12439,7 +12442,7 @@ interface MSBaseReader { DONE: number; EMPTY: number; LOADING: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -12595,7 +12598,7 @@ interface XMLHttpRequestEventTarget { onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -12617,12 +12620,32 @@ interface BlobPropertyBag { endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -12952,4 +12975,4 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any, declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; \ No newline at end of file diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts index 97291f742bd..e2b26747516 100644 --- a/src/lib/es6.d.ts +++ b/src/lib/es6.d.ts @@ -87,8 +87,8 @@ interface SymbolConstructor { split: symbol; /** - * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive - * abstract operation. + * A method that converts an object to a corresponding primitive value. + * Called by the ToPrimitive abstract operation. */ toPrimitive: symbol; @@ -98,8 +98,8 @@ interface SymbolConstructor { */ toStringTag: symbol; - /** - * An Object whose own property names are property names that are excluded from the with + /** + * An Object whose own property names are property names that are excluded from the 'with' * environment bindings of the associated objects. */ unscopables: symbol; @@ -125,7 +125,34 @@ interface ObjectConstructor { * 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 to copy properties from. + * @param source The source object from which to copy properties. + */ + assign(target: T, source: U): T & U; + + /** + * 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. + * @param source2 The second source object from which to copy properties. + */ + assign(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 + * 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. + * @param source2 The second source object from which to copy properties. + * @param source3 The third source object from which to copy properties. + */ + assign(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 + * 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 */ assign(target: any, ...sources: any[]): any; @@ -170,16 +197,19 @@ interface ObjectConstructor { } interface Function { - /** - * Returns a new function object that is identical to the argument object in all ways except - * for its identity and the value of its HomeObject internal slot. - */ - toMethod(newHome: Object): Function; - /** * Returns the name of the function. Function names are read-only and can not be changed. */ name: string; + + /** + * Determines whether the given value inherits from this function if this function was used + * as a constructor function. + * + * A constructor function can control which objects are recognized as its instances by + * 'instanceof' by overriding this method. + */ + [Symbol.hasInstance](value: any): boolean; } interface NumberConstructor { @@ -248,15 +278,24 @@ interface NumberConstructor { parseInt(string: string, radix?: number): number; } -interface ArrayLike { - length: number; - [n: number]: T; -} - interface Array { /** Iterator */ [Symbol.iterator](): IterableIterator; + /** + * Returns an object whose properties have the value 'true' + * when they will be absent when used in a 'with' statement. + */ + [Symbol.unscopables](): { + copyWithin: boolean; + entries: boolean; + fill: boolean; + find: boolean; + findIndex: boolean; + keys: boolean; + values: boolean; + }; + /** * Returns an array of key, value pairs for every entry in the array */ @@ -408,6 +447,41 @@ interface String { */ startsWith(searchString: string, position?: number): boolean; + // Overloads for objects with methods of well-known symbols. + + /** + * 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. + */ + match(matcher: { [Symbol.match](string: string): RegExpMatchArray; }): RegExpMatchArray; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replacer A function that returns the replacement text. + */ + replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param searcher An object which supports searching within a string. + */ + search(searcher: { [Symbol.search](string: string): number; }): number; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param splitter An object that can split a string. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; + /** * Returns an HTML anchor element and sets the name attribute to the text value * @param name @@ -619,37 +693,76 @@ interface Math { [Symbol.toStringTag]: string; } +interface Date { + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "default"): string; + /** + * Converts a Date object to a string. + */ + [Symbol.toPrimitive](hint: "string"): string; + /** + * Converts a Date object to a number. + */ + [Symbol.toPrimitive](hint: "number"): number; + /** + * Converts a Date object to a string or number. + * + * @param hint The strings "number", "string", or "default" to specify what primitive to return. + * + * @throws {TypeError} If 'hint' was given something other than "number", "string", or "default". + * @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default". + */ + [Symbol.toPrimitive](hint: string): string | number; +} + interface RegExp { - /** - * Matches a string with a regular expression, and returns an array containing the results of + /** + * Matches a string with this regular expression, and returns an array containing the results of * that search. * @param string A string to search within. */ - match(string: string): string[]; + [Symbol.match](string: string): RegExpMatchArray; /** - * Replaces text in a string, using a regular expression. - * @param searchValue A String object or string literal that represents the regular expression + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced * @param replaceValue A String object or string literal containing the text to replace for every - * successful match of rgExp in stringObj. + * successful match of this regular expression. */ - replace(string: string, replaceValue: string): string; - - search(string: string): number; + [Symbol.replace](string: string, replaceValue: string): string; /** - * Returns an Array object into which substrings of the result of converting string to a String - * have been stored. The substrings are determined by searching from left to right for matches - * of the this value regular expression; these occurrences are not part of any substring in the - * returned array, but serve to divide up the String value. - * - * If the regular expression that contains capturing parentheses, then each time separator is - * matched the results (including any undefined results) of the capturing parentheses are spliced. - * @param string string value to split - * @param limit if not undefined, the output array is truncated so that it contains no more - * than limit elements. + * Replaces text in a string, using this regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replacer A function that returns the replacement text. */ - split(string: string, limit?: number): string[]; + [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the position beginning first substring match in a regular expression search + * using this regular expression. + * + * @param string The string to search within. + */ + [Symbol.search](string: string): number; + + /** + * Returns an array of substrings that were delimited by strings in the original input that + * match against this regular expression. + * + * If the regular expression contains capturing parentheses, then each time this + * regular expression matches, the results (including any undefined results) of the + * capturing parentheses are spliced. + * + * @param string string value to split + * @param limit if not undefined, the output array is truncated so that it contains no more + * than 'limit' elements. + */ + [Symbol.split](string: string, limit?: number): string[]; /** * Returns a string indicating the flags of the regular expression in question. This field is read-only. @@ -678,6 +791,10 @@ interface RegExp { unicode: boolean; } +interface RegExpConstructor { + [Symbol.species](): RegExpConstructor; +} + interface Map { clear(): void; delete(key: K): boolean; @@ -767,440 +884,35 @@ interface JSON { * buffer as needed. */ interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; - - /** - * Returns a section of an ArrayBuffer. - */ - slice(begin: number, end?: number): ArrayBuffer; - [Symbol.toStringTag]: string; } -interface ArrayBufferConstructor { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; - isView(arg: any): boolean; -} -declare var ArrayBuffer: ArrayBufferConstructor; - interface DataView { - buffer: ArrayBuffer; - byteLength: number; - byteOffset: number; - /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat64(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt8(byteOffset: number): number; - - /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt16(byteOffset: number, littleEndian: boolean): number; - /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint8(byteOffset: number): number; - - /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint16(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint32(byteOffset: number, littleEndian: boolean): number; - - /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setInt8(byteOffset: number, value: number): void; - - /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setUint8(byteOffset: number, value: number): void; - - /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint32(byteOffset: number, value: number, littleEndian: boolean): void; - [Symbol.toStringTag]: string; } -interface DataViewConstructor { - new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; -} -declare var DataView: DataViewConstructor; - /** * 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 { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int8Array; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Int8ArrayConstructor { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int8Array; + new (elements: Iterable): Int8Array; /** * Creates an array from an array-like or iterable object. @@ -1208,289 +920,31 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -declare var Int8Array: Int8ArrayConstructor; /** * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint8Array; - - /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint8ArrayConstructor { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8Array; + new (elements: Iterable): Uint8Array; /** * Creates an array from an array-like or iterable object. @@ -1498,289 +952,35 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -declare var Uint8Array: Uint8ArrayConstructor; /** * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. * If the requested number of bytes could not be allocated an exception is raised. */ interface Uint8ClampedArray { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8ClampedArray; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8ClampedArray; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8ClampedArray, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8ClampedArray; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint8ClampedArray; - - /** - * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8ClampedArray; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint8ClampedArrayConstructor { - prototype: Uint8ClampedArray; - new (length: number): Uint8ClampedArray; - new (array: Uint8ClampedArray): Uint8ClampedArray; - new (array: number[]): Uint8ClampedArray; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + new (elements: Iterable): Uint8ClampedArray; - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8ClampedArray; /** * Creates an array from an array-like or iterable object. @@ -1788,289 +988,35 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; /** * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int16Array; - - /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - [index: number]: number; + [Symbol.iterator](): IterableIterator; } interface Int16ArrayConstructor { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int16Array; + new (elements: Iterable): Int16Array; /** * Creates an array from an array-like or iterable object. @@ -2078,289 +1024,31 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -declare var Int16Array: Int16ArrayConstructor; /** * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint16Array; - - /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint16ArrayConstructor { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint16Array; + new (elements: Iterable): Uint16Array; /** * Creates an array from an array-like or iterable object. @@ -2368,289 +1056,31 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -declare var Uint16Array: Uint16ArrayConstructor; /** * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int32Array; - - /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Int32ArrayConstructor { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int32Array; + new (elements: Iterable): Int32Array; /** * Creates an array from an array-like or iterable object. @@ -2658,289 +1088,31 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -declare var Int32Array: Int32ArrayConstructor; /** * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint32Array; - - /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Uint32ArrayConstructor { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint32Array; + new (elements: Iterable): Uint32Array; /** * Creates an array from an array-like or iterable object. @@ -2948,289 +1120,31 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -declare var Uint32Array: Uint32ArrayConstructor; /** * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number * of bytes could not be allocated an exception is raised. */ interface Float32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Float32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Float32Array; - - /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Float32ArrayConstructor { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float32Array; + new (elements: Iterable): Float32Array; /** * Creates an array from an array-like or iterable object. @@ -3238,289 +1152,31 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -declare var Float32Array: Float32ArrayConstructor; /** * A typed array of 64-bit float values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Float64Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - /** * Returns an array of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, number]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Float64Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** * Returns an list of keys in the array */ keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float64Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Float64Array; - - /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - /** * Returns an list of values in the array */ values(): IterableIterator; - - [index: number]: number; [Symbol.iterator](): IterableIterator; } interface Float64ArrayConstructor { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float64Array; + new (elements: Iterable): Float64Array; /** * Creates an array from an array-like or iterable object. @@ -3528,9 +1184,8 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } -declare var Float64Array: Float64ArrayConstructor; interface ProxyHandler { getPrototypeOf? (target: T): any; @@ -3555,9 +1210,9 @@ interface ProxyConstructor { } declare var Proxy: ProxyConstructor; -declare module Reflect { +declare namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; - function construct(target: Function, argumentsList: ArrayLike): any; + function construct(target: Function, argumentsList: ArrayLike, newTarget?: any): any; function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; function deleteProperty(target: any, propertyKey: PropertyKey): boolean; function enumerate(target: any): IterableIterator; @@ -3658,20 +1313,3 @@ interface PromiseConstructor { } declare var Promise: PromiseConstructor; - -interface ArrayBufferView { - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; -} \ No newline at end of file diff --git a/src/lib/extensions.d.ts b/src/lib/extensions.d.ts deleted file mode 100644 index 8c67c7e826f..00000000000 --- a/src/lib/extensions.d.ts +++ /dev/null @@ -1,2305 +0,0 @@ - -///////////////////////////// -/// IE10 ECMAScript Extensions -///////////////////////////// - -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ -interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; - - /** - * Returns a section of an ArrayBuffer. - */ - slice(begin:number, end?:number): ArrayBuffer; -} - -interface ArrayBufferConstructor { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; - isView(arg: any): boolean; -} -declare var ArrayBuffer: ArrayBufferConstructor; - -interface ArrayBufferView { - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; -} - -interface DataView { - buffer: ArrayBuffer; - byteLength: number; - byteOffset: number; - /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat64(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt8(byteOffset: number): number; - - /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt16(byteOffset: number, littleEndian: boolean): number; - /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt32(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint8(byteOffset: number): number; - - /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint16(byteOffset: number, littleEndian: boolean): number; - - /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint32(byteOffset: number, littleEndian: boolean): number; - - /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setFloat64(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setInt8(byteOffset: number, value: number): void; - - /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setInt32(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setUint8(byteOffset: number, value: number): void; - - /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint16(byteOffset: number, value: number, littleEndian: boolean): void; - - /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setUint32(byteOffset: number, value: number, littleEndian: boolean): void; -} - -interface DataViewConstructor { - new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; -} -declare var DataView: DataViewConstructor; - -/** - * 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 { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int8Array; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} -interface Int8ArrayConstructor { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int8Array; -} -declare var Int8Array: Int8ArrayConstructor; - -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint8Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint8Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint8Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint8Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint8Array; - - /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint8ArrayConstructor { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint8Array; -} -declare var Uint8Array: Uint8ArrayConstructor; - -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Int16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int16Array; - - /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Int16ArrayConstructor { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int16Array; -} -declare var Int16Array: Int16ArrayConstructor; - -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint16Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint16Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint16Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint16Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint16Array; - - /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint16ArrayConstructor { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint16Array; -} -declare var Uint16Array: Uint16ArrayConstructor; -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Int32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Int32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Int32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Int32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Int32Array; - - /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Int32ArrayConstructor { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Int32Array; -} -declare var Int32Array: Int32ArrayConstructor; - -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ -interface Uint32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Uint32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Uint32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Uint32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Uint32Array; - - /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Uint32ArrayConstructor { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Uint32Array; -} -declare var Uint32Array: Uint32ArrayConstructor; - -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ -interface Float32Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Float32Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float32Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float32Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Float32Array; - - /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Float32ArrayConstructor { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float32Array; -} -declare var Float32Array: Float32ArrayConstructor; - -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ -interface Float64Array { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The ArrayBuffer instance referenced by the array. - */ - buffer: ArrayBuffer; - - /** - * The length in bytes of the array. - */ - byteLength: number; - - /** - * The offset in bytes of the array. - */ - byteOffset: number; - - /** - * 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 - * 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; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * 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 - * length+end. - */ - fill(value: number, start?: number, end?: number): Float64Array; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; - - /** - * 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 - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - - /** - * 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 - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: number) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: number, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: number, fromIndex?: number): number; - - /** - * The length of the array. - */ - length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - - /** - * Reverses the elements in an Array. - */ - reverse(): Float64Array; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): Float64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; - - /** - * 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: number, b: number) => number): Float64Array; - - /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; - - /** - * Returns a string representation of an array. - */ - toString(): string; - - [index: number]: number; -} - -interface Float64ArrayConstructor { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: number[]): Float64Array; -} -declare var Float64Array: Float64ArrayConstructor; \ No newline at end of file diff --git a/src/lib/intl.d.ts b/src/lib/intl.d.ts index 57df70672d4..53894587259 100644 --- a/src/lib/intl.d.ts +++ b/src/lib/intl.d.ts @@ -41,7 +41,7 @@ declare module Intl { currency?: string; currencyDisplay?: string; useGrouping?: boolean; - minimumintegerDigits?: number; + minimumIntegerDigits?: number; minimumFractionDigits?: number; maximumFractionDigits?: number; minimumSignificantDigits?: number; @@ -54,7 +54,7 @@ declare module Intl { style: string; currency?: string; currencyDisplay?: string; - minimumintegerDigits: number; + minimumIntegerDigits: number; minimumFractionDigits: number; maximumFractionDigits: number; minimumSignificantDigits?: number; @@ -88,6 +88,7 @@ declare module Intl { timeZoneName?: string; formatMatcher?: string; hour12?: boolean; + timeZone?: string; } interface ResolvedDateTimeFormatOptions { @@ -157,17 +158,44 @@ interface Number { interface Date { /** - * Converts a date to a string by using the current or specified locale. + * Converts a date and time to a string by using the current or specified locale. * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + /** + * Converts a date to a string by using the current or specified locale. + * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; + /** + * Converts a time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a date and time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + /** * Converts a date to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ - toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string; + + /** + * Converts a time to a string by using the current or specified locale. + * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ + toLocaleTimeString(locale?: string, options?: Intl.DateTimeFormatOptions): string; } diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index db8b02f34d7..f37ea5c6ed2 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -3,10 +3,28 @@ /// IE Worker APIs ///////////////////////////// +interface EventInit { + bubbles?: boolean; + cancelable?: boolean; +} + interface EventListener { (evt: Event): void; } +interface AudioBuffer { + duration: number; + length: number; + numberOfChannels: number; + sampleRate: number; + getChannelData(channel: number): Float32Array; +} + +declare var AudioBuffer: { + prototype: AudioBuffer; + new(): AudioBuffer; +} + interface Blob { size: number; type: string; @@ -60,6 +78,21 @@ declare var Console: { new(): Console; } +interface Coordinates { + accuracy: number; + altitude: number; + altitudeAccuracy: number; + heading: number; + latitude: number; + longitude: number; + speed: number; +} + +declare var Coordinates: { + prototype: Coordinates; + new(): Coordinates; +} + interface DOMError { name: string; toString(): string; @@ -210,7 +243,7 @@ interface File extends Blob { declare var File: { prototype: File; - new(): File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; } interface FileList { @@ -281,7 +314,7 @@ interface IDBDatabase extends EventTarget { createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; deleteObjectStore(name: string): void; transaction(storeNames: any, mode?: string): IDBTransaction; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -402,7 +435,7 @@ interface IDBTransaction extends EventTarget { READ_ONLY: string; READ_WRITE: string; VERSION_CHANGE: string; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -432,11 +465,14 @@ interface ImageData { width: number; } -declare var ImageData: { +interface ImageDataConstructor { prototype: ImageData; - new(): ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; } +declare var ImageData: ImageDataConstructor; + interface MSApp { clearTemporaryWebDataAsync(): MSAppAsyncOperation; createBlobFromRandomAccessStream(type: string, seeker: any): Blob; @@ -460,6 +496,29 @@ interface MSApp { } declare var MSApp: MSApp; +interface MSAppAsyncOperation extends EventTarget { + error: DOMError; + oncomplete: (ev: Event) => any; + onerror: (ev: Event) => any; + readyState: number; + result: any; + start(): void; + COMPLETED: number; + ERROR: number; + STARTED: number; + addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSAppAsyncOperation: { + prototype: MSAppAsyncOperation; + new(): MSAppAsyncOperation; + COMPLETED: number; + ERROR: number; + STARTED: number; +} + interface MSBlobBuilder { append(data: any, endings?: string): void; getBlob(contentType?: string): Blob; @@ -496,6 +555,18 @@ declare var MSStreamReader: { new(): MSStreamReader; } +interface MediaQueryList { + matches: boolean; + media: string; + addListener(listener: MediaQueryListListener): void; + removeListener(listener: MediaQueryListListener): void; +} + +declare var MediaQueryList: { + prototype: MediaQueryList; + new(): MediaQueryList; +} + interface MessageChannel { port1: MessagePort; port2: MessagePort; @@ -516,7 +587,7 @@ interface MessageEvent extends Event { declare var MessageEvent: { prototype: MessageEvent; - new(): MessageEvent; + new(type: string, eventInitDict?: MessageEventInit): MessageEvent; } interface MessagePort extends EventTarget { @@ -533,6 +604,33 @@ declare var MessagePort: { new(): MessagePort; } +interface Position { + coords: Coordinates; + timestamp: number; +} + +declare var Position: { + prototype: Position; + new(): Position; +} + +interface PositionError { + code: number; + message: string; + toString(): string; + PERMISSION_DENIED: number; + POSITION_UNAVAILABLE: number; + TIMEOUT: number; +} + +declare var PositionError: { + prototype: PositionError; + new(): PositionError; + PERMISSION_DENIED: number; + POSITION_UNAVAILABLE: number; + TIMEOUT: number; +} + interface ProgressEvent extends Event { lengthComputable: boolean; loaded: number; @@ -542,7 +640,7 @@ interface ProgressEvent extends Event { declare var ProgressEvent: { prototype: ProgressEvent; - new(): ProgressEvent; + new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent; } interface WebSocket extends EventTarget { @@ -620,7 +718,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { LOADING: number; OPENED: number; UNSENT: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -642,6 +740,15 @@ declare var XMLHttpRequest: { create(): XMLHttpRequest; } +interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var XMLHttpRequestUpload: { + prototype: XMLHttpRequestUpload; + new(): XMLHttpRequestUpload; +} + interface AbstractWorker { onerror: (ev: Event) => any; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; @@ -661,7 +768,7 @@ interface MSBaseReader { DONE: number; EMPTY: number; LOADING: number; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -702,7 +809,7 @@ interface XMLHttpRequestEventTarget { onloadstart: (ev: Event) => any; onprogress: (ev: ProgressEvent) => any; ontimeout: (ev: ProgressEvent) => any; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; @@ -788,23 +895,37 @@ interface WorkerUtils extends Object, WindowBase64 { } -interface NodeListOf extends NodeList { - length: number; - item(index: number): TNode; - [index: number]: TNode; -} - interface BlobPropertyBag { type?: string; endings?: string; } +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + interface EventListenerObject { handleEvent(evt: Event): void; } declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface MessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + channel?: string; + source?: any; + ports?: MessagePort[]; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } @@ -820,11 +941,11 @@ interface MediaQueryListListener { interface MSLaunchUriCallback { (): void; } -interface FrameRequestCallback { - (time: number): void; +interface MSUnsafeFunctionCallback { + (): any; } -interface MutationCallback { - (mutations: MutationRecord[], observer: MutationObserver): void; +interface MSExecAtPriorityFunctionCallback { + (...args: any[]): any; } interface DecodeSuccessCallback { (decodedData: AudioBuffer): void; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 14bb7712ce7..7ab46fc689e 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -79,7 +79,7 @@ namespace ts.server { } } - interface TimestampedResolvedModule extends ResolvedModule { + interface TimestampedResolvedModule extends ResolvedModuleWithFailedLookupLocations { lastCheckTime: number; } @@ -99,11 +99,11 @@ namespace ts.server { } } - resolveModuleNames(moduleNames: string[], containingFile: string): string[] { + resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModule[] { let currentResolutionsInFile = this.resolvedModuleNames.get(containingFile); let newResolutions: Map = {}; - let resolvedFileNames: string[] = []; + let resolvedModules: ResolvedModule[] = []; let compilerOptions = this.getCompilationSettings(); @@ -119,25 +119,25 @@ namespace ts.server { else { resolution = resolveModuleName(moduleName, containingFile, compilerOptions, this.moduleResolutionHost); resolution.lastCheckTime = Date.now(); - newResolutions[moduleName] = resolution; + newResolutions[moduleName] = resolution; } } ts.Debug.assert(resolution !== undefined); - resolvedFileNames.push(resolution.resolvedFileName); + resolvedModules.push(resolution.resolvedModule); } // replace old results with a new one this.resolvedModuleNames.set(containingFile, newResolutions); - return resolvedFileNames; + return resolvedModules; function moduleResolutionIsValid(resolution: TimestampedResolvedModule): boolean { if (!resolution) { return false; } - if (resolution.resolvedFileName) { + if (resolution.resolvedModule) { // TODO: consider checking failedLookupLocations // TODO: use lastCheckTime to track expiration for module name resolution return true; @@ -224,6 +224,14 @@ namespace ts.server { this.roots.push(info); } } + + removeRoot(info: ScriptInfo) { + var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName); + if (scriptInfo) { + this.filenameToScript[info.fileName] = undefined; + this.roots = copyListRemovingItem(info, this.roots); + } + } saveTo(filename: string, tmpfilename: string) { var script = this.getScriptInfo(filename); @@ -345,6 +353,7 @@ namespace ts.server { export class Project { compilerService: CompilerService; projectFilename: string; + projectFileWatcher: FileWatcher; program: ts.Program; filenameToSourceFile: ts.Map = {}; updateGraphSeq = 0; @@ -352,7 +361,7 @@ namespace ts.server { openRefCount = 0; constructor(public projectService: ProjectService, public projectOptions?: ProjectOptions) { - this.compilerService = new CompilerService(this,projectOptions && projectOptions.compilerOptions); + this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions); } addOpenRef() { @@ -423,6 +432,12 @@ namespace ts.server { info.defaultProject = this; this.compilerService.host.addRoot(info); } + + // remove a root file from project + removeRoot(info: ScriptInfo) { + info.defaultProject = undefined; + this.compilerService.host.removeRoot(info); + } filesToString() { var strBuilder = ""; @@ -517,6 +532,12 @@ namespace ts.server { } } + watchedProjectConfigFileChanged(project: Project) { + this.log("Config File Changed: " + project.projectFilename); + this.updateConfiguredProject(project); + this.updateProjectStructure(); + } + log(msg: string, type = "Err") { this.psLogger.msg(msg, type); } @@ -594,16 +615,29 @@ namespace ts.server { this.configuredProjects = configuredProjects; } + removeConfiguredProject(project: Project) { + project.projectFileWatcher.close(); + this.configuredProjects = copyListRemovingItem(project, this.configuredProjects); + + let fileNames = project.getFileNames(); + for (let fileName of fileNames) { + let info = this.getScriptInfo(fileName); + if (info.defaultProject == project) { + info.defaultProject = undefined; + } + } + } + setConfiguredProjectRoot(info: ScriptInfo) { - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - let configuredProject = this.configuredProjects[i]; - if (configuredProject.isRoot(info)) { - info.defaultProject = configuredProject; - configuredProject.addOpenRef(); - return true; - } - } - return false; + for (var i = 0, len = this.configuredProjects.length; i < len; i++) { + let configuredProject = this.configuredProjects[i]; + if (configuredProject.isRoot(info)) { + info.defaultProject = configuredProject; + configuredProject.addOpenRef(); + return true; + } + } + return false; } addOpenFile(info: ScriptInfo) { @@ -647,7 +681,6 @@ namespace ts.server { /** * Remove this file from the set of open, non-configured files. * @param info The file that has been closed or newly configured - * @param openedByConfig True if info has become a root of a configured project */ closeOpenFile(info: ScriptInfo) { var openFileRoots: ScriptInfo[] = []; @@ -736,18 +769,42 @@ namespace ts.server { return referencingProjects; } + reloadProjects() { + // First check if there is new tsconfig file added for inferred project roots + for (let info of this.openFileRoots) { + this.openOrUpdateConfiguredProjectForFile(info.fileName); + } + this.updateProjectStructure(); + } + + /** + * This function is to update the project structure for every projects. + * It is called on the premise that all the configured projects are + * up to date. + */ updateProjectStructure() { this.log("updating project structure from ...", "Info"); this.printProjects(); + let unattachedOpenFiles: ScriptInfo[] = []; + let openFileRootsConfigured: ScriptInfo[] = []; + for (let info of this.openFileRootsConfigured) { + let project = info.defaultProject; + if (!project || !(project.getSourceFile(info))) { + info.defaultProject = undefined; + unattachedOpenFiles.push(info); + } + else { + openFileRootsConfigured.push(info); + } + } + this.openFileRootsConfigured = openFileRootsConfigured; + // First loop through all open files that are referenced by projects but are not // project roots. For each referenced file, see if the default project still // references that file. If so, then just keep the file in the referenced list. // If not, add the file to an unattached list, to be rechecked later. - var openFilesReferenced: ScriptInfo[] = []; - var unattachedOpenFiles: ScriptInfo[] = []; - for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { var referencedFile = this.openFilesReferenced[i]; referencedFile.defaultProject.updateGraph(); @@ -857,32 +914,40 @@ namespace ts.server { * Open file whose contents is managed by the client * @param filename is absolute pathname */ - openClientFile(fileName: string) { - var searchPath = ts.normalizePath(getDirectoryPath(fileName)); - this.log("Search path: " + searchPath,"Info"); - var configFileName = this.findConfigFile(searchPath); - if (configFileName) { - this.log("Config file name: " + configFileName, "Info"); - } else { - this.log("no config file"); - } - if (configFileName && (!this.configProjectIsActive(configFileName))) { - var configResult = this.openConfigFile(configFileName, fileName); - if (!configResult.success) { - this.log("Error opening config file " + configFileName + " " + configResult.errorMsg); - } - else { - this.log("Opened configuration file " + configFileName,"Info"); - this.configuredProjects.push(configResult.project); - } - } + this.openOrUpdateConfiguredProjectForFile(fileName); var info = this.openFile(fileName, true); this.addOpenFile(info); this.printProjects(); return info; } + openOrUpdateConfiguredProjectForFile(fileName: string) { + let searchPath = ts.normalizePath(getDirectoryPath(fileName)); + this.log("Search path: " + searchPath, "Info"); + let configFileName = this.findConfigFile(searchPath); + if (configFileName) { + this.log("Config file name: " + configFileName, "Info"); + let project = this.findConfiguredProjectByConfigFile(configFileName); + if (!project) { + var configResult = this.openConfigFile(configFileName, fileName); + if (!configResult.success) { + this.log("Error opening config file " + configFileName + " " + configResult.errorMsg); + } + else { + this.log("Opened configuration file " + configFileName, "Info"); + this.configuredProjects.push(configResult.project); + } + } + else { + this.updateConfiguredProject(project); + } + } + else { + this.log("No config files found."); + } + } + /** * Close file whose contents is managed by the client * @param filename is absolute pathname @@ -935,7 +1000,7 @@ namespace ts.server { for (var i = 0, len = this.configuredProjects.length; i < len; i++) { var project = this.configuredProjects[i]; project.updateGraph(); - this.psLogger.info("Project (configured) " + (i+this.inferredProjects.length).toString()); + this.psLogger.info("Project (configured) " + (i + this.inferredProjects.length).toString()); this.psLogger.info(project.filesToString()); this.psLogger.info("-----------------------------------------------"); } @@ -959,49 +1024,113 @@ namespace ts.server { } configProjectIsActive(fileName: string) { - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - if (this.configuredProjects[i].projectFilename == fileName) { - return true; - } - } - return false; + return this.findConfiguredProjectByConfigFile(fileName) === undefined; } - openConfigFile(configFilename: string, clientFileName?: string): ProjectOpenResult { + findConfiguredProjectByConfigFile(configFileName: string) { + for (var i = 0, len = this.configuredProjects.length; i < len; i++) { + if (this.configuredProjects[i].projectFilename == configFileName) { + return this.configuredProjects[i]; + } + } + return undefined; + } + + configFileToProjectOptions(configFilename: string): { succeeded: boolean, projectOptions?: ProjectOptions, error?: ProjectOpenResult } { configFilename = ts.normalizePath(configFilename); // file references will be relative to dirPath (or absolute) var dirPath = ts.getDirectoryPath(configFilename); var contents = this.host.readFile(configFilename) var rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.parseConfigFileText(configFilename, contents); if (rawConfig.error) { - return rawConfig.error; + return { succeeded: false, error: rawConfig.error }; } else { var parsedCommandLine = ts.parseConfigFile(rawConfig.config, this.host, dirPath); if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { - return { errorMsg: "tsconfig option errors" }; + return { succeeded: false, error: { errorMsg: "tsconfig option errors" } }; } - else if (parsedCommandLine.fileNames) { + else if (parsedCommandLine.fileNames == null) { + return { succeeded: false, error: { errorMsg: "no files found" } } + } + else { var projectOptions: ProjectOptions = { files: parsedCommandLine.fileNames, compilerOptions: parsedCommandLine.options }; - var proj = this.createProject(configFilename, projectOptions); - for (var i = 0, len = parsedCommandLine.fileNames.length; i < len; i++) { - var rootFilename = parsedCommandLine.fileNames[i]; - if (this.host.fileExists(rootFilename)) { - var info = this.openFile(rootFilename, clientFileName == rootFilename); - proj.addRoot(info); - } - else { - return { errorMsg: "specified file " + rootFilename + " not found" }; - } + return { succeeded: true, projectOptions }; + } + } + + } + + openConfigFile(configFilename: string, clientFileName?: string): ProjectOpenResult { + let { succeeded, projectOptions, error } = this.configFileToProjectOptions(configFilename); + if (!succeeded) { + return error; + } + else { + let proj = this.createProject(configFilename, projectOptions); + for (let i = 0, len = projectOptions.files.length; i < len; i++) { + let rootFilename = projectOptions.files[i]; + if (this.host.fileExists(rootFilename)) { + let info = this.openFile(rootFilename, /*openedByClient*/ clientFileName == rootFilename); + proj.addRoot(info); } - proj.finishGraph(); - return { success: true, project: proj }; + else { + return { errorMsg: "specified file " + rootFilename + " not found" }; + } + } + proj.finishGraph(); + proj.projectFileWatcher = this.host.watchFile(configFilename, _ => this.watchedProjectConfigFileChanged(proj)); + return { success: true, project: proj }; + } + } + + updateConfiguredProject(project: Project) { + if (!this.host.fileExists(project.projectFilename)) { + this.log("Config file deleted"); + this.removeConfiguredProject(project); + } + else { + let { succeeded, projectOptions, error } = this.configFileToProjectOptions(project.projectFilename); + if (!succeeded) { + return error; } else { - return { errorMsg: "no files found" }; + let oldFileNames = project.compilerService.host.roots.map(info => info.fileName); + let newFileNames = projectOptions.files; + let fileNamesToRemove = oldFileNames.filter(f => newFileNames.indexOf(f) < 0); + let fileNamesToAdd = newFileNames.filter(f => oldFileNames.indexOf(f) < 0); + + for (let fileName of fileNamesToRemove) { + let info = this.getScriptInfo(fileName); + project.removeRoot(info); + } + + for (let fileName of fileNamesToAdd) { + let info = this.getScriptInfo(fileName); + if (!info) { + info = this.openFile(fileName, false); + } + else { + // if the root file was opened by client, it would belong to either + // openFileRoots or openFileReferenced. + if (info.isOpen) { + if (this.openFileRoots.indexOf(info) >= 0) { + this.openFileRoots = copyListRemovingItem(info, this.openFileRoots); + } + if (this.openFilesReferenced.indexOf(info) >= 0) { + this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced); + } + this.openFileRootsConfigured.push(info); + } + } + project.addRoot(info); + } + + project.setProjectOptions(projectOptions); + project.finishGraph(); } } } diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index 2d694025c84..ce918abda3c 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -31,6 +31,12 @@ declare namespace ts.server.protocol { */ arguments?: any; } + + /** + * Request to reload the project structure for all the opened files + */ + export interface ReloadProjectsRequest extends Message { + } /** * Server-initiated event message diff --git a/src/server/server.ts b/src/server/server.ts index 843197b918a..c3942b01a39 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -11,7 +11,7 @@ namespace ts.server { input: process.stdin, output: process.stdout, terminal: false, - }); + }); class Logger implements ts.server.Logger { fd = -1; @@ -58,7 +58,7 @@ namespace ts.server { isVerbose() { return this.loggingEnabled() && (this.level == "verbose"); } - + msg(s: string, type = "Err") { if (this.fd < 0) { @@ -85,7 +85,7 @@ namespace ts.server { interface WatchedFile { fileName: string; - callback: (fileName: string) => void; + callback: (fileName: string, removed: boolean) => void; mtime: Date; } @@ -121,11 +121,11 @@ namespace ts.server { fs.stat(watchedFile.fileName,(err, stats) => { if (err) { - watchedFile.callback(watchedFile.fileName); + watchedFile.callback(watchedFile.fileName, /* removed */ false); } else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { watchedFile.mtime = WatchedFileSet.getModifiedTime(watchedFile.fileName); - watchedFile.callback(watchedFile.fileName); + watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); } }); } @@ -153,7 +153,7 @@ namespace ts.server { }, this.interval); } - addFile(fileName: string, callback: (fileName: string) => void ): WatchedFile { + addFile(fileName: string, callback: (fileName: string, removed: boolean) => void ): WatchedFile { var file: WatchedFile = { fileName, callback, @@ -170,7 +170,7 @@ namespace ts.server { removeFile(file: WatchedFile) { this.watchedFiles = WatchedFileSet.copyListRemovingItem(file, this.watchedFiles); } - } + } class IOSession extends Session { constructor(host: ServerHost, logger: ts.server.Logger) { @@ -243,11 +243,11 @@ namespace ts.server { // TODO: check that this location is writable var logger = createLoggerFromEnv(); - + // REVIEW: for now this implementation uses polling. // The advantage of polling is that it works reliably // on all os and with network mounted files. - // For 90 referenced files, the average time to detect + // For 90 referenced files, the average time to detect // changes is 2*msInterval (by default 5 seconds). // The overhead of this is .04 percent (1/2500) with // average pause of < 1 millisecond (and max @@ -271,4 +271,4 @@ namespace ts.server { }); // Start listening ioSession.listen(); -} \ No newline at end of file +} diff --git a/src/server/session.ts b/src/server/session.ts index 108cf4726dc..da044e7b4c6 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -100,6 +100,7 @@ namespace ts.server { export const SignatureHelp = "signatureHelp"; export const TypeDefinition = "typeDefinition"; export const ProjectInfo = "projectInfo"; + export const ReloadProjects = "reloadProjects"; export const Unknown = "unknown"; } @@ -226,6 +227,10 @@ namespace ts.server { this.syntacticCheck(file, project); this.semanticCheck(file, project); } + + private reloadProjects() { + this.projectService.reloadProjects(); + } private updateProjectStructure(seq: number, matchSeq: (seq: number) => boolean, ms = 1500) { setTimeout(() => { @@ -1033,6 +1038,10 @@ namespace ts.server { var { file, needFileNameList } = request.arguments; return {response: this.getProjectInfo(file, needFileNameList), responseRequired: true}; }, + [CommandNames.ReloadProjects]: (request: protocol.ReloadProjectsRequest) => { + this.reloadProjects(); + return {responseRequired: false}; + } }; public addProtocolHandler(command: string, handler: (request: protocol.Request) => {response?: any, responseRequired: boolean}) { if (this.handlers[command]) { diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 66cdbd53750..4a7033c6f3e 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -32,7 +32,7 @@ namespace ts.formatting { */ interface DynamicIndentation { getIndentationForToken(tokenLine: number, tokenKind: SyntaxKind): number; - getIndentationForComment(owningToken: SyntaxKind): number; + getIndentationForComment(owningToken: SyntaxKind, tokenIndentation: number): number; /** * Indentation for open and close tokens of the node if it is block or another node that needs special indentation * ... { @@ -325,7 +325,7 @@ namespace ts.formatting { let lastIndentedLine: number; let indentationOnLastIndentedLine: number; - + let edits: TextChange[] = []; formattingScanner.advance(); @@ -354,12 +354,12 @@ namespace ts.formatting { * If list element is in the range - its indentation will be equal * to inherited indentation from its predecessors. */ - function tryComputeIndentationForListItem(startPos: number, - endPos: number, - parentStartLine: number, - range: TextRange, + function tryComputeIndentationForListItem(startPos: number, + endPos: number, + parentStartLine: number, + range: TextRange, inheritedIndentation: number): number { - + if (rangeOverlapsWithStartEnd(range, startPos, endPos)) { if (inheritedIndentation !== Constants.Unknown) { return inheritedIndentation; @@ -376,7 +376,7 @@ namespace ts.formatting { return Constants.Unknown; } - + function computeIndentation( node: TextRangeWithKind, startLine: number, @@ -419,8 +419,8 @@ namespace ts.formatting { // if node is located on the same line with the parent // - inherit indentation from the parent // - push children if either parent of node itself has non-zero delta - indentation = startLine === lastIndentedLine - ? indentationOnLastIndentedLine + indentation = startLine === lastIndentedLine + ? indentationOnLastIndentedLine : parentDynamicIndentation.getIndentation(); delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta); } @@ -455,7 +455,7 @@ namespace ts.formatting { function getDynamicIndentation(node: Node, nodeStartLine: number, indentation: number, delta: number): DynamicIndentation { return { - getIndentationForComment: kind => { + getIndentationForComment: (kind, tokenIndentation) => { switch (kind) { // preceding comment to the token that closes the indentation scope inherits the indentation from the scope // .. { @@ -463,9 +463,10 @@ namespace ts.formatting { // } case SyntaxKind.CloseBraceToken: case SyntaxKind.CloseBracketToken: + case SyntaxKind.CloseParenToken: return indentation + delta; } - return indentation; + return tokenIndentation !== Constants.Unknown ? tokenIndentation : indentation; }, getIndentationForToken: (line, kind) => { if (nodeStartLine !== line && node.decorators) { @@ -585,7 +586,7 @@ namespace ts.formatting { if (!rangeOverlapsWithStartEnd(originalRange, child.pos, child.end)) { return inheritedIndentation; } - + if (child.getFullWidth() === 0) { return inheritedIndentation; } @@ -623,8 +624,8 @@ namespace ts.formatting { return inheritedIndentation; } - function processChildNodes(nodes: NodeArray, - parent: Node, + function processChildNodes(nodes: NodeArray, + parent: Node, parentStartLine: number, parentDynamicIndentation: DynamicIndentation): void { @@ -716,8 +717,14 @@ namespace ts.formatting { } if (indentToken) { - let indentNextTokenOrTrivia = true; + let tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) : + Constants.Unknown; + if (currentTokenInfo.leadingTrivia) { + let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation); + let indentNextTokenOrTrivia = true; + for (let triviaItem of currentTokenInfo.leadingTrivia) { if (!rangeContainsRange(originalRange, triviaItem)) { continue; @@ -725,13 +732,11 @@ namespace ts.formatting { switch (triviaItem.kind) { case SyntaxKind.MultiLineCommentTrivia: - let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); indentNextTokenOrTrivia = false; break; case SyntaxKind.SingleLineCommentTrivia: if (indentNextTokenOrTrivia) { - let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind); insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false); indentNextTokenOrTrivia = false; } @@ -744,10 +749,9 @@ namespace ts.formatting { } // indent token only if is it is in target range and does not overlap with any error ranges - if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) { - let tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind); + if (tokenIndentation !== Constants.Unknown) { insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); - + lastIndentedLine = tokenStart.line; indentationOnLastIndentedLine = tokenIndentation; } @@ -768,12 +772,12 @@ namespace ts.formatting { } } - function processRange(range: TextRangeWithKind, - rangeStart: LineAndCharacter, - parent: Node, - contextNode: Node, + function processRange(range: TextRangeWithKind, + rangeStart: LineAndCharacter, + parent: Node, + contextNode: Node, dynamicIndentation: DynamicIndentation): boolean { - + let rangeHasError = rangeContainsError(range); let lineAdded: boolean; if (!rangeHasError && !previousRangeHasError) { @@ -783,7 +787,7 @@ namespace ts.formatting { trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line); } else { - lineAdded = + lineAdded = processPair(range, rangeStart.line, parent, previousRange, previousRangeStartLine, previousParent, contextNode, dynamicIndentation) } } @@ -929,8 +933,8 @@ namespace ts.formatting { let lineStartPosition = getStartPositionOfLine(line, sourceFile); let lineEndPosition = getEndLinePosition(line, sourceFile); - // do not trim whitespaces in comments - if (range && isComment(range.kind) && range.pos <= lineEndPosition && range.end > lineEndPosition) { + // do not trim whitespaces in comments or template expression + if (range && (isComment(range.kind) || isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) { continue; } diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index 7e77878051c..58e2f304482 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -3,8 +3,14 @@ /* @internal */ namespace ts.formatting { - let scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false); - + const standardScanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false, LanguageVariant.Standard); + const jsxScanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false, LanguageVariant.JSX); + + /** + * Scanner that is currently used for formatting + */ + let scanner: Scanner; + export interface FormattingScanner { advance(): void; isOnToken(): boolean; @@ -17,10 +23,13 @@ namespace ts.formatting { Scan, RescanGreaterThanToken, RescanSlashToken, - RescanTemplateToken + RescanTemplateToken, + RescanJsxIdentifier } export function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner { + Debug.assert(scanner === undefined); + scanner = sourceFile.languageVariant === LanguageVariant.JSX ? jsxScanner : standardScanner; scanner.setText(sourceFile.text); scanner.setTextPos(startPos); @@ -39,12 +48,17 @@ namespace ts.formatting { isOnToken: isOnToken, lastTrailingTriviaWasNewLine: () => wasNewLine, close: () => { + Debug.assert(scanner !== undefined); + lastTokenInfo = undefined; scanner.setText(undefined); + scanner = undefined; } } function advance(): void { + Debug.assert(scanner !== undefined); + lastTokenInfo = undefined; let isStarted = scanner.getStartPos() !== startPos; @@ -108,6 +122,20 @@ namespace ts.formatting { return false; } + + function shouldRescanJsxIdentifier(node: Node): boolean { + if (node.parent) { + switch(node.parent.kind) { + case SyntaxKind.JsxAttribute: + case SyntaxKind.JsxOpeningElement: + case SyntaxKind.JsxClosingElement: + case SyntaxKind.JsxSelfClosingElement: + return node.kind === SyntaxKind.Identifier; + } + } + + return false; + } function shouldRescanSlashToken(container: Node): boolean { return container.kind === SyntaxKind.RegularExpressionLiteral; @@ -123,6 +151,8 @@ namespace ts.formatting { } function readTokenInfo(n: Node): TokenInfo { + Debug.assert(scanner !== undefined); + if (!isOnToken()) { // scanner is not on the token (either advance was not called yet or scanner is already past the end position) return { @@ -141,7 +171,9 @@ namespace ts.formatting { ? ScanAction.RescanSlashToken : shouldRescanTemplateToken(n) ? ScanAction.RescanTemplateToken - : ScanAction.Scan + : shouldRescanJsxIdentifier(n) + ? ScanAction.RescanJsxIdentifier + : ScanAction.Scan if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. @@ -176,6 +208,10 @@ namespace ts.formatting { currentToken = scanner.reScanTemplateToken(); lastScanAction = ScanAction.RescanTemplateToken; } + else if (expectedScanAction === ScanAction.RescanJsxIdentifier && currentToken === SyntaxKind.Identifier) { + currentToken = scanner.scanJsxIdentifier(); + lastScanAction = ScanAction.RescanJsxIdentifier; + } else { lastScanAction = ScanAction.Scan; } @@ -224,6 +260,8 @@ namespace ts.formatting { } function isOnToken(): boolean { + Debug.assert(scanner !== undefined); + let current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); let startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); return startPos < endPos && current !== SyntaxKind.EndOfFileToken && !isTrivia(current); diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index d4e096974b7..c3bc8e7802d 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -213,6 +213,14 @@ namespace ts.formatting { public NoSpaceBetweenYieldKeywordAndStar: Rule; public SpaceBetweenYieldOrYieldStarAndOperand: Rule; + // Async functions + public SpaceBetweenAsyncAndFunctionKeyword: Rule; + + // Template strings + public SpaceBetweenTagAndTemplateString: Rule; + public NoSpaceAfterTemplateHeadAndMiddle: Rule; + public NoSpaceBeforeTemplateMiddleAndTail: Rule; + constructor() { /// /// Common Rules @@ -252,7 +260,7 @@ namespace ts.formatting { this.SpaceBeforeOpenBraceInFunction = new Rule(RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.MultiLineCommentTrivia]); + this.TypeScriptOpenBraceLeftTokenRange = Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.MultiLineCommentTrivia, SyntaxKind.ClassKeyword]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new Rule(RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines); // Place a space before open brace in a control flow construct @@ -293,7 +301,7 @@ namespace ts.formatting { this.NoSpaceBeforeComma = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CommaToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - this.SpaceAfterCertainKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceAfterCertainKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword, SyntaxKind.AwaitKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.SpaceAfterLetConstInVariableDeclaration = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.LetKeyword, SyntaxKind.ConstKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), RuleAction.Space)); this.NoSpaceBeforeOpenParenInFuncCall = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), RuleAction.Delete)); this.SpaceAfterFunctionInFuncDecl = new Rule(RuleDescriptor.create3(SyntaxKind.FunctionKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space)); @@ -326,7 +334,7 @@ namespace ts.formatting { this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, SyntaxKind.TypeKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { @@ -360,6 +368,14 @@ namespace ts.formatting { this.NoSpaceBetweenYieldKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Delete)); this.SpaceBetweenYieldOrYieldStarAndOperand = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Space)); + // Async-await + this.SpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + + // template string + this.SpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.NoSpaceAfterTemplateHeadAndMiddle = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.TemplateHead, SyntaxKind.TemplateMiddle]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + this.NoSpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); + // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -386,6 +402,8 @@ namespace ts.formatting { this.NoSpaceBeforeOpenParenInFuncCall, this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, this.SpaceAfterVoidOperator, + this.SpaceBetweenAsyncAndFunctionKeyword, + this.SpaceBetweenTagAndTemplateString, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, // TypeScript-specific rules this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, @@ -489,6 +507,8 @@ namespace ts.formatting { case SyntaxKind.ConditionalExpression: case SyntaxKind.AsExpression: case SyntaxKind.TypePredicate: + case SyntaxKind.UnionType: + case SyntaxKind.IntersectionType: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) @@ -617,6 +637,7 @@ namespace ts.formatting { static NodeIsTypeScriptDeclWithBlockContext(node: Node): boolean { switch (node.kind) { case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: case SyntaxKind.TypeLiteral: diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index c7f762fea64..8035c963cf3 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -19,13 +19,7 @@ namespace ts.formatting { } // no indentation in string \regex\template literals - let precedingTokenIsLiteral = - precedingToken.kind === SyntaxKind.StringLiteral || - precedingToken.kind === SyntaxKind.RegularExpressionLiteral || - precedingToken.kind === SyntaxKind.NoSubstitutionTemplateLiteral || - precedingToken.kind === SyntaxKind.TemplateHead || - precedingToken.kind === SyntaxKind.TemplateMiddle || - precedingToken.kind === SyntaxKind.TemplateTail; + let precedingTokenIsLiteral = isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { return 0; } @@ -405,9 +399,12 @@ namespace ts.formatting { function nodeContentIsAlwaysIndented(kind: SyntaxKind): boolean { switch (kind) { + case SyntaxKind.ExpressionStatement: case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: + case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.Block: case SyntaxKind.ModuleBlock: @@ -429,6 +426,16 @@ namespace ts.formatting { case SyntaxKind.ArrayBindingPattern: case SyntaxKind.ObjectBindingPattern: case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: + case SyntaxKind.MethodSignature: + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.Parameter: + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + case SyntaxKind.ParenthesizedType: + case SyntaxKind.TaggedTemplateExpression: + case SyntaxKind.AwaitExpression: return true; } return false; @@ -448,8 +455,6 @@ namespace ts.formatting { case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.CallSignature: case SyntaxKind.ArrowFunction: case SyntaxKind.Constructor: case SyntaxKind.GetAccessor: diff --git a/src/services/services.ts b/src/services/services.ts index eb275120b89..99c6e4d6032 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -132,6 +132,46 @@ namespace ts { let scanner: Scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true); let emptyArray: any[] = []; + + const jsDocTagNames = [ + "augments", + "author", + "argument", + "borrows", + "class", + "constant", + "constructor", + "constructs", + "default", + "deprecated", + "description", + "event", + "example", + "extends", + "field", + "fileOverview", + "function", + "ignore", + "inner", + "lends", + "link", + "memberOf", + "name", + "namespace", + "param", + "private", + "property", + "public", + "requires", + "returns", + "see", + "since", + "static", + "throws", + "type", + "version" + ]; + let jsDocCompletionEntries: CompletionEntry[]; function createNode(kind: SyntaxKind, pos: number, end: number, flags: NodeFlags, parent?: Node): NodeObject { let node = new (getNodeConstructor(kind))(); @@ -685,7 +725,7 @@ namespace ts { } getBaseTypes(): ObjectType[] { return this.flags & (TypeFlags.Class | TypeFlags.Interface) - ? this.checker.getBaseTypes(this) + ? this.checker.getBaseTypes(this) : undefined; } } @@ -762,7 +802,7 @@ namespace ts { public languageVariant: LanguageVariant; public identifiers: Map; public nameTable: Map; - public resolvedModules: Map; + public resolvedModules: Map; public imports: LiteralExpression[]; private namedDeclarations: Map; @@ -982,7 +1022,7 @@ namespace ts { * if implementation is omitted then language service will use built-in module resolution logic and get answers to * host specific questions using 'getScriptSnapshot'. */ - resolveModuleNames?(moduleNames: string[], containingFile: string): string[]; + resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; } // @@ -1826,7 +1866,7 @@ namespace ts { let sourceMapText: string; // Create a compilerHost object to allow the compiler to read and write files let compilerHost: CompilerHost = { - getSourceFile: (fileName, target) => fileName === inputFileName ? sourceFile : undefined, + getSourceFile: (fileName, target) => fileName === normalizeSlashes(inputFileName) ? sourceFile : undefined, writeFile: (name, text, writeByteOrderMark) => { if (fileExtensionIs(name, ".map")) { Debug.assert(sourceMapText === undefined, `Unexpected multiple source map outputs for the file '${name}'`); @@ -1842,9 +1882,8 @@ namespace ts { getCanonicalFileName: fileName => fileName, getCurrentDirectory: () => "", getNewLine: () => newLine, - // these two methods should never be called in transpile scenarios since 'noResolve' is set to 'true' - fileExists: (fileName): boolean => { throw new Error("Should never be called."); }, - readFile: (fileName): string => { throw new Error("Should never be called."); } + fileExists: (fileName): boolean => fileName === inputFileName, + readFile: (fileName): string => "" }; let program = createProgram([inputFileName], options, compilerHost); @@ -2113,6 +2152,7 @@ namespace ts { // // export * from "mod" // export {a as b} from "mod" + // export import i = require("mod") while (token !== SyntaxKind.EndOfFileToken) { if (token === SyntaxKind.DeclareKeyword) { @@ -2237,6 +2277,25 @@ namespace ts { } } } + else if (token === SyntaxKind.ImportKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.Identifier || isKeyword(token)) { + token = scanner.scan(); + if (token === SyntaxKind.EqualsToken) { + token = scanner.scan(); + if (token === SyntaxKind.RequireKeyword) { + token = scanner.scan(); + if (token === SyntaxKind.OpenParenToken) { + token = scanner.scan(); + if (token === SyntaxKind.StringLiteral) { + // export import i = require("mod"); + recordModuleName(); + } + } + } + } + } + } } token = scanner.scan(); } @@ -2972,6 +3031,8 @@ namespace ts { let sourceFile = getValidSourceFile(fileName); let isJavaScriptFile = isJavaScript(fileName); + let isJsDocTagName = false; + let start = new Date().getTime(); let currentToken = getTokenAtPosition(sourceFile, position); log("getCompletionData: Get current token: " + (new Date().getTime() - start)); @@ -2982,8 +3043,44 @@ namespace ts { log("getCompletionData: Is inside comment: " + (new Date().getTime() - start)); if (insideComment) { - log("Returning an empty list because completion was inside a comment."); - return undefined; + // The current position is next to the '@' sign, when no tag name being provided yet. + // Provide a full list of tag names + if (hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === CharacterCodes.at) { + isJsDocTagName = true; + } + + // Completion should work inside certain JsDoc tags. For example: + // /** @type {number | string} */ + // Completion should work in the brackets + let insideJsDocTagExpression = false; + let tag = getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (tag.tagName.pos <= position && position <= tag.tagName.end) { + isJsDocTagName = true; + } + + switch (tag.kind) { + case SyntaxKind.JSDocTypeTag: + case SyntaxKind.JSDocParameterTag: + case SyntaxKind.JSDocReturnTag: + let tagWithExpression = tag; + if (tagWithExpression.typeExpression) { + insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; + } + break; + } + } + + if (isJsDocTagName) { + return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName }; + } + + if (!insideJsDocTagExpression) { + // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal + // comment or the plain text part of a jsDoc comment, so no completion should be available + log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); + return undefined; + } } start = new Date().getTime(); @@ -3069,7 +3166,7 @@ namespace ts { log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; + return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName }; function getTypeScriptMemberSymbols(): void { // Right of dot member completion list @@ -3452,6 +3549,9 @@ namespace ts { if (parent && (parent.kind === SyntaxKind.JsxSelfClosingElement || parent.kind === SyntaxKind.JsxOpeningElement)) { return parent; } + else if (parent.kind === SyntaxKind.JsxAttribute) { + return parent.parent; + } break; // The context token is the closing } or " of an attribute, which means @@ -3512,10 +3612,11 @@ namespace ts { containingNodeKind === SyntaxKind.EnumDeclaration || // enum a { foo, | isFunction(containingNodeKind) || containingNodeKind === SyntaxKind.ClassDeclaration || // class A { + return { + name: tagName, + kind: ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0", + } + })); + } + function createCompletionEntry(symbol: Symbol, location: Node): CompletionEntry { // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can @@ -4088,6 +4212,7 @@ namespace ts { displayParts.push(keywordPart(SyntaxKind.TypeKeyword)); displayParts.push(spacePart()); addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(spacePart()); displayParts.push(operatorPart(SyntaxKind.EqualsToken)); displayParts.push(spacePart()); @@ -4128,16 +4253,29 @@ namespace ts { } else { // Method/function type parameter - let signatureDeclaration = getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent; - let signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === SyntaxKind.ConstructSignature) { - displayParts.push(keywordPart(SyntaxKind.NewKeyword)); + let container = getContainingFunction(location); + if (container) { + let signatureDeclaration = getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent; + let signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === SyntaxKind.ConstructSignature) { + displayParts.push(keywordPart(SyntaxKind.NewKeyword)); + displayParts.push(spacePart()); + } + else if (signatureDeclaration.kind !== SyntaxKind.CallSignature && signatureDeclaration.name) { + addFullSymbolName(signatureDeclaration.symbol); + } + addRange(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature)); + } + else { + // Type aliash type parameter + // For example + // type list = T[]; // Both T will go through same code path + let declaration = getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent; + displayParts.push(keywordPart(SyntaxKind.TypeKeyword)); displayParts.push(spacePart()); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); } - else if (signatureDeclaration.kind !== SyntaxKind.CallSignature && signatureDeclaration.name) { - addFullSymbolName(signatureDeclaration.symbol); - } - addRange(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature)); } } if (symbolFlags & SymbolFlags.EnumMember) { @@ -4371,10 +4509,19 @@ namespace ts { // and in either case the symbol has a construct signature definition, i.e. class if (isNewExpressionTarget(location) || location.kind === SyntaxKind.ConstructorKeyword) { if (symbol.flags & SymbolFlags.Class) { - let classDeclaration = symbol.getDeclarations()[0]; - Debug.assert(classDeclaration && classDeclaration.kind === SyntaxKind.ClassDeclaration); + // Find the first class-like declaration and try to get the construct signature. + for (let declaration of symbol.getDeclarations()) { + if (isClassLike(declaration)) { + return tryAddSignature(declaration.members, + /*selectConstructors*/ true, + symbolKind, + symbolName, + containerName, + result); + } + } - return tryAddSignature(classDeclaration.members, /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); + Debug.fail("Expected declaration to have at least one class-like declaration"); } } return false; @@ -5767,6 +5914,7 @@ namespace ts { result.push(getReferenceEntryFromNode(node)); } break; + case SyntaxKind.ClassExpression: case SyntaxKind.ClassDeclaration: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. @@ -6110,7 +6258,8 @@ namespace ts { } return node.parent.kind === SyntaxKind.TypeReference || - (node.parent.kind === SyntaxKind.ExpressionWithTypeArguments && !isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + (node.parent.kind === SyntaxKind.ExpressionWithTypeArguments && !isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + node.kind === SyntaxKind.ThisKeyword && !isExpression(node); } function isNamespaceReference(node: Node): boolean { @@ -6858,8 +7007,12 @@ namespace ts { * Checks if position points to a valid position to add JSDoc comments, and if so, * returns the appropriate template. Otherwise returns an empty string. * Valid positions are - * - outside of comments, statements, and expressions, and - * - preceding a function declaration. + * - outside of comments, statements, and expressions, and + * - preceding a: + * - function/constructor/method declaration + * - class declarations + * - variable statements + * - namespace declarations * * Hosts should ideally check that: * - The line is all whitespace up to 'position' before performing the insertion. @@ -6886,16 +7039,37 @@ namespace ts { } // TODO: add support for: - // - methods - // - constructors - // - class decls - let containingFunction = getAncestor(tokenAtPos, SyntaxKind.FunctionDeclaration); + // - enums/enum members + // - interfaces + // - property declarations + // - potentially property assignments + let commentOwner: Node; + findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.Constructor: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.VariableStatement: + break findOwner; + case SyntaxKind.SourceFile: + return undefined; + case SyntaxKind.ModuleDeclaration: + // If in walking up the tree, we hit a a nested namespace declaration, + // then we must be somewhere within a dotted namespace name; however we don't + // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. + if (commentOwner.parent.kind === SyntaxKind.ModuleDeclaration) { + return undefined; + } + break findOwner; + } + } - if (!containingFunction || containingFunction.getStart() < position) { + if (!commentOwner || commentOwner.getStart() < position) { return undefined; } - let parameters = containingFunction.parameters; + let parameters = getParametersForJsDocOwningNode(commentOwner); let posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); let lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; @@ -6904,9 +7078,15 @@ namespace ts { // TODO: call a helper method instead once PR #4133 gets merged in. const newLine = host.getNewLine ? host.getNewLine() : "\r\n"; - let docParams = parameters.reduce((prev, cur, index) => - prev + - indentationStr + " * @param " + (cur.name.kind === SyntaxKind.Identifier ? (cur.name).text : "param" + index) + newLine, ""); + let docParams = ""; + for (let i = 0, numParams = parameters.length; i < numParams; i++) { + const currentName = parameters[i].name; + const paramName = currentName.kind === SyntaxKind.Identifier ? + (currentName).text : + "param" + i; + + docParams += `${indentationStr} * @param ${paramName}${newLine}`; + } // A doc comment consists of the following // * The opening comment line @@ -6926,6 +7106,52 @@ namespace ts { return { newText: result, caretOffset: preamble.length }; } + function getParametersForJsDocOwningNode(commentOwner: Node): ParameterDeclaration[] { + if (isFunctionLike(commentOwner)) { + return commentOwner.parameters; + } + + if (commentOwner.kind === SyntaxKind.VariableStatement) { + const varStatement = commentOwner; + const varDeclarations = varStatement.declarationList.declarations; + + if (varDeclarations.length === 1 && varDeclarations[0].initializer) { + return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + } + } + + return emptyArray; + } + + /** + * Digs into an an initializer or RHS operand of an assignment operation + * to get the parameters of an apt signature corresponding to a + * function expression or a class expression. + * + * @param rightHandSide the expression which may contain an appropriate set of parameters + * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. + */ + function getParametersFromRightHandSideOfAssignment(rightHandSide: Expression): ParameterDeclaration[] { + while (rightHandSide.kind === SyntaxKind.ParenthesizedExpression) { + rightHandSide = (rightHandSide).expression; + } + + switch (rightHandSide.kind) { + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + return (rightHandSide).parameters; + case SyntaxKind.ClassExpression: + for (let member of (rightHandSide).members) { + if (member.kind === SyntaxKind.Constructor) { + return (member).parameters; + } + } + break; + } + + return emptyArray; + } + function getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[] { // Note: while getting todo comments seems like a syntactic operation, we actually // treat it as a semantic operation here. This is because we expect our host to call @@ -7595,6 +7821,7 @@ namespace ts { case SyntaxKind.GreaterThanEqualsToken: case SyntaxKind.InstanceOfKeyword: case SyntaxKind.InKeyword: + case SyntaxKind.AsKeyword: case SyntaxKind.EqualsEqualsToken: case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: diff --git a/src/services/shims.ts b/src/services/shims.ts index e6ec71f368b..351514a1499 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -273,7 +273,7 @@ namespace ts { private loggingEnabled = false; private tracingEnabled = false; - public resolveModuleNames: (moduleName: string[], containingFile: string) => string[]; + public resolveModuleNames: (moduleName: string[], containingFile: string) => ResolvedModule[]; constructor(private shimHost: LanguageServiceShimHost) { // if shimHost is a COM object then property check will become method call with no arguments. @@ -281,7 +281,10 @@ namespace ts { if ("getModuleResolutionsForFile" in this.shimHost) { this.resolveModuleNames = (moduleNames: string[], containingFile: string) => { let resolutionsInFile = >JSON.parse(this.shimHost.getModuleResolutionsForFile(containingFile)); - return map(moduleNames, name => lookUp(resolutionsInFile, name)); + return map(moduleNames, name => { + const result = lookUp(resolutionsInFile, name); + return result ? { resolvedFileName: result } : undefined; + }); }; } } @@ -942,7 +945,11 @@ namespace ts { public resolveModuleName(fileName: string, moduleName: string, compilerOptionsJson: string): string { return this.forwardJSONCall(`resolveModuleName('${fileName}')`, () => { let compilerOptions = JSON.parse(compilerOptionsJson); - return resolveModuleName(moduleName, normalizeSlashes(fileName), compilerOptions, this.host); + const result = resolveModuleName(moduleName, normalizeSlashes(fileName), compilerOptions, this.host); + return { + resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName: undefined, + failedLookupLocations: result.failedLookupLocations + }; }); } @@ -1097,4 +1104,4 @@ module TypeScript.Services { } /* @internal */ -let toolsVersion = "1.5"; +const toolsVersion = "1.6"; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 04bfd04057c..a7198b4cc6d 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -9,7 +9,7 @@ namespace ts { export function getEndLinePosition(line: number, sourceFile: SourceFile): number { Debug.assert(line >= 0); let lineStarts = sourceFile.getLineStarts(); - + let lineIndex = line; if (lineIndex + 1 === lineStarts.length) { // last line - return EOF @@ -128,7 +128,8 @@ namespace ts { return isCompletedNode((n).thenStatement, sourceFile); case SyntaxKind.ExpressionStatement: - return isCompletedNode((n).expression, sourceFile); + return isCompletedNode((n).expression, sourceFile) || + hasChildOfKind(n, SyntaxKind.SemicolonToken); case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.ArrayBindingPattern: @@ -170,7 +171,7 @@ namespace ts { case SyntaxKind.VoidExpression: case SyntaxKind.YieldExpression: case SyntaxKind.SpreadElementExpression: - let unaryWordExpression = (n); + let unaryWordExpression = (n); return isCompletedNode(unaryWordExpression.expression, sourceFile); case SyntaxKind.TaggedTemplateExpression: @@ -252,7 +253,7 @@ namespace ts { }); // Either we didn't find an appropriate list, or the list must contain us. - Debug.assert(!syntaxList || contains(syntaxList.getChildren(), node)); + Debug.assert(!syntaxList || contains(syntaxList.getChildren(), node)); return syntaxList; } @@ -360,7 +361,7 @@ namespace ts { return find(startNode || sourceFile); function findRightmostToken(n: Node): Node { - if (isToken(n)) { + if (isToken(n) || n.kind === SyntaxKind.JsxText) { return n; } @@ -371,24 +372,35 @@ namespace ts { } function find(n: Node): Node { - if (isToken(n)) { + if (isToken(n) || n.kind === SyntaxKind.JsxText) { return n; } - let children = n.getChildren(); + const children = n.getChildren(); for (let i = 0, len = children.length; i < len; i++) { let child = children[i]; - if (nodeHasTokens(child)) { - if (position <= child.end) { - if (child.getStart(sourceFile) >= position) { - // 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) - } - else { - // candidate should be in this node - return find(child); - } + // condition 'position < child.end' checks if child node end after the position + // in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc' + // aaaa___bbbb___$__ccc + // after we found child node with end after the position we check if start of the node is after the position. + // if yes - then position is in the trivia and we need to look into the previous child to find the token in question. + // if no - position is in the node itself so we should recurse in it. + // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia). + // if this is the case - then we should assume that token in question is located in previous child. + if (position < child.end && (nodeHasTokens(child) || child.kind === SyntaxKind.JsxText)) { + const start = child.getStart(sourceFile); + const lookInPreviousChild = + (start >= position) || // cursor in the leading trivia + (child.kind === SyntaxKind.JsxText && start === child.end); // whitespace only JsxText + + 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) + } + else { + // candidate should be in this node + return find(child); } } } @@ -414,7 +426,7 @@ namespace ts { } } } - + export function isInString(sourceFile: SourceFile, position: number) { let token = getTokenAtPosition(sourceFile, position); return token && token.kind === SyntaxKind.StringLiteral && position > token.getStart(); @@ -462,13 +474,46 @@ namespace ts { let commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos); 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] === '*'; } } + /** + * Get the corresponding JSDocTag node if the position is in a jsDoc comment + */ + export function getJsDocTagAtPosition(sourceFile: SourceFile, position: number): JSDocTag { + let node = ts.getTokenAtPosition(sourceFile, position); + if (isToken(node)) { + switch (node.kind) { + case SyntaxKind.VarKeyword: + case SyntaxKind.LetKeyword: + case SyntaxKind.ConstKeyword: + // if the current token is var, let or const, skip the VariableDeclarationList + node = node.parent === undefined ? undefined : node.parent.parent; + break; + default: + node = node.parent; + break; + } + } + + if (node) { + let jsDocComment = node.jsDocComment; + if (jsDocComment) { + for (let tag of jsDocComment.tags) { + if (tag.pos <= position && position <= tag.end) { + return tag; + } + } + } + } + + return undefined; + } + function nodeHasTokens(n: Node): boolean { // If we have a token or node that has a non-zero width, it must have tokens. // Note, that getWidth() does not take trivia into account. @@ -518,6 +563,15 @@ namespace ts { return kind === SyntaxKind.SingleLineCommentTrivia || kind === SyntaxKind.MultiLineCommentTrivia; } + export function isStringOrRegularExpressionOrTemplateLiteral(kind: SyntaxKind): boolean { + if (kind === SyntaxKind.StringLiteral + || kind === SyntaxKind.RegularExpressionLiteral + || isTemplateLiteralKind(kind)) { + return true; + } + return false; + } + export function isPunctuation(kind: SyntaxKind): boolean { return SyntaxKind.FirstPunctuation <= kind && kind <= SyntaxKind.LastPunctuation; } @@ -582,7 +636,8 @@ namespace ts { increaseIndent: () => { indent++; }, decreaseIndent: () => { indent--; }, clear: resetWriter, - trackSymbol: () => { } + trackSymbol: () => { }, + reportInaccessibleThisError: () => { } }; function writeIndent() { @@ -640,13 +695,12 @@ namespace ts { else if (flags & SymbolFlags.TypeAlias) { return SymbolDisplayPartKind.aliasName; } else if (flags & SymbolFlags.Alias) { return SymbolDisplayPartKind.aliasName; } - return SymbolDisplayPartKind.text; } } export function displayPart(text: string, kind: SymbolDisplayPartKind, symbol?: Symbol): SymbolDisplayPart { - return { + return { text: text, kind: SymbolDisplayPartKind[kind] }; diff --git a/tests/baselines/reference/2dArrays.types b/tests/baselines/reference/2dArrays.types index b113ccdce7b..00805899294 100644 --- a/tests/baselines/reference/2dArrays.types +++ b/tests/baselines/reference/2dArrays.types @@ -28,7 +28,7 @@ class Board { >this.ships.every(function (val) { return val.isSunk; }) : boolean >this.ships.every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean >this.ships : Ship[] ->this : Board +>this : this >ships : Ship[] >every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean >function (val) { return val.isSunk; } : (val: Ship) => boolean diff --git a/tests/baselines/reference/accessOverriddenBaseClassMember1.types b/tests/baselines/reference/accessOverriddenBaseClassMember1.types index 2aeb541d723..f444544ea48 100644 --- a/tests/baselines/reference/accessOverriddenBaseClassMember1.types +++ b/tests/baselines/reference/accessOverriddenBaseClassMember1.types @@ -15,11 +15,11 @@ class Point { >"x=" + this.x : string >"x=" : string >this.x : number ->this : Point +>this : this >x : number >" y=" : string >this.y : number ->this : Point +>this : this >y : number } } @@ -50,7 +50,7 @@ class ColoredPoint extends Point { >toString : () => string >" color=" : string >this.color : string ->this : ColoredPoint +>this : this >color : string } } diff --git a/tests/baselines/reference/aliasAssignments.errors.txt b/tests/baselines/reference/aliasAssignments.errors.txt index 90a3672780f..fe13faba581 100644 --- a/tests/baselines/reference/aliasAssignments.errors.txt +++ b/tests/baselines/reference/aliasAssignments.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/aliasAssignments_1.ts(5,1): error TS2322: Type 'typeof "tes ==== tests/cases/compiler/aliasAssignments_1.ts (2 errors) ==== - import moduleA = require("aliasAssignments_moduleA"); + import moduleA = require("./aliasAssignments_moduleA"); var x = moduleA; x = 1; // Should be error ~ diff --git a/tests/baselines/reference/aliasAssignments.js b/tests/baselines/reference/aliasAssignments.js index a019d03f990..5283fe1bd99 100644 --- a/tests/baselines/reference/aliasAssignments.js +++ b/tests/baselines/reference/aliasAssignments.js @@ -6,7 +6,7 @@ export class someClass { } //// [aliasAssignments_1.ts] -import moduleA = require("aliasAssignments_moduleA"); +import moduleA = require("./aliasAssignments_moduleA"); var x = moduleA; x = 1; // Should be error var y = 1; @@ -21,7 +21,7 @@ var someClass = (function () { })(); exports.someClass = someClass; //// [aliasAssignments_1.js] -var moduleA = require("aliasAssignments_moduleA"); +var moduleA = require("./aliasAssignments_moduleA"); var x = moduleA; x = 1; // Should be error var y = 1; diff --git a/tests/baselines/reference/aliasUsageInAccessorsOfClass.js b/tests/baselines/reference/aliasUsageInAccessorsOfClass.js index 11e02297e47..bf7a7280f35 100644 --- a/tests/baselines/reference/aliasUsageInAccessorsOfClass.js +++ b/tests/baselines/reference/aliasUsageInAccessorsOfClass.js @@ -6,14 +6,14 @@ export class Model { } //// [aliasUsage1_moduleA.ts] -import Backbone = require("aliasUsage1_backbone"); +import Backbone = require("./aliasUsage1_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [aliasUsage1_main.ts] -import Backbone = require("aliasUsage1_backbone"); -import moduleA = require("aliasUsage1_moduleA"); +import Backbone = require("./aliasUsage1_backbone"); +import moduleA = require("./aliasUsage1_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -40,7 +40,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("aliasUsage1_backbone"); +var Backbone = require("./aliasUsage1_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -50,7 +50,7 @@ var VisualizationModel = (function (_super) { })(Backbone.Model); exports.VisualizationModel = VisualizationModel; //// [aliasUsage1_main.js] -var moduleA = require("aliasUsage1_moduleA"); +var moduleA = require("./aliasUsage1_moduleA"); var C2 = (function () { function C2() { } diff --git a/tests/baselines/reference/aliasUsageInAccessorsOfClass.symbols b/tests/baselines/reference/aliasUsageInAccessorsOfClass.symbols index 3524b1ce31e..62a2396e2b2 100644 --- a/tests/baselines/reference/aliasUsageInAccessorsOfClass.symbols +++ b/tests/baselines/reference/aliasUsageInAccessorsOfClass.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/aliasUsage1_main.ts === -import Backbone = require("aliasUsage1_backbone"); +import Backbone = require("./aliasUsage1_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsage1_main.ts, 0, 0)) -import moduleA = require("aliasUsage1_moduleA"); ->moduleA : Symbol(moduleA, Decl(aliasUsage1_main.ts, 0, 50)) +import moduleA = require("./aliasUsage1_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasUsage1_main.ts, 0, 52)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsage1_main.ts, 1, 48)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsage1_main.ts, 1, 50)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsage1_main.ts, 2, 34)) @@ -19,7 +19,7 @@ class C2 { x: IHasVisualizationModel; >x : Symbol(x, Decl(aliasUsage1_main.ts, 5, 10)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsage1_main.ts, 1, 48)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsage1_main.ts, 1, 50)) get A() { >A : Symbol(A, Decl(aliasUsage1_main.ts, 6, 30), Decl(aliasUsage1_main.ts, 9, 5)) @@ -35,7 +35,7 @@ class C2 { x = moduleA; >x : Symbol(x, Decl(aliasUsage1_main.ts, 10, 10)) ->moduleA : Symbol(moduleA, Decl(aliasUsage1_main.ts, 0, 50)) +>moduleA : Symbol(moduleA, Decl(aliasUsage1_main.ts, 0, 52)) } } === tests/cases/compiler/aliasUsage1_backbone.ts === @@ -47,11 +47,11 @@ export class Model { } === tests/cases/compiler/aliasUsage1_moduleA.ts === -import Backbone = require("aliasUsage1_backbone"); +import Backbone = require("./aliasUsage1_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsage1_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsage1_moduleA.ts, 0, 50)) +>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsage1_moduleA.ts, 0, 52)) >Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsage1_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(aliasUsage1_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(aliasUsage1_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/aliasUsageInAccessorsOfClass.types b/tests/baselines/reference/aliasUsageInAccessorsOfClass.types index 092643002e4..c66f4c5c193 100644 --- a/tests/baselines/reference/aliasUsageInAccessorsOfClass.types +++ b/tests/baselines/reference/aliasUsageInAccessorsOfClass.types @@ -1,8 +1,8 @@ === tests/cases/compiler/aliasUsage1_main.ts === -import Backbone = require("aliasUsage1_backbone"); +import Backbone = require("./aliasUsage1_backbone"); >Backbone : typeof Backbone -import moduleA = require("aliasUsage1_moduleA"); +import moduleA = require("./aliasUsage1_moduleA"); >moduleA : typeof moduleA interface IHasVisualizationModel { @@ -26,7 +26,7 @@ class C2 { return this.x; >this.x : IHasVisualizationModel ->this : C2 +>this : this >x : IHasVisualizationModel } set A(x) { @@ -48,7 +48,7 @@ export class Model { } === tests/cases/compiler/aliasUsage1_moduleA.ts === -import Backbone = require("aliasUsage1_backbone"); +import Backbone = require("./aliasUsage1_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/aliasUsageInArray.js b/tests/baselines/reference/aliasUsageInArray.js index ba0c954a3c2..108407345b7 100644 --- a/tests/baselines/reference/aliasUsageInArray.js +++ b/tests/baselines/reference/aliasUsageInArray.js @@ -6,14 +6,14 @@ export class Model { } //// [aliasUsageInArray_moduleA.ts] -import Backbone = require("aliasUsageInArray_backbone"); +import Backbone = require("./aliasUsageInArray_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [aliasUsageInArray_main.ts] -import Backbone = require("aliasUsageInArray_backbone"); -import moduleA = require("aliasUsageInArray_moduleA"); +import Backbone = require("./aliasUsageInArray_backbone"); +import moduleA = require("./aliasUsageInArray_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -34,7 +34,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("aliasUsageInArray_backbone"); +var Backbone = require("./aliasUsageInArray_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -44,6 +44,6 @@ var VisualizationModel = (function (_super) { })(Backbone.Model); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInArray_main.js] -var moduleA = require("aliasUsageInArray_moduleA"); +var moduleA = require("./aliasUsageInArray_moduleA"); var xs = [moduleA]; var xs2 = [moduleA]; diff --git a/tests/baselines/reference/aliasUsageInArray.symbols b/tests/baselines/reference/aliasUsageInArray.symbols index 7f1e31d2277..9bca1bc8864 100644 --- a/tests/baselines/reference/aliasUsageInArray.symbols +++ b/tests/baselines/reference/aliasUsageInArray.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/aliasUsageInArray_main.ts === -import Backbone = require("aliasUsageInArray_backbone"); +import Backbone = require("./aliasUsageInArray_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInArray_main.ts, 0, 0)) -import moduleA = require("aliasUsageInArray_moduleA"); ->moduleA : Symbol(moduleA, Decl(aliasUsageInArray_main.ts, 0, 56)) +import moduleA = require("./aliasUsageInArray_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasUsageInArray_main.ts, 0, 58)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInArray_main.ts, 1, 54)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInArray_main.ts, 1, 56)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInArray_main.ts, 2, 34)) @@ -17,13 +17,13 @@ interface IHasVisualizationModel { var xs: IHasVisualizationModel[] = [moduleA]; >xs : Symbol(xs, Decl(aliasUsageInArray_main.ts, 6, 3)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInArray_main.ts, 1, 54)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInArray_main.ts, 0, 56)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInArray_main.ts, 1, 56)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInArray_main.ts, 0, 58)) var xs2: typeof moduleA[] = [moduleA]; >xs2 : Symbol(xs2, Decl(aliasUsageInArray_main.ts, 7, 3)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInArray_main.ts, 0, 56)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInArray_main.ts, 0, 56)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInArray_main.ts, 0, 58)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInArray_main.ts, 0, 58)) === tests/cases/compiler/aliasUsageInArray_backbone.ts === export class Model { @@ -34,11 +34,11 @@ export class Model { } === tests/cases/compiler/aliasUsageInArray_moduleA.ts === -import Backbone = require("aliasUsageInArray_backbone"); +import Backbone = require("./aliasUsageInArray_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInArray_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInArray_moduleA.ts, 0, 56)) +>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInArray_moduleA.ts, 0, 58)) >Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsageInArray_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(aliasUsageInArray_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(aliasUsageInArray_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/aliasUsageInArray.types b/tests/baselines/reference/aliasUsageInArray.types index 488cc97d07f..218df8e10ed 100644 --- a/tests/baselines/reference/aliasUsageInArray.types +++ b/tests/baselines/reference/aliasUsageInArray.types @@ -1,8 +1,8 @@ === tests/cases/compiler/aliasUsageInArray_main.ts === -import Backbone = require("aliasUsageInArray_backbone"); +import Backbone = require("./aliasUsageInArray_backbone"); >Backbone : typeof Backbone -import moduleA = require("aliasUsageInArray_moduleA"); +import moduleA = require("./aliasUsageInArray_moduleA"); >moduleA : typeof moduleA interface IHasVisualizationModel { @@ -36,7 +36,7 @@ export class Model { } === tests/cases/compiler/aliasUsageInArray_moduleA.ts === -import Backbone = require("aliasUsageInArray_backbone"); +import Backbone = require("./aliasUsageInArray_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/aliasUsageInFunctionExpression.js b/tests/baselines/reference/aliasUsageInFunctionExpression.js index 702cbe4d53f..4229491c4c5 100644 --- a/tests/baselines/reference/aliasUsageInFunctionExpression.js +++ b/tests/baselines/reference/aliasUsageInFunctionExpression.js @@ -6,14 +6,14 @@ export class Model { } //// [aliasUsageInFunctionExpression_moduleA.ts] -import Backbone = require("aliasUsageInFunctionExpression_backbone"); +import Backbone = require("./aliasUsageInFunctionExpression_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [aliasUsageInFunctionExpression_main.ts] -import Backbone = require("aliasUsageInFunctionExpression_backbone"); -import moduleA = require("aliasUsageInFunctionExpression_moduleA"); +import Backbone = require("./aliasUsageInFunctionExpression_backbone"); +import moduleA = require("./aliasUsageInFunctionExpression_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -33,7 +33,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("aliasUsageInFunctionExpression_backbone"); +var Backbone = require("./aliasUsageInFunctionExpression_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -43,6 +43,6 @@ var VisualizationModel = (function (_super) { })(Backbone.Model); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInFunctionExpression_main.js] -var moduleA = require("aliasUsageInFunctionExpression_moduleA"); +var moduleA = require("./aliasUsageInFunctionExpression_moduleA"); var f = function (x) { return x; }; f = function (x) { return moduleA; }; diff --git a/tests/baselines/reference/aliasUsageInFunctionExpression.symbols b/tests/baselines/reference/aliasUsageInFunctionExpression.symbols index 2afb6be55c5..bd791d4d38f 100644 --- a/tests/baselines/reference/aliasUsageInFunctionExpression.symbols +++ b/tests/baselines/reference/aliasUsageInFunctionExpression.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/aliasUsageInFunctionExpression_main.ts === -import Backbone = require("aliasUsageInFunctionExpression_backbone"); +import Backbone = require("./aliasUsageInFunctionExpression_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInFunctionExpression_main.ts, 0, 0)) -import moduleA = require("aliasUsageInFunctionExpression_moduleA"); ->moduleA : Symbol(moduleA, Decl(aliasUsageInFunctionExpression_main.ts, 0, 69)) +import moduleA = require("./aliasUsageInFunctionExpression_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasUsageInFunctionExpression_main.ts, 0, 71)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInFunctionExpression_main.ts, 1, 67)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInFunctionExpression_main.ts, 1, 69)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInFunctionExpression_main.ts, 2, 34)) @@ -17,13 +17,13 @@ interface IHasVisualizationModel { var f = (x: IHasVisualizationModel) => x; >f : Symbol(f, Decl(aliasUsageInFunctionExpression_main.ts, 5, 3)) >x : Symbol(x, Decl(aliasUsageInFunctionExpression_main.ts, 5, 9)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInFunctionExpression_main.ts, 1, 67)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInFunctionExpression_main.ts, 1, 69)) >x : Symbol(x, Decl(aliasUsageInFunctionExpression_main.ts, 5, 9)) f = (x) => moduleA; >f : Symbol(f, Decl(aliasUsageInFunctionExpression_main.ts, 5, 3)) >x : Symbol(x, Decl(aliasUsageInFunctionExpression_main.ts, 6, 5)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInFunctionExpression_main.ts, 0, 69)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInFunctionExpression_main.ts, 0, 71)) === tests/cases/compiler/aliasUsageInFunctionExpression_backbone.ts === export class Model { @@ -34,11 +34,11 @@ export class Model { } === tests/cases/compiler/aliasUsageInFunctionExpression_moduleA.ts === -import Backbone = require("aliasUsageInFunctionExpression_backbone"); +import Backbone = require("./aliasUsageInFunctionExpression_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInFunctionExpression_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInFunctionExpression_moduleA.ts, 0, 69)) +>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInFunctionExpression_moduleA.ts, 0, 71)) >Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsageInFunctionExpression_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(aliasUsageInFunctionExpression_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(aliasUsageInFunctionExpression_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/aliasUsageInFunctionExpression.types b/tests/baselines/reference/aliasUsageInFunctionExpression.types index eec4341fd67..15716de5330 100644 --- a/tests/baselines/reference/aliasUsageInFunctionExpression.types +++ b/tests/baselines/reference/aliasUsageInFunctionExpression.types @@ -1,8 +1,8 @@ === tests/cases/compiler/aliasUsageInFunctionExpression_main.ts === -import Backbone = require("aliasUsageInFunctionExpression_backbone"); +import Backbone = require("./aliasUsageInFunctionExpression_backbone"); >Backbone : typeof Backbone -import moduleA = require("aliasUsageInFunctionExpression_moduleA"); +import moduleA = require("./aliasUsageInFunctionExpression_moduleA"); >moduleA : typeof moduleA interface IHasVisualizationModel { @@ -37,7 +37,7 @@ export class Model { } === tests/cases/compiler/aliasUsageInFunctionExpression_moduleA.ts === -import Backbone = require("aliasUsageInFunctionExpression_backbone"); +import Backbone = require("./aliasUsageInFunctionExpression_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/aliasUsageInGenericFunction.js b/tests/baselines/reference/aliasUsageInGenericFunction.js index 8706dd592eb..7091c6d27c6 100644 --- a/tests/baselines/reference/aliasUsageInGenericFunction.js +++ b/tests/baselines/reference/aliasUsageInGenericFunction.js @@ -6,14 +6,14 @@ export class Model { } //// [aliasUsageInGenericFunction_moduleA.ts] -import Backbone = require("aliasUsageInGenericFunction_backbone"); +import Backbone = require("./aliasUsageInGenericFunction_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [aliasUsageInGenericFunction_main.ts] -import Backbone = require("aliasUsageInGenericFunction_backbone"); -import moduleA = require("aliasUsageInGenericFunction_moduleA"); +import Backbone = require("./aliasUsageInGenericFunction_backbone"); +import moduleA = require("./aliasUsageInGenericFunction_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -37,7 +37,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("aliasUsageInGenericFunction_backbone"); +var Backbone = require("./aliasUsageInGenericFunction_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -47,7 +47,7 @@ var VisualizationModel = (function (_super) { })(Backbone.Model); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInGenericFunction_main.js] -var moduleA = require("aliasUsageInGenericFunction_moduleA"); +var moduleA = require("./aliasUsageInGenericFunction_moduleA"); function foo(x) { return x; } diff --git a/tests/baselines/reference/aliasUsageInGenericFunction.symbols b/tests/baselines/reference/aliasUsageInGenericFunction.symbols index 3f001e8bd1a..fccf60c3514 100644 --- a/tests/baselines/reference/aliasUsageInGenericFunction.symbols +++ b/tests/baselines/reference/aliasUsageInGenericFunction.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/aliasUsageInGenericFunction_main.ts === -import Backbone = require("aliasUsageInGenericFunction_backbone"); +import Backbone = require("./aliasUsageInGenericFunction_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInGenericFunction_main.ts, 0, 0)) -import moduleA = require("aliasUsageInGenericFunction_moduleA"); ->moduleA : Symbol(moduleA, Decl(aliasUsageInGenericFunction_main.ts, 0, 66)) +import moduleA = require("./aliasUsageInGenericFunction_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasUsageInGenericFunction_main.ts, 0, 68)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInGenericFunction_main.ts, 1, 64)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInGenericFunction_main.ts, 1, 66)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInGenericFunction_main.ts, 2, 34)) @@ -18,7 +18,7 @@ function foo(x: T) { >foo : Symbol(foo, Decl(aliasUsageInGenericFunction_main.ts, 4, 1)) >T : Symbol(T, Decl(aliasUsageInGenericFunction_main.ts, 5, 13)) >a : Symbol(a, Decl(aliasUsageInGenericFunction_main.ts, 5, 24)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInGenericFunction_main.ts, 1, 64)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInGenericFunction_main.ts, 1, 66)) >x : Symbol(x, Decl(aliasUsageInGenericFunction_main.ts, 5, 54)) >T : Symbol(T, Decl(aliasUsageInGenericFunction_main.ts, 5, 13)) @@ -29,13 +29,13 @@ var r = foo({ a: moduleA }); >r : Symbol(r, Decl(aliasUsageInGenericFunction_main.ts, 8, 3)) >foo : Symbol(foo, Decl(aliasUsageInGenericFunction_main.ts, 4, 1)) >a : Symbol(a, Decl(aliasUsageInGenericFunction_main.ts, 8, 13)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInGenericFunction_main.ts, 0, 66)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInGenericFunction_main.ts, 0, 68)) var r2 = foo({ a: null }); >r2 : Symbol(r2, Decl(aliasUsageInGenericFunction_main.ts, 9, 3)) >foo : Symbol(foo, Decl(aliasUsageInGenericFunction_main.ts, 4, 1)) >a : Symbol(a, Decl(aliasUsageInGenericFunction_main.ts, 9, 14)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInGenericFunction_main.ts, 1, 64)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInGenericFunction_main.ts, 1, 66)) === tests/cases/compiler/aliasUsageInGenericFunction_backbone.ts === export class Model { @@ -46,11 +46,11 @@ export class Model { } === tests/cases/compiler/aliasUsageInGenericFunction_moduleA.ts === -import Backbone = require("aliasUsageInGenericFunction_backbone"); +import Backbone = require("./aliasUsageInGenericFunction_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInGenericFunction_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInGenericFunction_moduleA.ts, 0, 66)) +>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInGenericFunction_moduleA.ts, 0, 68)) >Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsageInGenericFunction_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(aliasUsageInGenericFunction_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(aliasUsageInGenericFunction_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/aliasUsageInGenericFunction.types b/tests/baselines/reference/aliasUsageInGenericFunction.types index c21e691d773..5fe7a3e49ef 100644 --- a/tests/baselines/reference/aliasUsageInGenericFunction.types +++ b/tests/baselines/reference/aliasUsageInGenericFunction.types @@ -1,8 +1,8 @@ === tests/cases/compiler/aliasUsageInGenericFunction_main.ts === -import Backbone = require("aliasUsageInGenericFunction_backbone"); +import Backbone = require("./aliasUsageInGenericFunction_backbone"); >Backbone : typeof Backbone -import moduleA = require("aliasUsageInGenericFunction_moduleA"); +import moduleA = require("./aliasUsageInGenericFunction_moduleA"); >moduleA : typeof moduleA interface IHasVisualizationModel { @@ -52,7 +52,7 @@ export class Model { } === tests/cases/compiler/aliasUsageInGenericFunction_moduleA.ts === -import Backbone = require("aliasUsageInGenericFunction_backbone"); +import Backbone = require("./aliasUsageInGenericFunction_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/aliasUsageInIndexerOfClass.js b/tests/baselines/reference/aliasUsageInIndexerOfClass.js index 78ddd2d4a94..82490739687 100644 --- a/tests/baselines/reference/aliasUsageInIndexerOfClass.js +++ b/tests/baselines/reference/aliasUsageInIndexerOfClass.js @@ -6,14 +6,14 @@ export class Model { } //// [aliasUsageInIndexerOfClass_moduleA.ts] -import Backbone = require("aliasUsageInIndexerOfClass_backbone"); +import Backbone = require("./aliasUsageInIndexerOfClass_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [aliasUsageInIndexerOfClass_main.ts] -import Backbone = require("aliasUsageInIndexerOfClass_backbone"); -import moduleA = require("aliasUsageInIndexerOfClass_moduleA"); +import Backbone = require("./aliasUsageInIndexerOfClass_backbone"); +import moduleA = require("./aliasUsageInIndexerOfClass_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -39,7 +39,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("aliasUsageInIndexerOfClass_backbone"); +var Backbone = require("./aliasUsageInIndexerOfClass_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -49,7 +49,7 @@ var VisualizationModel = (function (_super) { })(Backbone.Model); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInIndexerOfClass_main.js] -var moduleA = require("aliasUsageInIndexerOfClass_moduleA"); +var moduleA = require("./aliasUsageInIndexerOfClass_moduleA"); var N = (function () { function N() { this.x = moduleA; diff --git a/tests/baselines/reference/aliasUsageInIndexerOfClass.symbols b/tests/baselines/reference/aliasUsageInIndexerOfClass.symbols index 900653c7fd1..37529d2ead2 100644 --- a/tests/baselines/reference/aliasUsageInIndexerOfClass.symbols +++ b/tests/baselines/reference/aliasUsageInIndexerOfClass.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/aliasUsageInIndexerOfClass_main.ts === -import Backbone = require("aliasUsageInIndexerOfClass_backbone"); +import Backbone = require("./aliasUsageInIndexerOfClass_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInIndexerOfClass_main.ts, 0, 0)) -import moduleA = require("aliasUsageInIndexerOfClass_moduleA"); ->moduleA : Symbol(moduleA, Decl(aliasUsageInIndexerOfClass_main.ts, 0, 65)) +import moduleA = require("./aliasUsageInIndexerOfClass_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasUsageInIndexerOfClass_main.ts, 0, 67)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInIndexerOfClass_main.ts, 1, 63)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInIndexerOfClass_main.ts, 1, 65)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInIndexerOfClass_main.ts, 2, 34)) @@ -19,22 +19,22 @@ class N { [idx: string]: IHasVisualizationModel >idx : Symbol(idx, Decl(aliasUsageInIndexerOfClass_main.ts, 6, 5)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInIndexerOfClass_main.ts, 1, 63)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInIndexerOfClass_main.ts, 1, 65)) x = moduleA; >x : Symbol(x, Decl(aliasUsageInIndexerOfClass_main.ts, 6, 41)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInIndexerOfClass_main.ts, 0, 65)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInIndexerOfClass_main.ts, 0, 67)) } class N2 { >N2 : Symbol(N2, Decl(aliasUsageInIndexerOfClass_main.ts, 8, 1)) [idx: string]: typeof moduleA >idx : Symbol(idx, Decl(aliasUsageInIndexerOfClass_main.ts, 10, 5)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInIndexerOfClass_main.ts, 0, 65)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInIndexerOfClass_main.ts, 0, 67)) x: IHasVisualizationModel; >x : Symbol(x, Decl(aliasUsageInIndexerOfClass_main.ts, 10, 33)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInIndexerOfClass_main.ts, 1, 63)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInIndexerOfClass_main.ts, 1, 65)) } === tests/cases/compiler/aliasUsageInIndexerOfClass_backbone.ts === export class Model { @@ -45,11 +45,11 @@ export class Model { } === tests/cases/compiler/aliasUsageInIndexerOfClass_moduleA.ts === -import Backbone = require("aliasUsageInIndexerOfClass_backbone"); +import Backbone = require("./aliasUsageInIndexerOfClass_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInIndexerOfClass_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInIndexerOfClass_moduleA.ts, 0, 65)) +>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInIndexerOfClass_moduleA.ts, 0, 67)) >Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsageInIndexerOfClass_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(aliasUsageInIndexerOfClass_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(aliasUsageInIndexerOfClass_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/aliasUsageInIndexerOfClass.types b/tests/baselines/reference/aliasUsageInIndexerOfClass.types index b7e4873ba34..d6040a90410 100644 --- a/tests/baselines/reference/aliasUsageInIndexerOfClass.types +++ b/tests/baselines/reference/aliasUsageInIndexerOfClass.types @@ -1,8 +1,8 @@ === tests/cases/compiler/aliasUsageInIndexerOfClass_main.ts === -import Backbone = require("aliasUsageInIndexerOfClass_backbone"); +import Backbone = require("./aliasUsageInIndexerOfClass_backbone"); >Backbone : typeof Backbone -import moduleA = require("aliasUsageInIndexerOfClass_moduleA"); +import moduleA = require("./aliasUsageInIndexerOfClass_moduleA"); >moduleA : typeof moduleA interface IHasVisualizationModel { @@ -45,7 +45,7 @@ export class Model { } === tests/cases/compiler/aliasUsageInIndexerOfClass_moduleA.ts === -import Backbone = require("aliasUsageInIndexerOfClass_backbone"); +import Backbone = require("./aliasUsageInIndexerOfClass_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/aliasUsageInObjectLiteral.js b/tests/baselines/reference/aliasUsageInObjectLiteral.js index f38cdf2111c..f1bb99018df 100644 --- a/tests/baselines/reference/aliasUsageInObjectLiteral.js +++ b/tests/baselines/reference/aliasUsageInObjectLiteral.js @@ -6,14 +6,14 @@ export class Model { } //// [aliasUsageInObjectLiteral_moduleA.ts] -import Backbone = require("aliasUsageInObjectLiteral_backbone"); +import Backbone = require("./aliasUsageInObjectLiteral_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [aliasUsageInObjectLiteral_main.ts] -import Backbone = require("aliasUsageInObjectLiteral_backbone"); -import moduleA = require("aliasUsageInObjectLiteral_moduleA"); +import Backbone = require("./aliasUsageInObjectLiteral_backbone"); +import moduleA = require("./aliasUsageInObjectLiteral_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -34,7 +34,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("aliasUsageInObjectLiteral_backbone"); +var Backbone = require("./aliasUsageInObjectLiteral_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -44,7 +44,7 @@ var VisualizationModel = (function (_super) { })(Backbone.Model); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInObjectLiteral_main.js] -var moduleA = require("aliasUsageInObjectLiteral_moduleA"); +var moduleA = require("./aliasUsageInObjectLiteral_moduleA"); var a = { x: moduleA }; var b = { x: moduleA }; var c = { y: { z: moduleA } }; diff --git a/tests/baselines/reference/aliasUsageInObjectLiteral.symbols b/tests/baselines/reference/aliasUsageInObjectLiteral.symbols index a508e9fafc1..ef94a9037ad 100644 --- a/tests/baselines/reference/aliasUsageInObjectLiteral.symbols +++ b/tests/baselines/reference/aliasUsageInObjectLiteral.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/aliasUsageInObjectLiteral_main.ts === -import Backbone = require("aliasUsageInObjectLiteral_backbone"); +import Backbone = require("./aliasUsageInObjectLiteral_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInObjectLiteral_main.ts, 0, 0)) -import moduleA = require("aliasUsageInObjectLiteral_moduleA"); ->moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 64)) +import moduleA = require("./aliasUsageInObjectLiteral_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 66)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInObjectLiteral_main.ts, 1, 62)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInObjectLiteral_main.ts, 1, 64)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInObjectLiteral_main.ts, 2, 34)) @@ -17,25 +17,25 @@ interface IHasVisualizationModel { var a: { x: typeof moduleA } = { x: moduleA }; >a : Symbol(a, Decl(aliasUsageInObjectLiteral_main.ts, 5, 3)) >x : Symbol(x, Decl(aliasUsageInObjectLiteral_main.ts, 5, 8)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 64)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 66)) >x : Symbol(x, Decl(aliasUsageInObjectLiteral_main.ts, 5, 32)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 64)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 66)) var b: { x: IHasVisualizationModel } = { x: moduleA }; >b : Symbol(b, Decl(aliasUsageInObjectLiteral_main.ts, 6, 3)) >x : Symbol(x, Decl(aliasUsageInObjectLiteral_main.ts, 6, 8)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInObjectLiteral_main.ts, 1, 62)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInObjectLiteral_main.ts, 1, 64)) >x : Symbol(x, Decl(aliasUsageInObjectLiteral_main.ts, 6, 40)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 64)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 66)) var c: { y: { z: IHasVisualizationModel } } = { y: { z: moduleA } }; >c : Symbol(c, Decl(aliasUsageInObjectLiteral_main.ts, 7, 3)) >y : Symbol(y, Decl(aliasUsageInObjectLiteral_main.ts, 7, 8)) >z : Symbol(z, Decl(aliasUsageInObjectLiteral_main.ts, 7, 13)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInObjectLiteral_main.ts, 1, 62)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInObjectLiteral_main.ts, 1, 64)) >y : Symbol(y, Decl(aliasUsageInObjectLiteral_main.ts, 7, 47)) >z : Symbol(z, Decl(aliasUsageInObjectLiteral_main.ts, 7, 52)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 64)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInObjectLiteral_main.ts, 0, 66)) === tests/cases/compiler/aliasUsageInObjectLiteral_backbone.ts === export class Model { @@ -46,11 +46,11 @@ export class Model { } === tests/cases/compiler/aliasUsageInObjectLiteral_moduleA.ts === -import Backbone = require("aliasUsageInObjectLiteral_backbone"); +import Backbone = require("./aliasUsageInObjectLiteral_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInObjectLiteral_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInObjectLiteral_moduleA.ts, 0, 64)) +>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInObjectLiteral_moduleA.ts, 0, 66)) >Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsageInObjectLiteral_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(aliasUsageInObjectLiteral_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(aliasUsageInObjectLiteral_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/aliasUsageInObjectLiteral.types b/tests/baselines/reference/aliasUsageInObjectLiteral.types index 5ab294b7350..5c8f08a6af2 100644 --- a/tests/baselines/reference/aliasUsageInObjectLiteral.types +++ b/tests/baselines/reference/aliasUsageInObjectLiteral.types @@ -1,8 +1,8 @@ === tests/cases/compiler/aliasUsageInObjectLiteral_main.ts === -import Backbone = require("aliasUsageInObjectLiteral_backbone"); +import Backbone = require("./aliasUsageInObjectLiteral_backbone"); >Backbone : typeof Backbone -import moduleA = require("aliasUsageInObjectLiteral_moduleA"); +import moduleA = require("./aliasUsageInObjectLiteral_moduleA"); >moduleA : typeof moduleA interface IHasVisualizationModel { @@ -50,7 +50,7 @@ export class Model { } === tests/cases/compiler/aliasUsageInObjectLiteral_moduleA.ts === -import Backbone = require("aliasUsageInObjectLiteral_backbone"); +import Backbone = require("./aliasUsageInObjectLiteral_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/aliasUsageInOrExpression.js b/tests/baselines/reference/aliasUsageInOrExpression.js index 906a2c019d7..817ad95aaea 100644 --- a/tests/baselines/reference/aliasUsageInOrExpression.js +++ b/tests/baselines/reference/aliasUsageInOrExpression.js @@ -6,14 +6,14 @@ export class Model { } //// [aliasUsageInOrExpression_moduleA.ts] -import Backbone = require("aliasUsageInOrExpression_backbone"); +import Backbone = require("./aliasUsageInOrExpression_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [aliasUsageInOrExpression_main.ts] -import Backbone = require("aliasUsageInOrExpression_backbone"); -import moduleA = require("aliasUsageInOrExpression_moduleA"); +import Backbone = require("./aliasUsageInOrExpression_backbone"); +import moduleA = require("./aliasUsageInOrExpression_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -37,7 +37,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("aliasUsageInOrExpression_backbone"); +var Backbone = require("./aliasUsageInOrExpression_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -47,7 +47,7 @@ var VisualizationModel = (function (_super) { })(Backbone.Model); exports.VisualizationModel = VisualizationModel; //// [aliasUsageInOrExpression_main.js] -var moduleA = require("aliasUsageInOrExpression_moduleA"); +var moduleA = require("./aliasUsageInOrExpression_moduleA"); var i; var d1 = i || moduleA; var d2 = i || moduleA; diff --git a/tests/baselines/reference/aliasUsageInOrExpression.symbols b/tests/baselines/reference/aliasUsageInOrExpression.symbols index adfba01a119..3d9331b1fa9 100644 --- a/tests/baselines/reference/aliasUsageInOrExpression.symbols +++ b/tests/baselines/reference/aliasUsageInOrExpression.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/aliasUsageInOrExpression_main.ts === -import Backbone = require("aliasUsageInOrExpression_backbone"); +import Backbone = require("./aliasUsageInOrExpression_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInOrExpression_main.ts, 0, 0)) -import moduleA = require("aliasUsageInOrExpression_moduleA"); ->moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 63)) +import moduleA = require("./aliasUsageInOrExpression_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 65)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 61)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 63)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 2, 34)) @@ -16,42 +16,42 @@ interface IHasVisualizationModel { } var i: IHasVisualizationModel; >i : Symbol(i, Decl(aliasUsageInOrExpression_main.ts, 5, 3)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 61)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 63)) var d1 = i || moduleA; >d1 : Symbol(d1, Decl(aliasUsageInOrExpression_main.ts, 6, 3)) >i : Symbol(i, Decl(aliasUsageInOrExpression_main.ts, 5, 3)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 63)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 65)) var d2: IHasVisualizationModel = i || moduleA; >d2 : Symbol(d2, Decl(aliasUsageInOrExpression_main.ts, 7, 3), Decl(aliasUsageInOrExpression_main.ts, 8, 3)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 61)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 63)) >i : Symbol(i, Decl(aliasUsageInOrExpression_main.ts, 5, 3)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 63)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 65)) var d2: IHasVisualizationModel = moduleA || i; >d2 : Symbol(d2, Decl(aliasUsageInOrExpression_main.ts, 7, 3), Decl(aliasUsageInOrExpression_main.ts, 8, 3)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 61)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 63)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 63)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 65)) >i : Symbol(i, Decl(aliasUsageInOrExpression_main.ts, 5, 3)) var e: { x: IHasVisualizationModel } = <{ x: IHasVisualizationModel }>null || { x: moduleA }; >e : Symbol(e, Decl(aliasUsageInOrExpression_main.ts, 9, 3)) >x : Symbol(x, Decl(aliasUsageInOrExpression_main.ts, 9, 8)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 61)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 63)) >x : Symbol(x, Decl(aliasUsageInOrExpression_main.ts, 9, 41)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 61)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 63)) >x : Symbol(x, Decl(aliasUsageInOrExpression_main.ts, 9, 79)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 63)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 65)) var f: { x: IHasVisualizationModel } = <{ x: IHasVisualizationModel }>null ? { x: moduleA } : null; >f : Symbol(f, Decl(aliasUsageInOrExpression_main.ts, 10, 3)) >x : Symbol(x, Decl(aliasUsageInOrExpression_main.ts, 10, 8)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 61)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 63)) >x : Symbol(x, Decl(aliasUsageInOrExpression_main.ts, 10, 41)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 61)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInOrExpression_main.ts, 1, 63)) >x : Symbol(x, Decl(aliasUsageInOrExpression_main.ts, 10, 78)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 63)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInOrExpression_main.ts, 0, 65)) === tests/cases/compiler/aliasUsageInOrExpression_backbone.ts === export class Model { @@ -62,11 +62,11 @@ export class Model { } === tests/cases/compiler/aliasUsageInOrExpression_moduleA.ts === -import Backbone = require("aliasUsageInOrExpression_backbone"); +import Backbone = require("./aliasUsageInOrExpression_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInOrExpression_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInOrExpression_moduleA.ts, 0, 63)) +>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInOrExpression_moduleA.ts, 0, 65)) >Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsageInOrExpression_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(aliasUsageInOrExpression_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(aliasUsageInOrExpression_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/aliasUsageInOrExpression.types b/tests/baselines/reference/aliasUsageInOrExpression.types index f009e7084eb..c43b7889cc5 100644 --- a/tests/baselines/reference/aliasUsageInOrExpression.types +++ b/tests/baselines/reference/aliasUsageInOrExpression.types @@ -1,8 +1,8 @@ === tests/cases/compiler/aliasUsageInOrExpression_main.ts === -import Backbone = require("aliasUsageInOrExpression_backbone"); +import Backbone = require("./aliasUsageInOrExpression_backbone"); >Backbone : typeof Backbone -import moduleA = require("aliasUsageInOrExpression_moduleA"); +import moduleA = require("./aliasUsageInOrExpression_moduleA"); >moduleA : typeof moduleA interface IHasVisualizationModel { @@ -74,7 +74,7 @@ export class Model { } === tests/cases/compiler/aliasUsageInOrExpression_moduleA.ts === -import Backbone = require("aliasUsageInOrExpression_backbone"); +import Backbone = require("./aliasUsageInOrExpression_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js index 27f85bb5fcd..270a2807319 100644 --- a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js +++ b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.js @@ -6,14 +6,14 @@ export class Model { } //// [aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts] -import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); +import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [aliasUsageInTypeArgumentOfExtendsClause_main.ts] -import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); -import moduleA = require("aliasUsageInTypeArgumentOfExtendsClause_moduleA"); +import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); +import moduleA = require("./aliasUsageInTypeArgumentOfExtendsClause_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -37,7 +37,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); +var Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -52,7 +52,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var moduleA = require("aliasUsageInTypeArgumentOfExtendsClause_moduleA"); +var moduleA = require("./aliasUsageInTypeArgumentOfExtendsClause_moduleA"); var C = (function () { function C() { } diff --git a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.symbols b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.symbols index f3ca1f7ec37..6fc639da2c1 100644 --- a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.symbols +++ b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause_main.ts === -import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); +import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 0, 0)) -import moduleA = require("aliasUsageInTypeArgumentOfExtendsClause_moduleA"); ->moduleA : Symbol(moduleA, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 0, 78)) +import moduleA = require("./aliasUsageInTypeArgumentOfExtendsClause_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 0, 80)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 1, 76)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 1, 78)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 2, 34)) @@ -17,7 +17,7 @@ interface IHasVisualizationModel { class C { >C : Symbol(C, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 4, 1)) >T : Symbol(T, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 5, 8)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 1, 76)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 1, 78)) x: T; >x : Symbol(x, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 5, 43)) @@ -26,11 +26,11 @@ class C { class D extends C { >D : Symbol(D, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 7, 1)) >C : Symbol(C, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 4, 1)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 1, 76)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 1, 78)) x = moduleA; >x : Symbol(x, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 8, 43)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 0, 78)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInTypeArgumentOfExtendsClause_main.ts, 0, 80)) } === tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause_backbone.ts === export class Model { @@ -41,11 +41,11 @@ export class Model { } === tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts === -import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); +import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts, 0, 78)) +>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts, 0, 80)) >Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsageInTypeArgumentOfExtendsClause_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(aliasUsageInTypeArgumentOfExtendsClause_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types index ae20caa9c37..3d3d3b6d3f5 100644 --- a/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types +++ b/tests/baselines/reference/aliasUsageInTypeArgumentOfExtendsClause.types @@ -1,8 +1,8 @@ === tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause_main.ts === -import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); +import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); >Backbone : typeof Backbone -import moduleA = require("aliasUsageInTypeArgumentOfExtendsClause_moduleA"); +import moduleA = require("./aliasUsageInTypeArgumentOfExtendsClause_moduleA"); >moduleA : typeof moduleA interface IHasVisualizationModel { @@ -41,7 +41,7 @@ export class Model { } === tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts === -import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); +import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/aliasUsageInVarAssignment.js b/tests/baselines/reference/aliasUsageInVarAssignment.js index bfc63868ff4..f7949348cdd 100644 --- a/tests/baselines/reference/aliasUsageInVarAssignment.js +++ b/tests/baselines/reference/aliasUsageInVarAssignment.js @@ -6,14 +6,14 @@ export class Model { } //// [aliasUsageInVarAssignment_moduleA.ts] -import Backbone = require("aliasUsageInVarAssignment_backbone"); +import Backbone = require("./aliasUsageInVarAssignment_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [aliasUsageInVarAssignment_main.ts] -import Backbone = require("aliasUsageInVarAssignment_backbone"); -import moduleA = require("aliasUsageInVarAssignment_moduleA"); +import Backbone = require("./aliasUsageInVarAssignment_backbone"); +import moduleA = require("./aliasUsageInVarAssignment_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -33,7 +33,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("aliasUsageInVarAssignment_backbone"); +var Backbone = require("./aliasUsageInVarAssignment_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { diff --git a/tests/baselines/reference/aliasUsageInVarAssignment.symbols b/tests/baselines/reference/aliasUsageInVarAssignment.symbols index d1996fe8ecb..d0e7f6b7d05 100644 --- a/tests/baselines/reference/aliasUsageInVarAssignment.symbols +++ b/tests/baselines/reference/aliasUsageInVarAssignment.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/aliasUsageInVarAssignment_main.ts === -import Backbone = require("aliasUsageInVarAssignment_backbone"); +import Backbone = require("./aliasUsageInVarAssignment_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInVarAssignment_main.ts, 0, 0)) -import moduleA = require("aliasUsageInVarAssignment_moduleA"); ->moduleA : Symbol(moduleA, Decl(aliasUsageInVarAssignment_main.ts, 0, 64)) +import moduleA = require("./aliasUsageInVarAssignment_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasUsageInVarAssignment_main.ts, 0, 66)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInVarAssignment_main.ts, 1, 62)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInVarAssignment_main.ts, 1, 64)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInVarAssignment_main.ts, 2, 34)) @@ -16,11 +16,11 @@ interface IHasVisualizationModel { } var i: IHasVisualizationModel; >i : Symbol(i, Decl(aliasUsageInVarAssignment_main.ts, 5, 3)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInVarAssignment_main.ts, 1, 62)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(aliasUsageInVarAssignment_main.ts, 1, 64)) var m: typeof moduleA = i; >m : Symbol(m, Decl(aliasUsageInVarAssignment_main.ts, 6, 3)) ->moduleA : Symbol(moduleA, Decl(aliasUsageInVarAssignment_main.ts, 0, 64)) +>moduleA : Symbol(moduleA, Decl(aliasUsageInVarAssignment_main.ts, 0, 66)) >i : Symbol(i, Decl(aliasUsageInVarAssignment_main.ts, 5, 3)) === tests/cases/compiler/aliasUsageInVarAssignment_backbone.ts === @@ -32,11 +32,11 @@ export class Model { } === tests/cases/compiler/aliasUsageInVarAssignment_moduleA.ts === -import Backbone = require("aliasUsageInVarAssignment_backbone"); +import Backbone = require("./aliasUsageInVarAssignment_backbone"); >Backbone : Symbol(Backbone, Decl(aliasUsageInVarAssignment_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInVarAssignment_moduleA.ts, 0, 64)) +>VisualizationModel : Symbol(VisualizationModel, Decl(aliasUsageInVarAssignment_moduleA.ts, 0, 66)) >Backbone.Model : Symbol(Backbone.Model, Decl(aliasUsageInVarAssignment_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(aliasUsageInVarAssignment_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(aliasUsageInVarAssignment_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/aliasUsageInVarAssignment.types b/tests/baselines/reference/aliasUsageInVarAssignment.types index 6a23293ea7c..cf636a15240 100644 --- a/tests/baselines/reference/aliasUsageInVarAssignment.types +++ b/tests/baselines/reference/aliasUsageInVarAssignment.types @@ -1,8 +1,8 @@ === tests/cases/compiler/aliasUsageInVarAssignment_main.ts === -import Backbone = require("aliasUsageInVarAssignment_backbone"); +import Backbone = require("./aliasUsageInVarAssignment_backbone"); >Backbone : typeof Backbone -import moduleA = require("aliasUsageInVarAssignment_moduleA"); +import moduleA = require("./aliasUsageInVarAssignment_moduleA"); >moduleA : typeof moduleA interface IHasVisualizationModel { @@ -32,7 +32,7 @@ export class Model { } === tests/cases/compiler/aliasUsageInVarAssignment_moduleA.ts === -import Backbone = require("aliasUsageInVarAssignment_backbone"); +import Backbone = require("./aliasUsageInVarAssignment_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/aliasUsedAsNameValue.js b/tests/baselines/reference/aliasUsedAsNameValue.js index c93acb43fa6..9893eae6e1c 100644 --- a/tests/baselines/reference/aliasUsedAsNameValue.js +++ b/tests/baselines/reference/aliasUsedAsNameValue.js @@ -9,8 +9,8 @@ export function b(a: any): any { return null; } //// [aliasUsedAsNameValue_2.ts] /// /// -import mod = require("aliasUsedAsNameValue_0"); -import b = require("aliasUsedAsNameValue_1"); +import mod = require("./aliasUsedAsNameValue_0"); +import b = require("./aliasUsedAsNameValue_1"); export var a = function () { //var x = mod.id; // TODO needed hack that mod is loaded @@ -25,8 +25,8 @@ exports.b = b; //// [aliasUsedAsNameValue_2.js] /// /// -var mod = require("aliasUsedAsNameValue_0"); -var b = require("aliasUsedAsNameValue_1"); +var mod = require("./aliasUsedAsNameValue_0"); +var b = require("./aliasUsedAsNameValue_1"); exports.a = function () { //var x = mod.id; // TODO needed hack that mod is loaded b.b(mod); diff --git a/tests/baselines/reference/aliasUsedAsNameValue.symbols b/tests/baselines/reference/aliasUsedAsNameValue.symbols index a816e2b2c63..314780eba7c 100644 --- a/tests/baselines/reference/aliasUsedAsNameValue.symbols +++ b/tests/baselines/reference/aliasUsedAsNameValue.symbols @@ -1,11 +1,11 @@ === tests/cases/compiler/aliasUsedAsNameValue_2.ts === /// /// -import mod = require("aliasUsedAsNameValue_0"); +import mod = require("./aliasUsedAsNameValue_0"); >mod : Symbol(mod, Decl(aliasUsedAsNameValue_2.ts, 0, 0)) -import b = require("aliasUsedAsNameValue_1"); ->b : Symbol(b, Decl(aliasUsedAsNameValue_2.ts, 2, 47)) +import b = require("./aliasUsedAsNameValue_1"); +>b : Symbol(b, Decl(aliasUsedAsNameValue_2.ts, 2, 49)) export var a = function () { >a : Symbol(a, Decl(aliasUsedAsNameValue_2.ts, 5, 10)) @@ -13,7 +13,7 @@ export var a = function () { //var x = mod.id; // TODO needed hack that mod is loaded b.b(mod); >b.b : Symbol(b.b, Decl(aliasUsedAsNameValue_1.ts, 0, 0)) ->b : Symbol(b, Decl(aliasUsedAsNameValue_2.ts, 2, 47)) +>b : Symbol(b, Decl(aliasUsedAsNameValue_2.ts, 2, 49)) >b : Symbol(b.b, Decl(aliasUsedAsNameValue_1.ts, 0, 0)) >mod : Symbol(mod, Decl(aliasUsedAsNameValue_2.ts, 0, 0)) } diff --git a/tests/baselines/reference/aliasUsedAsNameValue.types b/tests/baselines/reference/aliasUsedAsNameValue.types index 9c519786c76..86e1eeee9f5 100644 --- a/tests/baselines/reference/aliasUsedAsNameValue.types +++ b/tests/baselines/reference/aliasUsedAsNameValue.types @@ -1,10 +1,10 @@ === tests/cases/compiler/aliasUsedAsNameValue_2.ts === /// /// -import mod = require("aliasUsedAsNameValue_0"); +import mod = require("./aliasUsedAsNameValue_0"); >mod : typeof mod -import b = require("aliasUsedAsNameValue_1"); +import b = require("./aliasUsedAsNameValue_1"); >b : typeof b export var a = function () { diff --git a/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.errors.txt b/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.errors.txt index a2532be9344..1a9d7d26168 100644 --- a/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.errors.txt +++ b/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.ts ==== tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.ts (1 errors) ==== - import moduleA = require("aliasWithInterfaceExportAssignmentUsedInVarInitializer_0"); + import moduleA = require("./aliasWithInterfaceExportAssignmentUsedInVarInitializer_0"); var d = b.q3; ~ !!! error TS2304: Cannot find name 'b'. diff --git a/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.js b/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.js index bd76945438f..19534b279c0 100644 --- a/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.js +++ b/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.js @@ -7,7 +7,7 @@ interface c { export = c; //// [aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.ts] -import moduleA = require("aliasWithInterfaceExportAssignmentUsedInVarInitializer_0"); +import moduleA = require("./aliasWithInterfaceExportAssignmentUsedInVarInitializer_0"); var d = b.q3; //// [aliasWithInterfaceExportAssignmentUsedInVarInitializer_0.js] diff --git a/tests/baselines/reference/ambientEnum1.errors.txt b/tests/baselines/reference/ambientEnum1.errors.txt index b4bb534f5dd..be8a19b34ba 100644 --- a/tests/baselines/reference/ambientEnum1.errors.txt +++ b/tests/baselines/reference/ambientEnum1.errors.txt @@ -1,17 +1,14 @@ -tests/cases/compiler/ambientEnum1.ts(2,9): error TS1066: Ambient enum elements can only have integer literal initializers. -tests/cases/compiler/ambientEnum1.ts(7,9): error TS1066: Ambient enum elements can only have integer literal initializers. +tests/cases/compiler/ambientEnum1.ts(7,13): error TS1066: In ambient enum declarations member initializer must be constant expression. -==== tests/cases/compiler/ambientEnum1.ts (2 errors) ==== +==== tests/cases/compiler/ambientEnum1.ts (1 errors) ==== declare enum E1 { y = 4.23 - ~ -!!! error TS1066: Ambient enum elements can only have integer literal initializers. } // Ambient enum with computer member declare enum E2 { x = 'foo'.length - ~ -!!! error TS1066: Ambient enum elements can only have integer literal initializers. + ~~~~~~~~~~~~ +!!! error TS1066: In ambient enum declarations member initializer must be constant expression. } \ No newline at end of file diff --git a/tests/baselines/reference/ambientEnumDeclaration1.errors.txt b/tests/baselines/reference/ambientEnumDeclaration1.errors.txt deleted file mode 100644 index 419f7e184ac..00000000000 --- a/tests/baselines/reference/ambientEnumDeclaration1.errors.txt +++ /dev/null @@ -1,24 +0,0 @@ -tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(5,5): error TS1066: Ambient enum elements can only have integer literal initializers. -tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(6,5): error TS1066: Ambient enum elements can only have integer literal initializers. -tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(7,5): error TS1066: Ambient enum elements can only have integer literal initializers. -tests/cases/conformance/ambient/ambientEnumDeclaration1.ts(8,5): error TS1066: Ambient enum elements can only have integer literal initializers. - - -==== tests/cases/conformance/ambient/ambientEnumDeclaration1.ts (4 errors) ==== - // In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions. - - declare enum E { - a = 10, - b = 10 + 1, - ~ -!!! error TS1066: Ambient enum elements can only have integer literal initializers. - c = b, - ~ -!!! error TS1066: Ambient enum elements can only have integer literal initializers. - d = (c) + 1, - ~ -!!! error TS1066: Ambient enum elements can only have integer literal initializers. - e = 10 << 2 * 8, - ~ -!!! error TS1066: Ambient enum elements can only have integer literal initializers. - } \ No newline at end of file diff --git a/tests/baselines/reference/ambientEnumDeclaration1.symbols b/tests/baselines/reference/ambientEnumDeclaration1.symbols new file mode 100644 index 00000000000..62e6250cf95 --- /dev/null +++ b/tests/baselines/reference/ambientEnumDeclaration1.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/ambient/ambientEnumDeclaration1.ts === +// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions. + +declare enum E { +>E : Symbol(E, Decl(ambientEnumDeclaration1.ts, 0, 0)) + + a = 10, +>a : Symbol(E.a, Decl(ambientEnumDeclaration1.ts, 2, 16)) + + b = 10 + 1, +>b : Symbol(E.b, Decl(ambientEnumDeclaration1.ts, 3, 11)) + + c = b, +>c : Symbol(E.c, Decl(ambientEnumDeclaration1.ts, 4, 15)) +>b : Symbol(E.b, Decl(ambientEnumDeclaration1.ts, 3, 11)) + + d = (c) + 1, +>d : Symbol(E.d, Decl(ambientEnumDeclaration1.ts, 5, 10)) +>c : Symbol(E.c, Decl(ambientEnumDeclaration1.ts, 4, 15)) + + e = 10 << 2 * 8, +>e : Symbol(E.e, Decl(ambientEnumDeclaration1.ts, 6, 16)) +} diff --git a/tests/baselines/reference/ambientEnumDeclaration1.types b/tests/baselines/reference/ambientEnumDeclaration1.types new file mode 100644 index 00000000000..3ef30e458da --- /dev/null +++ b/tests/baselines/reference/ambientEnumDeclaration1.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/ambient/ambientEnumDeclaration1.ts === +// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions. + +declare enum E { +>E : E + + a = 10, +>a : E +>10 : number + + b = 10 + 1, +>b : E +>10 + 1 : number +>10 : number +>1 : number + + c = b, +>c : E +>b : E + + d = (c) + 1, +>d : E +>(c) + 1 : number +>(c) : E +>c : E +>1 : number + + e = 10 << 2 * 8, +>e : E +>10 << 2 * 8 : number +>10 : number +>2 * 8 : number +>2 : number +>8 : number +} diff --git a/tests/baselines/reference/ambientEnumElementInitializer3.errors.txt b/tests/baselines/reference/ambientEnumElementInitializer3.errors.txt deleted file mode 100644 index 56058210c16..00000000000 --- a/tests/baselines/reference/ambientEnumElementInitializer3.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/compiler/ambientEnumElementInitializer3.ts(2,2): error TS1066: Ambient enum elements can only have integer literal initializers. - - -==== tests/cases/compiler/ambientEnumElementInitializer3.ts (1 errors) ==== - declare enum E { - e = 3.3 // Decimal - ~ -!!! error TS1066: Ambient enum elements can only have integer literal initializers. - } \ No newline at end of file diff --git a/tests/baselines/reference/ambientEnumElementInitializer3.symbols b/tests/baselines/reference/ambientEnumElementInitializer3.symbols new file mode 100644 index 00000000000..ee0d5e4daea --- /dev/null +++ b/tests/baselines/reference/ambientEnumElementInitializer3.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/ambientEnumElementInitializer3.ts === +declare enum E { +>E : Symbol(E, Decl(ambientEnumElementInitializer3.ts, 0, 0)) + + e = 3.3 // Decimal +>e : Symbol(E.e, Decl(ambientEnumElementInitializer3.ts, 0, 16)) +} diff --git a/tests/baselines/reference/ambientEnumElementInitializer3.types b/tests/baselines/reference/ambientEnumElementInitializer3.types new file mode 100644 index 00000000000..f3d3b8f3ae2 --- /dev/null +++ b/tests/baselines/reference/ambientEnumElementInitializer3.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/ambientEnumElementInitializer3.ts === +declare enum E { +>E : E + + e = 3.3 // Decimal +>e : E +>3.3 : number +} diff --git a/tests/baselines/reference/ambientErrors.errors.txt b/tests/baselines/reference/ambientErrors.errors.txt index 16ce79a05dd..5e257c2de3f 100644 --- a/tests/baselines/reference/ambientErrors.errors.txt +++ b/tests/baselines/reference/ambientErrors.errors.txt @@ -1,22 +1,21 @@ tests/cases/conformance/ambient/ambientErrors.ts(2,15): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(6,18): error TS2382: Specialized overload signature is not assignable to any non-specialized signature. tests/cases/conformance/ambient/ambientErrors.ts(17,22): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/conformance/ambient/ambientErrors.ts(20,24): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/conformance/ambient/ambientErrors.ts(24,5): error TS1066: Ambient enum elements can only have integer literal initializers. -tests/cases/conformance/ambient/ambientErrors.ts(29,5): error TS1066: Ambient enum elements can only have integer literal initializers. +tests/cases/conformance/ambient/ambientErrors.ts(20,24): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/ambient/ambientErrors.ts(29,9): error TS1066: In ambient enum declarations member initializer must be constant expression. tests/cases/conformance/ambient/ambientErrors.ts(34,11): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/conformance/ambient/ambientErrors.ts(35,19): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/ambient/ambientErrors.ts(35,19): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(37,20): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/ambient/ambientErrors.ts(38,13): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/conformance/ambient/ambientErrors.ts(39,23): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/conformance/ambient/ambientErrors.ts(40,14): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/conformance/ambient/ambientErrors.ts(41,22): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/conformance/ambient/ambientErrors.ts(47,20): error TS2435: Ambient modules cannot be nested in other modules. +tests/cases/conformance/ambient/ambientErrors.ts(39,23): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/ambient/ambientErrors.ts(40,14): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/ambient/ambientErrors.ts(41,22): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/ambient/ambientErrors.ts(47,20): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/conformance/ambient/ambientErrors.ts(51,16): error TS2436: Ambient module declaration cannot specify relative module name. tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== tests/cases/conformance/ambient/ambientErrors.ts (16 errors) ==== +==== tests/cases/conformance/ambient/ambientErrors.ts (15 errors) ==== // Ambient variable with an initializer declare var x = 4; ~ @@ -44,20 +43,18 @@ tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export // Ambient function with function body declare function fn4() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. // Ambient enum with non - integer literal constant member declare enum E1 { y = 4.23 - ~ -!!! error TS1066: Ambient enum elements can only have integer literal initializers. } // Ambient enum with computer member declare enum E2 { x = 'foo'.length - ~ -!!! error TS1066: Ambient enum elements can only have integer literal initializers. + ~~~~~~~~~~~~ +!!! error TS1066: In ambient enum declarations member initializer must be constant expression. } // Ambient module with initializers for values, bodies for functions / classes @@ -67,7 +64,7 @@ tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export !!! error TS1039: Initializers are not allowed in ambient contexts. function fn() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. class C { static x = 3; ~ @@ -77,13 +74,13 @@ tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export !!! error TS1039: Initializers are not allowed in ambient contexts. constructor() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. fn() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. static sfn() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. } } @@ -91,7 +88,7 @@ tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export module M2 { declare module 'nope' { } ~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. } // Ambient external module with a string literal name that isn't a top level external module name diff --git a/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.errors.txt b/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.errors.txt index 79f37c4764e..0e508470b13 100644 --- a/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.errors.txt +++ b/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts(5,16): error TS2435: Ambient modules cannot be nested in other modules. +tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts(5,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts(10,22): error TS2307: Cannot find module 'ext'. @@ -9,7 +9,7 @@ tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts(10,22): err declare module "ext" { ~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. export class C { } } diff --git a/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.errors.txt b/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.errors.txt index 87aae44840e..7e4ac795d0d 100644 --- a/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.errors.txt +++ b/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts(2,27): error TS2435: Ambient modules cannot be nested in other modules. +tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts(2,27): error TS2435: Ambient modules cannot be nested in other modules or namespaces. ==== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts (1 errors) ==== module M { export declare module "M" { } ~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. } \ No newline at end of file diff --git a/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.errors.txt b/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.errors.txt index 763317ecc0c..e5905aaaf8f 100644 --- a/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.errors.txt +++ b/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts(1,23): error TS2435: Ambient modules cannot be nested in other modules. +tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts(1,23): error TS2435: Ambient modules cannot be nested in other modules or namespaces. ==== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts (1 errors) ==== export declare module "M" { } ~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. \ No newline at end of file +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. \ No newline at end of file diff --git a/tests/baselines/reference/ambiguousCallsWhereReturnTypesAgree.types b/tests/baselines/reference/ambiguousCallsWhereReturnTypesAgree.types index d4df0f75d16..65f26f25770 100644 --- a/tests/baselines/reference/ambiguousCallsWhereReturnTypesAgree.types +++ b/tests/baselines/reference/ambiguousCallsWhereReturnTypesAgree.types @@ -31,7 +31,7 @@ class TestClass { this.bar(x); // should not error >this.bar(x) : void >this.bar : { (x: string): void; (x: string[]): void; } ->this : TestClass +>this : this >bar : { (x: string): void; (x: string[]): void; } >x : any } @@ -71,7 +71,7 @@ class TestClass2 { return this.bar(x); // should not error >this.bar(x) : number >this.bar : { (x: string): number; (x: string[]): number; } ->this : TestClass2 +>this : this >bar : { (x: string): number; (x: string[]): number; } >x : any } diff --git a/tests/baselines/reference/amdModuleName1.types b/tests/baselines/reference/amdModuleName1.types index 64bc7842451..c0db9c8b1b5 100644 --- a/tests/baselines/reference/amdModuleName1.types +++ b/tests/baselines/reference/amdModuleName1.types @@ -10,7 +10,7 @@ class Foo { this.x = 5; >this.x = 5 : number >this.x : number ->this : Foo +>this : this >x : number >5 : number } diff --git a/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols b/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols index 208646dc101..2c5e611de68 100644 --- a/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols +++ b/tests/baselines/reference/argumentsObjectIterator02_ES6.symbols @@ -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.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) let result = []; >result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7)) diff --git a/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt b/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt index d13e0a265f7..d60f0b7d03c 100644 --- a/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt +++ b/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt @@ -34,6 +34,8 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(25,5): error tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(26,5): error TS2322: Type 'StrNum' is not assignable to type '[string]'. Types of property 'pop' are incompatible. Type '() => string | number' is not assignable to type '() => string'. + Type 'string | number' is not assignable to type 'string'. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(27,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[string]'. Property 'length' is missing in type '{ 0: string; 1: number; }'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(28,5): error TS2322: Type '[string, number]' is not assignable to type '[number, string]'. @@ -125,6 +127,8 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error !!! error TS2322: Type 'StrNum' is not assignable to type '[string]'. !!! error TS2322: Types of property 'pop' are incompatible. !!! error TS2322: Type '() => string | number' is not assignable to type '() => string'. +!!! error TS2322: Type 'string | number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. var m3: [string] = z; ~~ !!! error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[string]'. diff --git a/tests/baselines/reference/arrayBestCommonTypes.types b/tests/baselines/reference/arrayBestCommonTypes.types index 9b05aff5ac6..fca66793f40 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.types +++ b/tests/baselines/reference/arrayBestCommonTypes.types @@ -51,7 +51,7 @@ module EmptyTypes { >(this.voidIfAny([4, 2][0])) : number >this.voidIfAny([4, 2][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[4, 2][0] : number >[4, 2] : number[] @@ -64,7 +64,7 @@ module EmptyTypes { >(this.voidIfAny([4, 2, undefined][0])) : number >this.voidIfAny([4, 2, undefined][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[4, 2, undefined][0] : number >[4, 2, undefined] : number[] @@ -78,7 +78,7 @@ module EmptyTypes { >(this.voidIfAny([undefined, 2, 4][0])) : number >this.voidIfAny([undefined, 2, 4][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[undefined, 2, 4][0] : number >[undefined, 2, 4] : number[] @@ -92,7 +92,7 @@ module EmptyTypes { >(this.voidIfAny([null, 2, 4][0])) : number >this.voidIfAny([null, 2, 4][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[null, 2, 4][0] : number >[null, 2, 4] : number[] @@ -106,7 +106,7 @@ module EmptyTypes { >(this.voidIfAny([2, 4, null][0])) : number >this.voidIfAny([2, 4, null][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[2, 4, null][0] : number >[2, 4, null] : number[] @@ -120,7 +120,7 @@ module EmptyTypes { >(this.voidIfAny([undefined, 4, null][0])) : number >this.voidIfAny([undefined, 4, null][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[undefined, 4, null][0] : number >[undefined, 4, null] : number[] @@ -134,7 +134,7 @@ module EmptyTypes { >(this.voidIfAny(['', "q"][0])) : number >this.voidIfAny(['', "q"][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >['', "q"][0] : string >['', "q"] : string[] @@ -147,7 +147,7 @@ module EmptyTypes { >(this.voidIfAny(['', "q", undefined][0])) : number >this.voidIfAny(['', "q", undefined][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >['', "q", undefined][0] : string >['', "q", undefined] : string[] @@ -161,7 +161,7 @@ module EmptyTypes { >(this.voidIfAny([undefined, "q", ''][0])) : number >this.voidIfAny([undefined, "q", ''][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[undefined, "q", ''][0] : string >[undefined, "q", ''] : string[] @@ -175,7 +175,7 @@ module EmptyTypes { >(this.voidIfAny([null, "q", ''][0])) : number >this.voidIfAny([null, "q", ''][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[null, "q", ''][0] : string >[null, "q", ''] : string[] @@ -189,7 +189,7 @@ module EmptyTypes { >(this.voidIfAny(["q", '', null][0])) : number >this.voidIfAny(["q", '', null][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >["q", '', null][0] : string >["q", '', null] : string[] @@ -203,7 +203,7 @@ module EmptyTypes { >(this.voidIfAny([undefined, '', null][0])) : number >this.voidIfAny([undefined, '', null][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[undefined, '', null][0] : string >[undefined, '', null] : string[] @@ -217,7 +217,7 @@ module EmptyTypes { >(this.voidIfAny([[3, 4], [null]][0][0])) : number >this.voidIfAny([[3, 4], [null]][0][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[[3, 4], [null]][0][0] : number >[[3, 4], [null]][0] : number[] @@ -294,8 +294,8 @@ module EmptyTypes { // Order matters here so test all the variants var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; ->a1 : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] ->[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] +>a1 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -313,8 +313,8 @@ module EmptyTypes { >'a' : string var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; ->a2 : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] ->[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] +>a2 : { x: any; y: string; }[] +>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any @@ -332,8 +332,8 @@ module EmptyTypes { >'a' : string var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; ->a3 : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] ->[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] +>a3 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -454,7 +454,7 @@ module NonEmptyTypes { >(this.voidIfAny([4, 2][0])) : number >this.voidIfAny([4, 2][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[4, 2][0] : number >[4, 2] : number[] @@ -467,7 +467,7 @@ module NonEmptyTypes { >(this.voidIfAny([4, 2, undefined][0])) : number >this.voidIfAny([4, 2, undefined][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[4, 2, undefined][0] : number >[4, 2, undefined] : number[] @@ -481,7 +481,7 @@ module NonEmptyTypes { >(this.voidIfAny([undefined, 2, 4][0])) : number >this.voidIfAny([undefined, 2, 4][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[undefined, 2, 4][0] : number >[undefined, 2, 4] : number[] @@ -495,7 +495,7 @@ module NonEmptyTypes { >(this.voidIfAny([null, 2, 4][0])) : number >this.voidIfAny([null, 2, 4][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[null, 2, 4][0] : number >[null, 2, 4] : number[] @@ -509,7 +509,7 @@ module NonEmptyTypes { >(this.voidIfAny([2, 4, null][0])) : number >this.voidIfAny([2, 4, null][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[2, 4, null][0] : number >[2, 4, null] : number[] @@ -523,7 +523,7 @@ module NonEmptyTypes { >(this.voidIfAny([undefined, 4, null][0])) : number >this.voidIfAny([undefined, 4, null][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[undefined, 4, null][0] : number >[undefined, 4, null] : number[] @@ -537,7 +537,7 @@ module NonEmptyTypes { >(this.voidIfAny(['', "q"][0])) : number >this.voidIfAny(['', "q"][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >['', "q"][0] : string >['', "q"] : string[] @@ -550,7 +550,7 @@ module NonEmptyTypes { >(this.voidIfAny(['', "q", undefined][0])) : number >this.voidIfAny(['', "q", undefined][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >['', "q", undefined][0] : string >['', "q", undefined] : string[] @@ -564,7 +564,7 @@ module NonEmptyTypes { >(this.voidIfAny([undefined, "q", ''][0])) : number >this.voidIfAny([undefined, "q", ''][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[undefined, "q", ''][0] : string >[undefined, "q", ''] : string[] @@ -578,7 +578,7 @@ module NonEmptyTypes { >(this.voidIfAny([null, "q", ''][0])) : number >this.voidIfAny([null, "q", ''][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[null, "q", ''][0] : string >[null, "q", ''] : string[] @@ -592,7 +592,7 @@ module NonEmptyTypes { >(this.voidIfAny(["q", '', null][0])) : number >this.voidIfAny(["q", '', null][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >["q", '', null][0] : string >["q", '', null] : string[] @@ -606,7 +606,7 @@ module NonEmptyTypes { >(this.voidIfAny([undefined, '', null][0])) : number >this.voidIfAny([undefined, '', null][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[undefined, '', null][0] : string >[undefined, '', null] : string[] @@ -620,7 +620,7 @@ module NonEmptyTypes { >(this.voidIfAny([[3, 4], [null]][0][0])) : number >this.voidIfAny([[3, 4], [null]][0][0]) : number >this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } ->this : f +>this : this >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[[3, 4], [null]][0][0] : number >[[3, 4], [null]][0] : number[] @@ -639,7 +639,7 @@ module NonEmptyTypes { >x : number >y : base >base : base ->[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : ({ x: number; y: derived; } | { x: number; y: base; })[] +>[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : { x: number; y: base; }[] >{ x: 7, y: new derived() } : { x: number; y: derived; } >x : number >7 : number @@ -658,7 +658,7 @@ module NonEmptyTypes { >x : boolean >y : base >base : base ->[{ x: true, y: new derived() }, { x: false, y: new base() }] : ({ x: boolean; y: derived; } | { x: boolean; y: base; })[] +>[{ x: true, y: new derived() }, { x: false, y: new base() }] : { x: boolean; y: base; }[] >{ x: true, y: new derived() } : { x: boolean; y: derived; } >x : boolean >true : boolean @@ -697,8 +697,8 @@ module NonEmptyTypes { // Order matters here so test all the variants var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; ->a1 : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] ->[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[] +>a1 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -716,8 +716,8 @@ module NonEmptyTypes { >'a' : string var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; ->a2 : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] ->[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[] +>a2 : { x: any; y: string; }[] +>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any @@ -735,8 +735,8 @@ module NonEmptyTypes { >'a' : string var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; ->a3 : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] ->[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[] +>a3 : { x: any; y: string; }[] +>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number >0 : number @@ -769,29 +769,29 @@ module NonEmptyTypes { >base2 : typeof base2 var b1 = [baseObj, base2Obj, ifaceObj]; ->b1 : (base | base2 | iface)[] ->[baseObj, base2Obj, ifaceObj] : (base | base2 | iface)[] +>b1 : iface[] +>[baseObj, base2Obj, ifaceObj] : iface[] >baseObj : base >base2Obj : base2 >ifaceObj : iface var b2 = [base2Obj, baseObj, ifaceObj]; ->b2 : (base2 | base | iface)[] ->[base2Obj, baseObj, ifaceObj] : (base2 | base | iface)[] +>b2 : iface[] +>[base2Obj, baseObj, ifaceObj] : iface[] >base2Obj : base2 >baseObj : base >ifaceObj : iface var b3 = [baseObj, ifaceObj, base2Obj]; ->b3 : (base | iface | base2)[] ->[baseObj, ifaceObj, base2Obj] : (base | iface | base2)[] +>b3 : iface[] +>[baseObj, ifaceObj, base2Obj] : iface[] >baseObj : base >ifaceObj : iface >base2Obj : base2 var b4 = [ifaceObj, baseObj, base2Obj]; ->b4 : (iface | base | base2)[] ->[ifaceObj, baseObj, base2Obj] : (iface | base | base2)[] +>b4 : iface[] +>[ifaceObj, baseObj, base2Obj] : iface[] >ifaceObj : iface >baseObj : base >base2Obj : base2 diff --git a/tests/baselines/reference/arrayCast.errors.txt b/tests/baselines/reference/arrayCast.errors.txt index 82b4b856a97..815813ea727 100644 --- a/tests/baselines/reference/arrayCast.errors.txt +++ b/tests/baselines/reference/arrayCast.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other. +tests/cases/compiler/arrayCast.ts(3,23): error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other. Type '{ foo: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'. @@ -7,7 +7,7 @@ tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: strin // Should fail. Even though the array is contextually typed with { id: number }[], it still // has type { foo: string }[], which is not assignable to { id: number }[]. <{ id: number; }[]>[{ foo: "s" }]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other. !!! error TS2352: Type '{ foo: string; }' is not assignable to type '{ id: number; }'. !!! error TS2352: Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'. diff --git a/tests/baselines/reference/arrayLiteralTypeInference.errors.txt b/tests/baselines/reference/arrayLiteralTypeInference.errors.txt index 105375f2e74..a2c4597127f 100644 --- a/tests/baselines/reference/arrayLiteralTypeInference.errors.txt +++ b/tests/baselines/reference/arrayLiteralTypeInference.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/arrayLiteralTypeInference.ts(13,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'. +tests/cases/compiler/arrayLiteralTypeInference.ts(14,14): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'. Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'. Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'. Object literal may only specify known properties, and 'trueness' does not exist in type 'Action'. -tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. +tests/cases/compiler/arrayLiteralTypeInference.ts(31,18): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'trueness' does not exist in type '{ id: number; }'. @@ -22,12 +22,12 @@ tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({ } var x1: Action[] = [ - ~~ + { id: 2, trueness: false }, + ~~~~~~~~~~~~~~~ !!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'. !!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'. !!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'. !!! error TS2322: Object literal may only specify known properties, and 'trueness' does not exist in type 'Action'. - { id: 2, trueness: false }, { id: 3, name: "three" } ] @@ -43,13 +43,13 @@ tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({ ] var z1: { id: number }[] = - ~~ + [ + { id: 2, trueness: false }, + ~~~~~~~~~~~~~~~ !!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. !!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'trueness' does not exist in type '{ id: number; }'. - [ - { id: 2, trueness: false }, { id: 3, name: "three" } ] diff --git a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types index 5b5a1be6b8a..1bbb6c41e8a 100644 --- a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types +++ b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types @@ -36,8 +36,8 @@ var cs = [a, b, c]; // { x: number; y?: number };[] >c : { x: number; a?: number; } var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[] ->ds : (((x: Object) => number) | ((x: string) => number))[] ->[(x: Object) => 1, (x: string) => 2] : (((x: Object) => number) | ((x: string) => number))[] +>ds : ((x: Object) => number)[] +>[(x: Object) => 1, (x: string) => 2] : ((x: Object) => number)[] >(x: Object) => 1 : (x: Object) => number >x : Object >Object : Object @@ -47,8 +47,8 @@ var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[] >2 : number var es = [(x: string) => 2, (x: Object) => 1]; // { (x:string) => number }[] ->es : (((x: string) => number) | ((x: Object) => number))[] ->[(x: string) => 2, (x: Object) => 1] : (((x: string) => number) | ((x: Object) => number))[] +>es : ((x: string) => number)[] +>[(x: string) => 2, (x: Object) => 1] : ((x: string) => number)[] >(x: string) => 2 : (x: string) => number >x : string >2 : number diff --git a/tests/baselines/reference/arrayLiterals.errors.txt b/tests/baselines/reference/arrayLiterals.errors.txt index fd882804b8a..f5fe71b79a6 100644 --- a/tests/baselines/reference/arrayLiterals.errors.txt +++ b/tests/baselines/reference/arrayLiterals.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,5): error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'. +tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,77): error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'. Index signatures are incompatible. Type '{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }' is not assignable to type '{ a: string; b: number; }'. Type '{ a: string; b: number; c: string; }' is not assignable to type '{ a: string; b: number; }'. @@ -30,7 +30,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,5): error // Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[] var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; - ~~~~~~~~ + ~~~~~ !!! error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type '{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }' is not assignable to type '{ a: string; b: number; }'. diff --git a/tests/baselines/reference/arrayLiterals2ES6.symbols b/tests/baselines/reference/arrayLiterals2ES6.symbols index faf0b130738..75202d69690 100644 --- a/tests/baselines/reference/arrayLiterals2ES6.symbols +++ b/tests/baselines/reference/arrayLiterals2ES6.symbols @@ -72,14 +72,14 @@ var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; interface myArray extends Array { } >myArray : Symbol(myArray, Decl(arrayLiterals2ES6.ts, 40, 67)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4118, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) interface myArray2 extends Array { } >myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4118, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4236, 1)) var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[] >d0 : Symbol(d0, Decl(arrayLiterals2ES6.ts, 44, 3)) diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types index b7224fe91c4..9cdbe0a0a61 100644 --- a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types +++ b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.types @@ -77,8 +77,8 @@ var myDerivedList: DerivedList; >DerivedList : DerivedList var as = [list, myDerivedList]; // List[] ->as : (List | DerivedList)[] ->[list, myDerivedList] : (List | DerivedList)[] +>as : List[] +>[list, myDerivedList] : List[] >list : List >myDerivedList : DerivedList diff --git a/tests/baselines/reference/arrayOfExportedClass.js b/tests/baselines/reference/arrayOfExportedClass.js index 7fde4aa6775..c3f81aca7b0 100644 --- a/tests/baselines/reference/arrayOfExportedClass.js +++ b/tests/baselines/reference/arrayOfExportedClass.js @@ -9,7 +9,7 @@ export = Car; //// [arrayOfExportedClass_1.ts] /// -import Car = require('arrayOfExportedClass_0'); +import Car = require('./arrayOfExportedClass_0'); class Road { diff --git a/tests/baselines/reference/arrayOfExportedClass.symbols b/tests/baselines/reference/arrayOfExportedClass.symbols index 3d0905a1e2d..bdcaf98eb0d 100644 --- a/tests/baselines/reference/arrayOfExportedClass.symbols +++ b/tests/baselines/reference/arrayOfExportedClass.symbols @@ -1,10 +1,10 @@ === tests/cases/compiler/arrayOfExportedClass_1.ts === /// -import Car = require('arrayOfExportedClass_0'); +import Car = require('./arrayOfExportedClass_0'); >Car : Symbol(Car, Decl(arrayOfExportedClass_1.ts, 0, 0)) class Road { ->Road : Symbol(Road, Decl(arrayOfExportedClass_1.ts, 1, 47)) +>Road : Symbol(Road, Decl(arrayOfExportedClass_1.ts, 1, 49)) public cars: Car[]; >cars : Symbol(cars, Decl(arrayOfExportedClass_1.ts, 3, 12)) @@ -17,14 +17,14 @@ class Road { this.cars = cars; >this.cars : Symbol(cars, Decl(arrayOfExportedClass_1.ts, 3, 12)) ->this : Symbol(Road, Decl(arrayOfExportedClass_1.ts, 1, 47)) +>this : Symbol(Road, Decl(arrayOfExportedClass_1.ts, 1, 49)) >cars : Symbol(cars, Decl(arrayOfExportedClass_1.ts, 3, 12)) >cars : Symbol(cars, Decl(arrayOfExportedClass_1.ts, 7, 19)) } } export = Road; ->Road : Symbol(Road, Decl(arrayOfExportedClass_1.ts, 1, 47)) +>Road : Symbol(Road, Decl(arrayOfExportedClass_1.ts, 1, 49)) === tests/cases/compiler/arrayOfExportedClass_0.ts === class Car { diff --git a/tests/baselines/reference/arrayOfExportedClass.types b/tests/baselines/reference/arrayOfExportedClass.types index 3d542b88d80..8447ed2841f 100644 --- a/tests/baselines/reference/arrayOfExportedClass.types +++ b/tests/baselines/reference/arrayOfExportedClass.types @@ -1,6 +1,6 @@ === tests/cases/compiler/arrayOfExportedClass_1.ts === /// -import Car = require('arrayOfExportedClass_0'); +import Car = require('./arrayOfExportedClass_0'); >Car : typeof Car class Road { @@ -18,7 +18,7 @@ class Road { this.cars = cars; >this.cars = cars : Car[] >this.cars : Car[] ->this : Road +>this : this >cars : Car[] >cars : Car[] } diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.errors.txt b/tests/baselines/reference/arrayOfFunctionTypes3.errors.txt deleted file mode 100644 index 499d6bca387..00000000000 --- a/tests/baselines/reference/arrayOfFunctionTypes3.errors.txt +++ /dev/null @@ -1,35 +0,0 @@ -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(17,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(26,10): error TS2349: Cannot invoke an expression whose type lacks a call signature. - - -==== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts (2 errors) ==== - // valid uses of arrays of function types - - var x = [() => 1, () => { }]; - var r2 = x[0](); - - class C { - foo: string; - } - var y = [C, C]; - var r3 = new y[0](); - - var a: { (x: number): number; (x: string): string; }; - var b: { (x: number): number; (x: string): string; }; - var c: { (x: number): number; (x: any): any; }; - var z = [a, b, c]; - var r4 = z[0]; - var r5 = r4(''); // any not string - ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. - var r5b = r4(1); - - var a2: { (x: T): number; (x: string): string;}; - var b2: { (x: T): number; (x: string): string; }; - var c2: { (x: number): number; (x: T): any; }; - - var z2 = [a2, b2, c2]; - var r6 = z2[0]; - var r7 = r6(''); // any not string - ~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. \ No newline at end of file diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.symbols b/tests/baselines/reference/arrayOfFunctionTypes3.symbols new file mode 100644 index 00000000000..d26effeb5b7 --- /dev/null +++ b/tests/baselines/reference/arrayOfFunctionTypes3.symbols @@ -0,0 +1,93 @@ +=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts === +// valid uses of arrays of function types + +var x = [() => 1, () => { }]; +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 2, 3)) + +var r2 = x[0](); +>r2 : Symbol(r2, Decl(arrayOfFunctionTypes3.ts, 3, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 2, 3)) + +class C { +>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16)) + + foo: string; +>foo : Symbol(foo, Decl(arrayOfFunctionTypes3.ts, 5, 9)) +} +var y = [C, C]; +>y : Symbol(y, Decl(arrayOfFunctionTypes3.ts, 8, 3)) +>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16)) +>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16)) + +var r3 = new y[0](); +>r3 : Symbol(r3, Decl(arrayOfFunctionTypes3.ts, 9, 3)) +>y : Symbol(y, Decl(arrayOfFunctionTypes3.ts, 8, 3)) + +var a: { (x: number): number; (x: string): string; }; +>a : Symbol(a, Decl(arrayOfFunctionTypes3.ts, 11, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 11, 10)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 11, 31)) + +var b: { (x: number): number; (x: string): string; }; +>b : Symbol(b, Decl(arrayOfFunctionTypes3.ts, 12, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 12, 10)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 12, 31)) + +var c: { (x: number): number; (x: any): any; }; +>c : Symbol(c, Decl(arrayOfFunctionTypes3.ts, 13, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 13, 10)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 13, 31)) + +var z = [a, b, c]; +>z : Symbol(z, Decl(arrayOfFunctionTypes3.ts, 14, 3)) +>a : Symbol(a, Decl(arrayOfFunctionTypes3.ts, 11, 3)) +>b : Symbol(b, Decl(arrayOfFunctionTypes3.ts, 12, 3)) +>c : Symbol(c, Decl(arrayOfFunctionTypes3.ts, 13, 3)) + +var r4 = z[0]; +>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3)) +>z : Symbol(z, Decl(arrayOfFunctionTypes3.ts, 14, 3)) + +var r5 = r4(''); // any not string +>r5 : Symbol(r5, Decl(arrayOfFunctionTypes3.ts, 16, 3)) +>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3)) + +var r5b = r4(1); +>r5b : Symbol(r5b, Decl(arrayOfFunctionTypes3.ts, 17, 3)) +>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3)) + +var a2: { (x: T): number; (x: string): string;}; +>a2 : Symbol(a2, Decl(arrayOfFunctionTypes3.ts, 19, 3)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 19, 11)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 19, 14)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 19, 11)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 19, 30)) + +var b2: { (x: T): number; (x: string): string; }; +>b2 : Symbol(b2, Decl(arrayOfFunctionTypes3.ts, 20, 3)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 20, 11)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 20, 14)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 20, 11)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 20, 30)) + +var c2: { (x: number): number; (x: T): any; }; +>c2 : Symbol(c2, Decl(arrayOfFunctionTypes3.ts, 21, 3)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 21, 11)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 21, 32)) +>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 21, 35)) +>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 21, 32)) + +var z2 = [a2, b2, c2]; +>z2 : Symbol(z2, Decl(arrayOfFunctionTypes3.ts, 23, 3)) +>a2 : Symbol(a2, Decl(arrayOfFunctionTypes3.ts, 19, 3)) +>b2 : Symbol(b2, Decl(arrayOfFunctionTypes3.ts, 20, 3)) +>c2 : Symbol(c2, Decl(arrayOfFunctionTypes3.ts, 21, 3)) + +var r6 = z2[0]; +>r6 : Symbol(r6, Decl(arrayOfFunctionTypes3.ts, 24, 3)) +>z2 : Symbol(z2, Decl(arrayOfFunctionTypes3.ts, 23, 3)) + +var r7 = r6(''); // any not string +>r7 : Symbol(r7, Decl(arrayOfFunctionTypes3.ts, 25, 3)) +>r6 : Symbol(r6, Decl(arrayOfFunctionTypes3.ts, 24, 3)) + diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.types b/tests/baselines/reference/arrayOfFunctionTypes3.types new file mode 100644 index 00000000000..0ed92991ed0 --- /dev/null +++ b/tests/baselines/reference/arrayOfFunctionTypes3.types @@ -0,0 +1,116 @@ +=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts === +// valid uses of arrays of function types + +var x = [() => 1, () => { }]; +>x : (() => void)[] +>[() => 1, () => { }] : (() => void)[] +>() => 1 : () => number +>1 : number +>() => { } : () => void + +var r2 = x[0](); +>r2 : void +>x[0]() : void +>x[0] : () => void +>x : (() => void)[] +>0 : number + +class C { +>C : C + + foo: string; +>foo : string +} +var y = [C, C]; +>y : typeof C[] +>[C, C] : typeof C[] +>C : typeof C +>C : typeof C + +var r3 = new y[0](); +>r3 : C +>new y[0]() : C +>y[0] : typeof C +>y : typeof C[] +>0 : number + +var a: { (x: number): number; (x: string): string; }; +>a : { (x: number): number; (x: string): string; } +>x : number +>x : string + +var b: { (x: number): number; (x: string): string; }; +>b : { (x: number): number; (x: string): string; } +>x : number +>x : string + +var c: { (x: number): number; (x: any): any; }; +>c : { (x: number): number; (x: any): any; } +>x : number +>x : any + +var z = [a, b, c]; +>z : { (x: number): number; (x: any): any; }[] +>[a, b, c] : { (x: number): number; (x: any): any; }[] +>a : { (x: number): number; (x: string): string; } +>b : { (x: number): number; (x: string): string; } +>c : { (x: number): number; (x: any): any; } + +var r4 = z[0]; +>r4 : { (x: number): number; (x: any): any; } +>z[0] : { (x: number): number; (x: any): any; } +>z : { (x: number): number; (x: any): any; }[] +>0 : number + +var r5 = r4(''); // any not string +>r5 : any +>r4('') : any +>r4 : { (x: number): number; (x: any): any; } +>'' : string + +var r5b = r4(1); +>r5b : number +>r4(1) : number +>r4 : { (x: number): number; (x: any): any; } +>1 : number + +var a2: { (x: T): number; (x: string): string;}; +>a2 : { (x: T): number; (x: string): string; } +>T : T +>x : T +>T : T +>x : string + +var b2: { (x: T): number; (x: string): string; }; +>b2 : { (x: T): number; (x: string): string; } +>T : T +>x : T +>T : T +>x : string + +var c2: { (x: number): number; (x: T): any; }; +>c2 : { (x: number): number; (x: T): any; } +>x : number +>T : T +>x : T +>T : T + +var z2 = [a2, b2, c2]; +>z2 : { (x: number): number; (x: T): any; }[] +>[a2, b2, c2] : { (x: number): number; (x: T): any; }[] +>a2 : { (x: T): number; (x: string): string; } +>b2 : { (x: T): number; (x: string): string; } +>c2 : { (x: number): number; (x: T): any; } + +var r6 = z2[0]; +>r6 : { (x: number): number; (x: T): any; } +>z2[0] : { (x: number): number; (x: T): any; } +>z2 : { (x: number): number; (x: T): any; }[] +>0 : number + +var r7 = r6(''); // any not string +>r7 : any +>r6('') : any +>r6 : { (x: number): number; (x: T): any; } +>'' : string + diff --git a/tests/baselines/reference/arrayconcat.types b/tests/baselines/reference/arrayconcat.types index 3560272a363..45615cd63b8 100644 --- a/tests/baselines/reference/arrayconcat.types +++ b/tests/baselines/reference/arrayconcat.types @@ -38,12 +38,12 @@ class parser { this.options = this.options.sort(function(a, b) { >this.options = this.options.sort(function(a, b) { var aName = a.name.toLowerCase(); var bName = b.name.toLowerCase(); if (aName > bName) { return 1; } else if (aName < bName) { return -1; } else { return 0; } }) : IOptions[] >this.options : IOptions[] ->this : parser +>this : this >options : IOptions[] >this.options.sort(function(a, b) { var aName = a.name.toLowerCase(); var bName = b.name.toLowerCase(); if (aName > bName) { return 1; } else if (aName < bName) { return -1; } else { return 0; } }) : IOptions[] >this.options.sort : (compareFn?: (a: IOptions, b: IOptions) => number) => IOptions[] >this.options : IOptions[] ->this : parser +>this : this >options : IOptions[] >sort : (compareFn?: (a: IOptions, b: IOptions) => number) => IOptions[] >function(a, b) { var aName = a.name.toLowerCase(); var bName = b.name.toLowerCase(); if (aName > bName) { return 1; } else if (aName < bName) { return -1; } else { return 0; } } : (a: IOptions, b: IOptions) => number diff --git a/tests/baselines/reference/arrowFunctionExpressions.types b/tests/baselines/reference/arrowFunctionExpressions.types index fc9fdb8a3bd..eedd20944fe 100644 --- a/tests/baselines/reference/arrowFunctionExpressions.types +++ b/tests/baselines/reference/arrowFunctionExpressions.types @@ -100,12 +100,12 @@ var p8 = ({ a = 1 }) => { }; >1 : number var p9 = ({ a: { b = 1 } = { b: 1 } }) => { }; ->p9 : ({ a: { b = 1 } = { b: 1 } }: { a?: { b: number; }; }) => void ->({ a: { b = 1 } = { b: 1 } }) => { } : ({ a: { b = 1 } = { b: 1 } }: { a?: { b: number; }; }) => void +>p9 : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void +>({ a: { b = 1 } = { b: 1 } }) => { } : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void >a : any >b : number >1 : number ->{ b: 1 } : { b: number; } +>{ b: 1 } : { b?: number; } >b : number >1 : number @@ -129,12 +129,12 @@ class MyClass { >1 : number p = (n) => n && this; ->p : (n: any) => MyClass ->(n) => n && this : (n: any) => MyClass +>p : (n: any) => this +>(n) => n && this : (n: any) => this >n : any ->n && this : MyClass +>n && this : this >n : any ->this : MyClass +>this : this fn() { >fn : () => void @@ -148,12 +148,12 @@ class MyClass { >1 : number var p = (n) => n && this; ->p : (n: any) => MyClass ->(n) => n && this : (n: any) => MyClass +>p : (n: any) => this +>(n) => n && this : (n: any) => this >n : any ->n && this : MyClass +>n && this : this >n : any ->this : MyClass +>this : this } } diff --git a/tests/baselines/reference/asOperator4.js b/tests/baselines/reference/asOperator4.js new file mode 100644 index 00000000000..906b807fe73 --- /dev/null +++ b/tests/baselines/reference/asOperator4.js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/expressions/asOperator/asOperator4.ts] //// + +//// [foo.ts] + +export function foo() { } + +//// [bar.ts] +import { foo } from './foo'; + +// These should emit identically +foo; +(foo as any); + + +//// [foo.js] +function foo() { } +exports.foo = foo; +//// [bar.js] +var foo_1 = require('./foo'); +// These should emit identically +foo_1.foo; +foo_1.foo; diff --git a/tests/baselines/reference/asOperator4.symbols b/tests/baselines/reference/asOperator4.symbols new file mode 100644 index 00000000000..4ee5f6fe83f --- /dev/null +++ b/tests/baselines/reference/asOperator4.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/expressions/asOperator/foo.ts === + +export function foo() { } +>foo : Symbol(foo, Decl(foo.ts, 0, 0)) + +=== tests/cases/conformance/expressions/asOperator/bar.ts === +import { foo } from './foo'; +>foo : Symbol(foo, Decl(bar.ts, 0, 8)) + +// These should emit identically +foo; +>foo : Symbol(foo, Decl(bar.ts, 0, 8)) + +(foo as any); +>foo : Symbol(foo, Decl(bar.ts, 0, 8)) + diff --git a/tests/baselines/reference/asOperator4.types b/tests/baselines/reference/asOperator4.types new file mode 100644 index 00000000000..0dc6be46a2c --- /dev/null +++ b/tests/baselines/reference/asOperator4.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/expressions/asOperator/foo.ts === + +export function foo() { } +>foo : () => void + +=== tests/cases/conformance/expressions/asOperator/bar.ts === +import { foo } from './foo'; +>foo : () => void + +// These should emit identically +foo; +>foo : any +>foo : () => void + +(foo as any); +>(foo as any) : any +>foo as any : any +>foo : () => void + diff --git a/tests/baselines/reference/asiAbstract.errors.txt b/tests/baselines/reference/asiAbstract.errors.txt new file mode 100644 index 00000000000..3cc8999a2f2 --- /dev/null +++ b/tests/baselines/reference/asiAbstract.errors.txt @@ -0,0 +1,24 @@ +tests/cases/compiler/asiAbstract.ts(1,1): error TS2304: Cannot find name 'abstract'. +tests/cases/compiler/asiAbstract.ts(3,3): error TS1244: Abstract methods can only appear within an abstract class. + + +==== tests/cases/compiler/asiAbstract.ts (2 errors) ==== + abstract + ~~~~~~~~ +!!! error TS2304: Cannot find name 'abstract'. + class NonAbstractClass { + abstract s(); + ~~~~~~~~ +!!! error TS1244: Abstract methods can only appear within an abstract class. + } + + class C2 { + abstract + nonAbstractFunction() { + } + } + + class C3 { + abstract + } + \ No newline at end of file diff --git a/tests/baselines/reference/asiAbstract.js b/tests/baselines/reference/asiAbstract.js new file mode 100644 index 00000000000..8d5b412d022 --- /dev/null +++ b/tests/baselines/reference/asiAbstract.js @@ -0,0 +1,36 @@ +//// [asiAbstract.ts] +abstract +class NonAbstractClass { + abstract s(); +} + +class C2 { + abstract + nonAbstractFunction() { + } +} + +class C3 { + abstract +} + + +//// [asiAbstract.js] +abstract; +var NonAbstractClass = (function () { + function NonAbstractClass() { + } + return NonAbstractClass; +})(); +var C2 = (function () { + function C2() { + } + C2.prototype.nonAbstractFunction = function () { + }; + return C2; +})(); +var C3 = (function () { + function C3() { + } + return C3; +})(); diff --git a/tests/baselines/reference/asiPublicPrivateProtected.errors.txt b/tests/baselines/reference/asiPublicPrivateProtected.errors.txt new file mode 100644 index 00000000000..96d243536fb --- /dev/null +++ b/tests/baselines/reference/asiPublicPrivateProtected.errors.txt @@ -0,0 +1,52 @@ +tests/cases/compiler/asiPublicPrivateProtected.ts(1,1): error TS2304: Cannot find name 'public'. +tests/cases/compiler/asiPublicPrivateProtected.ts(12,1): error TS2304: Cannot find name 'private'. +tests/cases/compiler/asiPublicPrivateProtected.ts(23,1): error TS2304: Cannot find name 'protected'. + + +==== tests/cases/compiler/asiPublicPrivateProtected.ts (3 errors) ==== + public + ~~~~~~ +!!! error TS2304: Cannot find name 'public'. + class NonPublicClass { + public s() { + } + } + + class NonPublicClass2 { + public + private nonPublicFunction() { + } + } + private + ~~~~~~~ +!!! error TS2304: Cannot find name 'private'. + class NonPrivateClass { + private s() { + } + } + + class NonPrivateClass2 { + private + public nonPrivateFunction() { + } + } + protected + ~~~~~~~~~ +!!! error TS2304: Cannot find name 'protected'. + class NonProtectedClass { + protected s() { + } + } + + class NonProtectedClass2 { + protected + public nonProtectedFunction() { + } + } + + class ClassWithThreeMembers { + public + private + protected + } + \ No newline at end of file diff --git a/tests/baselines/reference/asiPublicPrivateProtected.js b/tests/baselines/reference/asiPublicPrivateProtected.js new file mode 100644 index 00000000000..a17bcb7509a --- /dev/null +++ b/tests/baselines/reference/asiPublicPrivateProtected.js @@ -0,0 +1,93 @@ +//// [asiPublicPrivateProtected.ts] +public +class NonPublicClass { + public s() { + } +} + +class NonPublicClass2 { + public + private nonPublicFunction() { + } +} +private +class NonPrivateClass { + private s() { + } +} + +class NonPrivateClass2 { + private + public nonPrivateFunction() { + } +} +protected +class NonProtectedClass { + protected s() { + } +} + +class NonProtectedClass2 { + protected + public nonProtectedFunction() { + } +} + +class ClassWithThreeMembers { + public + private + protected +} + + +//// [asiPublicPrivateProtected.js] +public; +var NonPublicClass = (function () { + function NonPublicClass() { + } + NonPublicClass.prototype.s = function () { + }; + return NonPublicClass; +})(); +var NonPublicClass2 = (function () { + function NonPublicClass2() { + } + NonPublicClass2.prototype.nonPublicFunction = function () { + }; + return NonPublicClass2; +})(); +private; +var NonPrivateClass = (function () { + function NonPrivateClass() { + } + NonPrivateClass.prototype.s = function () { + }; + return NonPrivateClass; +})(); +var NonPrivateClass2 = (function () { + function NonPrivateClass2() { + } + NonPrivateClass2.prototype.nonPrivateFunction = function () { + }; + return NonPrivateClass2; +})(); +protected; +var NonProtectedClass = (function () { + function NonProtectedClass() { + } + NonProtectedClass.prototype.s = function () { + }; + return NonProtectedClass; +})(); +var NonProtectedClass2 = (function () { + function NonProtectedClass2() { + } + NonProtectedClass2.prototype.nonProtectedFunction = function () { + }; + return NonProtectedClass2; +})(); +var ClassWithThreeMembers = (function () { + function ClassWithThreeMembers() { + } + return ClassWithThreeMembers; +})(); diff --git a/tests/baselines/reference/assignmentCompatBug2.errors.txt b/tests/baselines/reference/assignmentCompatBug2.errors.txt index 53e12635888..29ba96e6586 100644 --- a/tests/baselines/reference/assignmentCompatBug2.errors.txt +++ b/tests/baselines/reference/assignmentCompatBug2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/assignmentCompatBug2.ts(1,5): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. +tests/cases/compiler/assignmentCompatBug2.ts(1,27): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. -tests/cases/compiler/assignmentCompatBug2.ts(3,1): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. +tests/cases/compiler/assignmentCompatBug2.ts(3,8): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. -tests/cases/compiler/assignmentCompatBug2.ts(5,1): error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'. +tests/cases/compiler/assignmentCompatBug2.ts(5,13): error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'. Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. tests/cases/compiler/assignmentCompatBug2.ts(15,1): error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; }'. @@ -14,17 +14,17 @@ tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n: ==== tests/cases/compiler/assignmentCompatBug2.ts (6 errors) ==== var b2: { b: number;} = { a: 0 }; // error - ~~ + ~~~~ !!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. b2 = { a: 0 }; // error - ~~ + ~~~~ !!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. b2 = {b: 0, a: 0 }; - ~~ + ~~~~ !!! error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. diff --git a/tests/baselines/reference/assignmentCompatBug5.errors.txt b/tests/baselines/reference/assignmentCompatBug5.errors.txt index 790848babf4..1b5e3d80259 100644 --- a/tests/baselines/reference/assignmentCompatBug5.errors.txt +++ b/tests/baselines/reference/assignmentCompatBug5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/assignmentCompatBug5.ts(2,6): error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'. +tests/cases/compiler/assignmentCompatBug5.ts(2,8): error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'. Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. tests/cases/compiler/assignmentCompatBug5.ts(5,6): error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'number[]'. Type 'string' is not assignable to type 'number'. @@ -12,7 +12,7 @@ tests/cases/compiler/assignmentCompatBug5.ts(9,6): error TS2345: Argument of typ ==== tests/cases/compiler/assignmentCompatBug5.ts (4 errors) ==== function foo1(x: { a: number; }) { } foo1({ b: 5 }); - ~~~~~~~~ + ~~~~ !!! error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'. !!! error TS2345: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. diff --git a/tests/baselines/reference/asyncArrowFunction1_es6.symbols b/tests/baselines/reference/asyncArrowFunction1_es6.symbols index cb2c5255486..349a51c43ba 100644 --- a/tests/baselines/reference/asyncArrowFunction1_es6.symbols +++ b/tests/baselines/reference/asyncArrowFunction1_es6.symbols @@ -2,6 +2,6 @@ var foo = async (): Promise => { >foo : Symbol(foo, Decl(asyncArrowFunction1_es6.ts, 1, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) }; diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types index b3f6f18cde8..76853858c5c 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types @@ -11,11 +11,12 @@ class C { var fn = async () => await other.apply(this, arguments); >fn : () => Promise >async () => await other.apply(this, arguments) : () => Promise +>await other.apply(this, arguments) : any >other.apply(this, arguments) : any >other.apply : (thisArg: any, argArray?: any) => any >other : () => void >apply : (thisArg: any, argArray?: any) => any ->this : C +>this : this >arguments : IArguments } } diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.types b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.types index f3cd0f2d2de..5386a956ada 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.types +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es6.types @@ -6,9 +6,10 @@ class C { >method : () => void var fn = async () => await this; ->fn : () => Promise ->async () => await this : () => Promise ->this : C +>fn : () => Promise +>async () => await this : () => Promise +>await this : this +>this : this } } diff --git a/tests/baselines/reference/asyncAwait_es6.symbols b/tests/baselines/reference/asyncAwait_es6.symbols index 8d4b98a20a1..2eb28e12211 100644 --- a/tests/baselines/reference/asyncAwait_es6.symbols +++ b/tests/baselines/reference/asyncAwait_es6.symbols @@ -2,16 +2,16 @@ type MyPromise = Promise; >MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) >T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15)) declare var MyPromise: typeof Promise; >MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) declare var p: Promise; >p : Symbol(p, Decl(asyncAwait_es6.ts, 2, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) declare var mp: MyPromise; >mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) @@ -22,7 +22,7 @@ async function f0() { } async function f1(): Promise { } >f1 : Symbol(f1, Decl(asyncAwait_es6.ts, 5, 23)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) async function f3(): MyPromise { } >f3 : Symbol(f3, Decl(asyncAwait_es6.ts, 6, 38)) @@ -33,7 +33,7 @@ let f4 = async function() { } let f5 = async function(): Promise { } >f5 : Symbol(f5, Decl(asyncAwait_es6.ts, 10, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) let f6 = async function(): MyPromise { } >f6 : Symbol(f6, Decl(asyncAwait_es6.ts, 11, 3)) @@ -44,7 +44,7 @@ let f7 = async () => { }; let f8 = async (): Promise => { }; >f8 : Symbol(f8, Decl(asyncAwait_es6.ts, 14, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) let f9 = async (): MyPromise => { }; >f9 : Symbol(f9, Decl(asyncAwait_es6.ts, 15, 3)) @@ -60,7 +60,7 @@ let f11 = async () => mp; let f12 = async (): Promise => mp; >f12 : Symbol(f12, Decl(asyncAwait_es6.ts, 18, 3)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11)) let f13 = async (): MyPromise => p; @@ -76,7 +76,7 @@ let o = { async m2(): Promise { }, >m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 22, 16)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) async m3(): MyPromise { } >m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 23, 31)) @@ -92,7 +92,7 @@ class C { async m2(): Promise { } >m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 28, 15)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) async m3(): MyPromise { } >m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 29, 30)) @@ -103,7 +103,7 @@ class C { static async m5(): Promise { } >m5 : Symbol(C.m5, Decl(asyncAwait_es6.ts, 31, 22)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) static async m6(): MyPromise { } >m6 : Symbol(C.m6, Decl(asyncAwait_es6.ts, 32, 37)) diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols index 889614387d7..b970dbbf888 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts === async function await(): Promise { >await : Symbol(await, Decl(asyncFunctionDeclaration11_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) } diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols index 626b820e312..d17f4bf899e 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es6.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) return; } diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols index c71592c0463..c99ae35266b 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts === async function foo(): Promise { >foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es6.ts, 0, 0)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) } diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols index 6a72f1b1506..6ee2b1de415 100644 --- a/tests/baselines/reference/awaitBinaryExpression1_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.symbols @@ -4,15 +4,16 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression1_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression1_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) "before"; var b = await p || a; >b : Symbol(b, Decl(awaitBinaryExpression1_es6.ts, 4, 7)) +>p : Symbol(p, Decl(awaitBinaryExpression1_es6.ts, 1, 11)) >a : Symbol(a, Decl(awaitBinaryExpression1_es6.ts, 0, 11)) "after"; diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.types b/tests/baselines/reference/awaitBinaryExpression1_es6.types index 59370dda14b..4718f5f8fe9 100644 --- a/tests/baselines/reference/awaitBinaryExpression1_es6.types +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.types @@ -16,7 +16,8 @@ async function func(): Promise { var b = await p || a; >b : boolean >await p || a : boolean ->p : any +>await p : boolean +>p : Promise >a : boolean "after"; diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols index f81a146f943..9c65780cfad 100644 --- a/tests/baselines/reference/awaitBinaryExpression2_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.symbols @@ -4,15 +4,16 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression2_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression2_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) "before"; var b = await p && a; >b : Symbol(b, Decl(awaitBinaryExpression2_es6.ts, 4, 7)) +>p : Symbol(p, Decl(awaitBinaryExpression2_es6.ts, 1, 11)) >a : Symbol(a, Decl(awaitBinaryExpression2_es6.ts, 0, 11)) "after"; diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.types b/tests/baselines/reference/awaitBinaryExpression2_es6.types index c3f33bca2fa..6154377a6f1 100644 --- a/tests/baselines/reference/awaitBinaryExpression2_es6.types +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.types @@ -16,7 +16,8 @@ async function func(): Promise { var b = await p && a; >b : boolean >await p && a : boolean ->p : any +>await p : boolean +>p : Promise >a : boolean "after"; diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols index 479b3b30650..69d02403e85 100644 --- a/tests/baselines/reference/awaitBinaryExpression3_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.symbols @@ -4,15 +4,16 @@ declare var a: number; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression3_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression3_es6.ts, 1, 31)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) "before"; var b = await p + a; >b : Symbol(b, Decl(awaitBinaryExpression3_es6.ts, 4, 7)) +>p : Symbol(p, Decl(awaitBinaryExpression3_es6.ts, 1, 11)) >a : Symbol(a, Decl(awaitBinaryExpression3_es6.ts, 0, 11)) "after"; diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.types b/tests/baselines/reference/awaitBinaryExpression3_es6.types index 786eabadae4..2d5b087d6e3 100644 --- a/tests/baselines/reference/awaitBinaryExpression3_es6.types +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.types @@ -16,7 +16,8 @@ async function func(): Promise { var b = await p + a; >b : number >await p + a : number ->p : any +>await p : number +>p : Promise >a : number "after"; diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols index 5d15c754793..c88e0f247a5 100644 --- a/tests/baselines/reference/awaitBinaryExpression4_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.symbols @@ -4,15 +4,16 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression4_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression4_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) "before"; var b = await p, a; >b : Symbol(b, Decl(awaitBinaryExpression4_es6.ts, 4, 7)) +>p : Symbol(p, Decl(awaitBinaryExpression4_es6.ts, 1, 11)) >a : Symbol(a, Decl(awaitBinaryExpression4_es6.ts, 4, 20)) "after"; diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.types b/tests/baselines/reference/awaitBinaryExpression4_es6.types index 73126b7797d..80135203a82 100644 --- a/tests/baselines/reference/awaitBinaryExpression4_es6.types +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.types @@ -15,7 +15,8 @@ async function func(): Promise { var b = await p, a; >b : boolean ->p : any +>await p : boolean +>p : Promise >a : any "after"; diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols index bc1e2f19310..0ee4a03f3c5 100644 --- a/tests/baselines/reference/awaitBinaryExpression5_es6.symbols +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.symbols @@ -4,11 +4,11 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitBinaryExpression5_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) async function func(): Promise { >func : Symbol(func, Decl(awaitBinaryExpression5_es6.ts, 1, 32)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) "before"; var o: { a: boolean; }; @@ -19,6 +19,7 @@ async function func(): Promise { >o.a : Symbol(a, Decl(awaitBinaryExpression5_es6.ts, 4, 12)) >o : Symbol(o, Decl(awaitBinaryExpression5_es6.ts, 4, 7)) >a : Symbol(a, Decl(awaitBinaryExpression5_es6.ts, 4, 12)) +>p : Symbol(p, Decl(awaitBinaryExpression5_es6.ts, 1, 11)) "after"; } diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.types b/tests/baselines/reference/awaitBinaryExpression5_es6.types index 922e5887a77..8b76b6f8b88 100644 --- a/tests/baselines/reference/awaitBinaryExpression5_es6.types +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.types @@ -22,7 +22,8 @@ async function func(): Promise { >o.a : boolean >o : { a: boolean; } >a : boolean ->p : any +>await p : boolean +>p : Promise "after"; >"after" : string diff --git a/tests/baselines/reference/awaitCallExpression1_es6.symbols b/tests/baselines/reference/awaitCallExpression1_es6.symbols index 7e28d92cd9c..d70728a5b2d 100644 --- a/tests/baselines/reference/awaitCallExpression1_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression1_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression1_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression1_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression1_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression1_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) "before"; var b = fn(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression2_es6.symbols b/tests/baselines/reference/awaitCallExpression2_es6.symbols index 305a4c77aa3..a3fd474060a 100644 --- a/tests/baselines/reference/awaitCallExpression2_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression2_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression2_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression2_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression2_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 5, 43)) @@ -36,12 +36,13 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression2_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) "before"; var b = fn(await p, a, a); >b : Symbol(b, Decl(awaitCallExpression2_es6.ts, 8, 7)) >fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32)) +>p : Symbol(p, Decl(awaitCallExpression2_es6.ts, 1, 11)) >a : Symbol(a, Decl(awaitCallExpression2_es6.ts, 0, 11)) >a : Symbol(a, Decl(awaitCallExpression2_es6.ts, 0, 11)) diff --git a/tests/baselines/reference/awaitCallExpression2_es6.types b/tests/baselines/reference/awaitCallExpression2_es6.types index 6c7f02a578a..1617f4a14ff 100644 --- a/tests/baselines/reference/awaitCallExpression2_es6.types +++ b/tests/baselines/reference/awaitCallExpression2_es6.types @@ -45,7 +45,8 @@ async function func(): Promise { >b : void >fn(await p, a, a) : void >fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void ->p : any +>await p : boolean +>p : Promise >a : boolean >a : boolean diff --git a/tests/baselines/reference/awaitCallExpression3_es6.symbols b/tests/baselines/reference/awaitCallExpression3_es6.symbols index 715c125bcf0..6dde8fc7f58 100644 --- a/tests/baselines/reference/awaitCallExpression3_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression3_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression3_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression3_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression3_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 5, 43)) @@ -36,13 +36,14 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression3_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) "before"; var b = fn(a, await p, a); >b : Symbol(b, Decl(awaitCallExpression3_es6.ts, 8, 7)) >fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32)) >a : Symbol(a, Decl(awaitCallExpression3_es6.ts, 0, 11)) +>p : Symbol(p, Decl(awaitCallExpression3_es6.ts, 1, 11)) >a : Symbol(a, Decl(awaitCallExpression3_es6.ts, 0, 11)) "after"; diff --git a/tests/baselines/reference/awaitCallExpression3_es6.types b/tests/baselines/reference/awaitCallExpression3_es6.types index 24d22db3c8c..6304a803f64 100644 --- a/tests/baselines/reference/awaitCallExpression3_es6.types +++ b/tests/baselines/reference/awaitCallExpression3_es6.types @@ -46,7 +46,8 @@ async function func(): Promise { >fn(a, await p, a) : void >fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void >a : boolean ->p : any +>await p : boolean +>p : Promise >a : boolean "after"; diff --git a/tests/baselines/reference/awaitCallExpression4_es6.symbols b/tests/baselines/reference/awaitCallExpression4_es6.symbols index 98a995d8117..ca563274b51 100644 --- a/tests/baselines/reference/awaitCallExpression4_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression4_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression4_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression4_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression4_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 5, 43)) @@ -36,11 +36,12 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression4_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) "before"; var b = (await pfn)(a, a, a); >b : Symbol(b, Decl(awaitCallExpression4_es6.ts, 8, 7)) +>pfn : Symbol(pfn, Decl(awaitCallExpression4_es6.ts, 4, 11)) >a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11)) >a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11)) >a : Symbol(a, Decl(awaitCallExpression4_es6.ts, 0, 11)) diff --git a/tests/baselines/reference/awaitCallExpression4_es6.types b/tests/baselines/reference/awaitCallExpression4_es6.types index 04115466427..ff5d8f4012b 100644 --- a/tests/baselines/reference/awaitCallExpression4_es6.types +++ b/tests/baselines/reference/awaitCallExpression4_es6.types @@ -45,7 +45,8 @@ async function func(): Promise { >b : void >(await pfn)(a, a, a) : void >(await pfn) : (arg0: boolean, arg1: boolean, arg2: boolean) => void ->pfn : any +>await pfn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> >a : boolean >a : boolean >a : boolean diff --git a/tests/baselines/reference/awaitCallExpression5_es6.symbols b/tests/baselines/reference/awaitCallExpression5_es6.symbols index 30df9c8d022..4c75a6fec6d 100644 --- a/tests/baselines/reference/awaitCallExpression5_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression5_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression5_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression5_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression5_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression5_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) "before"; var b = o.fn(a, a, a); diff --git a/tests/baselines/reference/awaitCallExpression6_es6.symbols b/tests/baselines/reference/awaitCallExpression6_es6.symbols index ac1cca1c16f..effed91ec06 100644 --- a/tests/baselines/reference/awaitCallExpression6_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression6_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression6_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression6_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression6_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression6_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) "before"; var b = o.fn(await p, a, a); @@ -44,6 +44,7 @@ async function func(): Promise { >o.fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 3, 16)) >o : Symbol(o, Decl(awaitCallExpression6_es6.ts, 3, 11)) >fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 3, 16)) +>p : Symbol(p, Decl(awaitCallExpression6_es6.ts, 1, 11)) >a : Symbol(a, Decl(awaitCallExpression6_es6.ts, 0, 11)) >a : Symbol(a, Decl(awaitCallExpression6_es6.ts, 0, 11)) diff --git a/tests/baselines/reference/awaitCallExpression6_es6.types b/tests/baselines/reference/awaitCallExpression6_es6.types index d18377cebbb..3266733fab0 100644 --- a/tests/baselines/reference/awaitCallExpression6_es6.types +++ b/tests/baselines/reference/awaitCallExpression6_es6.types @@ -47,7 +47,8 @@ async function func(): Promise { >o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void >o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } >fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void ->p : any +>await p : boolean +>p : Promise >a : boolean >a : boolean diff --git a/tests/baselines/reference/awaitCallExpression7_es6.symbols b/tests/baselines/reference/awaitCallExpression7_es6.symbols index b48e99ddec1..3393d2a0759 100644 --- a/tests/baselines/reference/awaitCallExpression7_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression7_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression7_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression7_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression7_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 5, 43)) @@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression7_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) "before"; var b = o.fn(a, await p, a); @@ -45,6 +45,7 @@ async function func(): Promise { >o : Symbol(o, Decl(awaitCallExpression7_es6.ts, 3, 11)) >fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 3, 16)) >a : Symbol(a, Decl(awaitCallExpression7_es6.ts, 0, 11)) +>p : Symbol(p, Decl(awaitCallExpression7_es6.ts, 1, 11)) >a : Symbol(a, Decl(awaitCallExpression7_es6.ts, 0, 11)) "after"; diff --git a/tests/baselines/reference/awaitCallExpression7_es6.types b/tests/baselines/reference/awaitCallExpression7_es6.types index b213a75dcd6..b1b382f7325 100644 --- a/tests/baselines/reference/awaitCallExpression7_es6.types +++ b/tests/baselines/reference/awaitCallExpression7_es6.types @@ -48,7 +48,8 @@ async function func(): Promise { >o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } >fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void >a : boolean ->p : any +>await p : boolean +>p : Promise >a : boolean "after"; diff --git a/tests/baselines/reference/awaitCallExpression8_es6.symbols b/tests/baselines/reference/awaitCallExpression8_es6.symbols index 4dd9d500347..331ebbdb7e1 100644 --- a/tests/baselines/reference/awaitCallExpression8_es6.symbols +++ b/tests/baselines/reference/awaitCallExpression8_es6.symbols @@ -4,7 +4,7 @@ declare var a: boolean; declare var p: Promise; >p : Symbol(p, Decl(awaitCallExpression8_es6.ts, 1, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 1, 32)) @@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >pfn : Symbol(pfn, Decl(awaitCallExpression8_es6.ts, 4, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 4, 28)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 4, 42)) >arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 4, 57)) declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; >po : Symbol(po, Decl(awaitCallExpression8_es6.ts, 5, 11)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) >arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 5, 29)) >arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 5, 43)) @@ -36,12 +36,13 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; async function func(): Promise { >func : Symbol(func, Decl(awaitCallExpression8_es6.ts, 5, 84)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) "before"; var b = (await po).fn(a, a, a); >b : Symbol(b, Decl(awaitCallExpression8_es6.ts, 8, 7)) >(await po).fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) +>po : Symbol(po, Decl(awaitCallExpression8_es6.ts, 5, 11)) >fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25)) >a : Symbol(a, Decl(awaitCallExpression8_es6.ts, 0, 11)) >a : Symbol(a, Decl(awaitCallExpression8_es6.ts, 0, 11)) diff --git a/tests/baselines/reference/awaitCallExpression8_es6.types b/tests/baselines/reference/awaitCallExpression8_es6.types index 37511a7e3d7..76719c09c85 100644 --- a/tests/baselines/reference/awaitCallExpression8_es6.types +++ b/tests/baselines/reference/awaitCallExpression8_es6.types @@ -46,7 +46,8 @@ async function func(): Promise { >(await po).fn(a, a, a) : void >(await po).fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void >(await po) : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } ->po : any +>await po : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> >fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void >a : boolean >a : boolean diff --git a/tests/baselines/reference/awaitUnion_es6.symbols b/tests/baselines/reference/awaitUnion_es6.symbols index ca0b9afaf92..2db3b1a2fdb 100644 --- a/tests/baselines/reference/awaitUnion_es6.symbols +++ b/tests/baselines/reference/awaitUnion_es6.symbols @@ -24,16 +24,21 @@ async function f() { let await_a = await a; >await_a : Symbol(await_a, Decl(awaitUnion_es6.ts, 6, 4)) +>a : Symbol(a, Decl(awaitUnion_es6.ts, 0, 11)) let await_b = await b; >await_b : Symbol(await_b, Decl(awaitUnion_es6.ts, 7, 4)) +>b : Symbol(b, Decl(awaitUnion_es6.ts, 1, 11)) let await_c = await c; >await_c : Symbol(await_c, Decl(awaitUnion_es6.ts, 8, 4)) +>c : Symbol(c, Decl(awaitUnion_es6.ts, 2, 11)) let await_d = await d; >await_d : Symbol(await_d, Decl(awaitUnion_es6.ts, 9, 4)) +>d : Symbol(d, Decl(awaitUnion_es6.ts, 3, 11)) let await_e = await e; >await_e : Symbol(await_e, Decl(awaitUnion_es6.ts, 10, 4)) +>e : Symbol(e, Decl(awaitUnion_es6.ts, 4, 11)) } diff --git a/tests/baselines/reference/awaitUnion_es6.types b/tests/baselines/reference/awaitUnion_es6.types index d0b5b6ccfd0..97d4bd2fc57 100644 --- a/tests/baselines/reference/awaitUnion_es6.types +++ b/tests/baselines/reference/awaitUnion_es6.types @@ -24,21 +24,26 @@ async function f() { let await_a = await a; >await_a : number | string ->a : any +>await a : number | string +>a : number | string let await_b = await b; >await_b : number | string ->b : any +>await b : number | string +>b : PromiseLike | PromiseLike let await_c = await c; >await_c : number | string ->c : any +>await c : number | string +>c : PromiseLike let await_d = await d; >await_d : number | string ->d : any +>await d : number | string +>d : number | PromiseLike let await_e = await e; >await_e : number | string ->e : any +>await e : number | string +>e : number | PromiseLike } diff --git a/tests/baselines/reference/badThisBinding.types b/tests/baselines/reference/badThisBinding.types index a6b1c478d53..201f3e70288 100644 --- a/tests/baselines/reference/badThisBinding.types +++ b/tests/baselines/reference/badThisBinding.types @@ -22,8 +22,8 @@ class Greeter { >() => { var x = this; } : () => void var x = this; ->x : Greeter ->this : Greeter +>x : this +>this : this }); }); diff --git a/tests/baselines/reference/baseTypeWrappingInstantiationChain.types b/tests/baselines/reference/baseTypeWrappingInstantiationChain.types index 747b672dd0d..ba702171de9 100644 --- a/tests/baselines/reference/baseTypeWrappingInstantiationChain.types +++ b/tests/baselines/reference/baseTypeWrappingInstantiationChain.types @@ -13,7 +13,7 @@ class C extends CBase { >CBaseBase : typeof CBaseBase >Wrapper : Wrapper >T1 : T1 ->this : C +>this : this } public alsoWorks() { >alsoWorks : () => void @@ -22,7 +22,7 @@ class C extends CBase { >new CBase(this) : CBase >CBase : typeof CBase >T1 : T1 ->this : C +>this : this } public method(t: Wrapper) { } diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types index 933d46cc802..1191004a32b 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types @@ -46,8 +46,8 @@ var r = true ? 1 : 2; >2 : number var r3 = true ? 1 : {}; ->r3 : number | {} ->true ? 1 : {} : number | {} +>r3 : {} +>true ? 1 : {} : {} >true : boolean >1 : number >{} : {} @@ -67,8 +67,8 @@ var r5 = true ? b : a; // typeof b >a : { x: number; y?: number; } var r6 = true ? (x: number) => { } : (x: Object) => { }; // returns number => void ->r6 : ((x: number) => void) | ((x: Object) => void) ->true ? (x: number) => { } : (x: Object) => { } : ((x: number) => void) | ((x: Object) => void) +>r6 : (x: number) => void +>true ? (x: number) => { } : (x: Object) => { } : (x: number) => void >true : boolean >(x: number) => { } : (x: number) => void >x : number @@ -80,7 +80,7 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { }; >r7 : (x: Object) => void >x : Object >Object : Object ->true ? (x: number) => { } : (x: Object) => { } : ((x: number) => void) | ((x: Object) => void) +>true ? (x: number) => { } : (x: Object) => { } : (x: number) => void >true : boolean >(x: number) => { } : (x: number) => void >x : number @@ -89,8 +89,8 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { }; >Object : Object var r8 = true ? (x: Object) => { } : (x: number) => { }; // returns Object => void ->r8 : ((x: Object) => void) | ((x: number) => void) ->true ? (x: Object) => { } : (x: number) => { } : ((x: Object) => void) | ((x: number) => void) +>r8 : (x: Object) => void +>true ? (x: Object) => { } : (x: number) => { } : (x: Object) => void >true : boolean >(x: Object) => { } : (x: Object) => void >x : Object @@ -107,8 +107,8 @@ var r10: Base = true ? derived : derived2; // no error since we use the contextu >derived2 : Derived2 var r11 = true ? base : derived2; ->r11 : Base | Derived2 ->true ? base : derived2 : Base | Derived2 +>r11 : Base +>true ? base : derived2 : Base >true : boolean >base : Base >derived2 : Derived2 diff --git a/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types b/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types index 4c47753a90d..df40291b0e5 100644 --- a/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types +++ b/tests/baselines/reference/bestCommonTypeWithOptionalProperties.types @@ -27,43 +27,43 @@ var z: Z; // All these arrays should be X[] var b1 = [x, y, z]; ->b1 : (X | Y | Z)[] ->[x, y, z] : (X | Y | Z)[] +>b1 : X[] +>[x, y, z] : X[] >x : X >y : Y >z : Z var b2 = [x, z, y]; ->b2 : (X | Z | Y)[] ->[x, z, y] : (X | Z | Y)[] +>b2 : X[] +>[x, z, y] : X[] >x : X >z : Z >y : Y var b3 = [y, x, z]; ->b3 : (Y | X | Z)[] ->[y, x, z] : (Y | X | Z)[] +>b3 : X[] +>[y, x, z] : X[] >y : Y >x : X >z : Z var b4 = [y, z, x]; ->b4 : (Y | Z | X)[] ->[y, z, x] : (Y | Z | X)[] +>b4 : X[] +>[y, z, x] : X[] >y : Y >z : Z >x : X var b5 = [z, x, y]; ->b5 : (Z | X | Y)[] ->[z, x, y] : (Z | X | Y)[] +>b5 : X[] +>[z, x, y] : X[] >z : Z >x : X >y : Y var b6 = [z, y, x]; ->b6 : (Z | Y | X)[] ->[z, y, x] : (Z | Y | X)[] +>b6 : X[] +>[z, y, x] : X[] >z : Z >y : Y >x : X diff --git a/tests/baselines/reference/binopAssignmentShouldHaveType.types b/tests/baselines/reference/binopAssignmentShouldHaveType.types index fdef2fbcabd..d09138bbb88 100644 --- a/tests/baselines/reference/binopAssignmentShouldHaveType.types +++ b/tests/baselines/reference/binopAssignmentShouldHaveType.types @@ -32,7 +32,7 @@ module Test { >name : string >this.getName() : string >this.getName : () => string ->this : Bug +>this : this >getName : () => string >length : number >0 : number diff --git a/tests/baselines/reference/callWithSpread.types b/tests/baselines/reference/callWithSpread.types index 8964708c05e..eae92c471e9 100644 --- a/tests/baselines/reference/callWithSpread.types +++ b/tests/baselines/reference/callWithSpread.types @@ -180,7 +180,7 @@ class C { this.foo(x, y); >this.foo(x, y) : void >this.foo : (x: number, y: number, ...z: string[]) => void ->this : C +>this : this >foo : (x: number, y: number, ...z: string[]) => void >x : number >y : number @@ -188,7 +188,7 @@ class C { this.foo(x, y, ...z); >this.foo(x, y, ...z) : void >this.foo : (x: number, y: number, ...z: string[]) => void ->this : C +>this : this >foo : (x: number, y: number, ...z: string[]) => void >x : number >y : number diff --git a/tests/baselines/reference/callWithSpreadES6.symbols b/tests/baselines/reference/callWithSpreadES6.symbols index 0e236821020..d8604d8358a 100644 --- a/tests/baselines/reference/callWithSpreadES6.symbols +++ b/tests/baselines/reference/callWithSpreadES6.symbols @@ -94,7 +94,7 @@ xa[1].foo(1, 2, ...a, "abc"); >a : Symbol(a, Decl(callWithSpreadES6.ts, 8, 3)) (xa[1].foo)(...[1, 2, "abc"]); ->Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 1368, 1)) +>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11), Decl(lib.d.ts, 4036, 1)) >xa[1].foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) >xa : Symbol(xa, Decl(callWithSpreadES6.ts, 11, 3)) >foo : Symbol(X.foo, Decl(callWithSpreadES6.ts, 1, 13)) diff --git a/tests/baselines/reference/callWithSpreadES6.types b/tests/baselines/reference/callWithSpreadES6.types index 9c9e795ce24..b0c118855fe 100644 --- a/tests/baselines/reference/callWithSpreadES6.types +++ b/tests/baselines/reference/callWithSpreadES6.types @@ -181,7 +181,7 @@ class C { this.foo(x, y); >this.foo(x, y) : void >this.foo : (x: number, y: number, ...z: string[]) => void ->this : C +>this : this >foo : (x: number, y: number, ...z: string[]) => void >x : number >y : number @@ -189,7 +189,7 @@ class C { this.foo(x, y, ...z); >this.foo(x, y, ...z) : void >this.foo : (x: number, y: number, ...z: string[]) => void ->this : C +>this : this >foo : (x: number, y: number, ...z: string[]) => void >x : number >y : number diff --git a/tests/baselines/reference/captureThisInSuperCall.types b/tests/baselines/reference/captureThisInSuperCall.types index faa7d2ad97e..4a0902e9f1e 100644 --- a/tests/baselines/reference/captureThisInSuperCall.types +++ b/tests/baselines/reference/captureThisInSuperCall.types @@ -18,7 +18,7 @@ class B extends A { >() => this.someMethod() : () => void >this.someMethod() : void >this.someMethod : () => void ->this : B +>this : this >someMethod : () => void someMethod() {} diff --git a/tests/baselines/reference/castExpressionParentheses.js b/tests/baselines/reference/castExpressionParentheses.js index ec18d6e373e..b4754d0ad41 100644 --- a/tests/baselines/reference/castExpressionParentheses.js +++ b/tests/baselines/reference/castExpressionParentheses.js @@ -7,6 +7,11 @@ declare var a; ([1,3,]); ("string"); (23.0); +(1); +(1.); +(1.0); +(12e+34); +(0xff); (/regexp/g); (false); (true); @@ -23,6 +28,12 @@ declare var a; declare var A; // should keep the parentheses in emit +(1).foo; +(1.).foo; +(1.0).foo; +(12e+34).foo; +(0xff).foo; +((1.0)); (new A).foo; (typeof A).x; (-A).x; @@ -46,6 +57,11 @@ new (A()); [1, 3,]; "string"; 23.0; +1; +1.; +1.0; +12e+34; +0xff; /regexp/g; false; true; @@ -59,6 +75,12 @@ a[0]; a.b["0"]; a().x; // should keep the parentheses in emit +(1).foo; +(1.).foo; +(1.0).foo; +(12e+34).foo; +(0xff).foo; +(1.0); (new A).foo; (typeof A).x; (-A).x; diff --git a/tests/baselines/reference/castExpressionParentheses.symbols b/tests/baselines/reference/castExpressionParentheses.symbols index 7bc8169e40f..ef31ee0f226 100644 --- a/tests/baselines/reference/castExpressionParentheses.symbols +++ b/tests/baselines/reference/castExpressionParentheses.symbols @@ -10,6 +10,11 @@ declare var a; ([1,3,]); ("string"); (23.0); +(1); +(1.); +(1.0); +(12e+34); +(0xff); (/regexp/g); (false); (true); @@ -33,36 +38,42 @@ declare var a; >a : Symbol(a, Decl(castExpressionParentheses.ts, 0, 11)) declare var A; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) // should keep the parentheses in emit +(1).foo; +(1.).foo; +(1.0).foo; +(12e+34).foo; +(0xff).foo; +((1.0)); (new A).foo; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) (typeof A).x; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) (-A).x; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) new (A()); ->A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) (()=> {})(); ->Tany : Symbol(Tany, Decl(castExpressionParentheses.ts, 28, 2)) +>Tany : Symbol(Tany, Decl(castExpressionParentheses.ts, 39, 2)) (function foo() { })(); ->foo : Symbol(foo, Decl(castExpressionParentheses.ts, 29, 6)) +>foo : Symbol(foo, Decl(castExpressionParentheses.ts, 40, 6)) (-A).x; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) // nested cast, should keep one pair of parenthese ((-A)).x; ->A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) // nested parenthesized expression, should keep one pair of parenthese ((A)) ->A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11)) +>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11)) diff --git a/tests/baselines/reference/castExpressionParentheses.types b/tests/baselines/reference/castExpressionParentheses.types index ab563a4e8b7..cdfbf4f7db2 100644 --- a/tests/baselines/reference/castExpressionParentheses.types +++ b/tests/baselines/reference/castExpressionParentheses.types @@ -28,6 +28,31 @@ declare var a; >23.0 : any >23.0 : number +(1); +>(1) : any +>1 : any +>1 : number + +(1.); +>(1.) : any +>1. : any +>1. : number + +(1.0); +>(1.0) : any +>1.0 : any +>1.0 : number + +(12e+34); +>(12e+34) : any +>12e+34 : any +>12e+34 : number + +(0xff); +>(0xff) : any +>0xff : any +>0xff : number + (/regexp/g); >(/regexp/g) : any >/regexp/g : any @@ -104,6 +129,47 @@ declare var A; >A : any // should keep the parentheses in emit +(1).foo; +>(1).foo : any +>(1) : any +>1 : any +>1 : number +>foo : any + +(1.).foo; +>(1.).foo : any +>(1.) : any +>1. : any +>1. : number +>foo : any + +(1.0).foo; +>(1.0).foo : any +>(1.0) : any +>1.0 : any +>1.0 : number +>foo : any + +(12e+34).foo; +>(12e+34).foo : any +>(12e+34) : any +>12e+34 : any +>12e+34 : number +>foo : any + +(0xff).foo; +>(0xff).foo : any +>(0xff) : any +>0xff : any +>0xff : number +>foo : any + +((1.0)); +>((1.0)) : any +>(1.0) : any +>(1.0) : number +>1.0 : number + (new A).foo; >(new A).foo : any >(new A) : any diff --git a/tests/baselines/reference/chainedImportAlias.js b/tests/baselines/reference/chainedImportAlias.js index 077a92d7450..ec751b0329a 100644 --- a/tests/baselines/reference/chainedImportAlias.js +++ b/tests/baselines/reference/chainedImportAlias.js @@ -6,7 +6,7 @@ export module m { } //// [chainedImportAlias_file1.ts] -import x = require('chainedImportAlias_file0'); +import x = require('./chainedImportAlias_file0'); import y = x; y.m.foo(); @@ -18,6 +18,6 @@ var m; m.foo = foo; })(m = exports.m || (exports.m = {})); //// [chainedImportAlias_file1.js] -var x = require('chainedImportAlias_file0'); +var x = require('./chainedImportAlias_file0'); var y = x; y.m.foo(); diff --git a/tests/baselines/reference/chainedImportAlias.symbols b/tests/baselines/reference/chainedImportAlias.symbols index 3aebb4502f8..0f374305aeb 100644 --- a/tests/baselines/reference/chainedImportAlias.symbols +++ b/tests/baselines/reference/chainedImportAlias.symbols @@ -1,15 +1,15 @@ === tests/cases/compiler/chainedImportAlias_file1.ts === -import x = require('chainedImportAlias_file0'); +import x = require('./chainedImportAlias_file0'); >x : Symbol(x, Decl(chainedImportAlias_file1.ts, 0, 0)) import y = x; ->y : Symbol(y, Decl(chainedImportAlias_file1.ts, 0, 47)) +>y : Symbol(y, Decl(chainedImportAlias_file1.ts, 0, 49)) >x : Symbol(x, Decl(chainedImportAlias_file0.ts, 0, 0)) y.m.foo(); >y.m.foo : Symbol(x.m.foo, Decl(chainedImportAlias_file0.ts, 0, 17)) >y.m : Symbol(x.m, Decl(chainedImportAlias_file0.ts, 0, 0)) ->y : Symbol(y, Decl(chainedImportAlias_file1.ts, 0, 47)) +>y : Symbol(y, Decl(chainedImportAlias_file1.ts, 0, 49)) >m : Symbol(x.m, Decl(chainedImportAlias_file0.ts, 0, 0)) >foo : Symbol(x.m.foo, Decl(chainedImportAlias_file0.ts, 0, 17)) diff --git a/tests/baselines/reference/chainedImportAlias.types b/tests/baselines/reference/chainedImportAlias.types index 1435776fff2..db06c833d0b 100644 --- a/tests/baselines/reference/chainedImportAlias.types +++ b/tests/baselines/reference/chainedImportAlias.types @@ -1,5 +1,5 @@ === tests/cases/compiler/chainedImportAlias_file1.ts === -import x = require('chainedImportAlias_file0'); +import x = require('./chainedImportAlias_file0'); >x : typeof x import y = x; diff --git a/tests/baselines/reference/classAbstractDeclarations.d.errors.txt b/tests/baselines/reference/classAbstractDeclarations.d.errors.txt index 20d5ca46933..a1c0e55152c 100644 --- a/tests/baselines/reference/classAbstractDeclarations.d.errors.txt +++ b/tests/baselines/reference/classAbstractDeclarations.d.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,28): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,28): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(11,15): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(13,15): error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(17,15): error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. @@ -11,7 +11,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst ~~~~~~~~ !!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. } declare abstract class AA { diff --git a/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt b/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt deleted file mode 100644 index 5af440ed4df..00000000000 --- a/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt +++ /dev/null @@ -1,24 +0,0 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'A'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(11,1): error TS2511: Cannot create an instance of the abstract class 'B'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(12,1): error TS2511: Cannot create an instance of the abstract class 'C'. - - -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts (3 errors) ==== - abstract class A {} - - abstract - class B {} - - abstract - - class C {} - - new A; - ~~~~~ -!!! error TS2511: Cannot create an instance of the abstract class 'A'. - new B; - ~~~~~ -!!! error TS2511: Cannot create an instance of the abstract class 'B'. - new C; - ~~~~~ -!!! error TS2511: Cannot create an instance of the abstract class 'C'. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractSingleLineDecl.errors.txt b/tests/baselines/reference/classAbstractSingleLineDecl.errors.txt new file mode 100644 index 00000000000..0670ea108ea --- /dev/null +++ b/tests/baselines/reference/classAbstractSingleLineDecl.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSingleLineDecl.ts(3,1): error TS2304: Cannot find name 'abstract'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSingleLineDecl.ts(6,1): error TS2304: Cannot find name 'abstract'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSingleLineDecl.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'A'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSingleLineDecl.ts (3 errors) ==== + abstract class A {} + + abstract + ~~~~~~~~ +!!! error TS2304: Cannot find name 'abstract'. + class B {} + + abstract + ~~~~~~~~ +!!! error TS2304: Cannot find name 'abstract'. + + class C {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new B; + new C; \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMultiLineDecl.js b/tests/baselines/reference/classAbstractSingleLineDecl.js similarity index 72% rename from tests/baselines/reference/classAbstractMultiLineDecl.js rename to tests/baselines/reference/classAbstractSingleLineDecl.js index 3a92e2aa1e5..772ed564a66 100644 --- a/tests/baselines/reference/classAbstractMultiLineDecl.js +++ b/tests/baselines/reference/classAbstractSingleLineDecl.js @@ -1,4 +1,4 @@ -//// [classAbstractMultiLineDecl.ts] +//// [classAbstractSingleLineDecl.ts] abstract class A {} abstract @@ -12,17 +12,19 @@ new A; new B; new C; -//// [classAbstractMultiLineDecl.js] +//// [classAbstractSingleLineDecl.js] var A = (function () { function A() { } return A; })(); +abstract; var B = (function () { function B() { } return B; })(); +abstract; var C = (function () { function C() { } diff --git a/tests/baselines/reference/classConstructorParametersAccessibility3.types b/tests/baselines/reference/classConstructorParametersAccessibility3.types index 3372044569c..d664aaf3172 100644 --- a/tests/baselines/reference/classConstructorParametersAccessibility3.types +++ b/tests/baselines/reference/classConstructorParametersAccessibility3.types @@ -20,7 +20,7 @@ class Derived extends Base { this.p; // OK >this.p : number ->this : Derived +>this : this >p : number } } diff --git a/tests/baselines/reference/classExpressionES63.js b/tests/baselines/reference/classExpressionES63.js index 6d357af7c5a..6b3a06cf7c3 100644 --- a/tests/baselines/reference/classExpressionES63.js +++ b/tests/baselines/reference/classExpressionES63.js @@ -7,7 +7,7 @@ c.c; //// [classExpressionES63.js] -let C = class class_1 extends class class_2 extends class class_3 { +let C = class extends class extends class { constructor() { this.a = 1; } diff --git a/tests/baselines/reference/classExpressionExtendingAbstractClass.errors.txt b/tests/baselines/reference/classExpressionExtendingAbstractClass.errors.txt new file mode 100644 index 00000000000..b5d709fbf60 --- /dev/null +++ b/tests/baselines/reference/classExpressionExtendingAbstractClass.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/classExpressionExtendingAbstractClass.ts(5,9): error TS2653: Non-abstract class expression does not implement inherited abstract member 'foo' from class 'A'. + + +==== tests/cases/compiler/classExpressionExtendingAbstractClass.ts (1 errors) ==== + abstract class A { + abstract foo(): void; + } + + var C = class extends A { // no error reported! + ~~~~~ +!!! error TS2653: Non-abstract class expression does not implement inherited abstract member 'foo' from class 'A'. + }; + + \ No newline at end of file diff --git a/tests/baselines/reference/classExpressionExtendingAbstractClass.js b/tests/baselines/reference/classExpressionExtendingAbstractClass.js new file mode 100644 index 00000000000..a5149538da2 --- /dev/null +++ b/tests/baselines/reference/classExpressionExtendingAbstractClass.js @@ -0,0 +1,28 @@ +//// [classExpressionExtendingAbstractClass.ts] +abstract class A { + abstract foo(): void; +} + +var C = class extends A { // no error reported! +}; + + + +//// [classExpressionExtendingAbstractClass.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var C = (function (_super) { + __extends(class_1, _super); + function class_1() { + _super.apply(this, arguments); + } + return class_1; +})(A); diff --git a/tests/baselines/reference/classExpressionWithDecorator1.js b/tests/baselines/reference/classExpressionWithDecorator1.js index 4b1700df7af..8494ec32cda 100644 --- a/tests/baselines/reference/classExpressionWithDecorator1.js +++ b/tests/baselines/reference/classExpressionWithDecorator1.js @@ -3,12 +3,10 @@ var v = @decorate class C { static p = 1 }; //// [classExpressionWithDecorator1.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var v = ; var C = (function () { diff --git a/tests/baselines/reference/classOrder2.types b/tests/baselines/reference/classOrder2.types index 07bd6ba45a5..ac65da2ec9d 100644 --- a/tests/baselines/reference/classOrder2.types +++ b/tests/baselines/reference/classOrder2.types @@ -8,7 +8,7 @@ class A extends B { >foo : () => void >this.bar() : void >this.bar : () => void ->this : A +>this : this >bar : () => void } diff --git a/tests/baselines/reference/classOrderBug.types b/tests/baselines/reference/classOrderBug.types index 979b65b8008..703a87adc4f 100644 --- a/tests/baselines/reference/classOrderBug.types +++ b/tests/baselines/reference/classOrderBug.types @@ -11,7 +11,7 @@ class bar { this.baz = new foo(); >this.baz = new foo() : foo >this.baz : foo ->this : bar +>this : this >baz : foo >new foo() : foo >foo : typeof foo diff --git a/tests/baselines/reference/classSideInheritance2.types b/tests/baselines/reference/classSideInheritance2.types index 9c2d632ebbb..7a3ee630266 100644 --- a/tests/baselines/reference/classSideInheritance2.types +++ b/tests/baselines/reference/classSideInheritance2.types @@ -41,7 +41,7 @@ class TextBase implements IText { return new SubText(this, span); >new SubText(this, span) : SubText >SubText : typeof SubText ->this : TextBase +>this : this >span : TextSpan } } diff --git a/tests/baselines/reference/commentOnAmbientClass1.js b/tests/baselines/reference/commentOnAmbientClass1.js index beacc71335c..9837da4c371 100644 --- a/tests/baselines/reference/commentOnAmbientClass1.js +++ b/tests/baselines/reference/commentOnAmbientClass1.js @@ -1,7 +1,12 @@ //// [tests/cases/compiler/commentOnAmbientClass1.ts] //// //// [a.ts] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare class C { } @@ -15,6 +20,9 @@ declare class E extends C { } //// [a.js] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ //// [b.js] /// diff --git a/tests/baselines/reference/commentOnAmbientClass1.symbols b/tests/baselines/reference/commentOnAmbientClass1.symbols index 899c5f19a24..a08bb744df4 100644 --- a/tests/baselines/reference/commentOnAmbientClass1.symbols +++ b/tests/baselines/reference/commentOnAmbientClass1.symbols @@ -5,13 +5,18 @@ declare class E extends C { >C : Symbol(C, Decl(a.ts, 0, 0)) } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare class C { >C : Symbol(C, Decl(a.ts, 0, 0)) } // Don't keep this comment. declare class D { ->D : Symbol(D, Decl(a.ts, 2, 1)) +>D : Symbol(D, Decl(a.ts, 7, 1)) } diff --git a/tests/baselines/reference/commentOnAmbientClass1.types b/tests/baselines/reference/commentOnAmbientClass1.types index 44c0334ef6c..b0212056505 100644 --- a/tests/baselines/reference/commentOnAmbientClass1.types +++ b/tests/baselines/reference/commentOnAmbientClass1.types @@ -5,7 +5,12 @@ declare class E extends C { >C : C } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare class C { >C : C } diff --git a/tests/baselines/reference/commentOnAmbientEnum.js b/tests/baselines/reference/commentOnAmbientEnum.js index d602c68a0e5..f6c9d92ebff 100644 --- a/tests/baselines/reference/commentOnAmbientEnum.js +++ b/tests/baselines/reference/commentOnAmbientEnum.js @@ -1,7 +1,12 @@ //// [tests/cases/compiler/commentOnAmbientEnum.ts] //// //// [a.ts] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare enum C { a, b, @@ -18,6 +23,9 @@ declare enum E { } //// [a.js] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ //// [b.js] /// diff --git a/tests/baselines/reference/commentOnAmbientEnum.symbols b/tests/baselines/reference/commentOnAmbientEnum.symbols index d86d490113d..3a6e8089d4b 100644 --- a/tests/baselines/reference/commentOnAmbientEnum.symbols +++ b/tests/baselines/reference/commentOnAmbientEnum.symbols @@ -4,22 +4,27 @@ declare enum E { >E : Symbol(E, Decl(b.ts, 0, 0)) } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare enum C { >C : Symbol(C, Decl(a.ts, 0, 0)) a, ->a : Symbol(C.a, Decl(a.ts, 1, 16)) +>a : Symbol(C.a, Decl(a.ts, 6, 16)) b, ->b : Symbol(C.b, Decl(a.ts, 2, 6)) +>b : Symbol(C.b, Decl(a.ts, 7, 6)) c ->c : Symbol(C.c, Decl(a.ts, 3, 6)) +>c : Symbol(C.c, Decl(a.ts, 8, 6)) } // Don't keep this comment. declare enum D { ->D : Symbol(D, Decl(a.ts, 5, 1)) +>D : Symbol(D, Decl(a.ts, 10, 1)) } diff --git a/tests/baselines/reference/commentOnAmbientEnum.types b/tests/baselines/reference/commentOnAmbientEnum.types index 4a0193b7937..95f3d61b75f 100644 --- a/tests/baselines/reference/commentOnAmbientEnum.types +++ b/tests/baselines/reference/commentOnAmbientEnum.types @@ -4,7 +4,12 @@ declare enum E { >E : E } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare enum C { >C : C diff --git a/tests/baselines/reference/commentOnAmbientModule.js b/tests/baselines/reference/commentOnAmbientModule.js index d5a536302b5..2d43b502f29 100644 --- a/tests/baselines/reference/commentOnAmbientModule.js +++ b/tests/baselines/reference/commentOnAmbientModule.js @@ -1,7 +1,12 @@ //// [tests/cases/compiler/commentOnAmbientModule.ts] //// //// [a.ts] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare module C { function foo(); } @@ -20,6 +25,9 @@ declare module E { } //// [a.js] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ //// [b.js] /// diff --git a/tests/baselines/reference/commentOnAmbientModule.symbols b/tests/baselines/reference/commentOnAmbientModule.symbols index c1412c17880..e7525e6306f 100644 --- a/tests/baselines/reference/commentOnAmbientModule.symbols +++ b/tests/baselines/reference/commentOnAmbientModule.symbols @@ -5,28 +5,33 @@ declare module E { class foobar extends D.bar { >foobar : Symbol(foobar, Decl(b.ts, 1, 18)) ->D.bar : Symbol(D.bar, Decl(a.ts, 6, 18)) ->D : Symbol(D, Decl(a.ts, 3, 1)) ->bar : Symbol(D.bar, Decl(a.ts, 6, 18)) +>D.bar : Symbol(D.bar, Decl(a.ts, 11, 18)) +>D : Symbol(D, Decl(a.ts, 8, 1)) +>bar : Symbol(D.bar, Decl(a.ts, 11, 18)) foo(); >foo : Symbol(foo, Decl(b.ts, 2, 32)) } } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare module C { >C : Symbol(C, Decl(a.ts, 0, 0)) function foo(); ->foo : Symbol(foo, Decl(a.ts, 1, 18)) +>foo : Symbol(foo, Decl(a.ts, 6, 18)) } // Don't keep this comment. declare module D { ->D : Symbol(D, Decl(a.ts, 3, 1)) +>D : Symbol(D, Decl(a.ts, 8, 1)) class bar { } ->bar : Symbol(bar, Decl(a.ts, 6, 18)) +>bar : Symbol(bar, Decl(a.ts, 11, 18)) } diff --git a/tests/baselines/reference/commentOnAmbientModule.types b/tests/baselines/reference/commentOnAmbientModule.types index 629395a4e80..f54d248b461 100644 --- a/tests/baselines/reference/commentOnAmbientModule.types +++ b/tests/baselines/reference/commentOnAmbientModule.types @@ -14,7 +14,12 @@ declare module E { } } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare module C { >C : typeof C diff --git a/tests/baselines/reference/commentOnAmbientVariable1.js b/tests/baselines/reference/commentOnAmbientVariable1.js index b76fd3345b5..79c5dc85f23 100644 --- a/tests/baselines/reference/commentOnAmbientVariable1.js +++ b/tests/baselines/reference/commentOnAmbientVariable1.js @@ -1,9 +1,17 @@ //// [commentOnAmbientVariable1.ts] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare var v: number; // Don't keep this comment. declare var y: number; //// [commentOnAmbientVariable1.js] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ diff --git a/tests/baselines/reference/commentOnAmbientVariable1.symbols b/tests/baselines/reference/commentOnAmbientVariable1.symbols index 153653e7827..7847b4b85ad 100644 --- a/tests/baselines/reference/commentOnAmbientVariable1.symbols +++ b/tests/baselines/reference/commentOnAmbientVariable1.symbols @@ -1,9 +1,14 @@ === tests/cases/compiler/commentOnAmbientVariable1.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare var v: number; ->v : Symbol(v, Decl(commentOnAmbientVariable1.ts, 1, 11)) +>v : Symbol(v, Decl(commentOnAmbientVariable1.ts, 6, 11)) // Don't keep this comment. declare var y: number; ->y : Symbol(y, Decl(commentOnAmbientVariable1.ts, 4, 11)) +>y : Symbol(y, Decl(commentOnAmbientVariable1.ts, 9, 11)) diff --git a/tests/baselines/reference/commentOnAmbientVariable1.types b/tests/baselines/reference/commentOnAmbientVariable1.types index feff50f4293..645e1f099d4 100644 --- a/tests/baselines/reference/commentOnAmbientVariable1.types +++ b/tests/baselines/reference/commentOnAmbientVariable1.types @@ -1,5 +1,10 @@ === tests/cases/compiler/commentOnAmbientVariable1.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare var v: number; >v : number diff --git a/tests/baselines/reference/commentOnAmbientfunction.js b/tests/baselines/reference/commentOnAmbientfunction.js index 6290d407727..22613236941 100644 --- a/tests/baselines/reference/commentOnAmbientfunction.js +++ b/tests/baselines/reference/commentOnAmbientfunction.js @@ -1,7 +1,12 @@ //// [tests/cases/compiler/commentOnAmbientfunction.ts] //// //// [a.ts] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare function foo(); // Don't keep this comment. @@ -12,6 +17,9 @@ declare function bar(); declare function foobar(a: typeof foo): typeof bar; //// [a.js] -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ //// [b.js] /// diff --git a/tests/baselines/reference/commentOnAmbientfunction.symbols b/tests/baselines/reference/commentOnAmbientfunction.symbols index c6afb72eb9c..4d83d2794a0 100644 --- a/tests/baselines/reference/commentOnAmbientfunction.symbols +++ b/tests/baselines/reference/commentOnAmbientfunction.symbols @@ -4,14 +4,19 @@ declare function foobar(a: typeof foo): typeof bar; >foobar : Symbol(foobar, Decl(b.ts, 0, 0)) >a : Symbol(a, Decl(b.ts, 1, 24)) >foo : Symbol(foo, Decl(a.ts, 0, 0)) ->bar : Symbol(bar, Decl(a.ts, 1, 23)) +>bar : Symbol(bar, Decl(a.ts, 6, 23)) === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare function foo(); >foo : Symbol(foo, Decl(a.ts, 0, 0)) // Don't keep this comment. declare function bar(); ->bar : Symbol(bar, Decl(a.ts, 1, 23)) +>bar : Symbol(bar, Decl(a.ts, 6, 23)) diff --git a/tests/baselines/reference/commentOnAmbientfunction.types b/tests/baselines/reference/commentOnAmbientfunction.types index f75f7b377fb..3347a55bf68 100644 --- a/tests/baselines/reference/commentOnAmbientfunction.types +++ b/tests/baselines/reference/commentOnAmbientfunction.types @@ -7,7 +7,12 @@ declare function foobar(a: typeof foo): typeof bar; >bar : () => any === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare function foo(); >foo : () => any diff --git a/tests/baselines/reference/commentOnElidedModule1.js b/tests/baselines/reference/commentOnElidedModule1.js index 8a7b8d91b4c..72585e6a9e8 100644 --- a/tests/baselines/reference/commentOnElidedModule1.js +++ b/tests/baselines/reference/commentOnElidedModule1.js @@ -1,7 +1,12 @@ //// [tests/cases/compiler/commentOnElidedModule1.ts] //// //// [a.ts] -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ module ElidedModule { } @@ -15,6 +20,9 @@ module ElidedModule3 { } //// [a.js] -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ //// [b.js] /// diff --git a/tests/baselines/reference/commentOnElidedModule1.symbols b/tests/baselines/reference/commentOnElidedModule1.symbols index 63ce4dadf97..57b55adeee4 100644 --- a/tests/baselines/reference/commentOnElidedModule1.symbols +++ b/tests/baselines/reference/commentOnElidedModule1.symbols @@ -4,13 +4,18 @@ module ElidedModule3 { >ElidedModule3 : Symbol(ElidedModule3, Decl(b.ts, 0, 0)) } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ module ElidedModule { >ElidedModule : Symbol(ElidedModule, Decl(a.ts, 0, 0)) } // Don't keep this comment. module ElidedModule2 { ->ElidedModule2 : Symbol(ElidedModule2, Decl(a.ts, 2, 1)) +>ElidedModule2 : Symbol(ElidedModule2, Decl(a.ts, 7, 1)) } diff --git a/tests/baselines/reference/commentOnElidedModule1.types b/tests/baselines/reference/commentOnElidedModule1.types index 8e095b8102f..d028b62519a 100644 --- a/tests/baselines/reference/commentOnElidedModule1.types +++ b/tests/baselines/reference/commentOnElidedModule1.types @@ -4,7 +4,12 @@ module ElidedModule3 { >ElidedModule3 : any } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ module ElidedModule { >ElidedModule : any } diff --git a/tests/baselines/reference/commentOnInterface1.js b/tests/baselines/reference/commentOnInterface1.js index bde6202f03f..c51658e2dfa 100644 --- a/tests/baselines/reference/commentOnInterface1.js +++ b/tests/baselines/reference/commentOnInterface1.js @@ -1,7 +1,12 @@ //// [tests/cases/compiler/commentOnInterface1.ts] //// //// [a.ts] -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ interface I { } @@ -15,6 +20,9 @@ interface I3 { } //// [a.js] -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ //// [b.js] /// diff --git a/tests/baselines/reference/commentOnInterface1.symbols b/tests/baselines/reference/commentOnInterface1.symbols index 9564d9b4cfa..8ed7e020712 100644 --- a/tests/baselines/reference/commentOnInterface1.symbols +++ b/tests/baselines/reference/commentOnInterface1.symbols @@ -4,13 +4,18 @@ interface I3 { >I3 : Symbol(I3, Decl(b.ts, 0, 0)) } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ interface I { >I : Symbol(I, Decl(a.ts, 0, 0)) } // Don't keep this comment. interface I2 { ->I2 : Symbol(I2, Decl(a.ts, 2, 1)) +>I2 : Symbol(I2, Decl(a.ts, 7, 1)) } diff --git a/tests/baselines/reference/commentOnInterface1.types b/tests/baselines/reference/commentOnInterface1.types index d03b1939026..34b0e0ce14f 100644 --- a/tests/baselines/reference/commentOnInterface1.types +++ b/tests/baselines/reference/commentOnInterface1.types @@ -4,7 +4,12 @@ interface I3 { >I3 : I3 } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ interface I { >I : I } diff --git a/tests/baselines/reference/commentOnSignature1.js b/tests/baselines/reference/commentOnSignature1.js index 1b2327f9861..d29710c631c 100644 --- a/tests/baselines/reference/commentOnSignature1.js +++ b/tests/baselines/reference/commentOnSignature1.js @@ -1,7 +1,12 @@ //// [tests/cases/compiler/commentOnSignature1.ts] //// //// [a.ts] -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ function foo(n: number): void; // Don't keep this comment. function foo(s: string): void; @@ -33,14 +38,15 @@ function foo2(a: any): void { } //// [a.js] -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ function foo(a) { } var c = (function () { - /*! keep this pinned comment */ function c(a) { } - /*! keep this pinned comment */ c.prototype.foo = function (a) { }; return c; diff --git a/tests/baselines/reference/commentOnSignature1.symbols b/tests/baselines/reference/commentOnSignature1.symbols index 0d39565fb61..7f0d48401cd 100644 --- a/tests/baselines/reference/commentOnSignature1.symbols +++ b/tests/baselines/reference/commentOnSignature1.symbols @@ -14,49 +14,54 @@ function foo2(a: any): void { >a : Symbol(a, Decl(b.ts, 4, 14)) } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ function foo(n: number): void; ->foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 1, 30), Decl(a.ts, 3, 30)) ->n : Symbol(n, Decl(a.ts, 1, 13)) +>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 6, 30), Decl(a.ts, 8, 30)) +>n : Symbol(n, Decl(a.ts, 6, 13)) // Don't keep this comment. function foo(s: string): void; ->foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 1, 30), Decl(a.ts, 3, 30)) ->s : Symbol(s, Decl(a.ts, 3, 13)) +>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 6, 30), Decl(a.ts, 8, 30)) +>s : Symbol(s, Decl(a.ts, 8, 13)) function foo(a: any): void { ->foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 1, 30), Decl(a.ts, 3, 30)) ->a : Symbol(a, Decl(a.ts, 4, 13)) +>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 6, 30), Decl(a.ts, 8, 30)) +>a : Symbol(a, Decl(a.ts, 9, 13)) } class c { ->c : Symbol(c, Decl(a.ts, 5, 1)) +>c : Symbol(c, Decl(a.ts, 10, 1)) // dont keep this comment constructor(a: string); ->a : Symbol(a, Decl(a.ts, 9, 16)) +>a : Symbol(a, Decl(a.ts, 14, 16)) /*! keep this pinned comment */ constructor(a: number); ->a : Symbol(a, Decl(a.ts, 11, 16)) +>a : Symbol(a, Decl(a.ts, 16, 16)) constructor(a: any) { ->a : Symbol(a, Decl(a.ts, 12, 16)) +>a : Symbol(a, Decl(a.ts, 17, 16)) } // dont keep this comment foo(a: string); ->foo : Symbol(foo, Decl(a.ts, 13, 5), Decl(a.ts, 16, 19), Decl(a.ts, 18, 19)) ->a : Symbol(a, Decl(a.ts, 16, 8)) +>foo : Symbol(foo, Decl(a.ts, 18, 5), Decl(a.ts, 21, 19), Decl(a.ts, 23, 19)) +>a : Symbol(a, Decl(a.ts, 21, 8)) /*! keep this pinned comment */ foo(a: number); ->foo : Symbol(foo, Decl(a.ts, 13, 5), Decl(a.ts, 16, 19), Decl(a.ts, 18, 19)) ->a : Symbol(a, Decl(a.ts, 18, 8)) +>foo : Symbol(foo, Decl(a.ts, 18, 5), Decl(a.ts, 21, 19), Decl(a.ts, 23, 19)) +>a : Symbol(a, Decl(a.ts, 23, 8)) foo(a: any) { ->foo : Symbol(foo, Decl(a.ts, 13, 5), Decl(a.ts, 16, 19), Decl(a.ts, 18, 19)) ->a : Symbol(a, Decl(a.ts, 19, 8)) +>foo : Symbol(foo, Decl(a.ts, 18, 5), Decl(a.ts, 21, 19), Decl(a.ts, 23, 19)) +>a : Symbol(a, Decl(a.ts, 24, 8)) } } diff --git a/tests/baselines/reference/commentOnSignature1.types b/tests/baselines/reference/commentOnSignature1.types index 790aaaf7523..30898e22851 100644 --- a/tests/baselines/reference/commentOnSignature1.types +++ b/tests/baselines/reference/commentOnSignature1.types @@ -14,7 +14,12 @@ function foo2(a: any): void { >a : any } === tests/cases/compiler/a.ts === -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ function foo(n: number): void; >foo : { (n: number): void; (s: string): void; } >n : number diff --git a/tests/baselines/reference/commentsClassMembers.types b/tests/baselines/reference/commentsClassMembers.types index fbd514bf77b..b599edc0463 100644 --- a/tests/baselines/reference/commentsClassMembers.types +++ b/tests/baselines/reference/commentsClassMembers.types @@ -16,7 +16,7 @@ class c1 { return this.p1 + b; >this.p1 + b : number >this.p1 : number ->this : c1 +>this : this >p1 : number >b : number @@ -28,10 +28,10 @@ class c1 { return this.p2(this.p1); >this.p2(this.p1) : number >this.p2 : (b: number) => number ->this : c1 +>this : this >p2 : (b: number) => number >this.p1 : number ->this : c1 +>this : this >p1 : number }// trailing comment Getter @@ -43,11 +43,11 @@ class c1 { this.p1 = this.p2(value); >this.p1 = this.p2(value) : number >this.p1 : number ->this : c1 +>this : this >p1 : number >this.p2(value) : number >this.p2 : (b: number) => number ->this : c1 +>this : this >p2 : (b: number) => number >value : number @@ -64,7 +64,7 @@ class c1 { return this.p1 + b; >this.p1 + b : number >this.p1 : number ->this : c1 +>this : this >p1 : number >b : number @@ -76,10 +76,10 @@ class c1 { return this.pp2(this.pp1); >this.pp2(this.pp1) : number >this.pp2 : (b: number) => number ->this : c1 +>this : this >pp2 : (b: number) => number >this.pp1 : number ->this : c1 +>this : this >pp1 : number } /** setter property*/ @@ -90,11 +90,11 @@ class c1 { this.pp1 = this.pp2(value); >this.pp1 = this.pp2(value) : number >this.pp1 : number ->this : c1 +>this : this >pp1 : number >this.pp2(value) : number >this.pp2 : (b: number) => number ->this : c1 +>this : this >pp2 : (b: number) => number >value : number } @@ -158,7 +158,7 @@ class c1 { return this.nc_p1 + b; >this.nc_p1 + b : number >this.nc_p1 : number ->this : c1 +>this : this >nc_p1 : number >b : number } @@ -168,10 +168,10 @@ class c1 { return this.nc_p2(this.nc_p1); >this.nc_p2(this.nc_p1) : number >this.nc_p2 : (b: number) => number ->this : c1 +>this : this >nc_p2 : (b: number) => number >this.nc_p1 : number ->this : c1 +>this : this >nc_p1 : number } public set nc_p3(value: number) { @@ -181,11 +181,11 @@ class c1 { this.nc_p1 = this.nc_p2(value); >this.nc_p1 = this.nc_p2(value) : number >this.nc_p1 : number ->this : c1 +>this : this >nc_p1 : number >this.nc_p2(value) : number >this.nc_p2 : (b: number) => number ->this : c1 +>this : this >nc_p2 : (b: number) => number >value : number } @@ -199,7 +199,7 @@ class c1 { return this.nc_pp1 + b; >this.nc_pp1 + b : number >this.nc_pp1 : number ->this : c1 +>this : this >nc_pp1 : number >b : number } @@ -209,10 +209,10 @@ class c1 { return this.nc_pp2(this.nc_pp1); >this.nc_pp2(this.nc_pp1) : number >this.nc_pp2 : (b: number) => number ->this : c1 +>this : this >nc_pp2 : (b: number) => number >this.nc_pp1 : number ->this : c1 +>this : this >nc_pp1 : number } private set nc_pp3(value: number) { @@ -222,11 +222,11 @@ class c1 { this.nc_pp1 = this.nc_pp2(value); >this.nc_pp1 = this.nc_pp2(value) : number >this.nc_pp1 : number ->this : c1 +>this : this >nc_pp1 : number >this.nc_pp2(value) : number >this.nc_pp2 : (b: number) => number ->this : c1 +>this : this >nc_pp2 : (b: number) => number >value : number } @@ -284,7 +284,7 @@ class c1 { return this.a_p1 + b; >this.a_p1 + b : number >this.a_p1 : number ->this : c1 +>this : this >a_p1 : number >b : number } @@ -295,10 +295,10 @@ class c1 { return this.a_p2(this.a_p1); >this.a_p2(this.a_p1) : number >this.a_p2 : (b: number) => number ->this : c1 +>this : this >a_p2 : (b: number) => number >this.a_p1 : number ->this : c1 +>this : this >a_p1 : number } // setter property @@ -309,11 +309,11 @@ class c1 { this.a_p1 = this.a_p2(value); >this.a_p1 = this.a_p2(value) : number >this.a_p1 : number ->this : c1 +>this : this >a_p1 : number >this.a_p2(value) : number >this.a_p2 : (b: number) => number ->this : c1 +>this : this >a_p2 : (b: number) => number >value : number } @@ -329,7 +329,7 @@ class c1 { return this.a_p1 + b; >this.a_p1 + b : number >this.a_p1 : number ->this : c1 +>this : this >a_p1 : number >b : number } @@ -340,10 +340,10 @@ class c1 { return this.a_pp2(this.a_pp1); >this.a_pp2(this.a_pp1) : number >this.a_pp2 : (b: number) => number ->this : c1 +>this : this >a_pp2 : (b: number) => number >this.a_pp1 : number ->this : c1 +>this : this >a_pp1 : number } // setter property @@ -354,11 +354,11 @@ class c1 { this.a_pp1 = this.a_pp2(value); >this.a_pp1 = this.a_pp2(value) : number >this.a_pp1 : number ->this : c1 +>this : this >a_pp1 : number >this.a_pp2(value) : number >this.a_pp2 : (b: number) => number ->this : c1 +>this : this >a_pp2 : (b: number) => number >value : number } @@ -422,7 +422,7 @@ class c1 { return this.b_p1 + b; >this.b_p1 + b : number >this.b_p1 : number ->this : c1 +>this : this >b_p1 : number >b : number } @@ -433,10 +433,10 @@ class c1 { return this.b_p2(this.b_p1); >this.b_p2(this.b_p1) : number >this.b_p2 : (b: number) => number ->this : c1 +>this : this >b_p2 : (b: number) => number >this.b_p1 : number ->this : c1 +>this : this >b_p1 : number } /** setter property */ @@ -447,11 +447,11 @@ class c1 { this.b_p1 = this.b_p2(value); >this.b_p1 = this.b_p2(value) : number >this.b_p1 : number ->this : c1 +>this : this >b_p1 : number >this.b_p2(value) : number >this.b_p2 : (b: number) => number ->this : c1 +>this : this >b_p2 : (b: number) => number >value : number } @@ -467,7 +467,7 @@ class c1 { return this.b_p1 + b; >this.b_p1 + b : number >this.b_p1 : number ->this : c1 +>this : this >b_p1 : number >b : number } @@ -478,10 +478,10 @@ class c1 { return this.b_pp2(this.b_pp1); >this.b_pp2(this.b_pp1) : number >this.b_pp2 : (b: number) => number ->this : c1 +>this : this >b_pp2 : (b: number) => number >this.b_pp1 : number ->this : c1 +>this : this >b_pp1 : number } /** setter property */ @@ -492,11 +492,11 @@ class c1 { this.b_pp1 = this.b_pp2(value); >this.b_pp1 = this.b_pp2(value) : number >this.b_pp1 : number ->this : c1 +>this : this >b_pp1 : number >this.b_pp2(value) : number >this.b_pp2 : (b: number) => number ->this : c1 +>this : this >b_pp2 : (b: number) => number >value : number } @@ -704,7 +704,7 @@ class cProperties { return this.val; >this.val : number ->this : cProperties +>this : this >val : number } // trailing comment of only getter @@ -713,7 +713,7 @@ class cProperties { return this.val; >this.val : number ->this : cProperties +>this : this >val : number } /**setter only property*/ @@ -724,7 +724,7 @@ class cProperties { this.val = value; >this.val = value : number >this.val : number ->this : cProperties +>this : this >val : number >value : number } @@ -735,7 +735,7 @@ class cProperties { this.val = value; >this.val = value : number >this.val : number ->this : cProperties +>this : this >val : number >value : number diff --git a/tests/baselines/reference/commentsExternalModules3.js b/tests/baselines/reference/commentsExternalModules3.js index 283e07ebc7f..2acf93296de 100644 --- a/tests/baselines/reference/commentsExternalModules3.js +++ b/tests/baselines/reference/commentsExternalModules3.js @@ -54,7 +54,7 @@ var myvar2 = new m4.m2.c(); //// [commentsExternalModules_1.ts] /**This is on import declaration*/ -import extMod = require("commentsExternalModules2_0"); // trailing comment 1 +import extMod = require("./commentsExternalModules2_0"); // trailing comment 1 extMod.m1.fooExport(); export var newVar = new extMod.m1.m2.c(); extMod.m4.fooExport(); @@ -124,7 +124,7 @@ m4.fooExport(); var myvar2 = new m4.m2.c(); //// [commentsExternalModules_1.js] /**This is on import declaration*/ -var extMod = require("commentsExternalModules2_0"); // trailing comment 1 +var extMod = require("./commentsExternalModules2_0"); // trailing comment 1 extMod.m1.fooExport(); exports.newVar = new extMod.m1.m2.c(); extMod.m4.fooExport(); @@ -165,6 +165,6 @@ export declare module m4 { } //// [commentsExternalModules_1.d.ts] /**This is on import declaration*/ -import extMod = require("commentsExternalModules2_0"); +import extMod = require("./commentsExternalModules2_0"); export declare var newVar: extMod.m1.m2.c; export declare var newVar2: extMod.m4.m2.c; diff --git a/tests/baselines/reference/commentsExternalModules3.symbols b/tests/baselines/reference/commentsExternalModules3.symbols index cfd01db377d..4cab3b0d28a 100644 --- a/tests/baselines/reference/commentsExternalModules3.symbols +++ b/tests/baselines/reference/commentsExternalModules3.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/commentsExternalModules_1.ts === /**This is on import declaration*/ -import extMod = require("commentsExternalModules2_0"); // trailing comment 1 +import extMod = require("./commentsExternalModules2_0"); // trailing comment 1 >extMod : Symbol(extMod, Decl(commentsExternalModules_1.ts, 0, 0)) extMod.m1.fooExport(); diff --git a/tests/baselines/reference/commentsExternalModules3.types b/tests/baselines/reference/commentsExternalModules3.types index 556b5d11d35..2898784b7ea 100644 --- a/tests/baselines/reference/commentsExternalModules3.types +++ b/tests/baselines/reference/commentsExternalModules3.types @@ -1,6 +1,6 @@ === tests/cases/compiler/commentsExternalModules_1.ts === /**This is on import declaration*/ -import extMod = require("commentsExternalModules2_0"); // trailing comment 1 +import extMod = require("./commentsExternalModules2_0"); // trailing comment 1 >extMod : typeof extMod extMod.m1.fooExport(); diff --git a/tests/baselines/reference/commentsInheritance.types b/tests/baselines/reference/commentsInheritance.types index 1c25f13937b..21dcde99dbf 100644 --- a/tests/baselines/reference/commentsInheritance.types +++ b/tests/baselines/reference/commentsInheritance.types @@ -170,7 +170,7 @@ class c2 { this.c2_p1 = a; >this.c2_p1 = a : number >this.c2_p1 : number ->this : c2 +>this : this >c2_p1 : number >a : number } diff --git a/tests/baselines/reference/commentsdoNotEmitComments.types b/tests/baselines/reference/commentsdoNotEmitComments.types index 024f1c2a21f..067275f2151 100644 --- a/tests/baselines/reference/commentsdoNotEmitComments.types +++ b/tests/baselines/reference/commentsdoNotEmitComments.types @@ -43,7 +43,7 @@ class c { return this.b; >this.b : number ->this : c +>this : this >b : number } @@ -53,7 +53,7 @@ class c { return this.b; >this.b : number ->this : c +>this : this >b : number } @@ -65,7 +65,7 @@ class c { this.b = val; >this.b = val : number >this.b : number ->this : c +>this : this >b : number >val : number } diff --git a/tests/baselines/reference/commentsemitComments.types b/tests/baselines/reference/commentsemitComments.types index 2311ca09dd0..2594fb53fe9 100644 --- a/tests/baselines/reference/commentsemitComments.types +++ b/tests/baselines/reference/commentsemitComments.types @@ -43,7 +43,7 @@ class c { return this.b; >this.b : number ->this : c +>this : this >b : number } @@ -53,7 +53,7 @@ class c { return this.b; >this.b : number ->this : c +>this : this >b : number } @@ -65,7 +65,7 @@ class c { this.b = val; >this.b = val : number >this.b : number ->this : c +>this : this >b : number >val : number } diff --git a/tests/baselines/reference/commonjsSafeImport.js b/tests/baselines/reference/commonjsSafeImport.js new file mode 100644 index 00000000000..a0ef81cc277 --- /dev/null +++ b/tests/baselines/reference/commonjsSafeImport.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/commonjsSafeImport.ts] //// + +//// [10_lib.ts] + +export function Foo() {} + +//// [main.ts] +import { Foo } from './10_lib'; + +Foo(); + + +//// [10_lib.js] +function Foo() { } +exports.Foo = Foo; +//// [main.js] +var _10_lib_1 = require('./10_lib'); +_10_lib_1.Foo(); + + +//// [10_lib.d.ts] +export declare function Foo(): void; +//// [main.d.ts] diff --git a/tests/baselines/reference/commonjsSafeImport.symbols b/tests/baselines/reference/commonjsSafeImport.symbols new file mode 100644 index 00000000000..45e247b46a0 --- /dev/null +++ b/tests/baselines/reference/commonjsSafeImport.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/10_lib.ts === + +export function Foo() {} +>Foo : Symbol(Foo, Decl(10_lib.ts, 0, 0)) + +=== tests/cases/compiler/main.ts === +import { Foo } from './10_lib'; +>Foo : Symbol(Foo, Decl(main.ts, 0, 8)) + +Foo(); +>Foo : Symbol(Foo, Decl(main.ts, 0, 8)) + diff --git a/tests/baselines/reference/commonjsSafeImport.types b/tests/baselines/reference/commonjsSafeImport.types new file mode 100644 index 00000000000..5a4dded5b1f --- /dev/null +++ b/tests/baselines/reference/commonjsSafeImport.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/10_lib.ts === + +export function Foo() {} +>Foo : () => void + +=== tests/cases/compiler/main.ts === +import { Foo } from './10_lib'; +>Foo : () => void + +Foo(); +>Foo() : void +>Foo : () => void + diff --git a/tests/baselines/reference/complexClassRelationships.types b/tests/baselines/reference/complexClassRelationships.types index 43d0232e30a..525baf5168a 100644 --- a/tests/baselines/reference/complexClassRelationships.types +++ b/tests/baselines/reference/complexClassRelationships.types @@ -79,14 +79,14 @@ class Foo { return new GenericType(this); >new GenericType(this) : GenericType >GenericType : typeof GenericType ->this : Foo +>this : this } public populate() { >populate : () => void this.prop2; >this.prop2 : BaseCollection ->this : Foo +>this : this >prop2 : BaseCollection } public get prop2(): BaseCollection { diff --git a/tests/baselines/reference/computedPropertyNames22_ES5.types b/tests/baselines/reference/computedPropertyNames22_ES5.types index d3008669b4d..ca59250825c 100644 --- a/tests/baselines/reference/computedPropertyNames22_ES5.types +++ b/tests/baselines/reference/computedPropertyNames22_ES5.types @@ -12,7 +12,7 @@ class C { [this.bar()]() { } >this.bar() : number >this.bar : () => number ->this : C +>this : this >bar : () => number }; diff --git a/tests/baselines/reference/computedPropertyNames22_ES6.types b/tests/baselines/reference/computedPropertyNames22_ES6.types index 0936eab29ab..d5fbce29f7d 100644 --- a/tests/baselines/reference/computedPropertyNames22_ES6.types +++ b/tests/baselines/reference/computedPropertyNames22_ES6.types @@ -12,7 +12,7 @@ class C { [this.bar()]() { } >this.bar() : number >this.bar : () => number ->this : C +>this : this >bar : () => number }; diff --git a/tests/baselines/reference/computedPropertyNames29_ES5.types b/tests/baselines/reference/computedPropertyNames29_ES5.types index 674343b3a1a..f3448f10857 100644 --- a/tests/baselines/reference/computedPropertyNames29_ES5.types +++ b/tests/baselines/reference/computedPropertyNames29_ES5.types @@ -15,7 +15,7 @@ class C { [this.bar()]() { } // needs capture >this.bar() : number >this.bar : () => number ->this : C +>this : this >bar : () => number }; diff --git a/tests/baselines/reference/computedPropertyNames29_ES6.types b/tests/baselines/reference/computedPropertyNames29_ES6.types index 52f06bb9d88..cd01d37556a 100644 --- a/tests/baselines/reference/computedPropertyNames29_ES6.types +++ b/tests/baselines/reference/computedPropertyNames29_ES6.types @@ -15,7 +15,7 @@ class C { [this.bar()]() { } // needs capture >this.bar() : number >this.bar : () => number ->this : C +>this : this >bar : () => number }; diff --git a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types index d5530f98fe8..026c8f42272 100644 --- a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types +++ b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types @@ -31,21 +31,21 @@ var b: B; //Cond ? Expr1 : Expr2, Expr1 is supertype //Be Not contextually typed true ? x : a; ->true ? x : a : X | A +>true ? x : a : X >true : boolean >x : X >a : A var result1 = true ? x : a; ->result1 : X | A ->true ? x : a : X | A +>result1 : X +>true ? x : a : X >true : boolean >x : X >a : A //Expr1 and Expr2 are literals true ? {} : 1; ->true ? {} : 1 : {} | number +>true ? {} : 1 : {} >true : boolean >{} : {} >1 : number @@ -63,8 +63,8 @@ true ? { a: 1 } : { a: 2, b: 'string' }; >'string' : string var result2 = true ? {} : 1; ->result2 : {} | number ->true ? {} : 1 : {} | number +>result2 : {} +>true ? {} : 1 : {} >true : boolean >{} : {} >1 : number @@ -86,7 +86,7 @@ var result3 = true ? { a: 1 } : { a: 2, b: 'string' }; var resultIsX1: X = true ? x : a; >resultIsX1 : X >X : X ->true ? x : a : X | A +>true ? x : a : X >true : boolean >x : X >a : A @@ -95,7 +95,7 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA; >result4 : (t: A) => any >t : A >A : A ->true ? (m) => m.propertyX : (n) => n.propertyA : ((m: A) => any) | ((n: A) => number) +>true ? (m) => m.propertyX : (n) => n.propertyA : (m: A) => any >true : boolean >(m) => m.propertyX : (m: A) => any >m : A @@ -111,21 +111,21 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA; //Cond ? Expr1 : Expr2, Expr2 is supertype //Be Not contextually typed true ? a : x; ->true ? a : x : A | X +>true ? a : x : X >true : boolean >a : A >x : X var result5 = true ? a : x; ->result5 : A | X ->true ? a : x : A | X +>result5 : X +>true ? a : x : X >true : boolean >a : A >x : X //Expr1 and Expr2 are literals true ? 1 : {}; ->true ? 1 : {} : number | {} +>true ? 1 : {} : {} >true : boolean >1 : number >{} : {} @@ -143,8 +143,8 @@ true ? { a: 2, b: 'string' } : { a: 1 }; >1 : number var result6 = true ? 1 : {}; ->result6 : number | {} ->true ? 1 : {} : number | {} +>result6 : {} +>true ? 1 : {} : {} >true : boolean >1 : number >{} : {} @@ -166,7 +166,7 @@ var result7 = true ? { a: 2, b: 'string' } : { a: 1 }; var resultIsX2: X = true ? x : a; >resultIsX2 : X >X : X ->true ? x : a : X | A +>true ? x : a : X >true : boolean >x : X >a : A @@ -175,7 +175,7 @@ var result8: (t: A) => any = true ? (m) => m.propertyA : (n) => n.propertyX; >result8 : (t: A) => any >t : A >A : A ->true ? (m) => m.propertyA : (n) => n.propertyX : ((m: A) => number) | ((n: A) => any) +>true ? (m) => m.propertyA : (n) => n.propertyX : (n: A) => any >true : boolean >(m) => m.propertyA : (m: A) => number >m : A diff --git a/tests/baselines/reference/constDeclarationShadowedByVarDeclaration3.types b/tests/baselines/reference/constDeclarationShadowedByVarDeclaration3.types index c5b9ec9a6f2..1271d4ef869 100644 --- a/tests/baselines/reference/constDeclarationShadowedByVarDeclaration3.types +++ b/tests/baselines/reference/constDeclarationShadowedByVarDeclaration3.types @@ -20,7 +20,7 @@ class Rule { this.name = name; >this.name = name : string >this.name : string ->this : Rule +>this : this >name : string >name : string } diff --git a/tests/baselines/reference/constDeclarations-access5.errors.txt b/tests/baselines/reference/constDeclarations-access5.errors.txt index d58abfe6bd4..23200e50ee4 100644 --- a/tests/baselines/reference/constDeclarations-access5.errors.txt +++ b/tests/baselines/reference/constDeclarations-access5.errors.txt @@ -1,5 +1,3 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -tests/cases/compiler/constDeclarations_access_2.ts(2,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead. tests/cases/compiler/constDeclarations_access_2.ts(4,1): error TS2450: Left-hand side of assignment expression cannot be a constant. tests/cases/compiler/constDeclarations_access_2.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant. tests/cases/compiler/constDeclarations_access_2.ts(6,1): error TS2450: Left-hand side of assignment expression cannot be a constant. @@ -20,12 +18,9 @@ tests/cases/compiler/constDeclarations_access_2.ts(22,3): error TS2449: The oper tests/cases/compiler/constDeclarations_access_2.ts(24,1): error TS2450: Left-hand side of assignment expression cannot be a constant. -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/constDeclarations_access_2.ts (19 errors) ==== +==== tests/cases/compiler/constDeclarations_access_2.ts (18 errors) ==== /// import m = require('constDeclarations_access_1'); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead. // Errors m.x = 1; ~~~ diff --git a/tests/baselines/reference/constDeclarations-access5.js b/tests/baselines/reference/constDeclarations-access5.js index 7735e37d2b0..71b8c99ae58 100644 --- a/tests/baselines/reference/constDeclarations-access5.js +++ b/tests/baselines/reference/constDeclarations-access5.js @@ -49,35 +49,39 @@ m.x.toString(); //// [constDeclarations_access_1.js] -export const x = 0; +define(["require", "exports"], function (require, exports) { + exports.x = 0; +}); //// [constDeclarations_access_2.js] -// Errors -m.x = 1; -m.x += 2; -m.x -= 3; -m.x *= 4; -m.x /= 5; -m.x %= 6; -m.x <<= 7; -m.x >>= 8; -m.x >>>= 9; -m.x &= 10; -m.x |= 11; -m.x ^= 12; -m; -m.x++; -m.x--; -++m.x; ---m.x; -++((m.x)); -m["x"] = 0; -// OK -var a = m.x + 1; -function f(v) { } -f(m.x); -if (m.x) { } -m.x; -(m.x); --m.x; -+m.x; -m.x.toString(); +define(["require", "exports", 'constDeclarations_access_1'], function (require, exports, m) { + // Errors + m.x = 1; + m.x += 2; + m.x -= 3; + m.x *= 4; + m.x /= 5; + m.x %= 6; + m.x <<= 7; + m.x >>= 8; + m.x >>>= 9; + m.x &= 10; + m.x |= 11; + m.x ^= 12; + m; + m.x++; + m.x--; + ++m.x; + --m.x; + ++((m.x)); + m["x"] = 0; + // OK + var a = m.x + 1; + function f(v) { } + f(m.x); + if (m.x) { } + m.x; + (m.x); + -m.x; + +m.x; + m.x.toString(); +}); diff --git a/tests/baselines/reference/constEnumErrors.errors.txt b/tests/baselines/reference/constEnumErrors.errors.txt index 4236544defa..586652d41eb 100644 --- a/tests/baselines/reference/constEnumErrors.errors.txt +++ b/tests/baselines/reference/constEnumErrors.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/constEnumErrors.ts(1,12): error TS2300: Duplicate identifier 'E'. tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier 'E'. -tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums. +tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. tests/cases/compiler/constEnumErrors.ts(14,9): error TS2474: In 'const' enum declarations member initializer must be constant expression. tests/cases/compiler/constEnumErrors.ts(15,10): error TS2474: In 'const' enum declarations member initializer must be constant expression. tests/cases/compiler/constEnumErrors.ts(22,13): error TS2476: A const enum member can only be accessed using a string literal. @@ -31,7 +31,7 @@ tests/cases/compiler/constEnumErrors.ts(42,9): error TS2478: 'const' enum member // forward reference to the element of the same enum X = Y, ~ -!!! error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums. +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. // forward reference to the element of the same enum Y = E1.Z, ~~~~ diff --git a/tests/baselines/reference/constructorOverloads6.errors.txt b/tests/baselines/reference/constructorOverloads6.errors.txt index 65827007a8e..34beb264f45 100644 --- a/tests/baselines/reference/constructorOverloads6.errors.txt +++ b/tests/baselines/reference/constructorOverloads6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/constructorOverloads6.ts(4,25): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/constructorOverloads6.ts(4,25): error TS1183: An implementation cannot be declared in ambient contexts. ==== tests/cases/compiler/constructorOverloads6.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/constructorOverloads6.ts(4,25): error TS1184: An implementa constructor(n: number); constructor(x: any) { ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. } bar1():void; diff --git a/tests/baselines/reference/contextualThisType.js b/tests/baselines/reference/contextualThisType.js new file mode 100644 index 00000000000..1fce0828edc --- /dev/null +++ b/tests/baselines/reference/contextualThisType.js @@ -0,0 +1,24 @@ +//// [contextualThisType.ts] +interface X { + a: (p: this) => this; +} + +interface Y extends X { +} + +var x: Y = { + a(p) { + return p; + } +} + +var y = x.a(x); + + +//// [contextualThisType.js] +var x = { + a: function (p) { + return p; + } +}; +var y = x.a(x); diff --git a/tests/baselines/reference/contextualThisType.symbols b/tests/baselines/reference/contextualThisType.symbols new file mode 100644 index 00000000000..5030a9bbcde --- /dev/null +++ b/tests/baselines/reference/contextualThisType.symbols @@ -0,0 +1,34 @@ +=== tests/cases/conformance/types/thisType/contextualThisType.ts === +interface X { +>X : Symbol(X, Decl(contextualThisType.ts, 0, 0)) + + a: (p: this) => this; +>a : Symbol(a, Decl(contextualThisType.ts, 0, 13)) +>p : Symbol(p, Decl(contextualThisType.ts, 1, 8)) +} + +interface Y extends X { +>Y : Symbol(Y, Decl(contextualThisType.ts, 2, 1)) +>X : Symbol(X, Decl(contextualThisType.ts, 0, 0)) +} + +var x: Y = { +>x : Symbol(x, Decl(contextualThisType.ts, 7, 3)) +>Y : Symbol(Y, Decl(contextualThisType.ts, 2, 1)) + + a(p) { +>a : Symbol(a, Decl(contextualThisType.ts, 7, 12)) +>p : Symbol(p, Decl(contextualThisType.ts, 8, 6)) + + return p; +>p : Symbol(p, Decl(contextualThisType.ts, 8, 6)) + } +} + +var y = x.a(x); +>y : Symbol(y, Decl(contextualThisType.ts, 13, 3)) +>x.a : Symbol(X.a, Decl(contextualThisType.ts, 0, 13)) +>x : Symbol(x, Decl(contextualThisType.ts, 7, 3)) +>a : Symbol(X.a, Decl(contextualThisType.ts, 0, 13)) +>x : Symbol(x, Decl(contextualThisType.ts, 7, 3)) + diff --git a/tests/baselines/reference/contextualThisType.types b/tests/baselines/reference/contextualThisType.types new file mode 100644 index 00000000000..fb4588c5fb0 --- /dev/null +++ b/tests/baselines/reference/contextualThisType.types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/types/thisType/contextualThisType.ts === +interface X { +>X : X + + a: (p: this) => this; +>a : (p: this) => this +>p : this +} + +interface Y extends X { +>Y : Y +>X : X +} + +var x: Y = { +>x : Y +>Y : Y +>{ a(p) { return p; }} : { a(p: Y): Y; } + + a(p) { +>a : (p: Y) => Y +>p : Y + + return p; +>p : Y + } +} + +var y = x.a(x); +>y : Y +>x.a(x) : Y +>x.a : (p: Y) => Y +>x : Y +>a : (p: Y) => Y +>x : Y + diff --git a/tests/baselines/reference/contextualTypeAppliedToVarArgs.types b/tests/baselines/reference/contextualTypeAppliedToVarArgs.types index cbd16aea35f..df6ead16095 100644 --- a/tests/baselines/reference/contextualTypeAppliedToVarArgs.types +++ b/tests/baselines/reference/contextualTypeAppliedToVarArgs.types @@ -21,7 +21,7 @@ class Foo{ delegate(this, function (source, args2) >delegate(this, function (source, args2) { var a = source.node; var b = args2.node; } ) : (...args: any[]) => any >delegate : (instance: any, method: (...args: any[]) => any, data?: any) => (...args: any[]) => any ->this : Foo +>this : this >function (source, args2) { var a = source.node; var b = args2.node; } : (source: any, args2: any) => void >source : any >args2 : any diff --git a/tests/baselines/reference/contextualTyping12.errors.txt b/tests/baselines/reference/contextualTyping12.errors.txt index 8b079ecc5e0..22ed6ad931e 100644 --- a/tests/baselines/reference/contextualTyping12.errors.txt +++ b/tests/baselines/reference/contextualTyping12.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/contextualTyping12.ts(1,13): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. +tests/cases/compiler/contextualTyping12.ts(1,57): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. @@ -6,7 +6,7 @@ tests/cases/compiler/contextualTyping12.ts(1,13): error TS2322: Type '({ id: num ==== tests/cases/compiler/contextualTyping12.ts (1 errors) ==== class foo { public bar:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~ !!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. !!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. diff --git a/tests/baselines/reference/contextualTyping17.errors.txt b/tests/baselines/reference/contextualTyping17.errors.txt index 24c428db58b..b6375c9c9c9 100644 --- a/tests/baselines/reference/contextualTyping17.errors.txt +++ b/tests/baselines/reference/contextualTyping17.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/contextualTyping17.ts(1,33): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. +tests/cases/compiler/contextualTyping17.ts(1,47): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. ==== tests/cases/compiler/contextualTyping17.ts (1 errors) ==== var foo: {id:number;} = {id:4}; foo = {id: 5, name:"foo"}; - ~~~ + ~~~~~~~~~~ !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping2.errors.txt b/tests/baselines/reference/contextualTyping2.errors.txt index 2665204b167..1daa4a2a71f 100644 --- a/tests/baselines/reference/contextualTyping2.errors.txt +++ b/tests/baselines/reference/contextualTyping2.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/contextualTyping2.ts(1,5): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. +tests/cases/compiler/contextualTyping2.ts(1,32): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. ==== tests/cases/compiler/contextualTyping2.ts (1 errors) ==== var foo: {id:number;} = {id:4, name:"foo"}; - ~~~ + ~~~~~~~~~~ !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping20.errors.txt b/tests/baselines/reference/contextualTyping20.errors.txt index d723dcd1d1b..a9112f1db84 100644 --- a/tests/baselines/reference/contextualTyping20.errors.txt +++ b/tests/baselines/reference/contextualTyping20.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/contextualTyping20.ts(1,36): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. +tests/cases/compiler/contextualTyping20.ts(1,58): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. @@ -6,7 +6,7 @@ tests/cases/compiler/contextualTyping20.ts(1,36): error TS2322: Type '({ id: num ==== tests/cases/compiler/contextualTyping20.ts (1 errors) ==== var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2, name:"foo"}]; - ~~~ + ~~~~~~~~~~ !!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. !!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. diff --git a/tests/baselines/reference/contextualTyping4.errors.txt b/tests/baselines/reference/contextualTyping4.errors.txt index 48eb2c406f0..c472e7ccb18 100644 --- a/tests/baselines/reference/contextualTyping4.errors.txt +++ b/tests/baselines/reference/contextualTyping4.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/contextualTyping4.ts(1,13): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. +tests/cases/compiler/contextualTyping4.ts(1,46): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. ==== tests/cases/compiler/contextualTyping4.ts (1 errors) ==== class foo { public bar:{id:number;} = {id:5, name:"foo"}; } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~ !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping9.errors.txt b/tests/baselines/reference/contextualTyping9.errors.txt index f959d1e2e69..4a12574fa21 100644 --- a/tests/baselines/reference/contextualTyping9.errors.txt +++ b/tests/baselines/reference/contextualTyping9.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/contextualTyping9.ts(1,5): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. +tests/cases/compiler/contextualTyping9.ts(1,42): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. @@ -6,7 +6,7 @@ tests/cases/compiler/contextualTyping9.ts(1,5): error TS2322: Type '({ id: numbe ==== tests/cases/compiler/contextualTyping9.ts (1 errors) ==== var foo:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; - ~~~ + ~~~~~~~~~~ !!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'. !!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'. !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. diff --git a/tests/baselines/reference/contextualTypingArrayOfLambdas.types b/tests/baselines/reference/contextualTypingArrayOfLambdas.types index 0bb61604336..d3e5b9942e3 100644 --- a/tests/baselines/reference/contextualTypingArrayOfLambdas.types +++ b/tests/baselines/reference/contextualTypingArrayOfLambdas.types @@ -23,8 +23,8 @@ class C extends A { } var xs = [(x: A) => { }, (x: B) => { }, (x: C) => { }]; ->xs : (((x: A) => void) | ((x: B) => void) | ((x: C) => void))[] ->[(x: A) => { }, (x: B) => { }, (x: C) => { }] : (((x: A) => void) | ((x: B) => void) | ((x: C) => void))[] +>xs : ((x: A) => void)[] +>[(x: A) => { }, (x: B) => { }, (x: C) => { }] : ((x: A) => void)[] >(x: A) => { } : (x: A) => void >x : A >A : A diff --git a/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.errors.txt b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.errors.txt new file mode 100644 index 00000000000..dab85baf2cf --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.errors.txt @@ -0,0 +1,67 @@ +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts(17,24): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts(20,24): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts(28,27): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts(31,27): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts(39,36): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts(42,36): error TS7006: Parameter 'arg' implicitly has an 'any' type. + + +==== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts (6 errors) ==== + + interface A { + numProp: number; + } + + interface B { + strProp: string; + } + + interface Foo { + method1(arg: A): void; + method2(arg: B): void; + } + + function getFoo1(): Foo { + return class { + static method1(arg) { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.numProp = 10; + } + static method2(arg) { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.strProp = "hello"; + } + } + } + + function getFoo2(): Foo { + return class { + static method1 = (arg) => { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.numProp = 10; + } + static method2 = (arg) => { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.strProp = "hello"; + } + } + } + + function getFoo3(): Foo { + return class { + static method1 = function (arg) { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.numProp = 10; + } + static method2 = function (arg) { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.strProp = "hello"; + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.js b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.js new file mode 100644 index 00000000000..edbe8c4d338 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.js @@ -0,0 +1,88 @@ +//// [contextuallyTypedClassExpressionMethodDeclaration01.ts] + +interface A { + numProp: number; +} + +interface B { + strProp: string; +} + +interface Foo { + method1(arg: A): void; + method2(arg: B): void; +} + +function getFoo1(): Foo { + return class { + static method1(arg) { + arg.numProp = 10; + } + static method2(arg) { + arg.strProp = "hello"; + } + } +} + +function getFoo2(): Foo { + return class { + static method1 = (arg) => { + arg.numProp = 10; + } + static method2 = (arg) => { + arg.strProp = "hello"; + } + } +} + +function getFoo3(): Foo { + return class { + static method1 = function (arg) { + arg.numProp = 10; + } + static method2 = function (arg) { + arg.strProp = "hello"; + } + } +} + +//// [contextuallyTypedClassExpressionMethodDeclaration01.js] +function getFoo1() { + return (function () { + function class_1() { + } + class_1.method1 = function (arg) { + arg.numProp = 10; + }; + class_1.method2 = function (arg) { + arg.strProp = "hello"; + }; + return class_1; + })(); +} +function getFoo2() { + return (function () { + function class_2() { + } + class_2.method1 = function (arg) { + arg.numProp = 10; + }; + class_2.method2 = function (arg) { + arg.strProp = "hello"; + }; + return class_2; + })(); +} +function getFoo3() { + return (function () { + function class_3() { + } + class_3.method1 = function (arg) { + arg.numProp = 10; + }; + class_3.method2 = function (arg) { + arg.strProp = "hello"; + }; + return class_3; + })(); +} diff --git a/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration02.errors.txt b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration02.errors.txt new file mode 100644 index 00000000000..ae6dfee4866 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration02.errors.txt @@ -0,0 +1,71 @@ +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts(21,17): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts(24,17): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts(32,20): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts(35,20): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts(43,29): error TS7006: Parameter 'arg' implicitly has an 'any' type. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts(46,29): error TS7006: Parameter 'arg' implicitly has an 'any' type. + + +==== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts (6 errors) ==== + + interface A { + numProp: number; + } + + interface B { + strProp: string; + } + + interface Foo { + new (): Bar; + } + + interface Bar { + method1(arg: A): void; + method2(arg: B): void; + } + + function getFoo1(): Foo { + return class { + method1(arg) { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.numProp = 10; + } + method2(arg) { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.strProp = "hello"; + } + } + } + + function getFoo2(): Foo { + return class { + method1 = (arg) => { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.numProp = 10; + } + method2 = (arg) => { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.strProp = "hello"; + } + } + } + + function getFoo3(): Foo { + return class { + method1 = function (arg) { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.numProp = 10; + } + method2 = function (arg) { + ~~~ +!!! error TS7006: Parameter 'arg' implicitly has an 'any' type. + arg.strProp = "hello"; + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration02.js b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration02.js new file mode 100644 index 00000000000..43e9134689f --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration02.js @@ -0,0 +1,92 @@ +//// [contextuallyTypedClassExpressionMethodDeclaration02.ts] + +interface A { + numProp: number; +} + +interface B { + strProp: string; +} + +interface Foo { + new (): Bar; +} + +interface Bar { + method1(arg: A): void; + method2(arg: B): void; +} + +function getFoo1(): Foo { + return class { + method1(arg) { + arg.numProp = 10; + } + method2(arg) { + arg.strProp = "hello"; + } + } +} + +function getFoo2(): Foo { + return class { + method1 = (arg) => { + arg.numProp = 10; + } + method2 = (arg) => { + arg.strProp = "hello"; + } + } +} + +function getFoo3(): Foo { + return class { + method1 = function (arg) { + arg.numProp = 10; + } + method2 = function (arg) { + arg.strProp = "hello"; + } + } +} + +//// [contextuallyTypedClassExpressionMethodDeclaration02.js] +function getFoo1() { + return (function () { + function class_1() { + } + class_1.prototype.method1 = function (arg) { + arg.numProp = 10; + }; + class_1.prototype.method2 = function (arg) { + arg.strProp = "hello"; + }; + return class_1; + })(); +} +function getFoo2() { + return (function () { + function class_2() { + this.method1 = function (arg) { + arg.numProp = 10; + }; + this.method2 = function (arg) { + arg.strProp = "hello"; + }; + } + return class_2; + })(); +} +function getFoo3() { + return (function () { + function class_3() { + this.method1 = function (arg) { + arg.numProp = 10; + }; + this.method2 = function (arg) { + arg.strProp = "hello"; + }; + } + return class_3; + })(); +} diff --git a/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.js b/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.js new file mode 100644 index 00000000000..373854114d5 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.js @@ -0,0 +1,79 @@ +//// [contextuallyTypedObjectLiteralMethodDeclaration01.ts] + +interface A { + numProp: number; +} + +interface B { + strProp: string; +} + +interface Foo { + method1(arg: A): void; + method2(arg: B): void; +} + +function getFoo1(): Foo { + return { + method1(arg) { + arg.numProp = 10; + }, + method2(arg) { + arg.strProp = "hello"; + } + } +} + +function getFoo2(): Foo { + return { + method1: (arg) => { + arg.numProp = 10; + }, + method2: (arg) => { + arg.strProp = "hello"; + } + } +} + +function getFoo3(): Foo { + return { + method1: function (arg) { + arg.numProp = 10; + }, + method2: function (arg) { + arg.strProp = "hello"; + } + } +} + +//// [contextuallyTypedObjectLiteralMethodDeclaration01.js] +function getFoo1() { + return { + method1: function (arg) { + arg.numProp = 10; + }, + method2: function (arg) { + arg.strProp = "hello"; + } + }; +} +function getFoo2() { + return { + method1: function (arg) { + arg.numProp = 10; + }, + method2: function (arg) { + arg.strProp = "hello"; + } + }; +} +function getFoo3() { + return { + method1: function (arg) { + arg.numProp = 10; + }, + method2: function (arg) { + arg.strProp = "hello"; + } + }; +} diff --git a/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.symbols b/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.symbols new file mode 100644 index 00000000000..3c26110157a --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.symbols @@ -0,0 +1,110 @@ +=== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedObjectLiteralMethodDeclaration01.ts === + +interface A { +>A : Symbol(A, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 0, 0)) + + numProp: number; +>numProp : Symbol(numProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 1, 13)) +} + +interface B { +>B : Symbol(B, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 3, 1)) + + strProp: string; +>strProp : Symbol(strProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 5, 14)) +} + +interface Foo { +>Foo : Symbol(Foo, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 7, 1)) + + method1(arg: A): void; +>method1 : Symbol(method1, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 9, 15)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 10, 12)) +>A : Symbol(A, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 0, 0)) + + method2(arg: B): void; +>method2 : Symbol(method2, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 10, 26)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 11, 12)) +>B : Symbol(B, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 3, 1)) +} + +function getFoo1(): Foo { +>getFoo1 : Symbol(getFoo1, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 12, 1)) +>Foo : Symbol(Foo, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 7, 1)) + + return { + method1(arg) { +>method1 : Symbol(method1, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 15, 12)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 16, 16)) + + arg.numProp = 10; +>arg.numProp : Symbol(A.numProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 1, 13)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 16, 16)) +>numProp : Symbol(A.numProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 1, 13)) + + }, + method2(arg) { +>method2 : Symbol(method2, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 18, 10)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 19, 16)) + + arg.strProp = "hello"; +>arg.strProp : Symbol(B.strProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 5, 14)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 19, 16)) +>strProp : Symbol(B.strProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 5, 14)) + } + } +} + +function getFoo2(): Foo { +>getFoo2 : Symbol(getFoo2, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 23, 1)) +>Foo : Symbol(Foo, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 7, 1)) + + return { + method1: (arg) => { +>method1 : Symbol(method1, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 26, 12)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 27, 18)) + + arg.numProp = 10; +>arg.numProp : Symbol(A.numProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 1, 13)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 27, 18)) +>numProp : Symbol(A.numProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 1, 13)) + + }, + method2: (arg) => { +>method2 : Symbol(method2, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 29, 10)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 30, 18)) + + arg.strProp = "hello"; +>arg.strProp : Symbol(B.strProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 5, 14)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 30, 18)) +>strProp : Symbol(B.strProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 5, 14)) + } + } +} + +function getFoo3(): Foo { +>getFoo3 : Symbol(getFoo3, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 34, 1)) +>Foo : Symbol(Foo, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 7, 1)) + + return { + method1: function (arg) { +>method1 : Symbol(method1, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 37, 12)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 38, 27)) + + arg.numProp = 10; +>arg.numProp : Symbol(A.numProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 1, 13)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 38, 27)) +>numProp : Symbol(A.numProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 1, 13)) + + }, + method2: function (arg) { +>method2 : Symbol(method2, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 40, 10)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 41, 27)) + + arg.strProp = "hello"; +>arg.strProp : Symbol(B.strProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 5, 14)) +>arg : Symbol(arg, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 41, 27)) +>strProp : Symbol(B.strProp, Decl(contextuallyTypedObjectLiteralMethodDeclaration01.ts, 5, 14)) + } + } +} diff --git a/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.types b/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.types new file mode 100644 index 00000000000..dcb25792fe0 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.types @@ -0,0 +1,132 @@ +=== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedObjectLiteralMethodDeclaration01.ts === + +interface A { +>A : A + + numProp: number; +>numProp : number +} + +interface B { +>B : B + + strProp: string; +>strProp : string +} + +interface Foo { +>Foo : Foo + + method1(arg: A): void; +>method1 : (arg: A) => void +>arg : A +>A : A + + method2(arg: B): void; +>method2 : (arg: B) => void +>arg : B +>B : B +} + +function getFoo1(): Foo { +>getFoo1 : () => Foo +>Foo : Foo + + return { +>{ method1(arg) { arg.numProp = 10; }, method2(arg) { arg.strProp = "hello"; } } : { method1(arg: A): void; method2(arg: B): void; } + + method1(arg) { +>method1 : (arg: A) => void +>arg : A + + arg.numProp = 10; +>arg.numProp = 10 : number +>arg.numProp : number +>arg : A +>numProp : number +>10 : number + + }, + method2(arg) { +>method2 : (arg: B) => void +>arg : B + + arg.strProp = "hello"; +>arg.strProp = "hello" : string +>arg.strProp : string +>arg : B +>strProp : string +>"hello" : string + } + } +} + +function getFoo2(): Foo { +>getFoo2 : () => Foo +>Foo : Foo + + return { +>{ method1: (arg) => { arg.numProp = 10; }, method2: (arg) => { arg.strProp = "hello"; } } : { method1: (arg: A) => void; method2: (arg: B) => void; } + + method1: (arg) => { +>method1 : (arg: A) => void +>(arg) => { arg.numProp = 10; } : (arg: A) => void +>arg : A + + arg.numProp = 10; +>arg.numProp = 10 : number +>arg.numProp : number +>arg : A +>numProp : number +>10 : number + + }, + method2: (arg) => { +>method2 : (arg: B) => void +>(arg) => { arg.strProp = "hello"; } : (arg: B) => void +>arg : B + + arg.strProp = "hello"; +>arg.strProp = "hello" : string +>arg.strProp : string +>arg : B +>strProp : string +>"hello" : string + } + } +} + +function getFoo3(): Foo { +>getFoo3 : () => Foo +>Foo : Foo + + return { +>{ method1: function (arg) { arg.numProp = 10; }, method2: function (arg) { arg.strProp = "hello"; } } : { method1: (arg: A) => void; method2: (arg: B) => void; } + + method1: function (arg) { +>method1 : (arg: A) => void +>function (arg) { arg.numProp = 10; } : (arg: A) => void +>arg : A + + arg.numProp = 10; +>arg.numProp = 10 : number +>arg.numProp : number +>arg : A +>numProp : number +>10 : number + + }, + method2: function (arg) { +>method2 : (arg: B) => void +>function (arg) { arg.strProp = "hello"; } : (arg: B) => void +>arg : B + + arg.strProp = "hello"; +>arg.strProp = "hello" : string +>arg.strProp : string +>arg : B +>strProp : string +>"hello" : string + } + } +} diff --git a/tests/baselines/reference/declFileAliasUseBeforeDeclaration.js b/tests/baselines/reference/declFileAliasUseBeforeDeclaration.js index 7814e9641ba..2355d7bbc7a 100644 --- a/tests/baselines/reference/declFileAliasUseBeforeDeclaration.js +++ b/tests/baselines/reference/declFileAliasUseBeforeDeclaration.js @@ -6,7 +6,7 @@ export class Foo { } //// [declFileAliasUseBeforeDeclaration_test.ts] export function bar(a: foo.Foo) { } -import foo = require("declFileAliasUseBeforeDeclaration_foo"); +import foo = require("./declFileAliasUseBeforeDeclaration_foo"); //// [declFileAliasUseBeforeDeclaration_foo.js] var Foo = (function () { @@ -25,4 +25,4 @@ export declare class Foo { } //// [declFileAliasUseBeforeDeclaration_test.d.ts] export declare function bar(a: foo.Foo): void; -import foo = require("declFileAliasUseBeforeDeclaration_foo"); +import foo = require("./declFileAliasUseBeforeDeclaration_foo"); diff --git a/tests/baselines/reference/declFileAliasUseBeforeDeclaration.symbols b/tests/baselines/reference/declFileAliasUseBeforeDeclaration.symbols index ee7795ae455..ba74b6cdfb7 100644 --- a/tests/baselines/reference/declFileAliasUseBeforeDeclaration.symbols +++ b/tests/baselines/reference/declFileAliasUseBeforeDeclaration.symbols @@ -5,7 +5,7 @@ export function bar(a: foo.Foo) { } >foo : Symbol(foo, Decl(declFileAliasUseBeforeDeclaration_test.ts, 0, 35)) >Foo : Symbol(foo.Foo, Decl(declFileAliasUseBeforeDeclaration_foo.ts, 0, 0)) -import foo = require("declFileAliasUseBeforeDeclaration_foo"); +import foo = require("./declFileAliasUseBeforeDeclaration_foo"); >foo : Symbol(foo, Decl(declFileAliasUseBeforeDeclaration_test.ts, 0, 35)) === tests/cases/compiler/declFileAliasUseBeforeDeclaration_foo.ts === diff --git a/tests/baselines/reference/declFileAliasUseBeforeDeclaration.types b/tests/baselines/reference/declFileAliasUseBeforeDeclaration.types index c21d98d90d5..544efded5ee 100644 --- a/tests/baselines/reference/declFileAliasUseBeforeDeclaration.types +++ b/tests/baselines/reference/declFileAliasUseBeforeDeclaration.types @@ -5,7 +5,7 @@ export function bar(a: foo.Foo) { } >foo : any >Foo : foo.Foo -import foo = require("declFileAliasUseBeforeDeclaration_foo"); +import foo = require("./declFileAliasUseBeforeDeclaration_foo"); >foo : typeof foo === tests/cases/compiler/declFileAliasUseBeforeDeclaration_foo.ts === diff --git a/tests/baselines/reference/declFileClassExtendsNull.js b/tests/baselines/reference/declFileClassExtendsNull.js new file mode 100644 index 00000000000..0d50b320592 --- /dev/null +++ b/tests/baselines/reference/declFileClassExtendsNull.js @@ -0,0 +1,23 @@ +//// [declFileClassExtendsNull.ts] + +class ExtendsNull extends null { +} + +//// [declFileClassExtendsNull.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var ExtendsNull = (function (_super) { + __extends(ExtendsNull, _super); + function ExtendsNull() { + _super.apply(this, arguments); + } + return ExtendsNull; +})(null); + + +//// [declFileClassExtendsNull.d.ts] +declare class ExtendsNull extends null { +} diff --git a/tests/baselines/reference/declFileClassExtendsNull.symbols b/tests/baselines/reference/declFileClassExtendsNull.symbols new file mode 100644 index 00000000000..e86276faad8 --- /dev/null +++ b/tests/baselines/reference/declFileClassExtendsNull.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/declFileClassExtendsNull.ts === + +class ExtendsNull extends null { +>ExtendsNull : Symbol(ExtendsNull, Decl(declFileClassExtendsNull.ts, 0, 0)) +} diff --git a/tests/baselines/reference/declFileClassExtendsNull.types b/tests/baselines/reference/declFileClassExtendsNull.types new file mode 100644 index 00000000000..bbd43d99c0d --- /dev/null +++ b/tests/baselines/reference/declFileClassExtendsNull.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/declFileClassExtendsNull.ts === + +class ExtendsNull extends null { +>ExtendsNull : ExtendsNull +>null : null +} diff --git a/tests/baselines/reference/declFileForExportedImport.js b/tests/baselines/reference/declFileForExportedImport.js index af7cfa46b73..88967c4c2a4 100644 --- a/tests/baselines/reference/declFileForExportedImport.js +++ b/tests/baselines/reference/declFileForExportedImport.js @@ -5,7 +5,7 @@ export var x: number; //// [declFileForExportedImport_1.ts] /// -export import a = require('declFileForExportedImport_0'); +export import a = require('./declFileForExportedImport_0'); var y = a.x; export import b = a; @@ -14,7 +14,7 @@ var z = b.x; //// [declFileForExportedImport_0.js] //// [declFileForExportedImport_1.js] /// -exports.a = require('declFileForExportedImport_0'); +exports.a = require('./declFileForExportedImport_0'); var y = exports.a.x; exports.b = exports.a; var z = exports.b.x; @@ -24,5 +24,5 @@ var z = exports.b.x; export declare var x: number; //// [declFileForExportedImport_1.d.ts] /// -export import a = require('declFileForExportedImport_0'); +export import a = require('./declFileForExportedImport_0'); export import b = a; diff --git a/tests/baselines/reference/declFileForExportedImport.symbols b/tests/baselines/reference/declFileForExportedImport.symbols index fb7b7cd343f..fe14836199c 100644 --- a/tests/baselines/reference/declFileForExportedImport.symbols +++ b/tests/baselines/reference/declFileForExportedImport.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/declFileForExportedImport_1.ts === /// -export import a = require('declFileForExportedImport_0'); +export import a = require('./declFileForExportedImport_0'); >a : Symbol(a, Decl(declFileForExportedImport_1.ts, 0, 0)) var y = a.x; diff --git a/tests/baselines/reference/declFileForExportedImport.types b/tests/baselines/reference/declFileForExportedImport.types index 987f82bf5a0..0ff8c2f454b 100644 --- a/tests/baselines/reference/declFileForExportedImport.types +++ b/tests/baselines/reference/declFileForExportedImport.types @@ -1,6 +1,6 @@ === tests/cases/compiler/declFileForExportedImport_1.ts === /// -export import a = require('declFileForExportedImport_0'); +export import a = require('./declFileForExportedImport_0'); >a : typeof a var y = a.x; diff --git a/tests/baselines/reference/declFileForTypeParameters.types b/tests/baselines/reference/declFileForTypeParameters.types index 6308a0c92ba..fe69da2cd0f 100644 --- a/tests/baselines/reference/declFileForTypeParameters.types +++ b/tests/baselines/reference/declFileForTypeParameters.types @@ -16,7 +16,7 @@ class C { return this.x; >this.x : T ->this : C +>this : this >x : T } } diff --git a/tests/baselines/reference/declFileGenericType2.types b/tests/baselines/reference/declFileGenericType2.types index 07bcba3e85a..c2a43db1921 100644 --- a/tests/baselines/reference/declFileGenericType2.types +++ b/tests/baselines/reference/declFileGenericType2.types @@ -142,7 +142,7 @@ module templa.dom.mvc.composite { this._controllers = []; >this._controllers = [] : undefined[] >this._controllers : templa.mvc.IController[] ->this : AbstractCompositeElementController +>this : this >_controllers : templa.mvc.IController[] >[] : undefined[] } diff --git a/tests/baselines/reference/declFileImportModuleWithExportAssignment.js b/tests/baselines/reference/declFileImportModuleWithExportAssignment.js index 145d4ad3ff2..b070b67ad18 100644 --- a/tests/baselines/reference/declFileImportModuleWithExportAssignment.js +++ b/tests/baselines/reference/declFileImportModuleWithExportAssignment.js @@ -21,7 +21,7 @@ export = m2; //// [declFileImportModuleWithExportAssignment_1.ts] /**This is on import declaration*/ -import a1 = require("declFileImportModuleWithExportAssignment_0"); +import a1 = require("./declFileImportModuleWithExportAssignment_0"); export var a = a1; a.test1(null, null, null); @@ -31,7 +31,7 @@ var m2; module.exports = m2; //// [declFileImportModuleWithExportAssignment_1.js] /**This is on import declaration*/ -var a1 = require("declFileImportModuleWithExportAssignment_0"); +var a1 = require("./declFileImportModuleWithExportAssignment_0"); exports.a = a1; exports.a.test1(null, null, null); @@ -54,7 +54,7 @@ declare var m2: { export = m2; //// [declFileImportModuleWithExportAssignment_1.d.ts] /**This is on import declaration*/ -import a1 = require("declFileImportModuleWithExportAssignment_0"); +import a1 = require("./declFileImportModuleWithExportAssignment_0"); export declare var a: { (): a1.connectExport; test1: a1.connectModule; diff --git a/tests/baselines/reference/declFileImportModuleWithExportAssignment.symbols b/tests/baselines/reference/declFileImportModuleWithExportAssignment.symbols index 62d9d599939..a33e0fef758 100644 --- a/tests/baselines/reference/declFileImportModuleWithExportAssignment.symbols +++ b/tests/baselines/reference/declFileImportModuleWithExportAssignment.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/declFileImportModuleWithExportAssignment_1.ts === /**This is on import declaration*/ -import a1 = require("declFileImportModuleWithExportAssignment_0"); +import a1 = require("./declFileImportModuleWithExportAssignment_0"); >a1 : Symbol(a1, Decl(declFileImportModuleWithExportAssignment_1.ts, 0, 0)) export var a = a1; diff --git a/tests/baselines/reference/declFileImportModuleWithExportAssignment.types b/tests/baselines/reference/declFileImportModuleWithExportAssignment.types index d3082311c1d..123b7b56d4f 100644 --- a/tests/baselines/reference/declFileImportModuleWithExportAssignment.types +++ b/tests/baselines/reference/declFileImportModuleWithExportAssignment.types @@ -1,6 +1,6 @@ === tests/cases/compiler/declFileImportModuleWithExportAssignment_1.ts === /**This is on import declaration*/ -import a1 = require("declFileImportModuleWithExportAssignment_0"); +import a1 = require("./declFileImportModuleWithExportAssignment_0"); >a1 : { (): a1.connectExport; test1: a1.connectModule; test2(): a1.connectModule; } export var a = a1; diff --git a/tests/baselines/reference/declarationEmitDestructuring2.js b/tests/baselines/reference/declarationEmitDestructuring2.js index eeabbf1ff37..09980c5c9dd 100644 --- a/tests/baselines/reference/declarationEmitDestructuring2.js +++ b/tests/baselines/reference/declarationEmitDestructuring2.js @@ -21,8 +21,8 @@ function h1(_a) { //// [declarationEmitDestructuring2.d.ts] declare function f({x, y: [a, b, c, d]}?: { - x: number; - y: [number, number, number, number]; + x?: number; + y?: [number, number, number, number]; }): void; declare function g([a, b, c, d]?: [number, number, number, number]): void; declare function h([a, [b], [[c]], {x, y: [a, b, c], z: {a1, b1}}]: [any, [any], [[any]], { diff --git a/tests/baselines/reference/declarationEmitDestructuring4.errors.txt b/tests/baselines/reference/declarationEmitDestructuring4.errors.txt new file mode 100644 index 00000000000..2787d5e6674 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuring4.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/declarationEmitDestructuring4.ts(9,22): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. + + +==== tests/cases/compiler/declarationEmitDestructuring4.ts (1 errors) ==== + // For an array binding pattern with empty elements, + // we will not make any modification and will emit + // the similar binding pattern users' have written + function baz([]) { } + function baz1([] = [1,2,3]) { } + function baz2([[]] = [[1,2,3]]) { } + + function baz3({}) { } + function baz4({} = { x: 10 }) { } + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. + + \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDestructuring4.symbols b/tests/baselines/reference/declarationEmitDestructuring4.symbols deleted file mode 100644 index 9f2eb162b6f..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuring4.symbols +++ /dev/null @@ -1,21 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuring4.ts === -// For an array binding pattern with empty elements, -// we will not make any modification and will emit -// the similar binding pattern users' have written -function baz([]) { } ->baz : Symbol(baz, Decl(declarationEmitDestructuring4.ts, 0, 0)) - -function baz1([] = [1,2,3]) { } ->baz1 : Symbol(baz1, Decl(declarationEmitDestructuring4.ts, 3, 20)) - -function baz2([[]] = [[1,2,3]]) { } ->baz2 : Symbol(baz2, Decl(declarationEmitDestructuring4.ts, 4, 31)) - -function baz3({}) { } ->baz3 : Symbol(baz3, Decl(declarationEmitDestructuring4.ts, 5, 35)) - -function baz4({} = { x: 10 }) { } ->baz4 : Symbol(baz4, Decl(declarationEmitDestructuring4.ts, 7, 21)) ->x : Symbol(x, Decl(declarationEmitDestructuring4.ts, 8, 20)) - - diff --git a/tests/baselines/reference/declarationEmitDestructuring4.types b/tests/baselines/reference/declarationEmitDestructuring4.types deleted file mode 100644 index 9621d61e02b..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuring4.types +++ /dev/null @@ -1,32 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuring4.ts === -// For an array binding pattern with empty elements, -// we will not make any modification and will emit -// the similar binding pattern users' have written -function baz([]) { } ->baz : ([]: any[]) => void - -function baz1([] = [1,2,3]) { } ->baz1 : ([]?: number[]) => void ->[1,2,3] : number[] ->1 : number ->2 : number ->3 : number - -function baz2([[]] = [[1,2,3]]) { } ->baz2 : ([[]]?: [number[]]) => void ->[[1,2,3]] : [number[]] ->[1,2,3] : number[] ->1 : number ->2 : number ->3 : number - -function baz3({}) { } ->baz3 : ({}: {}) => void - -function baz4({} = { x: 10 }) { } ->baz4 : ({}?: { x: number; }) => void ->{ x: 10 } : { x: number; } ->x : number ->10 : number - - diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.errors.txt b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.errors.txt new file mode 100644 index 00000000000..26998fd83ae --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts(4,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + + +==== tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts (3 errors) ==== + var [x10, [y10, [z10]]] = [1, ["hello", [true]]]; + + var [x11 = 0, y11 = ""] = [1, "hello"]; + var [a11, b11, c11] = []; + ~~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + ~~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + ~~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + + var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]]; + + var [x13, y13] = [1, "hello"]; + var [a3, b3] = [[x13, y13], { x: x13, y: y13 }]; + \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.symbols b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.symbols deleted file mode 100644 index 0a3c6f4044d..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.symbols +++ /dev/null @@ -1,40 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts === -var [x10, [y10, [z10]]] = [1, ["hello", [true]]]; ->x10 : Symbol(x10, Decl(declarationEmitDestructuringArrayPattern2.ts, 0, 5)) ->y10 : Symbol(y10, Decl(declarationEmitDestructuringArrayPattern2.ts, 0, 11)) ->z10 : Symbol(z10, Decl(declarationEmitDestructuringArrayPattern2.ts, 0, 17)) - -var [x11 = 0, y11 = ""] = [1, "hello"]; ->x11 : Symbol(x11, Decl(declarationEmitDestructuringArrayPattern2.ts, 2, 5)) ->y11 : Symbol(y11, Decl(declarationEmitDestructuringArrayPattern2.ts, 2, 13)) - -var [a11, b11, c11] = []; ->a11 : Symbol(a11, Decl(declarationEmitDestructuringArrayPattern2.ts, 3, 5)) ->b11 : Symbol(b11, Decl(declarationEmitDestructuringArrayPattern2.ts, 3, 9)) ->c11 : Symbol(c11, Decl(declarationEmitDestructuringArrayPattern2.ts, 3, 14)) - -var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]]; ->a2 : Symbol(a2, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 5)) ->b2 : Symbol(b2, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 10)) ->x12 : Symbol(x12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 15)) ->y12 : Symbol(y12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 91)) ->c2 : Symbol(c2, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 20)) ->x12 : Symbol(x12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 41)) ->y12 : Symbol(y12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 50)) ->x12 : Symbol(x12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 83)) ->y12 : Symbol(y12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 91)) - -var [x13, y13] = [1, "hello"]; ->x13 : Symbol(x13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 5)) ->y13 : Symbol(y13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 9)) - -var [a3, b3] = [[x13, y13], { x: x13, y: y13 }]; ->a3 : Symbol(a3, Decl(declarationEmitDestructuringArrayPattern2.ts, 8, 5)) ->b3 : Symbol(b3, Decl(declarationEmitDestructuringArrayPattern2.ts, 8, 8)) ->x13 : Symbol(x13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 5)) ->y13 : Symbol(y13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 9)) ->x : Symbol(x, Decl(declarationEmitDestructuringArrayPattern2.ts, 8, 29)) ->x13 : Symbol(x13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 5)) ->y : Symbol(y, Decl(declarationEmitDestructuringArrayPattern2.ts, 8, 37)) ->y13 : Symbol(y13, Decl(declarationEmitDestructuringArrayPattern2.ts, 7, 9)) - diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types b/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types deleted file mode 100644 index eb028aacff4..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern2.types +++ /dev/null @@ -1,70 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuringArrayPattern2.ts === -var [x10, [y10, [z10]]] = [1, ["hello", [true]]]; ->x10 : number ->y10 : string ->z10 : boolean ->[1, ["hello", [true]]] : [number, [string, [boolean]]] ->1 : number ->["hello", [true]] : [string, [boolean]] ->"hello" : string ->[true] : [boolean] ->true : boolean - -var [x11 = 0, y11 = ""] = [1, "hello"]; ->x11 : number ->0 : number ->y11 : string ->"" : string ->[1, "hello"] : [number, string] ->1 : number ->"hello" : string - -var [a11, b11, c11] = []; ->a11 : any ->b11 : any ->c11 : any ->[] : undefined[] - -var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello", { x12: 5, y12: true }]]; ->a2 : number ->b2 : string ->x12 : number ->y12 : any ->c2 : boolean ->["abc", { x12: 10, y12: false }] : [string, { x12: number; y12: boolean; }] ->"abc" : string ->{ x12: 10, y12: false } : { x12: number; y12: boolean; } ->x12 : number ->10 : number ->y12 : boolean ->false : boolean ->[1, ["hello", { x12: 5, y12: true }]] : [number, [string, { x12: number; y12: boolean; }]] ->1 : number ->["hello", { x12: 5, y12: true }] : [string, { x12: number; y12: boolean; }] ->"hello" : string ->{ x12: 5, y12: true } : { x12: number; y12: boolean; } ->x12 : number ->5 : number ->y12 : boolean ->true : boolean - -var [x13, y13] = [1, "hello"]; ->x13 : number ->y13 : string ->[1, "hello"] : [number, string] ->1 : number ->"hello" : string - -var [a3, b3] = [[x13, y13], { x: x13, y: y13 }]; ->a3 : (number | string)[] ->b3 : { x: number; y: string; } ->[[x13, y13], { x: x13, y: y13 }] : [(number | string)[], { x: number; y: string; }] ->[x13, y13] : (number | string)[] ->x13 : number ->y13 : string ->{ x: x13, y: y13 } : { x: number; y: string; } ->x : number ->x13 : number ->y : string ->y13 : string - diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.errors.txt b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.errors.txt new file mode 100644 index 00000000000..92a8cba2d40 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.errors.txt @@ -0,0 +1,43 @@ +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(2,13): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(2,19): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(3,23): error TS2353: Object literal may only specify known properties, and 'y4' does not exist in type '{ x4: any; }'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(4,16): error TS2353: Object literal may only specify known properties, and 'x5' does not exist in type '{ y5: any; }'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(6,27): error TS2353: Object literal may only specify known properties, and 'y7' does not exist in type '{ x7: any; }'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts(7,20): error TS2353: Object literal may only specify known properties, and 'x8' does not exist in type '{ y8: any; }'. + + +==== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts (6 errors) ==== + + var { } = { x: 5, y: "hello" }; + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. + var { x4 } = { x4: 5, y4: "hello" }; + ~~ +!!! error TS2353: Object literal may only specify known properties, and 'y4' does not exist in type '{ x4: any; }'. + var { y5 } = { x5: 5, y5: "hello" }; + ~~ +!!! error TS2353: Object literal may only specify known properties, and 'x5' does not exist in type '{ y5: any; }'. + var { x6, y6 } = { x6: 5, y6: "hello" }; + var { x7: a1 } = { x7: 5, y7: "hello" }; + ~~ +!!! error TS2353: Object literal may only specify known properties, and 'y7' does not exist in type '{ x7: any; }'. + var { y8: b1 } = { x8: 5, y8: "hello" }; + ~~ +!!! error TS2353: Object literal may only specify known properties, and 'x8' does not exist in type '{ y8: any; }'. + var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; + + var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } }; + + function f15() { + var a4 = "hello"; + var b4 = 1; + var c4 = true; + return { a4, b4, c4 }; + } + var { a4, b4, c4 } = f15(); + + module m { + export var { a4, b4, c4 } = f15(); + } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.symbols b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.symbols deleted file mode 100644 index 0a57a93f3d0..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.symbols +++ /dev/null @@ -1,89 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts === - -var { } = { x: 5, y: "hello" }; ->x : Symbol(x, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 1, 11)) ->y : Symbol(y, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 1, 17)) - -var { x4 } = { x4: 5, y4: "hello" }; ->x4 : Symbol(x4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 2, 5)) ->x4 : Symbol(x4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 2, 14)) ->y4 : Symbol(y4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 2, 21)) - -var { y5 } = { x5: 5, y5: "hello" }; ->y5 : Symbol(y5, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 3, 5)) ->x5 : Symbol(x5, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 3, 14)) ->y5 : Symbol(y5, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 3, 21)) - -var { x6, y6 } = { x6: 5, y6: "hello" }; ->x6 : Symbol(x6, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 4, 5)) ->y6 : Symbol(y6, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 4, 9)) ->x6 : Symbol(x6, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 4, 18)) ->y6 : Symbol(y6, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 4, 25)) - -var { x7: a1 } = { x7: 5, y7: "hello" }; ->x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 18)) ->a1 : Symbol(a1, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 5)) ->x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 18)) ->y7 : Symbol(y7, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 25)) - -var { y8: b1 } = { x8: 5, y8: "hello" }; ->y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 25)) ->b1 : Symbol(b1, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 5)) ->x8 : Symbol(x8, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 18)) ->y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 25)) - -var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; ->x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 26)) ->a2 : Symbol(a2, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 5)) ->y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 33)) ->b2 : Symbol(b2, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 13)) ->x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 26)) ->y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 33)) - -var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } }; ->a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 46)) ->x11 : Symbol(x11, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 5)) ->b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 52)) ->a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 57)) ->y11 : Symbol(y11, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 18)) ->b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 69)) ->a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 74)) ->z11 : Symbol(z11, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 31)) ->a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 46)) ->b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 52)) ->a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 57)) ->b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 69)) ->a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 74)) - -function f15() { ->f15 : Symbol(f15, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 89)) - - var a4 = "hello"; ->a4 : Symbol(a4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 12, 7)) - - var b4 = 1; ->b4 : Symbol(b4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 13, 7)) - - var c4 = true; ->c4 : Symbol(c4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 14, 7)) - - return { a4, b4, c4 }; ->a4 : Symbol(a4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 15, 12)) ->b4 : Symbol(b4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 15, 16)) ->c4 : Symbol(c4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 15, 20)) -} -var { a4, b4, c4 } = f15(); ->a4 : Symbol(a4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 17, 5)) ->b4 : Symbol(b4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 17, 9)) ->c4 : Symbol(c4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 17, 13)) ->f15 : Symbol(f15, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 89)) - -module m { ->m : Symbol(m, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 17, 27)) - - export var { a4, b4, c4 } = f15(); ->a4 : Symbol(a4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 20, 16)) ->b4 : Symbol(b4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 20, 20)) ->c4 : Symbol(c4, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 20, 24)) ->f15 : Symbol(f15, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 89)) -} diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.types b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.types deleted file mode 100644 index 0911a27838b..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.types +++ /dev/null @@ -1,122 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern.ts === - -var { } = { x: 5, y: "hello" }; ->{ x: 5, y: "hello" } : { x: number; y: string; } ->x : number ->5 : number ->y : string ->"hello" : string - -var { x4 } = { x4: 5, y4: "hello" }; ->x4 : number ->{ x4: 5, y4: "hello" } : { x4: number; y4: string; } ->x4 : number ->5 : number ->y4 : string ->"hello" : string - -var { y5 } = { x5: 5, y5: "hello" }; ->y5 : string ->{ x5: 5, y5: "hello" } : { x5: number; y5: string; } ->x5 : number ->5 : number ->y5 : string ->"hello" : string - -var { x6, y6 } = { x6: 5, y6: "hello" }; ->x6 : number ->y6 : string ->{ x6: 5, y6: "hello" } : { x6: number; y6: string; } ->x6 : number ->5 : number ->y6 : string ->"hello" : string - -var { x7: a1 } = { x7: 5, y7: "hello" }; ->x7 : any ->a1 : number ->{ x7: 5, y7: "hello" } : { x7: number; y7: string; } ->x7 : number ->5 : number ->y7 : string ->"hello" : string - -var { y8: b1 } = { x8: 5, y8: "hello" }; ->y8 : any ->b1 : string ->{ x8: 5, y8: "hello" } : { x8: number; y8: string; } ->x8 : number ->5 : number ->y8 : string ->"hello" : string - -var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; ->x9 : any ->a2 : number ->y9 : any ->b2 : string ->{ x9: 5, y9: "hello" } : { x9: number; y9: string; } ->x9 : number ->5 : number ->y9 : string ->"hello" : string - -var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } }; ->a : any ->x11 : number ->b : any ->a : any ->y11 : string ->b : any ->a : any ->z11 : boolean ->{ a: 1, b: { a: "hello", b: { a: true } } } : { a: number; b: { a: string; b: { a: boolean; }; }; } ->a : number ->1 : number ->b : { a: string; b: { a: boolean; }; } ->{ a: "hello", b: { a: true } } : { a: string; b: { a: boolean; }; } ->a : string ->"hello" : string ->b : { a: boolean; } ->{ a: true } : { a: boolean; } ->a : boolean ->true : boolean - -function f15() { ->f15 : () => { a4: string; b4: number; c4: boolean; } - - var a4 = "hello"; ->a4 : string ->"hello" : string - - var b4 = 1; ->b4 : number ->1 : number - - var c4 = true; ->c4 : boolean ->true : boolean - - return { a4, b4, c4 }; ->{ a4, b4, c4 } : { a4: string; b4: number; c4: boolean; } ->a4 : string ->b4 : number ->c4 : boolean -} -var { a4, b4, c4 } = f15(); ->a4 : string ->b4 : number ->c4 : boolean ->f15() : { a4: string; b4: number; c4: boolean; } ->f15 : () => { a4: string; b4: number; c4: boolean; } - -module m { ->m : typeof m - - export var { a4, b4, c4 } = f15(); ->a4 : string ->b4 : number ->c4 : boolean ->f15() : { a4: string; b4: number; c4: boolean; } ->f15 : () => { a4: string; b4: number; c4: boolean; } -} diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.errors.txt b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.errors.txt new file mode 100644 index 00000000000..24fbcf99ad1 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.errors.txt @@ -0,0 +1,29 @@ +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(2,13): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(2,19): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(3,23): error TS2353: Object literal may only specify known properties, and 'y4' does not exist in type '{ x4: any; }'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(4,16): error TS2353: Object literal may only specify known properties, and 'x5' does not exist in type '{ y5: any; }'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(6,27): error TS2353: Object literal may only specify known properties, and 'y7' does not exist in type '{ x7: any; }'. +tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts(7,20): error TS2353: Object literal may only specify known properties, and 'x8' does not exist in type '{ y8: any; }'. + + +==== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts (6 errors) ==== + + var { } = { x: 5, y: "hello" }; + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. + var { x4 } = { x4: 5, y4: "hello" }; + ~~ +!!! error TS2353: Object literal may only specify known properties, and 'y4' does not exist in type '{ x4: any; }'. + var { y5 } = { x5: 5, y5: "hello" }; + ~~ +!!! error TS2353: Object literal may only specify known properties, and 'x5' does not exist in type '{ y5: any; }'. + var { x6, y6 } = { x6: 5, y6: "hello" }; + var { x7: a1 } = { x7: 5, y7: "hello" }; + ~~ +!!! error TS2353: Object literal may only specify known properties, and 'y7' does not exist in type '{ x7: any; }'. + var { y8: b1 } = { x8: 5, y8: "hello" }; + ~~ +!!! error TS2353: Object literal may only specify known properties, and 'x8' does not exist in type '{ y8: any; }'. + var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.symbols b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.symbols deleted file mode 100644 index cac2431411e..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.symbols +++ /dev/null @@ -1,42 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts === - -var { } = { x: 5, y: "hello" }; ->x : Symbol(x, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 1, 11)) ->y : Symbol(y, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 1, 17)) - -var { x4 } = { x4: 5, y4: "hello" }; ->x4 : Symbol(x4, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 2, 5)) ->x4 : Symbol(x4, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 2, 14)) ->y4 : Symbol(y4, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 2, 21)) - -var { y5 } = { x5: 5, y5: "hello" }; ->y5 : Symbol(y5, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 3, 5)) ->x5 : Symbol(x5, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 3, 14)) ->y5 : Symbol(y5, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 3, 21)) - -var { x6, y6 } = { x6: 5, y6: "hello" }; ->x6 : Symbol(x6, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 4, 5)) ->y6 : Symbol(y6, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 4, 9)) ->x6 : Symbol(x6, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 4, 18)) ->y6 : Symbol(y6, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 4, 25)) - -var { x7: a1 } = { x7: 5, y7: "hello" }; ->x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 18)) ->a1 : Symbol(a1, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 5)) ->x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 18)) ->y7 : Symbol(y7, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 25)) - -var { y8: b1 } = { x8: 5, y8: "hello" }; ->y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 25)) ->b1 : Symbol(b1, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 5)) ->x8 : Symbol(x8, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 18)) ->y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 25)) - -var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; ->x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 26)) ->a2 : Symbol(a2, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 5)) ->y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 33)) ->b2 : Symbol(b2, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 13)) ->x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 26)) ->y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 33)) - diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.types b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.types deleted file mode 100644 index 5411f36fa9a..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.types +++ /dev/null @@ -1,63 +0,0 @@ -=== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern1.ts === - -var { } = { x: 5, y: "hello" }; ->{ x: 5, y: "hello" } : { x: number; y: string; } ->x : number ->5 : number ->y : string ->"hello" : string - -var { x4 } = { x4: 5, y4: "hello" }; ->x4 : number ->{ x4: 5, y4: "hello" } : { x4: number; y4: string; } ->x4 : number ->5 : number ->y4 : string ->"hello" : string - -var { y5 } = { x5: 5, y5: "hello" }; ->y5 : string ->{ x5: 5, y5: "hello" } : { x5: number; y5: string; } ->x5 : number ->5 : number ->y5 : string ->"hello" : string - -var { x6, y6 } = { x6: 5, y6: "hello" }; ->x6 : number ->y6 : string ->{ x6: 5, y6: "hello" } : { x6: number; y6: string; } ->x6 : number ->5 : number ->y6 : string ->"hello" : string - -var { x7: a1 } = { x7: 5, y7: "hello" }; ->x7 : any ->a1 : number ->{ x7: 5, y7: "hello" } : { x7: number; y7: string; } ->x7 : number ->5 : number ->y7 : string ->"hello" : string - -var { y8: b1 } = { x8: 5, y8: "hello" }; ->y8 : any ->b1 : string ->{ x8: 5, y8: "hello" } : { x8: number; y8: string; } ->x8 : number ->5 : number ->y8 : string ->"hello" : string - -var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; ->x9 : any ->a2 : number ->y9 : any ->b2 : string ->{ x9: 5, y9: "hello" } : { x9: number; y9: string; } ->x9 : number ->5 : number ->y9 : string ->"hello" : string - diff --git a/tests/baselines/reference/declarationEmit_exportAssignment.js b/tests/baselines/reference/declarationEmit_exportAssignment.js index 54f3eb5fd0e..d761e2c45eb 100644 --- a/tests/baselines/reference/declarationEmit_exportAssignment.js +++ b/tests/baselines/reference/declarationEmit_exportAssignment.js @@ -7,7 +7,7 @@ export function bar() { } export interface Buzz { } //// [index.ts] -import {foo} from "utils"; +import {foo} from "./utils"; export = foo; //// [utils.js] @@ -16,7 +16,7 @@ exports.foo = foo; function bar() { } exports.bar = bar; //// [index.js] -var utils_1 = require("utils"); +var utils_1 = require("./utils"); module.exports = utils_1.foo; @@ -26,5 +26,5 @@ export declare function bar(): void; export interface Buzz { } //// [index.d.ts] -import { foo } from "utils"; +import { foo } from "./utils"; export = foo; diff --git a/tests/baselines/reference/declarationEmit_exportAssignment.symbols b/tests/baselines/reference/declarationEmit_exportAssignment.symbols index b443ba6e797..d2131d27a8f 100644 --- a/tests/baselines/reference/declarationEmit_exportAssignment.symbols +++ b/tests/baselines/reference/declarationEmit_exportAssignment.symbols @@ -10,7 +10,7 @@ export interface Buzz { } >Buzz : Symbol(Buzz, Decl(utils.ts, 2, 25)) === tests/cases/compiler/index.ts === -import {foo} from "utils"; +import {foo} from "./utils"; >foo : Symbol(foo, Decl(index.ts, 0, 8)) export = foo; diff --git a/tests/baselines/reference/declarationEmit_exportAssignment.types b/tests/baselines/reference/declarationEmit_exportAssignment.types index 81c56da432f..763441b8a90 100644 --- a/tests/baselines/reference/declarationEmit_exportAssignment.types +++ b/tests/baselines/reference/declarationEmit_exportAssignment.types @@ -10,7 +10,7 @@ export interface Buzz { } >Buzz : Buzz === tests/cases/compiler/index.ts === -import {foo} from "utils"; +import {foo} from "./utils"; >foo : () => void export = foo; diff --git a/tests/baselines/reference/declarationEmit_exportDeclaration.js b/tests/baselines/reference/declarationEmit_exportDeclaration.js index f05639dc18f..e2cb15b408c 100644 --- a/tests/baselines/reference/declarationEmit_exportDeclaration.js +++ b/tests/baselines/reference/declarationEmit_exportDeclaration.js @@ -7,7 +7,7 @@ export function bar() { } export interface Buzz { } //// [index.ts] -import {foo, bar, Buzz} from "utils"; +import {foo, bar, Buzz} from "./utils"; foo(); let obj: Buzz; @@ -19,7 +19,7 @@ exports.foo = foo; function bar() { } exports.bar = bar; //// [index.js] -var utils_1 = require("utils"); +var utils_1 = require("./utils"); exports.bar = utils_1.bar; utils_1.foo(); var obj; @@ -31,5 +31,5 @@ export declare function bar(): void; export interface Buzz { } //// [index.d.ts] -import { bar } from "utils"; +import { bar } from "./utils"; export { bar }; diff --git a/tests/baselines/reference/declarationEmit_exportDeclaration.symbols b/tests/baselines/reference/declarationEmit_exportDeclaration.symbols index 5cd8c5fee99..40d6bafdee5 100644 --- a/tests/baselines/reference/declarationEmit_exportDeclaration.symbols +++ b/tests/baselines/reference/declarationEmit_exportDeclaration.symbols @@ -10,7 +10,7 @@ export interface Buzz { } >Buzz : Symbol(Buzz, Decl(utils.ts, 2, 25)) === tests/cases/compiler/index.ts === -import {foo, bar, Buzz} from "utils"; +import {foo, bar, Buzz} from "./utils"; >foo : Symbol(foo, Decl(index.ts, 0, 8)) >bar : Symbol(bar, Decl(index.ts, 0, 12)) >Buzz : Symbol(Buzz, Decl(index.ts, 0, 17)) diff --git a/tests/baselines/reference/declarationEmit_exportDeclaration.types b/tests/baselines/reference/declarationEmit_exportDeclaration.types index 058ee863c61..25a8f1d29bd 100644 --- a/tests/baselines/reference/declarationEmit_exportDeclaration.types +++ b/tests/baselines/reference/declarationEmit_exportDeclaration.types @@ -10,7 +10,7 @@ export interface Buzz { } >Buzz : Buzz === tests/cases/compiler/index.ts === -import {foo, bar, Buzz} from "utils"; +import {foo, bar, Buzz} from "./utils"; >foo : () => void >bar : () => void >Buzz : any diff --git a/tests/baselines/reference/declarationEmit_nameConflicts.js b/tests/baselines/reference/declarationEmit_nameConflicts.js index ae517bb7460..857fbee764d 100644 --- a/tests/baselines/reference/declarationEmit_nameConflicts.js +++ b/tests/baselines/reference/declarationEmit_nameConflicts.js @@ -5,7 +5,7 @@ module f { export class c { } } export = f; //// [declarationEmit_nameConflicts_0.ts] -import im = require('declarationEmit_nameConflicts_1'); +import im = require('./declarationEmit_nameConflicts_1'); export module M { export function f() { } export class C { } @@ -61,7 +61,7 @@ var f; })(f || (f = {})); module.exports = f; //// [declarationEmit_nameConflicts_0.js] -var im = require('declarationEmit_nameConflicts_1'); +var im = require('./declarationEmit_nameConflicts_1'); var M; (function (M) { function f() { } @@ -138,7 +138,7 @@ declare module f { } export = f; //// [declarationEmit_nameConflicts_0.d.ts] -import im = require('declarationEmit_nameConflicts_1'); +import im = require('./declarationEmit_nameConflicts_1'); export declare module M { function f(): void; class C { diff --git a/tests/baselines/reference/declarationEmit_nameConflicts.symbols b/tests/baselines/reference/declarationEmit_nameConflicts.symbols index a626ed05b15..1c5bb35b756 100644 --- a/tests/baselines/reference/declarationEmit_nameConflicts.symbols +++ b/tests/baselines/reference/declarationEmit_nameConflicts.symbols @@ -1,9 +1,9 @@ === tests/cases/compiler/declarationEmit_nameConflicts_0.ts === -import im = require('declarationEmit_nameConflicts_1'); +import im = require('./declarationEmit_nameConflicts_1'); >im : Symbol(im, Decl(declarationEmit_nameConflicts_0.ts, 0, 0)) export module M { ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) export function f() { } >f : Symbol(f, Decl(declarationEmit_nameConflicts_0.ts, 1, 17)) @@ -23,12 +23,12 @@ export module M { export import a = M.f; >a : Symbol(a, Decl(declarationEmit_nameConflicts_0.ts, 7, 5)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >f : Symbol(f, Decl(declarationEmit_nameConflicts_0.ts, 1, 17)) export import b = M.C; >b : Symbol(b, Decl(declarationEmit_nameConflicts_0.ts, 9, 26)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >C : Symbol(C, Decl(declarationEmit_nameConflicts_0.ts, 2, 27)) export import c = N; @@ -41,7 +41,7 @@ export module M { } export module M.P { ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >P : Symbol(P, Decl(declarationEmit_nameConflicts_0.ts, 15, 16)) export function f() { } @@ -61,45 +61,45 @@ export module M.P { } export import im = M.P.f; >im : Symbol(im, Decl(declarationEmit_nameConflicts_0.ts, 21, 5)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >P : Symbol(P, Decl(declarationEmit_nameConflicts_0.ts, 15, 16)) >f : Symbol(f, Decl(declarationEmit_nameConflicts_0.ts, 15, 19)) export var a = M.a; // emitted incorrectly as typeof f >a : Symbol(a, Decl(declarationEmit_nameConflicts_0.ts, 23, 14)) >M.a : Symbol(a, Decl(declarationEmit_nameConflicts_0.ts, 7, 5)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >a : Symbol(a, Decl(declarationEmit_nameConflicts_0.ts, 7, 5)) export var b = M.b; // ok >b : Symbol(b, Decl(declarationEmit_nameConflicts_0.ts, 24, 14)) >M.b : Symbol(b, Decl(declarationEmit_nameConflicts_0.ts, 9, 26)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >b : Symbol(b, Decl(declarationEmit_nameConflicts_0.ts, 9, 26)) export var c = M.c; // ok >c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 25, 14)) >M.c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 10, 26)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 10, 26)) export var g = M.c.g; // ok >g : Symbol(g, Decl(declarationEmit_nameConflicts_0.ts, 26, 14)) >M.c.g : Symbol(c.g, Decl(declarationEmit_nameConflicts_0.ts, 4, 21)) >M.c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 10, 26)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 10, 26)) >g : Symbol(c.g, Decl(declarationEmit_nameConflicts_0.ts, 4, 21)) export var d = M.d; // emitted incorrectly as typeof im >d : Symbol(d, Decl(declarationEmit_nameConflicts_0.ts, 27, 14)) >M.d : Symbol(d, Decl(declarationEmit_nameConflicts_0.ts, 11, 24)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >d : Symbol(d, Decl(declarationEmit_nameConflicts_0.ts, 11, 24)) } export module M.Q { ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >Q : Symbol(Q, Decl(declarationEmit_nameConflicts_0.ts, 30, 16)) export function f() { } @@ -120,14 +120,14 @@ export module M.Q { export interface b extends M.b { } // ok >b : Symbol(b, Decl(declarationEmit_nameConflicts_0.ts, 36, 5)) >M.b : Symbol(b, Decl(declarationEmit_nameConflicts_0.ts, 9, 26)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >b : Symbol(b, Decl(declarationEmit_nameConflicts_0.ts, 9, 26)) export interface I extends M.c.I { } // ok >I : Symbol(I, Decl(declarationEmit_nameConflicts_0.ts, 37, 38)) >M.c.I : Symbol(M.c.I, Decl(declarationEmit_nameConflicts_0.ts, 5, 32)) >M.c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 10, 26)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 10, 26)) >I : Symbol(M.c.I, Decl(declarationEmit_nameConflicts_0.ts, 5, 32)) @@ -138,7 +138,7 @@ export module M.Q { >I : Symbol(I, Decl(declarationEmit_nameConflicts_0.ts, 39, 21)) >M.c.I : Symbol(M.c.I, Decl(declarationEmit_nameConflicts_0.ts, 5, 32)) >M.c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 10, 26)) ->M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 55), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) +>M : Symbol(M, Decl(declarationEmit_nameConflicts_0.ts, 0, 57), Decl(declarationEmit_nameConflicts_0.ts, 13, 1), Decl(declarationEmit_nameConflicts_0.ts, 28, 1)) >c : Symbol(c, Decl(declarationEmit_nameConflicts_0.ts, 10, 26)) >I : Symbol(M.c.I, Decl(declarationEmit_nameConflicts_0.ts, 5, 32)) } diff --git a/tests/baselines/reference/declarationEmit_nameConflicts.types b/tests/baselines/reference/declarationEmit_nameConflicts.types index dacd657706d..6ea650946c5 100644 --- a/tests/baselines/reference/declarationEmit_nameConflicts.types +++ b/tests/baselines/reference/declarationEmit_nameConflicts.types @@ -1,5 +1,5 @@ === tests/cases/compiler/declarationEmit_nameConflicts_0.ts === -import im = require('declarationEmit_nameConflicts_1'); +import im = require('./declarationEmit_nameConflicts_1'); >im : typeof im export module M { diff --git a/tests/baselines/reference/declarationEmit_protectedMembers.types b/tests/baselines/reference/declarationEmit_protectedMembers.types index 89aa3f56332..d541e1d14d2 100644 --- a/tests/baselines/reference/declarationEmit_protectedMembers.types +++ b/tests/baselines/reference/declarationEmit_protectedMembers.types @@ -12,7 +12,7 @@ class C1 { return this.x; >this.x : number ->this : C1 +>this : this >x : number } @@ -60,7 +60,7 @@ class C2 extends C1 { >super : C1 >f : () => number >this.x : number ->this : C2 +>this : this >x : number } protected static sf() { diff --git a/tests/baselines/reference/declarationFiles.errors.txt b/tests/baselines/reference/declarationFiles.errors.txt new file mode 100644 index 00000000000..c55cac9000b --- /dev/null +++ b/tests/baselines/reference/declarationFiles.errors.txt @@ -0,0 +1,63 @@ +tests/cases/conformance/types/thisType/declarationFiles.ts(31,5): error TS2527: The inferred type of 'x1' references an inaccessible 'this' type. A type annotation is necessary. +tests/cases/conformance/types/thisType/declarationFiles.ts(33,5): error TS2527: The inferred type of 'x3' references an inaccessible 'this' type. A type annotation is necessary. +tests/cases/conformance/types/thisType/declarationFiles.ts(35,5): error TS2527: The inferred type of 'f1' references an inaccessible 'this' type. A type annotation is necessary. +tests/cases/conformance/types/thisType/declarationFiles.ts(41,5): error TS2527: The inferred type of 'f3' references an inaccessible 'this' type. A type annotation is necessary. + + +==== tests/cases/conformance/types/thisType/declarationFiles.ts (4 errors) ==== + + class C1 { + x: this; + f(x: this): this { return undefined; } + constructor(x: this) { } + } + + class C2 { + [x: string]: this; + } + + interface Foo { + x: T; + y: this; + } + + class C3 { + a: this[]; + b: [this, this]; + c: this | Date; + d: this & Date; + e: (((this))); + f: (x: this) => this; + g: new (x: this) => this; + h: Foo; + i: Foo this)>; + j: (x: any) => x is this; + } + + class C4 { + x1 = { a: this }; + ~~ +!!! error TS2527: The inferred type of 'x1' references an inaccessible 'this' type. A type annotation is necessary. + x2 = [this]; + x3 = [{ a: this }]; + ~~ +!!! error TS2527: The inferred type of 'x3' references an inaccessible 'this' type. A type annotation is necessary. + x4 = () => this; + f1() { + ~~ +!!! error TS2527: The inferred type of 'f1' references an inaccessible 'this' type. A type annotation is necessary. + return { a: this }; + } + f2() { + return [this]; + } + f3() { + ~~ +!!! error TS2527: The inferred type of 'f3' references an inaccessible 'this' type. A type annotation is necessary. + return [{ a: this }]; + } + f4() { + return () => this; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/declarationFiles.js b/tests/baselines/reference/declarationFiles.js new file mode 100644 index 00000000000..d7ed9bde8c7 --- /dev/null +++ b/tests/baselines/reference/declarationFiles.js @@ -0,0 +1,135 @@ +//// [declarationFiles.ts] + +class C1 { + x: this; + f(x: this): this { return undefined; } + constructor(x: this) { } +} + +class C2 { + [x: string]: this; +} + +interface Foo { + x: T; + y: this; +} + +class C3 { + a: this[]; + b: [this, this]; + c: this | Date; + d: this & Date; + e: (((this))); + f: (x: this) => this; + g: new (x: this) => this; + h: Foo; + i: Foo this)>; + j: (x: any) => x is this; +} + +class C4 { + x1 = { a: this }; + x2 = [this]; + x3 = [{ a: this }]; + x4 = () => this; + f1() { + return { a: this }; + } + f2() { + return [this]; + } + f3() { + return [{ a: this }]; + } + f4() { + return () => this; + } +} + + +//// [declarationFiles.js] +var C1 = (function () { + function C1(x) { + } + C1.prototype.f = function (x) { return undefined; }; + return C1; +})(); +var C2 = (function () { + function C2() { + } + return C2; +})(); +var C3 = (function () { + function C3() { + } + return C3; +})(); +var C4 = (function () { + function C4() { + var _this = this; + this.x1 = { a: this }; + this.x2 = [this]; + this.x3 = [{ a: this }]; + this.x4 = function () { return _this; }; + } + C4.prototype.f1 = function () { + return { a: this }; + }; + C4.prototype.f2 = function () { + return [this]; + }; + C4.prototype.f3 = function () { + return [{ a: this }]; + }; + C4.prototype.f4 = function () { + var _this = this; + return function () { return _this; }; + }; + return C4; +})(); + + +//// [declarationFiles.d.ts] +declare class C1 { + x: this; + f(x: this): this; + constructor(x: this); +} +declare class C2 { + [x: string]: this; +} +interface Foo { + x: T; + y: this; +} +declare class C3 { + a: this[]; + b: [this, this]; + c: this | Date; + d: this & Date; + e: (((this))); + f: (x: this) => this; + g: new (x: this) => this; + h: Foo; + i: Foo this)>; + j: (x: any) => x is this; +} +declare class C4 { + x1: { + a: this; + }; + x2: this[]; + x3: { + a: this; + }[]; + x4: () => this; + f1(): { + a: this; + }; + f2(): this[]; + f3(): { + a: this; + }[]; + f4(): () => this; +} diff --git a/tests/baselines/reference/declarationsAndAssignments.errors.txt b/tests/baselines/reference/declarationsAndAssignments.errors.txt index 828083e7687..7c4671022ea 100644 --- a/tests/baselines/reference/declarationsAndAssignments.errors.txt +++ b/tests/baselines/reference/declarationsAndAssignments.errors.txt @@ -1,11 +1,20 @@ -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(5,16): error TS2493: Tuple type '[number, string]' with length '2' cannot be assigned to tuple with length '3'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(5,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(22,17): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(22,23): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(23,25): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(24,19): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(28,28): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(29,22): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(56,17): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,13): error TS2493: Tuple type '[number]' with length '1' cannot be assigned to tuple with length '3'. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,16): error TS2493: Tuple type '[number]' with length '1' cannot be assigned to tuple with length '3'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,10): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,13): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,13): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(63,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(67,9): error TS2461: Type '{ [x: number]: undefined; }' is not an array type. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(68,9): error TS2461: Type '{ [x: number]: number; 0: number; 1: number; }' is not an array type. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,11): error TS2459: Type '{}' has no property 'a' and no string index signature. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): error TS2459: Type '{}' has no property 'b' and no string index signature. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,11): error TS2459: Type 'undefined[]' has no property 'a' and no string index signature. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,14): error TS2459: Type 'undefined[]' has no property 'b' and no string index signature. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(106,5): error TS2345: Argument of type '[number, [string, { y: boolean; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'. @@ -18,15 +27,15 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,6): tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): error TS2322: Type 'number' is not assignable to type 'string'. -==== tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts (13 errors) ==== +==== tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts (22 errors) ==== function f0() { var [] = [1, "hello"]; var [x] = [1, "hello"]; var [x, y] = [1, "hello"]; - var [x, y, z] = [1, "hello"]; // Error + var [x, y, z] = [1, "hello"]; ~ -!!! error TS2493: Tuple type '[number, string]' with length '2' cannot be assigned to tuple with length '3'. - var [,, z] = [0, 1, 2]; +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + var [,, x] = [0, 1, 2]; var x: number; var y: string; } @@ -42,14 +51,26 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): } function f2() { - var { } = { x: 5, y: "hello" }; - var { x } = { x: 5, y: "hello" }; - var { y } = { x: 5, y: "hello" }; + var { } = { x: 5, y: "hello" }; // Error, no x and y in target + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. + var { x } = { x: 5, y: "hello" }; // Error, no y in target + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. + var { y } = { x: 5, y: "hello" }; // Error, no x in target + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. var { x, y } = { x: 5, y: "hello" }; var x: number; var y: string; - var { x: a } = { x: 5, y: "hello" }; - var { y: b } = { x: 5, y: "hello" }; + var { x: a } = { x: 5, y: "hello" }; // Error, no y in target + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. + var { y: b } = { x: 5, y: "hello" }; // Error, no x in target + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. var { x: a, y: b } = { x: 5, y: "hello" }; var a: number; var b: string; @@ -85,11 +106,17 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): function f8() { var [a, b, c] = []; // Ok, [] is an array + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. var [d, e, f] = [1]; // Error, [1] is a tuple ~ -!!! error TS2493: Tuple type '[number]' with length '1' cannot be assigned to tuple with length '3'. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~ -!!! error TS2493: Tuple type '[number]' with length '1' cannot be assigned to tuple with length '3'. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. } function f9() { @@ -105,9 +132,9 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): function f10() { var { a, b } = {}; // Error ~ -!!! error TS2459: Type '{}' has no property 'a' and no string index signature. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~ -!!! error TS2459: Type '{}' has no property 'b' and no string index signature. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. var { a, b } = []; // Error ~ !!! error TS2459: Type 'undefined[]' has no property 'a' and no string index signature. diff --git a/tests/baselines/reference/declarationsAndAssignments.js b/tests/baselines/reference/declarationsAndAssignments.js index 5c47756e7fe..018aa5522ca 100644 --- a/tests/baselines/reference/declarationsAndAssignments.js +++ b/tests/baselines/reference/declarationsAndAssignments.js @@ -3,8 +3,8 @@ function f0() { var [] = [1, "hello"]; var [x] = [1, "hello"]; var [x, y] = [1, "hello"]; - var [x, y, z] = [1, "hello"]; // Error - var [,, z] = [0, 1, 2]; + var [x, y, z] = [1, "hello"]; + var [,, x] = [0, 1, 2]; var x: number; var y: string; } @@ -20,14 +20,14 @@ function f1() { } function f2() { - var { } = { x: 5, y: "hello" }; - var { x } = { x: 5, y: "hello" }; - var { y } = { x: 5, y: "hello" }; + var { } = { x: 5, y: "hello" }; // Error, no x and y in target + var { x } = { x: 5, y: "hello" }; // Error, no y in target + var { y } = { x: 5, y: "hello" }; // Error, no x in target var { x, y } = { x: 5, y: "hello" }; var x: number; var y: string; - var { x: a } = { x: 5, y: "hello" }; - var { y: b } = { x: 5, y: "hello" }; + var { x: a } = { x: 5, y: "hello" }; // Error, no y in target + var { y: b } = { x: 5, y: "hello" }; // Error, no x in target var { x: a, y: b } = { x: 5, y: "hello" }; var a: number; var b: string; @@ -185,8 +185,8 @@ function f0() { var _a = [1, "hello"]; var x = [1, "hello"][0]; var _b = [1, "hello"], x = _b[0], y = _b[1]; - var _c = [1, "hello"], x = _c[0], y = _c[1], z = _c[2]; // Error - var _d = [0, 1, 2], z = _d[2]; + var _c = [1, "hello"], x = _c[0], y = _c[1], z = _c[2]; + var _d = [0, 1, 2], x = _d[2]; var x; var y; } @@ -200,14 +200,14 @@ function f1() { var z; } function f2() { - var _a = { x: 5, y: "hello" }; - var x = { x: 5, y: "hello" }.x; - var y = { x: 5, y: "hello" }.y; + var _a = { x: 5, y: "hello" }; // Error, no x and y in target + var x = { x: 5, y: "hello" }.x; // Error, no y in target + var y = { x: 5, y: "hello" }.y; // Error, no x in target var _b = { x: 5, y: "hello" }, x = _b.x, y = _b.y; var x; var y; - var a = { x: 5, y: "hello" }.x; - var b = { x: 5, y: "hello" }.y; + var a = { x: 5, y: "hello" }.x; // Error, no y in target + var b = { x: 5, y: "hello" }.y; // Error, no x in target var _c = { x: 5, y: "hello" }, a = _c.x, b = _c.y; var a; var b; diff --git a/tests/baselines/reference/decoratedClassFromExternalModule.js b/tests/baselines/reference/decoratedClassFromExternalModule.js index aca1d28b952..000fe2f37d6 100644 --- a/tests/baselines/reference/decoratedClassFromExternalModule.js +++ b/tests/baselines/reference/decoratedClassFromExternalModule.js @@ -11,12 +11,10 @@ import Decorated from 'decorated'; //// [decorated.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; function decorate(target) { } let Decorated = class { diff --git a/tests/baselines/reference/decoratorChecksFunctionBodies.js b/tests/baselines/reference/decoratorChecksFunctionBodies.js index adb710efccc..a5aa63b0b31 100644 --- a/tests/baselines/reference/decoratorChecksFunctionBodies.js +++ b/tests/baselines/reference/decoratorChecksFunctionBodies.js @@ -17,12 +17,10 @@ class A { //// [decoratorChecksFunctionBodies.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; // from #2971 function func(s) { @@ -32,13 +30,12 @@ var A = (function () { } A.prototype.m = function () { }; - Object.defineProperty(A.prototype, "m", - __decorate([ - (function (x, p) { - var a = 3; - func(a); - return x; - }) - ], A.prototype, "m", Object.getOwnPropertyDescriptor(A.prototype, "m"))); + __decorate([ + (function (x, p) { + var a = 3; + func(a); + return x; + }) + ], A.prototype, "m", null); return A; })(); diff --git a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js index 08ba6e9ea7e..ee39c1746a2 100644 --- a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js +++ b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js @@ -26,12 +26,10 @@ class Wat { exports.test = 'abc'; //// [b.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var a_1 = require('./a'); function filter(handler) { @@ -45,9 +43,8 @@ var Wat = (function () { Wat.whatever = function () { // ... }; - Object.defineProperty(Wat, "whatever", - __decorate([ - filter(function () { return a_1.test == 'abc'; }) - ], Wat, "whatever", Object.getOwnPropertyDescriptor(Wat, "whatever"))); + __decorate([ + filter(function () { return a_1.test == 'abc'; }) + ], Wat, "whatever", null); return Wat; })(); diff --git a/tests/baselines/reference/decoratorMetadata.js b/tests/baselines/reference/decoratorMetadata.js index ea776d09910..3c4637d9dab 100644 --- a/tests/baselines/reference/decoratorMetadata.js +++ b/tests/baselines/reference/decoratorMetadata.js @@ -24,16 +24,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Service; //// [component.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +var service_1 = require("./service"); var MyComponent = (function () { function MyComponent(Service) { this.Service = Service; diff --git a/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js b/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js index 204b1ba9a49..911a93f948d 100644 --- a/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js +++ b/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js @@ -20,12 +20,11 @@ var MyClass = (function () { } MyClass.prototype.doSomething = function () { }; - Object.defineProperty(MyClass.prototype, "doSomething", - __decorate([ - decorator, - __metadata('design:type', Function), - __metadata('design:paramtypes', []), - __metadata('design:returntype', void 0) - ], MyClass.prototype, "doSomething", Object.getOwnPropertyDescriptor(MyClass.prototype, "doSomething"))); + __decorate([ + decorator, + __metadata('design:type', Function), + __metadata('design:paramtypes', []), + __metadata('design:returntype', void 0) + ], MyClass.prototype, "doSomething", null); return MyClass; })(); diff --git a/tests/baselines/reference/decoratorMetadataOnInferredType.js b/tests/baselines/reference/decoratorMetadataOnInferredType.js new file mode 100644 index 00000000000..32aeca93c1b --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataOnInferredType.js @@ -0,0 +1,39 @@ +//// [decoratorMetadataOnInferredType.ts] + +declare var console: { + log(msg: string): void; +}; + +class A { + constructor() { console.log('new A'); } +} + +function decorator(target: Object, propertyKey: string) { +} + +export class B { + @decorator + x = new A(); +} + + +//// [decoratorMetadataOnInferredType.js] +var A = (function () { + function A() { + console.log('new A'); + } + return A; +})(); +function decorator(target, propertyKey) { +} +var B = (function () { + function B() { + this.x = new A(); + } + __decorate([ + decorator, + __metadata('design:type', Object) + ], B.prototype, "x", void 0); + return B; +})(); +exports.B = B; diff --git a/tests/baselines/reference/decoratorMetadataOnInferredType.symbols b/tests/baselines/reference/decoratorMetadataOnInferredType.symbols new file mode 100644 index 00000000000..e1507c75e94 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataOnInferredType.symbols @@ -0,0 +1,38 @@ +=== tests/cases/compiler/decoratorMetadataOnInferredType.ts === + +declare var console: { +>console : Symbol(console, Decl(decoratorMetadataOnInferredType.ts, 1, 11)) + + log(msg: string): void; +>log : Symbol(log, Decl(decoratorMetadataOnInferredType.ts, 1, 22)) +>msg : Symbol(msg, Decl(decoratorMetadataOnInferredType.ts, 2, 8)) + +}; + +class A { +>A : Symbol(A, Decl(decoratorMetadataOnInferredType.ts, 3, 2)) + + constructor() { console.log('new A'); } +>console.log : Symbol(log, Decl(decoratorMetadataOnInferredType.ts, 1, 22)) +>console : Symbol(console, Decl(decoratorMetadataOnInferredType.ts, 1, 11)) +>log : Symbol(log, Decl(decoratorMetadataOnInferredType.ts, 1, 22)) +} + +function decorator(target: Object, propertyKey: string) { +>decorator : Symbol(decorator, Decl(decoratorMetadataOnInferredType.ts, 7, 1)) +>target : Symbol(target, Decl(decoratorMetadataOnInferredType.ts, 9, 19)) +>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) +>propertyKey : Symbol(propertyKey, Decl(decoratorMetadataOnInferredType.ts, 9, 34)) +} + +export class B { +>B : Symbol(B, Decl(decoratorMetadataOnInferredType.ts, 10, 1)) + + @decorator +>decorator : Symbol(decorator, Decl(decoratorMetadataOnInferredType.ts, 7, 1)) + + x = new A(); +>x : Symbol(x, Decl(decoratorMetadataOnInferredType.ts, 12, 16)) +>A : Symbol(A, Decl(decoratorMetadataOnInferredType.ts, 3, 2)) +} + diff --git a/tests/baselines/reference/decoratorMetadataOnInferredType.types b/tests/baselines/reference/decoratorMetadataOnInferredType.types new file mode 100644 index 00000000000..41c9334244f --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataOnInferredType.types @@ -0,0 +1,41 @@ +=== tests/cases/compiler/decoratorMetadataOnInferredType.ts === + +declare var console: { +>console : { log(msg: string): void; } + + log(msg: string): void; +>log : (msg: string) => void +>msg : string + +}; + +class A { +>A : A + + constructor() { console.log('new A'); } +>console.log('new A') : void +>console.log : (msg: string) => void +>console : { log(msg: string): void; } +>log : (msg: string) => void +>'new A' : string +} + +function decorator(target: Object, propertyKey: string) { +>decorator : (target: Object, propertyKey: string) => void +>target : Object +>Object : Object +>propertyKey : string +} + +export class B { +>B : B + + @decorator +>decorator : (target: Object, propertyKey: string) => void + + x = new A(); +>x : A +>new A() : A +>A : typeof A +} + diff --git a/tests/baselines/reference/decoratorMetadataWithConstructorType.js b/tests/baselines/reference/decoratorMetadataWithConstructorType.js new file mode 100644 index 00000000000..717ae5c4ce2 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithConstructorType.js @@ -0,0 +1,39 @@ +//// [decoratorMetadataWithConstructorType.ts] + +declare var console: { + log(msg: string): void; +}; + +class A { + constructor() { console.log('new A'); } +} + +function decorator(target: Object, propertyKey: string) { +} + +export class B { + @decorator + x: A = new A(); +} + + +//// [decoratorMetadataWithConstructorType.js] +var A = (function () { + function A() { + console.log('new A'); + } + return A; +})(); +function decorator(target, propertyKey) { +} +var B = (function () { + function B() { + this.x = new A(); + } + __decorate([ + decorator, + __metadata('design:type', A) + ], B.prototype, "x", void 0); + return B; +})(); +exports.B = B; diff --git a/tests/baselines/reference/decoratorMetadataWithConstructorType.symbols b/tests/baselines/reference/decoratorMetadataWithConstructorType.symbols new file mode 100644 index 00000000000..57221f0d139 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithConstructorType.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/decoratorMetadataWithConstructorType.ts === + +declare var console: { +>console : Symbol(console, Decl(decoratorMetadataWithConstructorType.ts, 1, 11)) + + log(msg: string): void; +>log : Symbol(log, Decl(decoratorMetadataWithConstructorType.ts, 1, 22)) +>msg : Symbol(msg, Decl(decoratorMetadataWithConstructorType.ts, 2, 8)) + +}; + +class A { +>A : Symbol(A, Decl(decoratorMetadataWithConstructorType.ts, 3, 2)) + + constructor() { console.log('new A'); } +>console.log : Symbol(log, Decl(decoratorMetadataWithConstructorType.ts, 1, 22)) +>console : Symbol(console, Decl(decoratorMetadataWithConstructorType.ts, 1, 11)) +>log : Symbol(log, Decl(decoratorMetadataWithConstructorType.ts, 1, 22)) +} + +function decorator(target: Object, propertyKey: string) { +>decorator : Symbol(decorator, Decl(decoratorMetadataWithConstructorType.ts, 7, 1)) +>target : Symbol(target, Decl(decoratorMetadataWithConstructorType.ts, 9, 19)) +>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11)) +>propertyKey : Symbol(propertyKey, Decl(decoratorMetadataWithConstructorType.ts, 9, 34)) +} + +export class B { +>B : Symbol(B, Decl(decoratorMetadataWithConstructorType.ts, 10, 1)) + + @decorator +>decorator : Symbol(decorator, Decl(decoratorMetadataWithConstructorType.ts, 7, 1)) + + x: A = new A(); +>x : Symbol(x, Decl(decoratorMetadataWithConstructorType.ts, 12, 16)) +>A : Symbol(A, Decl(decoratorMetadataWithConstructorType.ts, 3, 2)) +>A : Symbol(A, Decl(decoratorMetadataWithConstructorType.ts, 3, 2)) +} + diff --git a/tests/baselines/reference/decoratorMetadataWithConstructorType.types b/tests/baselines/reference/decoratorMetadataWithConstructorType.types new file mode 100644 index 00000000000..ad83706f4f9 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithConstructorType.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/decoratorMetadataWithConstructorType.ts === + +declare var console: { +>console : { log(msg: string): void; } + + log(msg: string): void; +>log : (msg: string) => void +>msg : string + +}; + +class A { +>A : A + + constructor() { console.log('new A'); } +>console.log('new A') : void +>console.log : (msg: string) => void +>console : { log(msg: string): void; } +>log : (msg: string) => void +>'new A' : string +} + +function decorator(target: Object, propertyKey: string) { +>decorator : (target: Object, propertyKey: string) => void +>target : Object +>Object : Object +>propertyKey : string +} + +export class B { +>B : B + + @decorator +>decorator : (target: Object, propertyKey: string) => void + + x: A = new A(); +>x : A +>A : A +>new A() : A +>A : typeof A +} + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js new file mode 100644 index 00000000000..392506e5368 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision.ts] //// + +//// [db.ts] +export class db { + public doSomething() { + } +} + +//// [service.ts] +import {db} from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db; + + constructor(db: db) { + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +exports.db = db; +//// [service.js] +var db_1 = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db_1.db]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.symbols new file mode 100644 index 00000000000..c967239df99 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.symbols @@ -0,0 +1,51 @@ +=== tests/cases/compiler/db.ts === +export class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17)) + } +} + +=== tests/cases/compiler/service.ts === +import {db} from './db'; +>db : Symbol(db, Decl(service.ts, 0, 8)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 24)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 24)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: db; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 0, 8)) + + constructor(db: db) { +>db : Symbol(db, Decl(service.ts, 8, 16)) +>db : Symbol(db, Decl(service.ts, 0, 8)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 17)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 17)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.types new file mode 100644 index 00000000000..aa705735f3e --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.types @@ -0,0 +1,53 @@ +=== tests/cases/compiler/db.ts === +export class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + +=== tests/cases/compiler/service.ts === +import {db} from './db'; +>db : typeof db + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: db; +>db : db +>db : db + + constructor(db: db) { +>db : db +>db : db + + this.db = db; +>this.db = db : db +>this.db : db +>this : this +>db : db +>db : db + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : db +>this : this +>db : db +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js new file mode 100644 index 00000000000..da011acf110 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision2.ts] //// + +//// [db.ts] +export class db { + public doSomething() { + } +} + +//// [service.ts] +import {db as Database} from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: Database; + + constructor(db: Database) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +exports.db = db; +//// [service.js] +var db_1 = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db_1.db]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.symbols new file mode 100644 index 00000000000..d79b05f68f6 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.symbols @@ -0,0 +1,52 @@ +=== tests/cases/compiler/db.ts === +export class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17)) + } +} + +=== tests/cases/compiler/service.ts === +import {db as Database} from './db'; +>db : Symbol(Database, Decl(service.ts, 0, 8)) +>Database : Symbol(Database, Decl(service.ts, 0, 8)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 36)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 36)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: Database; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>Database : Symbol(Database, Decl(service.ts, 0, 8)) + + constructor(db: Database) { // no collision +>db : Symbol(db, Decl(service.ts, 8, 16)) +>Database : Symbol(Database, Decl(service.ts, 0, 8)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(Database.doSomething, Decl(db.ts, 0, 17)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(Database.doSomething, Decl(db.ts, 0, 17)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.types new file mode 100644 index 00000000000..3d8ad0937bc --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.types @@ -0,0 +1,54 @@ +=== tests/cases/compiler/db.ts === +export class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + +=== tests/cases/compiler/service.ts === +import {db as Database} from './db'; +>db : typeof Database +>Database : typeof Database + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: Database; +>db : Database +>Database : Database + + constructor(db: Database) { // no collision +>db : Database +>Database : Database + + this.db = db; +>this.db = db : Database +>this.db : Database +>this : this +>db : Database +>db : Database + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : Database +>this : this +>db : Database +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js new file mode 100644 index 00000000000..b219bba4102 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision3.ts] //// + +//// [db.ts] +export class db { + public doSomething() { + } +} + +//// [service.ts] +import db = require('./db'); +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; + + constructor(db: db.db) { // collision with namespace of external module db + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +exports.db = db; +//// [service.js] +var db = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db.db]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.symbols new file mode 100644 index 00000000000..b34468c7bd5 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.symbols @@ -0,0 +1,53 @@ +=== tests/cases/compiler/service.ts === +import db = require('./db'); +>db : Symbol(db, Decl(service.ts, 0, 0)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: db.db; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 0, 0)) +>db : Symbol(db.db, Decl(db.ts, 0, 0)) + + constructor(db: db.db) { // collision with namespace of external module db +>db : Symbol(db, Decl(service.ts, 8, 16)) +>db : Symbol(db, Decl(service.ts, 0, 0)) +>db : Symbol(db.db, Decl(db.ts, 0, 0)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(db.db.doSomething, Decl(db.ts, 0, 17)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(db.db.doSomething, Decl(db.ts, 0, 17)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + +=== tests/cases/compiler/db.ts === +export class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17)) + } +} + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.types new file mode 100644 index 00000000000..634c45e650c --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.types @@ -0,0 +1,55 @@ +=== tests/cases/compiler/service.ts === +import db = require('./db'); +>db : typeof db + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: db.db; +>db : db.db +>db : any +>db : db.db + + constructor(db: db.db) { // collision with namespace of external module db +>db : db.db +>db : any +>db : db.db + + this.db = db; +>this.db = db : db.db +>this.db : db.db +>this : this +>db : db.db +>db : db.db + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : db.db +>this : this +>db : db.db +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + +=== tests/cases/compiler/db.ts === +export class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.errors.txt b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.errors.txt new file mode 100644 index 00000000000..611a0804812 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/service.ts(1,8): error TS1192: Module '"tests/cases/compiler/db"' has no default export. + + +==== tests/cases/compiler/db.ts (0 errors) ==== + export class db { + public doSomething() { + } + } + +==== tests/cases/compiler/service.ts (1 errors) ==== + import db from './db'; // error no default export + ~~ +!!! error TS1192: Module '"tests/cases/compiler/db"' has no default export. + function someDecorator(target) { + return target; + } + @someDecorator + class MyClass { + db: db.db; + + constructor(db: db.db) { + this.db = db; + this.db.doSomething(); + } + } + export {MyClass}; + \ No newline at end of file diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js new file mode 100644 index 00000000000..d0d201e62b5 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision4.ts] //// + +//// [db.ts] +export class db { + public doSomething() { + } +} + +//// [service.ts] +import db from './db'; // error no default export +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; + + constructor(db: db.db) { + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +exports.db = db; +//// [service.js] +var db_1 = require('./db'); // error no default export +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [Object]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js new file mode 100644 index 00000000000..a2599515338 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision5.ts] //// + +//// [db.ts] +export default class db { + public doSomething() { + } +} + +//// [service.ts] +import db from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db; + + constructor(db: db) { // collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = db; +//// [service.js] +var db_1 = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db_1.default]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.symbols new file mode 100644 index 00000000000..6047d7f2882 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.symbols @@ -0,0 +1,51 @@ +=== tests/cases/compiler/db.ts === +export default class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 25)) + } +} + +=== tests/cases/compiler/service.ts === +import db from './db'; +>db : Symbol(db, Decl(service.ts, 0, 6)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 22)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 22)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: db; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 0, 6)) + + constructor(db: db) { // collision +>db : Symbol(db, Decl(service.ts, 8, 16)) +>db : Symbol(db, Decl(service.ts, 0, 6)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 25)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(db.doSomething, Decl(db.ts, 0, 25)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.types new file mode 100644 index 00000000000..987d7a532e8 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.types @@ -0,0 +1,53 @@ +=== tests/cases/compiler/db.ts === +export default class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + +=== tests/cases/compiler/service.ts === +import db from './db'; +>db : typeof db + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: db; +>db : db +>db : db + + constructor(db: db) { // collision +>db : db +>db : db + + this.db = db; +>this.db = db : db +>this.db : db +>this : this +>db : db +>db : db + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : db +>this : this +>db : db +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js new file mode 100644 index 00000000000..917cdc7036f --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision6.ts] //// + +//// [db.ts] +export default class db { + public doSomething() { + } +} + +//// [service.ts] +import database from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: database; + + constructor(db: database) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = db; +//// [service.js] +var db_1 = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db_1.default]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.symbols new file mode 100644 index 00000000000..27f807503bf --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.symbols @@ -0,0 +1,51 @@ +=== tests/cases/compiler/db.ts === +export default class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 25)) + } +} + +=== tests/cases/compiler/service.ts === +import database from './db'; +>database : Symbol(database, Decl(service.ts, 0, 6)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 28)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: database; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>database : Symbol(database, Decl(service.ts, 0, 6)) + + constructor(db: database) { // no collision +>db : Symbol(db, Decl(service.ts, 8, 16)) +>database : Symbol(database, Decl(service.ts, 0, 6)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(database.doSomething, Decl(db.ts, 0, 25)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(database.doSomething, Decl(db.ts, 0, 25)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.types new file mode 100644 index 00000000000..3bd8df0eff3 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.types @@ -0,0 +1,53 @@ +=== tests/cases/compiler/db.ts === +export default class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + +=== tests/cases/compiler/service.ts === +import database from './db'; +>database : typeof database + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: database; +>db : database +>database : database + + constructor(db: database) { // no collision +>db : database +>database : database + + this.db = db; +>this.db = db : database +>this.db : database +>this : this +>db : database +>db : database + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : database +>this : this +>db : database +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.errors.txt b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.errors.txt new file mode 100644 index 00000000000..d4b714f1d4a --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.errors.txt @@ -0,0 +1,30 @@ +tests/cases/compiler/service.ts(7,9): error TS2503: Cannot find namespace 'db'. +tests/cases/compiler/service.ts(9,21): error TS2503: Cannot find namespace 'db'. + + +==== tests/cases/compiler/db.ts (0 errors) ==== + export default class db { + public doSomething() { + } + } + +==== tests/cases/compiler/service.ts (2 errors) ==== + import db from './db'; + function someDecorator(target) { + return target; + } + @someDecorator + class MyClass { + db: db.db; //error + ~~ +!!! error TS2503: Cannot find namespace 'db'. + + constructor(db: db.db) { // error + ~~ +!!! error TS2503: Cannot find namespace 'db'. + this.db = db; + this.db.doSomething(); + } + } + export {MyClass}; + \ No newline at end of file diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js new file mode 100644 index 00000000000..1dd93b12915 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts] //// + +//// [db.ts] +export default class db { + public doSomething() { + } +} + +//// [service.ts] +import db from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; //error + + constructor(db: db.db) { // error + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = db; +//// [service.js] +var db_1 = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [Object]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js new file mode 100644 index 00000000000..0aee9e471dd --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision8.ts] //// + +//// [db.ts] +export class db { + public doSomething() { + } +} + +//// [service.ts] +import database = require('./db'); +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: database.db; + + constructor(db: database.db) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; + + +//// [db.js] +var db = (function () { + function db() { + } + db.prototype.doSomething = function () { + }; + return db; +})(); +exports.db = db; +//// [service.js] +var database = require('./db'); +function someDecorator(target) { + return target; +} +var MyClass = (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [database.db]) + ], MyClass); + return MyClass; +})(); +exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.symbols b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.symbols new file mode 100644 index 00000000000..1b73ea2e9a3 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.symbols @@ -0,0 +1,53 @@ +=== tests/cases/compiler/service.ts === +import database = require('./db'); +>database : Symbol(database, Decl(service.ts, 0, 0)) + +function someDecorator(target) { +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 34)) +>target : Symbol(target, Decl(service.ts, 1, 23)) + + return target; +>target : Symbol(target, Decl(service.ts, 1, 23)) +} +@someDecorator +>someDecorator : Symbol(someDecorator, Decl(service.ts, 0, 34)) + +class MyClass { +>MyClass : Symbol(MyClass, Decl(service.ts, 3, 1)) + + db: database.db; +>db : Symbol(db, Decl(service.ts, 5, 15)) +>database : Symbol(database, Decl(service.ts, 0, 0)) +>db : Symbol(database.db, Decl(db.ts, 0, 0)) + + constructor(db: database.db) { // no collision +>db : Symbol(db, Decl(service.ts, 8, 16)) +>database : Symbol(database, Decl(service.ts, 0, 0)) +>db : Symbol(database.db, Decl(db.ts, 0, 0)) + + this.db = db; +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>db : Symbol(db, Decl(service.ts, 8, 16)) + + this.db.doSomething(); +>this.db.doSomething : Symbol(database.db.doSomething, Decl(db.ts, 0, 17)) +>this.db : Symbol(db, Decl(service.ts, 5, 15)) +>this : Symbol(MyClass, Decl(service.ts, 3, 1)) +>db : Symbol(db, Decl(service.ts, 5, 15)) +>doSomething : Symbol(database.db.doSomething, Decl(db.ts, 0, 17)) + } +} +export {MyClass}; +>MyClass : Symbol(MyClass, Decl(service.ts, 13, 8)) + +=== tests/cases/compiler/db.ts === +export class db { +>db : Symbol(db, Decl(db.ts, 0, 0)) + + public doSomething() { +>doSomething : Symbol(doSomething, Decl(db.ts, 0, 17)) + } +} + diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.types b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.types new file mode 100644 index 00000000000..f0f1ca190aa --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.types @@ -0,0 +1,55 @@ +=== tests/cases/compiler/service.ts === +import database = require('./db'); +>database : typeof database + +function someDecorator(target) { +>someDecorator : (target: any) => any +>target : any + + return target; +>target : any +} +@someDecorator +>someDecorator : (target: any) => any + +class MyClass { +>MyClass : MyClass + + db: database.db; +>db : database.db +>database : any +>db : database.db + + constructor(db: database.db) { // no collision +>db : database.db +>database : any +>db : database.db + + this.db = db; +>this.db = db : database.db +>this.db : database.db +>this : this +>db : database.db +>db : database.db + + this.db.doSomething(); +>this.db.doSomething() : void +>this.db.doSomething : () => void +>this.db : database.db +>this : this +>db : database.db +>doSomething : () => void + } +} +export {MyClass}; +>MyClass : typeof MyClass + +=== tests/cases/compiler/db.ts === +export class db { +>db : db + + public doSomething() { +>doSomething : () => void + } +} + diff --git a/tests/baselines/reference/decoratorOnClass1.js b/tests/baselines/reference/decoratorOnClass1.js index b8099222acc..81fb8a4afbf 100644 --- a/tests/baselines/reference/decoratorOnClass1.js +++ b/tests/baselines/reference/decoratorOnClass1.js @@ -7,12 +7,10 @@ class C { //// [decoratorOnClass1.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { diff --git a/tests/baselines/reference/decoratorOnClass2.js b/tests/baselines/reference/decoratorOnClass2.js index 18492794331..5e5f4e4b07d 100644 --- a/tests/baselines/reference/decoratorOnClass2.js +++ b/tests/baselines/reference/decoratorOnClass2.js @@ -7,12 +7,10 @@ export class C { //// [decoratorOnClass2.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { diff --git a/tests/baselines/reference/decoratorOnClass3.js b/tests/baselines/reference/decoratorOnClass3.js index 2291a2dbc57..53888b7f107 100644 --- a/tests/baselines/reference/decoratorOnClass3.js +++ b/tests/baselines/reference/decoratorOnClass3.js @@ -8,12 +8,10 @@ class C { //// [decoratorOnClass3.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { diff --git a/tests/baselines/reference/decoratorOnClass4.js b/tests/baselines/reference/decoratorOnClass4.js index 484efdf6128..bfcfe490498 100644 --- a/tests/baselines/reference/decoratorOnClass4.js +++ b/tests/baselines/reference/decoratorOnClass4.js @@ -7,12 +7,10 @@ class C { //// [decoratorOnClass4.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { diff --git a/tests/baselines/reference/decoratorOnClass5.js b/tests/baselines/reference/decoratorOnClass5.js index 02ea01c3fd6..b3ceb807408 100644 --- a/tests/baselines/reference/decoratorOnClass5.js +++ b/tests/baselines/reference/decoratorOnClass5.js @@ -7,12 +7,10 @@ class C { //// [decoratorOnClass5.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { diff --git a/tests/baselines/reference/decoratorOnClass8.js b/tests/baselines/reference/decoratorOnClass8.js index e75ccac3c86..81edefc39fa 100644 --- a/tests/baselines/reference/decoratorOnClass8.js +++ b/tests/baselines/reference/decoratorOnClass8.js @@ -7,12 +7,10 @@ class C { //// [decoratorOnClass8.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { diff --git a/tests/baselines/reference/decoratorOnClassAccessor1.js b/tests/baselines/reference/decoratorOnClassAccessor1.js index 2700c531e42..5a5d7ec98ee 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor1.js +++ b/tests/baselines/reference/decoratorOnClassAccessor1.js @@ -7,12 +7,10 @@ class C { //// [decoratorOnClassAccessor1.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { @@ -22,9 +20,8 @@ var C = (function () { enumerable: true, configurable: true }); - Object.defineProperty(C.prototype, "accessor", - __decorate([ - dec - ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); + __decorate([ + dec + ], C.prototype, "accessor", null); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassAccessor2.js b/tests/baselines/reference/decoratorOnClassAccessor2.js index c29c7598013..62b4d46669b 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor2.js +++ b/tests/baselines/reference/decoratorOnClassAccessor2.js @@ -7,12 +7,10 @@ class C { //// [decoratorOnClassAccessor2.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { @@ -22,9 +20,8 @@ var C = (function () { enumerable: true, configurable: true }); - Object.defineProperty(C.prototype, "accessor", - __decorate([ - dec - ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); + __decorate([ + dec + ], C.prototype, "accessor", null); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassAccessor3.js b/tests/baselines/reference/decoratorOnClassAccessor3.js index 61430a986ac..ce630dde3b2 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor3.js +++ b/tests/baselines/reference/decoratorOnClassAccessor3.js @@ -7,12 +7,10 @@ class C { //// [decoratorOnClassAccessor3.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { @@ -22,9 +20,8 @@ var C = (function () { enumerable: true, configurable: true }); - Object.defineProperty(C.prototype, "accessor", - __decorate([ - dec - ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); + __decorate([ + dec + ], C.prototype, "accessor", null); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassAccessor4.js b/tests/baselines/reference/decoratorOnClassAccessor4.js index 0ad11c4c09e..5d47233c797 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor4.js +++ b/tests/baselines/reference/decoratorOnClassAccessor4.js @@ -7,12 +7,10 @@ class C { //// [decoratorOnClassAccessor4.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { @@ -22,9 +20,8 @@ var C = (function () { enumerable: true, configurable: true }); - Object.defineProperty(C.prototype, "accessor", - __decorate([ - dec - ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); + __decorate([ + dec + ], C.prototype, "accessor", null); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassAccessor5.js b/tests/baselines/reference/decoratorOnClassAccessor5.js index 53a43f7912c..b0383637272 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor5.js +++ b/tests/baselines/reference/decoratorOnClassAccessor5.js @@ -7,12 +7,10 @@ class C { //// [decoratorOnClassAccessor5.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { @@ -22,9 +20,8 @@ var C = (function () { enumerable: true, configurable: true }); - Object.defineProperty(C.prototype, "accessor", - __decorate([ - dec - ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); + __decorate([ + dec + ], C.prototype, "accessor", null); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassAccessor6.js b/tests/baselines/reference/decoratorOnClassAccessor6.js index eaa21f45234..e76151ef562 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor6.js +++ b/tests/baselines/reference/decoratorOnClassAccessor6.js @@ -7,12 +7,10 @@ class C { //// [decoratorOnClassAccessor6.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { @@ -22,9 +20,8 @@ var C = (function () { enumerable: true, configurable: true }); - Object.defineProperty(C.prototype, "accessor", - __decorate([ - dec - ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); + __decorate([ + dec + ], C.prototype, "accessor", null); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassConstructorParameter1.js b/tests/baselines/reference/decoratorOnClassConstructorParameter1.js index b2af1450123..b100a5a60f8 100644 --- a/tests/baselines/reference/decoratorOnClassConstructorParameter1.js +++ b/tests/baselines/reference/decoratorOnClassConstructorParameter1.js @@ -7,12 +7,10 @@ class C { //// [decoratorOnClassConstructorParameter1.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } diff --git a/tests/baselines/reference/decoratorOnClassConstructorParameter4.js b/tests/baselines/reference/decoratorOnClassConstructorParameter4.js index 5273482586e..73d7bfba5a9 100644 --- a/tests/baselines/reference/decoratorOnClassConstructorParameter4.js +++ b/tests/baselines/reference/decoratorOnClassConstructorParameter4.js @@ -7,12 +7,10 @@ class C { //// [decoratorOnClassConstructorParameter4.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } diff --git a/tests/baselines/reference/decoratorOnClassMethod1.js b/tests/baselines/reference/decoratorOnClassMethod1.js index 65c2f4b6008..3b8d308570c 100644 --- a/tests/baselines/reference/decoratorOnClassMethod1.js +++ b/tests/baselines/reference/decoratorOnClassMethod1.js @@ -7,20 +7,17 @@ class C { //// [decoratorOnClassMethod1.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { } C.prototype.method = function () { }; - Object.defineProperty(C.prototype, "method", - __decorate([ - dec - ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + __decorate([ + dec + ], C.prototype, "method", null); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassMethod10.js b/tests/baselines/reference/decoratorOnClassMethod10.js index bae4e97fb5b..22a6be7f613 100644 --- a/tests/baselines/reference/decoratorOnClassMethod10.js +++ b/tests/baselines/reference/decoratorOnClassMethod10.js @@ -7,20 +7,17 @@ class C { //// [decoratorOnClassMethod10.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { } C.prototype.method = function () { }; - Object.defineProperty(C.prototype, "method", - __decorate([ - dec - ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + __decorate([ + dec + ], C.prototype, "method", null); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassMethod11.js b/tests/baselines/reference/decoratorOnClassMethod11.js index 5d4ac60c14e..59f0594f483 100644 --- a/tests/baselines/reference/decoratorOnClassMethod11.js +++ b/tests/baselines/reference/decoratorOnClassMethod11.js @@ -10,12 +10,10 @@ module M { //// [decoratorOnClassMethod11.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var M; (function (M) { @@ -24,10 +22,9 @@ var M; } C.prototype.decorator = function (target, key) { }; C.prototype.method = function () { }; - Object.defineProperty(C.prototype, "method", - __decorate([ - this.decorator - ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + __decorate([ + this.decorator + ], C.prototype, "method", null); return C; })(); })(M || (M = {})); diff --git a/tests/baselines/reference/decoratorOnClassMethod12.js b/tests/baselines/reference/decoratorOnClassMethod12.js index 05c4f285291..5c43251e4c1 100644 --- a/tests/baselines/reference/decoratorOnClassMethod12.js +++ b/tests/baselines/reference/decoratorOnClassMethod12.js @@ -16,12 +16,10 @@ var __extends = (this && this.__extends) || function (d, b) { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var M; (function (M) { @@ -37,10 +35,9 @@ var M; _super.apply(this, arguments); } C.prototype.method = function () { }; - Object.defineProperty(C.prototype, "method", - __decorate([ - _super.decorator - ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + __decorate([ + _super.decorator + ], C.prototype, "method", null); return C; })(S); })(M || (M = {})); diff --git a/tests/baselines/reference/decoratorOnClassMethod13.js b/tests/baselines/reference/decoratorOnClassMethod13.js index b39fa63686a..adf21f733eb 100644 --- a/tests/baselines/reference/decoratorOnClassMethod13.js +++ b/tests/baselines/reference/decoratorOnClassMethod13.js @@ -8,23 +8,19 @@ class C { //// [decoratorOnClassMethod13.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; class C { [_a = "1"]() { } [_b = "b"]() { } } -Object.defineProperty(C.prototype, _a, - __decorate([ - dec - ], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); -Object.defineProperty(C.prototype, _b, - __decorate([ - dec - ], C.prototype, _b, Object.getOwnPropertyDescriptor(C.prototype, _b))); +__decorate([ + dec +], C.prototype, _a, null); +__decorate([ + dec +], C.prototype, _b, null); var _a, _b; diff --git a/tests/baselines/reference/decoratorOnClassMethod2.js b/tests/baselines/reference/decoratorOnClassMethod2.js index 8b4ceeb47ee..1841baeb724 100644 --- a/tests/baselines/reference/decoratorOnClassMethod2.js +++ b/tests/baselines/reference/decoratorOnClassMethod2.js @@ -7,20 +7,17 @@ class C { //// [decoratorOnClassMethod2.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { } C.prototype.method = function () { }; - Object.defineProperty(C.prototype, "method", - __decorate([ - dec - ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + __decorate([ + dec + ], C.prototype, "method", null); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassMethod3.js b/tests/baselines/reference/decoratorOnClassMethod3.js index fff0e845860..8ede72027d8 100644 --- a/tests/baselines/reference/decoratorOnClassMethod3.js +++ b/tests/baselines/reference/decoratorOnClassMethod3.js @@ -7,20 +7,17 @@ class C { //// [decoratorOnClassMethod3.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { } C.prototype.method = function () { }; - Object.defineProperty(C.prototype, "method", - __decorate([ - dec - ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + __decorate([ + dec + ], C.prototype, "method", null); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassMethod4.js b/tests/baselines/reference/decoratorOnClassMethod4.js index 9f5b0d67eb1..5c7b91c1c83 100644 --- a/tests/baselines/reference/decoratorOnClassMethod4.js +++ b/tests/baselines/reference/decoratorOnClassMethod4.js @@ -7,18 +7,15 @@ class C { //// [decoratorOnClassMethod4.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; class C { [_a = "method"]() { } } -Object.defineProperty(C.prototype, _a, - __decorate([ - dec - ], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); +__decorate([ + dec +], C.prototype, _a, null); var _a; diff --git a/tests/baselines/reference/decoratorOnClassMethod5.js b/tests/baselines/reference/decoratorOnClassMethod5.js index f767b176207..2fedbaaf764 100644 --- a/tests/baselines/reference/decoratorOnClassMethod5.js +++ b/tests/baselines/reference/decoratorOnClassMethod5.js @@ -7,18 +7,15 @@ class C { //// [decoratorOnClassMethod5.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; class C { [_a = "method"]() { } } -Object.defineProperty(C.prototype, _a, - __decorate([ - dec() - ], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); +__decorate([ + dec() +], C.prototype, _a, null); var _a; diff --git a/tests/baselines/reference/decoratorOnClassMethod6.js b/tests/baselines/reference/decoratorOnClassMethod6.js index 33dc4c86fd2..7966225e221 100644 --- a/tests/baselines/reference/decoratorOnClassMethod6.js +++ b/tests/baselines/reference/decoratorOnClassMethod6.js @@ -7,18 +7,15 @@ class C { //// [decoratorOnClassMethod6.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; class C { [_a = "method"]() { } } -Object.defineProperty(C.prototype, _a, - __decorate([ - dec - ], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); +__decorate([ + dec +], C.prototype, _a, null); var _a; diff --git a/tests/baselines/reference/decoratorOnClassMethod7.js b/tests/baselines/reference/decoratorOnClassMethod7.js index c20a726fc46..3ec509e17f0 100644 --- a/tests/baselines/reference/decoratorOnClassMethod7.js +++ b/tests/baselines/reference/decoratorOnClassMethod7.js @@ -7,18 +7,15 @@ class C { //// [decoratorOnClassMethod7.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; class C { [_a = "method"]() { } } -Object.defineProperty(C.prototype, _a, - __decorate([ - dec - ], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a))); +__decorate([ + dec +], C.prototype, _a, null); var _a; diff --git a/tests/baselines/reference/decoratorOnClassMethod8.js b/tests/baselines/reference/decoratorOnClassMethod8.js index a664bdb8494..2cb404cf078 100644 --- a/tests/baselines/reference/decoratorOnClassMethod8.js +++ b/tests/baselines/reference/decoratorOnClassMethod8.js @@ -7,20 +7,17 @@ class C { //// [decoratorOnClassMethod8.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { } C.prototype.method = function () { }; - Object.defineProperty(C.prototype, "method", - __decorate([ - dec - ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + __decorate([ + dec + ], C.prototype, "method", null); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassMethodParameter1.js b/tests/baselines/reference/decoratorOnClassMethodParameter1.js index a6ab1704acc..099f746727c 100644 --- a/tests/baselines/reference/decoratorOnClassMethodParameter1.js +++ b/tests/baselines/reference/decoratorOnClassMethodParameter1.js @@ -7,12 +7,10 @@ class C { //// [decoratorOnClassMethodParameter1.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } @@ -21,9 +19,8 @@ var C = (function () { function C() { } C.prototype.method = function (p) { }; - Object.defineProperty(C.prototype, "method", - __decorate([ - __param(0, dec) - ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + __decorate([ + __param(0, dec) + ], C.prototype, "method", null); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassProperty1.js b/tests/baselines/reference/decoratorOnClassProperty1.js index 567eb510cb3..9283570bf3a 100644 --- a/tests/baselines/reference/decoratorOnClassProperty1.js +++ b/tests/baselines/reference/decoratorOnClassProperty1.js @@ -7,18 +7,16 @@ class C { //// [decoratorOnClassProperty1.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { } __decorate([ dec - ], C.prototype, "prop"); + ], C.prototype, "prop", void 0); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassProperty10.js b/tests/baselines/reference/decoratorOnClassProperty10.js index b64986a8c97..5246dff9643 100644 --- a/tests/baselines/reference/decoratorOnClassProperty10.js +++ b/tests/baselines/reference/decoratorOnClassProperty10.js @@ -7,18 +7,16 @@ class C { //// [decoratorOnClassProperty10.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { } __decorate([ dec() - ], C.prototype, "prop"); + ], C.prototype, "prop", void 0); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassProperty11.js b/tests/baselines/reference/decoratorOnClassProperty11.js index a33fc724180..51bce1f1385 100644 --- a/tests/baselines/reference/decoratorOnClassProperty11.js +++ b/tests/baselines/reference/decoratorOnClassProperty11.js @@ -7,18 +7,16 @@ class C { //// [decoratorOnClassProperty11.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { } __decorate([ dec - ], C.prototype, "prop"); + ], C.prototype, "prop", void 0); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassProperty2.js b/tests/baselines/reference/decoratorOnClassProperty2.js index f5de593b057..153c72ce0b9 100644 --- a/tests/baselines/reference/decoratorOnClassProperty2.js +++ b/tests/baselines/reference/decoratorOnClassProperty2.js @@ -7,18 +7,16 @@ class C { //// [decoratorOnClassProperty2.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { } __decorate([ dec - ], C.prototype, "prop"); + ], C.prototype, "prop", void 0); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassProperty3.js b/tests/baselines/reference/decoratorOnClassProperty3.js index d2876d2cd6a..4f3b1ca5929 100644 --- a/tests/baselines/reference/decoratorOnClassProperty3.js +++ b/tests/baselines/reference/decoratorOnClassProperty3.js @@ -7,18 +7,16 @@ class C { //// [decoratorOnClassProperty3.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { } __decorate([ dec - ], C.prototype, "prop"); + ], C.prototype, "prop", void 0); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassProperty6.js b/tests/baselines/reference/decoratorOnClassProperty6.js index 4ebd19ceee8..e92e018c587 100644 --- a/tests/baselines/reference/decoratorOnClassProperty6.js +++ b/tests/baselines/reference/decoratorOnClassProperty6.js @@ -7,18 +7,16 @@ class C { //// [decoratorOnClassProperty6.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { } __decorate([ dec - ], C.prototype, "prop"); + ], C.prototype, "prop", void 0); return C; })(); diff --git a/tests/baselines/reference/decoratorOnClassProperty7.js b/tests/baselines/reference/decoratorOnClassProperty7.js index 045f8722b97..9521fe0ce5e 100644 --- a/tests/baselines/reference/decoratorOnClassProperty7.js +++ b/tests/baselines/reference/decoratorOnClassProperty7.js @@ -7,18 +7,16 @@ class C { //// [decoratorOnClassProperty7.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { } __decorate([ dec - ], C.prototype, "prop"); + ], C.prototype, "prop", void 0); return C; })(); diff --git a/tests/baselines/reference/defaultExportsCannotMerge01.errors.txt b/tests/baselines/reference/defaultExportsCannotMerge01.errors.txt index be08d976eeb..15c60e32d9f 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge01.errors.txt +++ b/tests/baselines/reference/defaultExportsCannotMerge01.errors.txt @@ -1,9 +1,6 @@ tests/cases/conformance/es6/modules/m1.ts(2,25): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. tests/cases/conformance/es6/modules/m1.ts(11,18): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. -tests/cases/conformance/es6/modules/m2.ts(5,8): error TS2304: Cannot find name 'Entity'. -tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'. -tests/cases/conformance/es6/modules/m2.ts(8,8): error TS2339: Property 'x' does not exist on type '() => number'. -tests/cases/conformance/es6/modules/m2.ts(9,8): error TS2339: Property 'y' does not exist on type '() => number'. +tests/cases/conformance/es6/modules/m2.ts(1,20): error TS2307: Cannot find module 'm1'. ==== tests/cases/conformance/es6/modules/m1.ts (2 errors) ==== @@ -29,21 +26,15 @@ tests/cases/conformance/es6/modules/m2.ts(9,8): error TS2339: Property 'y' does } } -==== tests/cases/conformance/es6/modules/m2.ts (4 errors) ==== +==== tests/cases/conformance/es6/modules/m2.ts (1 errors) ==== import Entity from "m1" + ~~~~ +!!! error TS2307: Cannot find module 'm1'. Entity(); var x: Entity; - ~~~~~~ -!!! error TS2304: Cannot find name 'Entity'. var y: Entity.I; - ~~~~~~ -!!! error TS2503: Cannot find namespace 'Entity'. Entity.x; - ~ -!!! error TS2339: Property 'x' does not exist on type '() => number'. - Entity.y; - ~ -!!! error TS2339: Property 'y' does not exist on type '() => number'. \ No newline at end of file + Entity.y; \ No newline at end of file diff --git a/tests/baselines/reference/defaultExportsCannotMerge02.errors.txt b/tests/baselines/reference/defaultExportsCannotMerge02.errors.txt index ad9b85c7e94..30bab504c7e 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge02.errors.txt +++ b/tests/baselines/reference/defaultExportsCannotMerge02.errors.txt @@ -1,9 +1,6 @@ tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. tests/cases/conformance/es6/modules/m1.ts(5,18): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. -tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'? -tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'. -tests/cases/conformance/es6/modules/m2.ts(8,13): error TS2339: Property 'p1' does not exist on type 'Decl'. -tests/cases/conformance/es6/modules/m2.ts(8,20): error TS2339: Property 'p2' does not exist on type 'Decl'. +tests/cases/conformance/es6/modules/m2.ts(1,20): error TS2307: Cannot find module 'm1'. ==== tests/cases/conformance/es6/modules/m1.ts (2 errors) ==== @@ -25,20 +22,14 @@ tests/cases/conformance/es6/modules/m2.ts(8,20): error TS2339: Property 'p2' doe } } -==== tests/cases/conformance/es6/modules/m2.ts (4 errors) ==== +==== tests/cases/conformance/es6/modules/m2.ts (1 errors) ==== import Entity from "m1" + ~~~~ +!!! error TS2307: Cannot find module 'm1'. Entity(); - ~~~~~~~~ -!!! error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'? var x: Entity; var y: Entity.I; - ~~~~~~ -!!! error TS2503: Cannot find namespace 'Entity'. var z = new Entity(); - var sum = z.p1 + z.p2 - ~~ -!!! error TS2339: Property 'p1' does not exist on type 'Decl'. - ~~ -!!! error TS2339: Property 'p2' does not exist on type 'Decl'. \ No newline at end of file + var sum = z.p1 + z.p2 \ No newline at end of file diff --git a/tests/baselines/reference/defaultExportsCannotMerge03.errors.txt b/tests/baselines/reference/defaultExportsCannotMerge03.errors.txt index b1d405671e3..11e9c63b893 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge03.errors.txt +++ b/tests/baselines/reference/defaultExportsCannotMerge03.errors.txt @@ -1,10 +1,7 @@ tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2518: Only an ambient class can be merged with an interface. tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead. -tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'? -tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'. -tests/cases/conformance/es6/modules/m2.ts(8,13): error TS2339: Property 'p1' does not exist on type 'Decl'. -tests/cases/conformance/es6/modules/m2.ts(8,20): error TS2339: Property 'p2' does not exist on type 'Decl'. +tests/cases/conformance/es6/modules/m2.ts(1,20): error TS2307: Cannot find module 'm1'. ==== tests/cases/conformance/es6/modules/m1.ts (3 errors) ==== @@ -28,20 +25,14 @@ tests/cases/conformance/es6/modules/m2.ts(8,20): error TS2339: Property 'p2' doe } } -==== tests/cases/conformance/es6/modules/m2.ts (4 errors) ==== +==== tests/cases/conformance/es6/modules/m2.ts (1 errors) ==== import Entity from "m1" + ~~~~ +!!! error TS2307: Cannot find module 'm1'. Entity(); - ~~~~~~~~ -!!! error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'? var x: Entity; var y: Entity.I; - ~~~~~~ -!!! error TS2503: Cannot find namespace 'Entity'. var z = new Entity(); - var sum = z.p1 + z.p2 - ~~ -!!! error TS2339: Property 'p1' does not exist on type 'Decl'. - ~~ -!!! error TS2339: Property 'p2' does not exist on type 'Decl'. \ No newline at end of file + var sum = z.p1 + z.p2 \ No newline at end of file diff --git a/tests/baselines/reference/derivedClasses.types b/tests/baselines/reference/derivedClasses.types index 906cfb2741c..7fc585e29ce 100644 --- a/tests/baselines/reference/derivedClasses.types +++ b/tests/baselines/reference/derivedClasses.types @@ -11,7 +11,7 @@ class Red extends Color { >() => { return this.hue(); } : () => string >this.hue() : string >this.hue : () => string ->this : Red +>this : this >hue : () => string return getHue() + " red"; @@ -46,7 +46,7 @@ class Blue extends Color { >() => { return this.hue(); } : () => string >this.hue() : string >this.hue : () => string ->this : Blue +>this : this >hue : () => string return getHue() + " blue"; diff --git a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.errors.txt b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.errors.txt index dc2db292eb5..19bf8d1ff22 100644 --- a/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.errors.txt +++ b/tests/baselines/reference/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts(14,28): error TS2345: Argument of type '{ a: number; b: number; }' is not assignable to parameter of type '{ a: number; }'. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts(14,36): error TS2345: Argument of type '{ a: number; b: number; }' is not assignable to parameter of type '{ a: number; }'. Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. @@ -17,7 +17,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclara bar() { var r = super.foo({ a: 1 }); // { a: number } var r2 = super.foo({ a: 1, b: 2 }); // { a: number } - ~~~~~~~~~~~~~~ + ~~~~ !!! error TS2345: Argument of type '{ a: number; b: number; }' is not assignable to parameter of type '{ a: number; }'. !!! error TS2345: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. var r3 = this.foo({ a: 1, b: 2 }); // { a: number; b: number; } diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.errors.txt new file mode 100644 index 00000000000..1f1bc85757b --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.errors.txt @@ -0,0 +1,65 @@ +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(43,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(44,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts(44,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + + +==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts (3 errors) ==== + /* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ + + // In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + // An expression of type S is considered assignable to an assignment target V if one of the following is true + + // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, + // S is the type Any, or + + var [a0, a1]: any = undefined; + var [a2 = false, a3 = 1]: any = undefined; + + // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, + // S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, + // where N is the numeric index of E in the array assignment pattern, or + var [b0, b1, b2] = [2, 3, 4]; + var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; + + function foo() { + return [1, 2, 3]; + } + + var [b6, b7] = foo(); + var [...b8] = foo(); + + // S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. + var temp = [1,2,3] + var [c0, c1] = [...temp]; + var [c2] = []; + ~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] + ~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + ~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + var [[c5], c6]: [[string|number], boolean] = [[1], true]; + var [, c7] = [1, 2, 3]; + var [,,, c8] = [1, 2, 3, 4]; + var [,,, c9] = [1, 2, 3, 4]; + var [,,,...c10] = [1, 2, 3, 4, "hello"]; + var [c11, c12, ...c13] = [1, 2, "string"]; + var [c14, c15, c16] = [1, 2, "string"]; + + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.symbols b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.symbols deleted file mode 100644 index d8e319f4120..00000000000 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.symbols +++ /dev/null @@ -1,105 +0,0 @@ -=== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts === -/* AssignmentPattern: - * ObjectAssignmentPattern - * ArrayAssignmentPattern - * ArrayAssignmentPattern: - * [Elision AssignmentRestElementopt ] - * [AssignmentElementList] - * [AssignmentElementList, Elision AssignmentRestElementopt ] - * AssignmentElementList: - * Elision AssignmentElement - * AssignmentElementList, Elisionopt AssignmentElement - * AssignmentElement: - * LeftHandSideExpression Initialiseropt - * AssignmentPattern Initialiseropt - * AssignmentRestElement: - * ... LeftHandSideExpression - */ - -// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. -// An expression of type S is considered assignable to an assignment target V if one of the following is true - -// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, -// S is the type Any, or - -var [a0, a1]: any = undefined; ->a0 : Symbol(a0, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 23, 5)) ->a1 : Symbol(a1, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 23, 8)) ->undefined : Symbol(undefined) - -var [a2 = false, a3 = 1]: any = undefined; ->a2 : Symbol(a2, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 24, 5)) ->a3 : Symbol(a3, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 24, 16)) ->undefined : Symbol(undefined) - -// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, -// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, -// where N is the numeric index of E in the array assignment pattern, or -var [b0, b1, b2] = [2, 3, 4]; ->b0 : Symbol(b0, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 29, 5)) ->b1 : Symbol(b1, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 29, 8)) ->b2 : Symbol(b2, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 29, 12)) - -var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; ->b3 : Symbol(b3, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 5)) ->b4 : Symbol(b4, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 8)) ->b5 : Symbol(b5, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 12)) - -function foo() { ->foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 62)) - - return [1, 2, 3]; -} - -var [b6, b7] = foo(); ->b6 : Symbol(b6, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 36, 5)) ->b7 : Symbol(b7, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 36, 8)) ->foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 62)) - -var [...b8] = foo(); ->b8 : Symbol(b8, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 37, 5)) ->foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 30, 62)) - -// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. -var temp = [1,2,3] ->temp : Symbol(temp, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 40, 3)) - -var [c0, c1] = [...temp]; ->c0 : Symbol(c0, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 41, 5)) ->c1 : Symbol(c1, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 41, 8)) ->temp : Symbol(temp, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 40, 3)) - -var [c2] = []; ->c2 : Symbol(c2, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 42, 5)) - -var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] ->c3 : Symbol(c3, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 43, 7)) ->c4 : Symbol(c4, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 43, 17)) - -var [[c5], c6]: [[string|number], boolean] = [[1], true]; ->c5 : Symbol(c5, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 44, 6)) ->c6 : Symbol(c6, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 44, 10)) - -var [, c7] = [1, 2, 3]; ->c7 : Symbol(c7, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 45, 6)) - -var [,,, c8] = [1, 2, 3, 4]; ->c8 : Symbol(c8, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 46, 8)) - -var [,,, c9] = [1, 2, 3, 4]; ->c9 : Symbol(c9, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 47, 8)) - -var [,,,...c10] = [1, 2, 3, 4, "hello"]; ->c10 : Symbol(c10, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 48, 8)) - -var [c11, c12, ...c13] = [1, 2, "string"]; ->c11 : Symbol(c11, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 49, 5)) ->c12 : Symbol(c12, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 49, 9)) ->c13 : Symbol(c13, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 49, 14)) - -var [c14, c15, c16] = [1, 2, "string"]; ->c14 : Symbol(c14, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 50, 5)) ->c15 : Symbol(c15, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 50, 9)) ->c16 : Symbol(c16, Decl(destructuringArrayBindingPatternAndAssignment1ES5.ts, 50, 14)) - - diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types deleted file mode 100644 index adff61e407c..00000000000 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.types +++ /dev/null @@ -1,177 +0,0 @@ -=== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES5.ts === -/* AssignmentPattern: - * ObjectAssignmentPattern - * ArrayAssignmentPattern - * ArrayAssignmentPattern: - * [Elision AssignmentRestElementopt ] - * [AssignmentElementList] - * [AssignmentElementList, Elision AssignmentRestElementopt ] - * AssignmentElementList: - * Elision AssignmentElement - * AssignmentElementList, Elisionopt AssignmentElement - * AssignmentElement: - * LeftHandSideExpression Initialiseropt - * AssignmentPattern Initialiseropt - * AssignmentRestElement: - * ... LeftHandSideExpression - */ - -// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. -// An expression of type S is considered assignable to an assignment target V if one of the following is true - -// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, -// S is the type Any, or - -var [a0, a1]: any = undefined; ->a0 : any ->a1 : any ->undefined : undefined - -var [a2 = false, a3 = 1]: any = undefined; ->a2 : boolean ->false : boolean ->a3 : number ->1 : number ->undefined : undefined - -// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, -// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, -// where N is the numeric index of E in the array assignment pattern, or -var [b0, b1, b2] = [2, 3, 4]; ->b0 : number ->b1 : number ->b2 : number ->[2, 3, 4] : [number, number, number] ->2 : number ->3 : number ->4 : number - -var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; ->b3 : number ->b4 : number ->b5 : string ->[1, 2, "string"] : [number, number, string] ->1 : number ->2 : number ->"string" : string - -function foo() { ->foo : () => number[] - - return [1, 2, 3]; ->[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number -} - -var [b6, b7] = foo(); ->b6 : number ->b7 : number ->foo() : number[] ->foo : () => number[] - -var [...b8] = foo(); ->b8 : number[] ->foo() : number[] ->foo : () => number[] - -// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. -var temp = [1,2,3] ->temp : number[] ->[1,2,3] : number[] ->1 : number ->2 : number ->3 : number - -var [c0, c1] = [...temp]; ->c0 : number ->c1 : number ->[...temp] : number[] ->...temp : number ->temp : number[] - -var [c2] = []; ->c2 : any ->[] : undefined[] - -var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] ->c3 : any ->c4 : any ->[[[]], [[[[]]]]] : [[undefined[]], [[[undefined[]]]]] ->[[]] : [undefined[]] ->[] : undefined[] ->[[[[]]]] : [[[undefined[]]]] ->[[[]]] : [[undefined[]]] ->[[]] : [undefined[]] ->[] : undefined[] - -var [[c5], c6]: [[string|number], boolean] = [[1], true]; ->c5 : string | number ->c6 : boolean ->[[1], true] : [[number], boolean] ->[1] : [number] ->1 : number ->true : boolean - -var [, c7] = [1, 2, 3]; -> : undefined ->c7 : number ->[1, 2, 3] : [number, number, number] ->1 : number ->2 : number ->3 : number - -var [,,, c8] = [1, 2, 3, 4]; -> : undefined -> : undefined -> : undefined ->c8 : number ->[1, 2, 3, 4] : [number, number, number, number] ->1 : number ->2 : number ->3 : number ->4 : number - -var [,,, c9] = [1, 2, 3, 4]; -> : undefined -> : undefined -> : undefined ->c9 : number ->[1, 2, 3, 4] : [number, number, number, number] ->1 : number ->2 : number ->3 : number ->4 : number - -var [,,,...c10] = [1, 2, 3, 4, "hello"]; -> : undefined -> : undefined -> : undefined ->c10 : (number | string)[] ->[1, 2, 3, 4, "hello"] : (number | string)[] ->1 : number ->2 : number ->3 : number ->4 : number ->"hello" : string - -var [c11, c12, ...c13] = [1, 2, "string"]; ->c11 : number | string ->c12 : number | string ->c13 : (number | string)[] ->[1, 2, "string"] : (number | string)[] ->1 : number ->2 : number ->"string" : string - -var [c14, c15, c16] = [1, 2, "string"]; ->c14 : number ->c15 : number ->c16 : string ->[1, 2, "string"] : [number, number, string] ->1 : number ->2 : number ->"string" : string - - diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.errors.txt new file mode 100644 index 00000000000..beefbc9a85b --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.errors.txt @@ -0,0 +1,64 @@ +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts(44,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts(45,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts(45,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + + +==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts (3 errors) ==== + + /* AssignmentPattern: + * ObjectAssignmentPattern + * ArrayAssignmentPattern + * ArrayAssignmentPattern: + * [Elision AssignmentRestElementopt ] + * [AssignmentElementList] + * [AssignmentElementList, Elision AssignmentRestElementopt ] + * AssignmentElementList: + * Elision AssignmentElement + * AssignmentElementList, Elisionopt AssignmentElement + * AssignmentElement: + * LeftHandSideExpression Initialiseropt + * AssignmentPattern Initialiseropt + * AssignmentRestElement: + * ... LeftHandSideExpression + */ + + // In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. + // An expression of type S is considered assignable to an assignment target V if one of the following is true + + // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, + // S is the type Any, or + + var [a0, a1]: any = undefined; + var [a2 = false, a3 = 1]: any = undefined; + + // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, + // S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, + // where N is the numeric index of E in the array assignment pattern, or + var [b0, b1, b2] = [2, 3, 4]; + var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; + + function foo() { + return [1, 2, 3]; + } + + var [b6, b7] = foo(); + var [...b8] = foo(); + + // S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. + var temp = [1,2,3] + var [c0, c1] = [...temp]; + var [c2] = []; + ~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] + ~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + ~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + var [[c5], c6]: [[string|number], boolean] = [[1], true]; + var [, c7] = [1, 2, 3]; + var [,,, c8] = [1, 2, 3, 4]; + var [,,, c9] = [1, 2, 3, 4]; + var [,,,...c10] = [1, 2, 3, 4, "hello"]; + var [c11, c12, ...c13] = [1, 2, "string"]; + var [c14, c15, c16] = [1, 2, "string"]; \ No newline at end of file diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.symbols b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.symbols deleted file mode 100644 index 33f9b4e88be..00000000000 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.symbols +++ /dev/null @@ -1,105 +0,0 @@ -=== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts === - -/* AssignmentPattern: - * ObjectAssignmentPattern - * ArrayAssignmentPattern - * ArrayAssignmentPattern: - * [Elision AssignmentRestElementopt ] - * [AssignmentElementList] - * [AssignmentElementList, Elision AssignmentRestElementopt ] - * AssignmentElementList: - * Elision AssignmentElement - * AssignmentElementList, Elisionopt AssignmentElement - * AssignmentElement: - * LeftHandSideExpression Initialiseropt - * AssignmentPattern Initialiseropt - * AssignmentRestElement: - * ... LeftHandSideExpression - */ - -// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. -// An expression of type S is considered assignable to an assignment target V if one of the following is true - -// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, -// S is the type Any, or - -var [a0, a1]: any = undefined; ->a0 : Symbol(a0, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 24, 5)) ->a1 : Symbol(a1, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 24, 8)) ->undefined : Symbol(undefined) - -var [a2 = false, a3 = 1]: any = undefined; ->a2 : Symbol(a2, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 25, 5)) ->a3 : Symbol(a3, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 25, 16)) ->undefined : Symbol(undefined) - -// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, -// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, -// where N is the numeric index of E in the array assignment pattern, or -var [b0, b1, b2] = [2, 3, 4]; ->b0 : Symbol(b0, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 30, 5)) ->b1 : Symbol(b1, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 30, 8)) ->b2 : Symbol(b2, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 30, 12)) - -var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; ->b3 : Symbol(b3, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 5)) ->b4 : Symbol(b4, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 8)) ->b5 : Symbol(b5, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 12)) - -function foo() { ->foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 62)) - - return [1, 2, 3]; -} - -var [b6, b7] = foo(); ->b6 : Symbol(b6, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 37, 5)) ->b7 : Symbol(b7, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 37, 8)) ->foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 62)) - -var [...b8] = foo(); ->b8 : Symbol(b8, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 38, 5)) ->foo : Symbol(foo, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 31, 62)) - -// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. -var temp = [1,2,3] ->temp : Symbol(temp, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 41, 3)) - -var [c0, c1] = [...temp]; ->c0 : Symbol(c0, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 42, 5)) ->c1 : Symbol(c1, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 42, 8)) ->temp : Symbol(temp, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 41, 3)) - -var [c2] = []; ->c2 : Symbol(c2, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 43, 5)) - -var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] ->c3 : Symbol(c3, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 44, 7)) ->c4 : Symbol(c4, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 44, 17)) - -var [[c5], c6]: [[string|number], boolean] = [[1], true]; ->c5 : Symbol(c5, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 45, 6)) ->c6 : Symbol(c6, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 45, 10)) - -var [, c7] = [1, 2, 3]; ->c7 : Symbol(c7, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 46, 6)) - -var [,,, c8] = [1, 2, 3, 4]; ->c8 : Symbol(c8, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 47, 8)) - -var [,,, c9] = [1, 2, 3, 4]; ->c9 : Symbol(c9, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 48, 8)) - -var [,,,...c10] = [1, 2, 3, 4, "hello"]; ->c10 : Symbol(c10, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 49, 8)) - -var [c11, c12, ...c13] = [1, 2, "string"]; ->c11 : Symbol(c11, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 50, 5)) ->c12 : Symbol(c12, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 50, 9)) ->c13 : Symbol(c13, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 50, 14)) - -var [c14, c15, c16] = [1, 2, "string"]; ->c14 : Symbol(c14, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 51, 5)) ->c15 : Symbol(c15, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 51, 9)) ->c16 : Symbol(c16, Decl(destructuringArrayBindingPatternAndAssignment1ES6.ts, 51, 14)) - diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types deleted file mode 100644 index 0a9e75a8aed..00000000000 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES6.types +++ /dev/null @@ -1,177 +0,0 @@ -=== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment1ES6.ts === - -/* AssignmentPattern: - * ObjectAssignmentPattern - * ArrayAssignmentPattern - * ArrayAssignmentPattern: - * [Elision AssignmentRestElementopt ] - * [AssignmentElementList] - * [AssignmentElementList, Elision AssignmentRestElementopt ] - * AssignmentElementList: - * Elision AssignmentElement - * AssignmentElementList, Elisionopt AssignmentElement - * AssignmentElement: - * LeftHandSideExpression Initialiseropt - * AssignmentPattern Initialiseropt - * AssignmentRestElement: - * ... LeftHandSideExpression - */ - -// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left. -// An expression of type S is considered assignable to an assignment target V if one of the following is true - -// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, -// S is the type Any, or - -var [a0, a1]: any = undefined; ->a0 : any ->a1 : any ->undefined : undefined - -var [a2 = false, a3 = 1]: any = undefined; ->a2 : boolean ->false : boolean ->a3 : number ->1 : number ->undefined : undefined - -// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, -// S is a tuple- like type (section 3.3.3) with a property named N of a type that is assignable to the target given in E, -// where N is the numeric index of E in the array assignment pattern, or -var [b0, b1, b2] = [2, 3, 4]; ->b0 : number ->b1 : number ->b2 : number ->[2, 3, 4] : [number, number, number] ->2 : number ->3 : number ->4 : number - -var [b3, b4, b5]: [number, number, string] = [1, 2, "string"]; ->b3 : number ->b4 : number ->b5 : string ->[1, 2, "string"] : [number, number, string] ->1 : number ->2 : number ->"string" : string - -function foo() { ->foo : () => number[] - - return [1, 2, 3]; ->[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number -} - -var [b6, b7] = foo(); ->b6 : number ->b7 : number ->foo() : number[] ->foo : () => number[] - -var [...b8] = foo(); ->b8 : number[] ->foo() : number[] ->foo : () => number[] - -// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. -var temp = [1,2,3] ->temp : number[] ->[1,2,3] : number[] ->1 : number ->2 : number ->3 : number - -var [c0, c1] = [...temp]; ->c0 : number ->c1 : number ->[...temp] : number[] ->...temp : number ->temp : number[] - -var [c2] = []; ->c2 : any ->[] : undefined[] - -var [[[c3]], [[[[c4]]]]] = [[[]], [[[[]]]]] ->c3 : any ->c4 : any ->[[[]], [[[[]]]]] : [[undefined[]], [[[undefined[]]]]] ->[[]] : [undefined[]] ->[] : undefined[] ->[[[[]]]] : [[[undefined[]]]] ->[[[]]] : [[undefined[]]] ->[[]] : [undefined[]] ->[] : undefined[] - -var [[c5], c6]: [[string|number], boolean] = [[1], true]; ->c5 : string | number ->c6 : boolean ->[[1], true] : [[number], boolean] ->[1] : [number] ->1 : number ->true : boolean - -var [, c7] = [1, 2, 3]; -> : undefined ->c7 : number ->[1, 2, 3] : [number, number, number] ->1 : number ->2 : number ->3 : number - -var [,,, c8] = [1, 2, 3, 4]; -> : undefined -> : undefined -> : undefined ->c8 : number ->[1, 2, 3, 4] : [number, number, number, number] ->1 : number ->2 : number ->3 : number ->4 : number - -var [,,, c9] = [1, 2, 3, 4]; -> : undefined -> : undefined -> : undefined ->c9 : number ->[1, 2, 3, 4] : [number, number, number, number] ->1 : number ->2 : number ->3 : number ->4 : number - -var [,,,...c10] = [1, 2, 3, 4, "hello"]; -> : undefined -> : undefined -> : undefined ->c10 : (number | string)[] ->[1, 2, 3, 4, "hello"] : (number | string)[] ->1 : number ->2 : number ->3 : number ->4 : number ->"hello" : string - -var [c11, c12, ...c13] = [1, 2, "string"]; ->c11 : number | string ->c12 : number | string ->c13 : (number | string)[] ->[1, 2, "string"] : (number | string)[] ->1 : number ->2 : number ->"string" : string - -var [c14, c15, c16] = [1, 2, "string"]; ->c14 : number ->c15 : number ->c16 : string ->[1, 2, "string"] : [number, number, string] ->1 : number ->2 : number ->"string" : string - diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt index a2e5cb7e17c..91405285973 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2461: Type 'undefined' is not an array type. -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2461: Type 'undefined' is not an array type. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(4,5): error TS2461: Type 'undefined' is not an array type. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,5): error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'. Types of property '1' are incompatible. @@ -18,9 +18,9 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss // S is the type Any, or var [[a0], [[a1]]] = [] // Error ~~~~ -!!! error TS2461: Type 'undefined' is not an array type. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~~~~~~ -!!! error TS2461: Type 'undefined' is not an array type. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. var [[a2], [[a3]]] = undefined // Error ~~~~~~~~~~~~~~ !!! error TS2461: Type 'undefined' is not an array type. diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types index f44adab359f..476b5bee0cc 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types @@ -27,7 +27,7 @@ var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; >{ b21: "string" } : { b21: string; } >b21 : string >"string" : string ->{ b2: { b21: "world" } } : { b2: { b21: string; }; } +>{ b2: { b21: "world" } } : { b2?: { b21: string; }; } >b2 : { b21: string; } >{ b21: "world" } : { b21: string; } >b21 : string diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types index 47d4474b63e..7a7f631eddf 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types @@ -27,7 +27,7 @@ var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; >{ b21: "string" } : { b21: string; } >b21 : string >"string" : string ->{ b2: { b21: "world" } } : { b2: { b21: string; }; } +>{ b2: { b21: "world" } } : { b2?: { b21: string; }; } >b2 : { b21: string; } >{ b21: "world" } : { b21: string; } >b21 : string diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt index 9025f24f992..bb4b79987e3 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt @@ -3,14 +3,18 @@ tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAs Type '{ i: number; }' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(3,6): error TS2459: Type 'string | number' has no property 'i' and no string index signature. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(4,6): error TS2459: Type 'string | number | {}' has no property 'i1' and no string index signature. -tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(5,12): error TS2459: Type '{ f212: string; }' has no property 'f21' and no string index signature. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(5,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(5,21): error TS2353: Object literal may only specify known properties, and 'f212' does not exist in type '{ f21: any; }'. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(6,7): error TS1180: Property destructuring pattern expected. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(7,5): error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{ d1: any; }'. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(7,11): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type '{ d1: any; }'. +tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(7,24): error TS2353: Object literal may only specify known properties, and 'e' does not exist in type '{ d1: any; }'. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(9,7): error TS1005: ':' expected. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(9,15): error TS1005: ':' expected. tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts(10,12): error TS1005: ':' expected. -==== tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts (9 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment3.ts (13 errors) ==== // Error var {h?} = { h?: 1 }; ~ @@ -26,11 +30,19 @@ tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAs !!! error TS2459: Type 'string | number | {}' has no property 'i1' and no string index signature. var { f2: {f21} = { f212: "string" } }: any = undefined; ~~~ -!!! error TS2459: Type '{ f212: string; }' has no property 'f21' and no string index signature. +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + ~~~~ +!!! error TS2353: Object literal may only specify known properties, and 'f212' does not exist in type '{ f21: any; }'. var { ...d1 } = { ~~~ !!! error TS1180: Property destructuring pattern expected. a: 1, b: 1, d1: 9, e: 10 + ~ +!!! error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{ d1: any; }'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type '{ d1: any; }'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'e' does not exist in type '{ d1: any; }'. } var {1} = { 1 }; ~ diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols index c232eb24636..c2130f060ab 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.symbols @@ -8,18 +8,18 @@ type arrayString = Array >arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES5.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4118, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4236, 1)) type someArray = Array | number[]; >someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES5.ts, 7, 32)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4118, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4236, 1)) type stringOrNumArray = Array; >stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES5.ts, 8, 42)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4118, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4236, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) function a1(...x: (number|string)[]) { } @@ -33,8 +33,8 @@ function a2(...a) { } function a3(...a: Array) { } >a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES5.ts, 12, 21)) >a : Symbol(a, Decl(destructuringParameterDeclaration3ES5.ts, 13, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4118, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4236, 1)) function a4(...a: arrayString) { } >a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES5.ts, 13, 36)) diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols index 89f62f97185..976c402d2b0 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.symbols @@ -8,18 +8,18 @@ type arrayString = Array >arrayString : Symbol(arrayString, Decl(destructuringParameterDeclaration3ES6.ts, 0, 0)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4118, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4236, 1)) type someArray = Array | number[]; >someArray : Symbol(someArray, Decl(destructuringParameterDeclaration3ES6.ts, 7, 32)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4118, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4236, 1)) type stringOrNumArray = Array; >stringOrNumArray : Symbol(stringOrNumArray, Decl(destructuringParameterDeclaration3ES6.ts, 8, 42)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4118, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4236, 1)) >Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11)) function a1(...x: (number|string)[]) { } @@ -33,8 +33,8 @@ function a2(...a) { } function a3(...a: Array) { } >a3 : Symbol(a3, Decl(destructuringParameterDeclaration3ES6.ts, 12, 21)) >a : Symbol(a, Decl(destructuringParameterDeclaration3ES6.ts, 13, 12)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1452, 1)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4118, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4236, 1)) function a4(...a: arrayString) { } >a4 : Symbol(a4, Decl(destructuringParameterDeclaration3ES6.ts, 13, 36)) diff --git a/tests/baselines/reference/destructuringParameterProperties5.errors.txt b/tests/baselines/reference/destructuringParameterProperties5.errors.txt index 47e50b1df83..cfb38fde90b 100644 --- a/tests/baselines/reference/destructuringParameterProperties5.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties5.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7 tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,51): error TS2339: Property 'x3' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,62): error TS2339: Property 'y' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,72): error TS2339: Property 'z' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,16): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,19): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. Types of property '0' are incompatible. Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. Object literal may only specify known properties, and 'x1' does not exist in type '{ x: number; y: string; z: boolean; }'. @@ -43,7 +43,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(1 } var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. !!! error TS2345: Types of property '0' are incompatible. !!! error TS2345: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types index a0630fee995..f8188147a79 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types @@ -31,7 +31,7 @@ var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; >{ b11: "string" } : { b11: string; } >b11 : string >"string" : string ->{ b1: { b11: "world" } } : { b1: { b11: string; }; } +>{ b1: { b11: "world" } } : { b1?: { b11: string; }; } >b1 : { b11: string; } >{ b11: "world" } : { b11: string; } >b11 : string @@ -151,9 +151,9 @@ var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; >f4 : number >f5 : number > : undefined ->{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }]; } ->f : [number, number, { f3: number; f5: number; }] ->[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }] +>{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }, any]; } +>f : [number, number, { f3: number; f5: number; }, any] +>[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }, any] >1 : number >2 : number >{ f3: 4, f5: 0 } : { f3: number; f5: number; } diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types index f9faf519b0a..7b4fe5409db 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types @@ -31,7 +31,7 @@ var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; >{ b11: "string" } : { b11: string; } >b11 : string >"string" : string ->{ b1: { b11: "world" } } : { b1: { b11: string; }; } +>{ b1: { b11: "world" } } : { b1?: { b11: string; }; } >b1 : { b11: string; } >{ b11: "world" } : { b11: string; } >b11 : string @@ -151,9 +151,9 @@ var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; >f4 : number >f5 : number > : undefined ->{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }]; } ->f : [number, number, { f3: number; f5: number; }] ->[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }] +>{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }, any]; } +>f : [number, number, { f3: number; f5: number; }, any] +>[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }, any] >1 : number >2 : number >{ f3: 4, f5: 0 } : { f3: number; f5: number; } diff --git a/tests/baselines/reference/destructuringWithGenericParameter.js b/tests/baselines/reference/destructuringWithGenericParameter.js new file mode 100644 index 00000000000..61d523f81fa --- /dev/null +++ b/tests/baselines/reference/destructuringWithGenericParameter.js @@ -0,0 +1,30 @@ +//// [destructuringWithGenericParameter.ts] +class GenericClass { + payload: T; +} + +var genericObject = new GenericClass<{ greeting: string }>(); + +function genericFunction(object: GenericClass, callback: (payload: T) => void) { + callback(object.payload); +} + +genericFunction(genericObject, ({greeting}) => { + var s = greeting.toLocaleLowerCase(); // Greeting should be of type string +}); + + +//// [destructuringWithGenericParameter.js] +var GenericClass = (function () { + function GenericClass() { + } + return GenericClass; +})(); +var genericObject = new GenericClass(); +function genericFunction(object, callback) { + callback(object.payload); +} +genericFunction(genericObject, function (_a) { + var greeting = _a.greeting; + var s = greeting.toLocaleLowerCase(); // Greeting should be of type string +}); diff --git a/tests/baselines/reference/destructuringWithGenericParameter.symbols b/tests/baselines/reference/destructuringWithGenericParameter.symbols new file mode 100644 index 00000000000..941cb0bf237 --- /dev/null +++ b/tests/baselines/reference/destructuringWithGenericParameter.symbols @@ -0,0 +1,45 @@ +=== tests/cases/compiler/destructuringWithGenericParameter.ts === +class GenericClass { +>GenericClass : Symbol(GenericClass, Decl(destructuringWithGenericParameter.ts, 0, 0)) +>T : Symbol(T, Decl(destructuringWithGenericParameter.ts, 0, 19)) + + payload: T; +>payload : Symbol(payload, Decl(destructuringWithGenericParameter.ts, 0, 23)) +>T : Symbol(T, Decl(destructuringWithGenericParameter.ts, 0, 19)) +} + +var genericObject = new GenericClass<{ greeting: string }>(); +>genericObject : Symbol(genericObject, Decl(destructuringWithGenericParameter.ts, 4, 3)) +>GenericClass : Symbol(GenericClass, Decl(destructuringWithGenericParameter.ts, 0, 0)) +>greeting : Symbol(greeting, Decl(destructuringWithGenericParameter.ts, 4, 38)) + +function genericFunction(object: GenericClass, callback: (payload: T) => void) { +>genericFunction : Symbol(genericFunction, Decl(destructuringWithGenericParameter.ts, 4, 61)) +>T : Symbol(T, Decl(destructuringWithGenericParameter.ts, 6, 25)) +>object : Symbol(object, Decl(destructuringWithGenericParameter.ts, 6, 28)) +>GenericClass : Symbol(GenericClass, Decl(destructuringWithGenericParameter.ts, 0, 0)) +>T : Symbol(T, Decl(destructuringWithGenericParameter.ts, 6, 25)) +>callback : Symbol(callback, Decl(destructuringWithGenericParameter.ts, 6, 52)) +>payload : Symbol(payload, Decl(destructuringWithGenericParameter.ts, 6, 64)) +>T : Symbol(T, Decl(destructuringWithGenericParameter.ts, 6, 25)) + + callback(object.payload); +>callback : Symbol(callback, Decl(destructuringWithGenericParameter.ts, 6, 52)) +>object.payload : Symbol(GenericClass.payload, Decl(destructuringWithGenericParameter.ts, 0, 23)) +>object : Symbol(object, Decl(destructuringWithGenericParameter.ts, 6, 28)) +>payload : Symbol(GenericClass.payload, Decl(destructuringWithGenericParameter.ts, 0, 23)) +} + +genericFunction(genericObject, ({greeting}) => { +>genericFunction : Symbol(genericFunction, Decl(destructuringWithGenericParameter.ts, 4, 61)) +>genericObject : Symbol(genericObject, Decl(destructuringWithGenericParameter.ts, 4, 3)) +>greeting : Symbol(greeting, Decl(destructuringWithGenericParameter.ts, 10, 33)) + + var s = greeting.toLocaleLowerCase(); // Greeting should be of type string +>s : Symbol(s, Decl(destructuringWithGenericParameter.ts, 11, 7)) +>greeting.toLocaleLowerCase : Symbol(String.toLocaleLowerCase, Decl(lib.d.ts, 402, 26)) +>greeting : Symbol(greeting, Decl(destructuringWithGenericParameter.ts, 10, 33)) +>toLocaleLowerCase : Symbol(String.toLocaleLowerCase, Decl(lib.d.ts, 402, 26)) + +}); + diff --git a/tests/baselines/reference/destructuringWithGenericParameter.types b/tests/baselines/reference/destructuringWithGenericParameter.types new file mode 100644 index 00000000000..07a86e679a9 --- /dev/null +++ b/tests/baselines/reference/destructuringWithGenericParameter.types @@ -0,0 +1,50 @@ +=== tests/cases/compiler/destructuringWithGenericParameter.ts === +class GenericClass { +>GenericClass : GenericClass +>T : T + + payload: T; +>payload : T +>T : T +} + +var genericObject = new GenericClass<{ greeting: string }>(); +>genericObject : GenericClass<{ greeting: string; }> +>new GenericClass<{ greeting: string }>() : GenericClass<{ greeting: string; }> +>GenericClass : typeof GenericClass +>greeting : string + +function genericFunction(object: GenericClass, callback: (payload: T) => void) { +>genericFunction : (object: GenericClass, callback: (payload: T) => void) => void +>T : T +>object : GenericClass +>GenericClass : GenericClass +>T : T +>callback : (payload: T) => void +>payload : T +>T : T + + callback(object.payload); +>callback(object.payload) : void +>callback : (payload: T) => void +>object.payload : T +>object : GenericClass +>payload : T +} + +genericFunction(genericObject, ({greeting}) => { +>genericFunction(genericObject, ({greeting}) => { var s = greeting.toLocaleLowerCase(); // Greeting should be of type string}) : void +>genericFunction : (object: GenericClass, callback: (payload: T) => void) => void +>genericObject : GenericClass<{ greeting: string; }> +>({greeting}) => { var s = greeting.toLocaleLowerCase(); // Greeting should be of type string} : ({greeting}: { greeting: string; }) => void +>greeting : string + + var s = greeting.toLocaleLowerCase(); // Greeting should be of type string +>s : string +>greeting.toLocaleLowerCase() : string +>greeting.toLocaleLowerCase : () => string +>greeting : string +>toLocaleLowerCase : () => string + +}); + diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.js b/tests/baselines/reference/destructuringWithLiteralInitializers.js new file mode 100644 index 00000000000..740648b04e8 --- /dev/null +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.js @@ -0,0 +1,147 @@ +//// [destructuringWithLiteralInitializers.ts] +// (arg: { x: any, y: any }) => void +function f1({ x, y }) { } +f1({ x: 1, y: 1 }); + +// (arg: { x: any, y?: number }) => void +function f2({ x, y = 0 }) { } +f2({ x: 1 }); +f2({ x: 1, y: 1 }); + +// (arg: { x?: number, y?: number }) => void +function f3({ x = 0, y = 0 }) { } +f3({}); +f3({ x: 1 }); +f3({ y: 1 }); +f3({ x: 1, y: 1 }); + +// (arg?: { x: number, y: number }) => void +function f4({ x, y } = { x: 0, y: 0 }) { } +f4(); +f4({ x: 1, y: 1 }); + +// (arg?: { x: number, y?: number }) => void +function f5({ x, y = 0 } = { x: 0 }) { } +f5(); +f5({ x: 1 }); +f5({ x: 1, y: 1 }); + +// (arg?: { x?: number, y?: number }) => void +function f6({ x = 0, y = 0 } = {}) { } +f6(); +f6({}); +f6({ x: 1 }); +f6({ y: 1 }); +f6({ x: 1, y: 1 }); + +// (arg?: { a: { x?: number, y?: number } }) => void +function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } +f7(); +f7({ a: {} }); +f7({ a: { x: 1 } }); +f7({ a: { y: 1 } }); +f7({ a: { x: 1, y: 1 } }); + +// (arg: [any, any]) => void +function g1([x, y]) { } +g1([1, 1]); + +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +g2([1, 1]); + +// (arg?: [number, number]) => void +function g3([x, y] = [0, 0]) { } +g3(); +g3([1, 1]); + +// (arg?: [number, number]) => void +function g4([x, y = 0] = [0]) { } +g4(); +g4([1, 1]); + +// (arg?: [number, number]) => void +function g5([x = 0, y = 0] = []) { } +g5(); +g5([1, 1]); + + +//// [destructuringWithLiteralInitializers.js] +// (arg: { x: any, y: any }) => void +function f1(_a) { + var x = _a.x, y = _a.y; +} +f1({ x: 1, y: 1 }); +// (arg: { x: any, y?: number }) => void +function f2(_a) { + var x = _a.x, _b = _a.y, y = _b === void 0 ? 0 : _b; +} +f2({ x: 1 }); +f2({ x: 1, y: 1 }); +// (arg: { x?: number, y?: number }) => void +function f3(_a) { + var _b = _a.x, x = _b === void 0 ? 0 : _b, _c = _a.y, y = _c === void 0 ? 0 : _c; +} +f3({}); +f3({ x: 1 }); +f3({ y: 1 }); +f3({ x: 1, y: 1 }); +// (arg?: { x: number, y: number }) => void +function f4(_a) { + var _b = _a === void 0 ? { x: 0, y: 0 } : _a, x = _b.x, y = _b.y; +} +f4(); +f4({ x: 1, y: 1 }); +// (arg?: { x: number, y?: number }) => void +function f5(_a) { + var _b = _a === void 0 ? { x: 0 } : _a, x = _b.x, _c = _b.y, y = _c === void 0 ? 0 : _c; +} +f5(); +f5({ x: 1 }); +f5({ x: 1, y: 1 }); +// (arg?: { x?: number, y?: number }) => void +function f6(_a) { + var _b = _a === void 0 ? {} : _a, _c = _b.x, x = _c === void 0 ? 0 : _c, _d = _b.y, y = _d === void 0 ? 0 : _d; +} +f6(); +f6({}); +f6({ x: 1 }); +f6({ y: 1 }); +f6({ x: 1, y: 1 }); +// (arg?: { a: { x?: number, y?: number } }) => void +function f7(_a) { + var _b = (_a === void 0 ? { a: {} } : _a).a, _c = _b.x, x = _c === void 0 ? 0 : _c, _d = _b.y, y = _d === void 0 ? 0 : _d; +} +f7(); +f7({ a: {} }); +f7({ a: { x: 1 } }); +f7({ a: { y: 1 } }); +f7({ a: { x: 1, y: 1 } }); +// (arg: [any, any]) => void +function g1(_a) { + var x = _a[0], y = _a[1]; +} +g1([1, 1]); +// (arg: [number, number]) => void +function g2(_a) { + var _b = _a[0], x = _b === void 0 ? 0 : _b, _c = _a[1], y = _c === void 0 ? 0 : _c; +} +g2([1, 1]); +// (arg?: [number, number]) => void +function g3(_a) { + var _b = _a === void 0 ? [0, 0] : _a, x = _b[0], y = _b[1]; +} +g3(); +g3([1, 1]); +// (arg?: [number, number]) => void +function g4(_a) { + var _b = _a === void 0 ? [0] : _a, x = _b[0], _c = _b[1], y = _c === void 0 ? 0 : _c; +} +g4(); +g4([1, 1]); +// (arg?: [number, number]) => void +function g5(_a) { + var _b = _a === void 0 ? [] : _a, _c = _b[0], x = _c === void 0 ? 0 : _c, _d = _b[1], y = _d === void 0 ? 0 : _d; +} +g5(); +g5([1, 1]); diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.symbols b/tests/baselines/reference/destructuringWithLiteralInitializers.symbols new file mode 100644 index 00000000000..1141fc140c7 --- /dev/null +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.symbols @@ -0,0 +1,194 @@ +=== tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts === +// (arg: { x: any, y: any }) => void +function f1({ x, y }) { } +>f1 : Symbol(f1, Decl(destructuringWithLiteralInitializers.ts, 0, 0)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 1, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 1, 16)) + +f1({ x: 1, y: 1 }); +>f1 : Symbol(f1, Decl(destructuringWithLiteralInitializers.ts, 0, 0)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 2, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 2, 10)) + +// (arg: { x: any, y?: number }) => void +function f2({ x, y = 0 }) { } +>f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 5, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 5, 16)) + +f2({ x: 1 }); +>f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 6, 4)) + +f2({ x: 1, y: 1 }); +>f2 : Symbol(f2, Decl(destructuringWithLiteralInitializers.ts, 2, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 7, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 7, 10)) + +// (arg: { x?: number, y?: number }) => void +function f3({ x = 0, y = 0 }) { } +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 10, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 10, 20)) + +f3({}); +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) + +f3({ x: 1 }); +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 12, 4)) + +f3({ y: 1 }); +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 13, 4)) + +f3({ x: 1, y: 1 }); +>f3 : Symbol(f3, Decl(destructuringWithLiteralInitializers.ts, 7, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 14, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 14, 10)) + +// (arg?: { x: number, y: number }) => void +function f4({ x, y } = { x: 0, y: 0 }) { } +>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 14, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 17, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 17, 16)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 17, 24)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 17, 30)) + +f4(); +>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 14, 19)) + +f4({ x: 1, y: 1 }); +>f4 : Symbol(f4, Decl(destructuringWithLiteralInitializers.ts, 14, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 19, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 19, 10)) + +// (arg?: { x: number, y?: number }) => void +function f5({ x, y = 0 } = { x: 0 }) { } +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 22, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 22, 16)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 22, 28)) + +f5(); +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19)) + +f5({ x: 1 }); +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 24, 4)) + +f5({ x: 1, y: 1 }); +>f5 : Symbol(f5, Decl(destructuringWithLiteralInitializers.ts, 19, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 25, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 25, 10)) + +// (arg?: { x?: number, y?: number }) => void +function f6({ x = 0, y = 0 } = {}) { } +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 28, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 28, 20)) + +f6(); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) + +f6({}); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) + +f6({ x: 1 }); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 31, 4)) + +f6({ y: 1 }); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 32, 4)) + +f6({ x: 1, y: 1 }); +>f6 : Symbol(f6, Decl(destructuringWithLiteralInitializers.ts, 25, 19)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 33, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 33, 10)) + +// (arg?: { a: { x?: number, y?: number } }) => void +function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 36, 39)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 36, 18)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 36, 25)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 36, 39)) + +f7(); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) + +f7({ a: {} }); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 38, 4)) + +f7({ a: { x: 1 } }); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 39, 4)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 39, 9)) + +f7({ a: { y: 1 } }); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 40, 4)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 40, 9)) + +f7({ a: { x: 1, y: 1 } }); +>f7 : Symbol(f7, Decl(destructuringWithLiteralInitializers.ts, 33, 19)) +>a : Symbol(a, Decl(destructuringWithLiteralInitializers.ts, 41, 4)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 41, 9)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 41, 15)) + +// (arg: [any, any]) => void +function g1([x, y]) { } +>g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 41, 26)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 44, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 44, 15)) + +g1([1, 1]); +>g1 : Symbol(g1, Decl(destructuringWithLiteralInitializers.ts, 41, 26)) + +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +>g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 45, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 48, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 48, 19)) + +g2([1, 1]); +>g2 : Symbol(g2, Decl(destructuringWithLiteralInitializers.ts, 45, 11)) + +// (arg?: [number, number]) => void +function g3([x, y] = [0, 0]) { } +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 52, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 52, 15)) + +g3(); +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11)) + +g3([1, 1]); +>g3 : Symbol(g3, Decl(destructuringWithLiteralInitializers.ts, 49, 11)) + +// (arg?: [number, number]) => void +function g4([x, y = 0] = [0]) { } +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 57, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 57, 15)) + +g4(); +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11)) + +g4([1, 1]); +>g4 : Symbol(g4, Decl(destructuringWithLiteralInitializers.ts, 54, 11)) + +// (arg?: [number, number]) => void +function g5([x = 0, y = 0] = []) { } +>g5 : Symbol(g5, Decl(destructuringWithLiteralInitializers.ts, 59, 11)) +>x : Symbol(x, Decl(destructuringWithLiteralInitializers.ts, 62, 13)) +>y : Symbol(y, Decl(destructuringWithLiteralInitializers.ts, 62, 19)) + +g5(); +>g5 : Symbol(g5, Decl(destructuringWithLiteralInitializers.ts, 59, 11)) + +g5([1, 1]); +>g5 : Symbol(g5, Decl(destructuringWithLiteralInitializers.ts, 59, 11)) + diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.types b/tests/baselines/reference/destructuringWithLiteralInitializers.types new file mode 100644 index 00000000000..da1e4bfd6f3 --- /dev/null +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.types @@ -0,0 +1,310 @@ +=== tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts === +// (arg: { x: any, y: any }) => void +function f1({ x, y }) { } +>f1 : ({ x, y }: { x: any; y: any; }) => void +>x : any +>y : any + +f1({ x: 1, y: 1 }); +>f1({ x: 1, y: 1 }) : void +>f1 : ({ x, y }: { x: any; y: any; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>1 : number + +// (arg: { x: any, y?: number }) => void +function f2({ x, y = 0 }) { } +>f2 : ({ x, y = 0 }: { x: any; y?: number; }) => void +>x : any +>y : number +>0 : number + +f2({ x: 1 }); +>f2({ x: 1 }) : void +>f2 : ({ x, y = 0 }: { x: any; y?: number; }) => void +>{ x: 1 } : { x: number; } +>x : number +>1 : number + +f2({ x: 1, y: 1 }); +>f2({ x: 1, y: 1 }) : void +>f2 : ({ x, y = 0 }: { x: any; y?: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>1 : number + +// (arg: { x?: number, y?: number }) => void +function f3({ x = 0, y = 0 }) { } +>f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void +>x : number +>0 : number +>y : number +>0 : number + +f3({}); +>f3({}) : void +>f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void +>{} : {} + +f3({ x: 1 }); +>f3({ x: 1 }) : void +>f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void +>{ x: 1 } : { x: number; } +>x : number +>1 : number + +f3({ y: 1 }); +>f3({ y: 1 }) : void +>f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void +>{ y: 1 } : { y: number; } +>y : number +>1 : number + +f3({ x: 1, y: 1 }); +>f3({ x: 1, y: 1 }) : void +>f3 : ({ x = 0, y = 0 }: { x?: number; y?: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>1 : number + +// (arg?: { x: number, y: number }) => void +function f4({ x, y } = { x: 0, y: 0 }) { } +>f4 : ({ x, y }?: { x: number; y: number; }) => void +>x : number +>y : number +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : number +>y : number +>0 : number + +f4(); +>f4() : void +>f4 : ({ x, y }?: { x: number; y: number; }) => void + +f4({ x: 1, y: 1 }); +>f4({ x: 1, y: 1 }) : void +>f4 : ({ x, y }?: { x: number; y: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>1 : number + +// (arg?: { x: number, y?: number }) => void +function f5({ x, y = 0 } = { x: 0 }) { } +>f5 : ({ x, y = 0 }?: { x: number; y?: number; }) => void +>x : number +>y : number +>0 : number +>{ x: 0 } : { x: number; y?: number; } +>x : number +>0 : number + +f5(); +>f5() : void +>f5 : ({ x, y = 0 }?: { x: number; y?: number; }) => void + +f5({ x: 1 }); +>f5({ x: 1 }) : void +>f5 : ({ x, y = 0 }?: { x: number; y?: number; }) => void +>{ x: 1 } : { x: number; } +>x : number +>1 : number + +f5({ x: 1, y: 1 }); +>f5({ x: 1, y: 1 }) : void +>f5 : ({ x, y = 0 }?: { x: number; y?: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>1 : number + +// (arg?: { x?: number, y?: number }) => void +function f6({ x = 0, y = 0 } = {}) { } +>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void +>x : number +>0 : number +>y : number +>0 : number +>{} : { x?: number; y?: number; } + +f6(); +>f6() : void +>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void + +f6({}); +>f6({}) : void +>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void +>{} : {} + +f6({ x: 1 }); +>f6({ x: 1 }) : void +>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void +>{ x: 1 } : { x: number; } +>x : number +>1 : number + +f6({ y: 1 }); +>f6({ y: 1 }) : void +>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void +>{ y: 1 } : { y: number; } +>y : number +>1 : number + +f6({ x: 1, y: 1 }); +>f6({ x: 1, y: 1 }) : void +>f6 : ({ x = 0, y = 0 }?: { x?: number; y?: number; }) => void +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>1 : number + +// (arg?: { a: { x?: number, y?: number } }) => void +function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } +>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void +>a : any +>x : number +>0 : number +>y : number +>0 : number +>{ a: {} } : { a: { x?: number; y?: number; }; } +>a : { x?: number; y?: number; } +>{} : { x?: number; y?: number; } + +f7(); +>f7() : void +>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void + +f7({ a: {} }); +>f7({ a: {} }) : void +>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void +>{ a: {} } : { a: {}; } +>a : {} +>{} : {} + +f7({ a: { x: 1 } }); +>f7({ a: { x: 1 } }) : void +>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void +>{ a: { x: 1 } } : { a: { x: number; }; } +>a : { x: number; } +>{ x: 1 } : { x: number; } +>x : number +>1 : number + +f7({ a: { y: 1 } }); +>f7({ a: { y: 1 } }) : void +>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void +>{ a: { y: 1 } } : { a: { y: number; }; } +>a : { y: number; } +>{ y: 1 } : { y: number; } +>y : number +>1 : number + +f7({ a: { x: 1, y: 1 } }); +>f7({ a: { x: 1, y: 1 } }) : void +>f7 : ({ a: { x = 0, y = 0 } }?: { a: { x?: number; y?: number; }; }) => void +>{ a: { x: 1, y: 1 } } : { a: { x: number; y: number; }; } +>a : { x: number; y: number; } +>{ x: 1, y: 1 } : { x: number; y: number; } +>x : number +>1 : number +>y : number +>1 : number + +// (arg: [any, any]) => void +function g1([x, y]) { } +>g1 : ([x, y]: [any, any]) => void +>x : any +>y : any + +g1([1, 1]); +>g1([1, 1]) : void +>g1 : ([x, y]: [any, any]) => void +>[1, 1] : [number, number] +>1 : number +>1 : number + +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +>g2 : ([x = 0, y = 0]: [number, number]) => void +>x : number +>0 : number +>y : number +>0 : number + +g2([1, 1]); +>g2([1, 1]) : void +>g2 : ([x = 0, y = 0]: [number, number]) => void +>[1, 1] : [number, number] +>1 : number +>1 : number + +// (arg?: [number, number]) => void +function g3([x, y] = [0, 0]) { } +>g3 : ([x, y]?: [number, number]) => void +>x : number +>y : number +>[0, 0] : [number, number] +>0 : number +>0 : number + +g3(); +>g3() : void +>g3 : ([x, y]?: [number, number]) => void + +g3([1, 1]); +>g3([1, 1]) : void +>g3 : ([x, y]?: [number, number]) => void +>[1, 1] : [number, number] +>1 : number +>1 : number + +// (arg?: [number, number]) => void +function g4([x, y = 0] = [0]) { } +>g4 : ([x, y = 0]?: [number, number]) => void +>x : number +>y : number +>0 : number +>[0] : [number, number] +>0 : number + +g4(); +>g4() : void +>g4 : ([x, y = 0]?: [number, number]) => void + +g4([1, 1]); +>g4([1, 1]) : void +>g4 : ([x, y = 0]?: [number, number]) => void +>[1, 1] : [number, number] +>1 : number +>1 : number + +// (arg?: [number, number]) => void +function g5([x = 0, y = 0] = []) { } +>g5 : ([x = 0, y = 0]?: [number, number]) => void +>x : number +>0 : number +>y : number +>0 : number +>[] : [number, number] + +g5(); +>g5() : void +>g5 : ([x = 0, y = 0]?: [number, number]) => void + +g5([1, 1]); +>g5([1, 1]) : void +>g5 : ([x = 0, y = 0]?: [number, number]) => void +>[1, 1] : [number, number] +>1 : number +>1 : number + diff --git a/tests/baselines/reference/detachedCommentAtStartOfConstructor1.types b/tests/baselines/reference/detachedCommentAtStartOfConstructor1.types index 392821de751..7cbae62f83d 100644 --- a/tests/baselines/reference/detachedCommentAtStartOfConstructor1.types +++ b/tests/baselines/reference/detachedCommentAtStartOfConstructor1.types @@ -19,13 +19,13 @@ class TestFile { >message + this.name : string >message : string >this.name : any ->this : TestFile +>this : this >name : any this.message = getMessage(); >this.message = getMessage() : string >this.message : string ->this : TestFile +>this : this >message : string >getMessage() : string >getMessage : () => string diff --git a/tests/baselines/reference/detachedCommentAtStartOfConstructor2.types b/tests/baselines/reference/detachedCommentAtStartOfConstructor2.types index b413cd557a5..830be456e9a 100644 --- a/tests/baselines/reference/detachedCommentAtStartOfConstructor2.types +++ b/tests/baselines/reference/detachedCommentAtStartOfConstructor2.types @@ -20,13 +20,13 @@ class TestFile { >message + this.name : string >message : string >this.name : string ->this : TestFile +>this : this >name : string this.message = getMessage(); >this.message = getMessage() : string >this.message : string ->this : TestFile +>this : this >message : string >getMessage() : string >getMessage : () => string diff --git a/tests/baselines/reference/detachedCommentAtStartOfLambdaFunction1.types b/tests/baselines/reference/detachedCommentAtStartOfLambdaFunction1.types index 016a123c5c1..e05a4c083cb 100644 --- a/tests/baselines/reference/detachedCommentAtStartOfLambdaFunction1.types +++ b/tests/baselines/reference/detachedCommentAtStartOfLambdaFunction1.types @@ -20,7 +20,7 @@ class TestFile { >message + this.name : string >message : string >this.name : string ->this : TestFile +>this : this >name : string } } diff --git a/tests/baselines/reference/detachedCommentAtStartOfLambdaFunction2.types b/tests/baselines/reference/detachedCommentAtStartOfLambdaFunction2.types index 2199a4490b5..8dde223dad0 100644 --- a/tests/baselines/reference/detachedCommentAtStartOfLambdaFunction2.types +++ b/tests/baselines/reference/detachedCommentAtStartOfLambdaFunction2.types @@ -21,7 +21,7 @@ class TestFile { >message + this.name : string >message : string >this.name : string ->this : TestFile +>this : this >name : string } } diff --git a/tests/baselines/reference/doNotEmitDetachedComments.js b/tests/baselines/reference/doNotEmitDetachedComments.js new file mode 100644 index 00000000000..74acb537fa8 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedComments.js @@ -0,0 +1,33 @@ +//// [doNotEmitDetachedComments.ts] +/* + + multi line + comment +*/ + +var x = 10; + +// Single Line comment + +function foo() { } + + +/* + multi-line comment + +*/ + + +//======================== + + +function bar() { } + + +//======================== + + +//// [doNotEmitDetachedComments.js] +var x = 10; +function foo() { } +function bar() { } diff --git a/tests/baselines/reference/doNotEmitDetachedComments.symbols b/tests/baselines/reference/doNotEmitDetachedComments.symbols new file mode 100644 index 00000000000..c718da7bb9a --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedComments.symbols @@ -0,0 +1,31 @@ +=== tests/cases/compiler/doNotEmitDetachedComments.ts === +/* + + multi line + comment +*/ + +var x = 10; +>x : Symbol(x, Decl(doNotEmitDetachedComments.ts, 6, 3)) + +// Single Line comment + +function foo() { } +>foo : Symbol(foo, Decl(doNotEmitDetachedComments.ts, 6, 11)) + + +/* + multi-line comment + +*/ + + +//======================== + + +function bar() { } +>bar : Symbol(bar, Decl(doNotEmitDetachedComments.ts, 10, 18)) + + +//======================== + diff --git a/tests/baselines/reference/doNotEmitDetachedComments.types b/tests/baselines/reference/doNotEmitDetachedComments.types new file mode 100644 index 00000000000..d9b5f0634c2 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedComments.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/doNotEmitDetachedComments.ts === +/* + + multi line + comment +*/ + +var x = 10; +>x : number +>10 : number + +// Single Line comment + +function foo() { } +>foo : () => void + + +/* + multi-line comment + +*/ + + +//======================== + + +function bar() { } +>bar : () => void + + +//======================== + diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.js b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.js new file mode 100644 index 00000000000..ba6dbf8b743 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.js @@ -0,0 +1,64 @@ +//// [doNotEmitDetachedCommentsAtStartOfConstructor.ts] +class A { + constructor() { + // Single Line Comment + + var x = 10; + } +} + +class B { + constructor() { + /* + Multi-line comment + */ + + var y = 10; + } +} + +class C { + constructor() { + // Single Line Comment with more than one blank line + + + var x = 10; + } +} + +class D { + constructor() { + /* + Multi-line comment with more than one blank line + */ + + + var y = 10; + } +} + +//// [doNotEmitDetachedCommentsAtStartOfConstructor.js] +var A = (function () { + function A() { + var x = 10; + } + return A; +})(); +var B = (function () { + function B() { + var y = 10; + } + return B; +})(); +var C = (function () { + function C() { + var x = 10; + } + return C; +})(); +var D = (function () { + function D() { + var y = 10; + } + return D; +})(); diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.symbols b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.symbols new file mode 100644 index 00000000000..d7c4f5b2ca9 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.symbols @@ -0,0 +1,50 @@ +=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts === +class A { +>A : Symbol(A, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 0, 0)) + + constructor() { + // Single Line Comment + + var x = 10; +>x : Symbol(x, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 4, 11)) + } +} + +class B { +>B : Symbol(B, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 6, 1)) + + constructor() { + /* + Multi-line comment + */ + + var y = 10; +>y : Symbol(y, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 14, 11)) + } +} + +class C { +>C : Symbol(C, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 16, 1)) + + constructor() { + // Single Line Comment with more than one blank line + + + var x = 10; +>x : Symbol(x, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 23, 11)) + } +} + +class D { +>D : Symbol(D, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 25, 1)) + + constructor() { + /* + Multi-line comment with more than one blank line + */ + + + var y = 10; +>y : Symbol(y, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 34, 11)) + } +} diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.types b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.types new file mode 100644 index 00000000000..c316c6403c0 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.types @@ -0,0 +1,54 @@ +=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts === +class A { +>A : A + + constructor() { + // Single Line Comment + + var x = 10; +>x : number +>10 : number + } +} + +class B { +>B : B + + constructor() { + /* + Multi-line comment + */ + + var y = 10; +>y : number +>10 : number + } +} + +class C { +>C : C + + constructor() { + // Single Line Comment with more than one blank line + + + var x = 10; +>x : number +>10 : number + } +} + +class D { +>D : D + + constructor() { + /* + Multi-line comment with more than one blank line + */ + + + var y = 10; +>y : number +>10 : number + } +} diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.js b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.js new file mode 100644 index 00000000000..dbd0f0be783 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.js @@ -0,0 +1,48 @@ +//// [doNotEmitDetachedCommentsAtStartOfFunctionBody.ts] +function foo1() { + // Single line comment + + return 42; +} + +function foo2() { + /* + + multi line + comment + */ + + return 42; +} + +function foo3() { + // Single line comment with more than one blank line + + + return 42; +} + +function foo4() { + /* + + multi line comment with more than one blank line + */ + + return 42; +} + + + +//// [doNotEmitDetachedCommentsAtStartOfFunctionBody.js] +function foo1() { + return 42; +} +function foo2() { + return 42; +} +function foo3() { + return 42; +} +function foo4() { + return 42; +} diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.symbols b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.symbols new file mode 100644 index 00000000000..c1680100369 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.symbols @@ -0,0 +1,42 @@ +=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts === +function foo1() { +>foo1 : Symbol(foo1, Decl(doNotEmitDetachedCommentsAtStartOfFunctionBody.ts, 0, 0)) + + // Single line comment + + return 42; +} + +function foo2() { +>foo2 : Symbol(foo2, Decl(doNotEmitDetachedCommentsAtStartOfFunctionBody.ts, 4, 1)) + + /* + + multi line + comment + */ + + return 42; +} + +function foo3() { +>foo3 : Symbol(foo3, Decl(doNotEmitDetachedCommentsAtStartOfFunctionBody.ts, 14, 1)) + + // Single line comment with more than one blank line + + + return 42; +} + +function foo4() { +>foo4 : Symbol(foo4, Decl(doNotEmitDetachedCommentsAtStartOfFunctionBody.ts, 21, 1)) + + /* + + multi line comment with more than one blank line + */ + + return 42; +} + + diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.types b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.types new file mode 100644 index 00000000000..3b4814bbbb2 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.types @@ -0,0 +1,46 @@ +=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts === +function foo1() { +>foo1 : () => number + + // Single line comment + + return 42; +>42 : number +} + +function foo2() { +>foo2 : () => number + + /* + + multi line + comment + */ + + return 42; +>42 : number +} + +function foo3() { +>foo3 : () => number + + // Single line comment with more than one blank line + + + return 42; +>42 : number +} + +function foo4() { +>foo4 : () => number + + /* + + multi line comment with more than one blank line + */ + + return 42; +>42 : number +} + + diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.js b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.js new file mode 100644 index 00000000000..7fd5c2b8f8e --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.js @@ -0,0 +1,45 @@ +//// [doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts] +() => { + // Single line comment + + return 0; +} + +() => { + /* + multi-line comment + */ + + return 0; +} + +() => { + // Single line comment with more than one blank line + + + return 0; +} + +() => { + /* + multi-line comment with more than one blank line + */ + + + return 0; +} + + +//// [doNotEmitDetachedCommentsAtStartOfLambdaFunction.js] +(function () { + return 0; +}); +(function () { + return 0; +}); +(function () { + return 0; +}); +(function () { + return 0; +}); diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.symbols b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.symbols new file mode 100644 index 00000000000..e57fc793920 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.symbols @@ -0,0 +1,32 @@ +=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts === +() => { +No type information for this code. // Single line comment +No type information for this code. +No type information for this code. return 0; +No type information for this code.} +No type information for this code. +No type information for this code.() => { +No type information for this code. /* +No type information for this code. multi-line comment +No type information for this code. */ +No type information for this code. +No type information for this code. return 0; +No type information for this code.} +No type information for this code. +No type information for this code.() => { +No type information for this code. // Single line comment with more than one blank line +No type information for this code. +No type information for this code. +No type information for this code. return 0; +No type information for this code.} +No type information for this code. +No type information for this code.() => { +No type information for this code. /* +No type information for this code. multi-line comment with more than one blank line +No type information for this code. */ +No type information for this code. +No type information for this code. +No type information for this code. return 0; +No type information for this code.} +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.types b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.types new file mode 100644 index 00000000000..d90e93d84c5 --- /dev/null +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.types @@ -0,0 +1,43 @@ +=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts === +() => { +>() => { // Single line comment return 0;} : () => number + + // Single line comment + + return 0; +>0 : number +} + +() => { +>() => { /* multi-line comment */ return 0;} : () => number + + /* + multi-line comment + */ + + return 0; +>0 : number +} + +() => { +>() => { // Single line comment with more than one blank line return 0;} : () => number + + // Single line comment with more than one blank line + + + return 0; +>0 : number +} + +() => { +>() => { /* multi-line comment with more than one blank line */ return 0;} : () => number + + /* + multi-line comment with more than one blank line + */ + + + return 0; +>0 : number +} + diff --git a/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.js b/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.js new file mode 100644 index 00000000000..8232ad66ef5 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.js @@ -0,0 +1,14 @@ +//// [doNotEmitPinnedCommentNotOnTopOfFile.ts] +var x = 10; + +/*! + + multi line + comment +*/ + +var x = 10; + +//// [doNotEmitPinnedCommentNotOnTopOfFile.js] +var x = 10; +var x = 10; diff --git a/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.symbols b/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.symbols new file mode 100644 index 00000000000..97cfb5df214 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts === +var x = 10; +>x : Symbol(x, Decl(doNotEmitPinnedCommentNotOnTopOfFile.ts, 0, 3), Decl(doNotEmitPinnedCommentNotOnTopOfFile.ts, 8, 3)) + +/*! + + multi line + comment +*/ + +var x = 10; +>x : Symbol(x, Decl(doNotEmitPinnedCommentNotOnTopOfFile.ts, 0, 3), Decl(doNotEmitPinnedCommentNotOnTopOfFile.ts, 8, 3)) + diff --git a/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.types b/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.types new file mode 100644 index 00000000000..3426c70dfb9 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts === +var x = 10; +>x : number +>10 : number + +/*! + + multi line + comment +*/ + +var x = 10; +>x : number +>10 : number + diff --git a/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.js b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.js new file mode 100644 index 00000000000..99e50801d50 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.js @@ -0,0 +1,21 @@ +//// [doNotEmitPinnedCommentOnNotEmittedNode.ts] + +class C { + /*! remove pinned comment anywhere else */ + public foo(x: string, y: any) + public foo(x: string, y: number) { } +} + +var x = 10; + +/*! remove pinned comment anywhere else */ +declare var OData: any; + +//// [doNotEmitPinnedCommentOnNotEmittedNode.js] +var C = (function () { + function C() { + } + C.prototype.foo = function (x, y) { }; + return C; +})(); +var x = 10; diff --git a/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.symbols b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.symbols new file mode 100644 index 00000000000..64609266044 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.symbols @@ -0,0 +1,24 @@ +=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts === + +class C { +>C : Symbol(C, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 0, 0)) + + /*! remove pinned comment anywhere else */ + public foo(x: string, y: any) +>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 33)) +>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 15)) +>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 25)) + + public foo(x: string, y: number) { } +>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 33)) +>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 4, 15)) +>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 4, 25)) +} + +var x = 10; +>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 7, 3)) + +/*! remove pinned comment anywhere else */ +declare var OData: any; +>OData : Symbol(OData, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 10, 11)) + diff --git a/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.types b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.types new file mode 100644 index 00000000000..b0f71137c2d --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts === + +class C { +>C : C + + /*! remove pinned comment anywhere else */ + public foo(x: string, y: any) +>foo : (x: string, y: any) => any +>x : string +>y : any + + public foo(x: string, y: number) { } +>foo : (x: string, y: any) => any +>x : string +>y : number +} + +var x = 10; +>x : number +>10 : number + +/*! remove pinned comment anywhere else */ +declare var OData: any; +>OData : any + diff --git a/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.js b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.js new file mode 100644 index 00000000000..66896350e6d --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.js @@ -0,0 +1,18 @@ +//// [doNotEmitPinnedCommentOnNotEmittedNodets.ts] + +class C { + /*! remove pinned comment anywhere else */ + public foo(x: string, y: any) + public foo(x: string, y: number) { } +} + +/*! remove pinned comment anywhere else */ +declare var OData: any; + +//// [doNotEmitPinnedCommentOnNotEmittedNodets.js] +var C = (function () { + function C() { + } + C.prototype.foo = function (x, y) { }; + return C; +})(); diff --git a/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.symbols b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.symbols new file mode 100644 index 00000000000..dcd27478115 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.symbols @@ -0,0 +1,21 @@ +=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts === + +class C { +>C : Symbol(C, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 0, 0)) + + /*! remove pinned comment anywhere else */ + public foo(x: string, y: any) +>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 3, 33)) +>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 3, 15)) +>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 3, 25)) + + public foo(x: string, y: number) { } +>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 3, 33)) +>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 4, 15)) +>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 4, 25)) +} + +/*! remove pinned comment anywhere else */ +declare var OData: any; +>OData : Symbol(OData, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 8, 11)) + diff --git a/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.types b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.types new file mode 100644 index 00000000000..4369af63f53 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNodets.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts === + +class C { +>C : C + + /*! remove pinned comment anywhere else */ + public foo(x: string, y: any) +>foo : (x: string, y: any) => any +>x : string +>y : any + + public foo(x: string, y: number) { } +>foo : (x: string, y: any) => any +>x : string +>y : number +} + +/*! remove pinned comment anywhere else */ +declare var OData: any; +>OData : any + diff --git a/tests/baselines/reference/doNotEmitPinnedDetachedComments.js b/tests/baselines/reference/doNotEmitPinnedDetachedComments.js new file mode 100644 index 00000000000..5f5a3b19aaa --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedDetachedComments.js @@ -0,0 +1,42 @@ +//// [doNotEmitPinnedDetachedComments.ts] +var x = 10; + +/*! Single Line comment */ + +function baz() { } + + +/*! + multi-line comment + +*/ + + +//======================== + + +function bar() { + /*! + Remove this comment + */ + +} + +function foo() { + /*! Remove this */ + + return 0; +} + + +//======================== + + +//// [doNotEmitPinnedDetachedComments.js] +var x = 10; +function baz() { } +function bar() { +} +function foo() { + return 0; +} diff --git a/tests/baselines/reference/doNotEmitPinnedDetachedComments.symbols b/tests/baselines/reference/doNotEmitPinnedDetachedComments.symbols new file mode 100644 index 00000000000..2be35804b38 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedDetachedComments.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/doNotEmitPinnedDetachedComments.ts === +var x = 10; +>x : Symbol(x, Decl(doNotEmitPinnedDetachedComments.ts, 0, 3)) + +/*! Single Line comment */ + +function baz() { } +>baz : Symbol(baz, Decl(doNotEmitPinnedDetachedComments.ts, 0, 11)) + + +/*! + multi-line comment + +*/ + + +//======================== + + +function bar() { +>bar : Symbol(bar, Decl(doNotEmitPinnedDetachedComments.ts, 4, 18)) + + /*! + Remove this comment + */ + +} + +function foo() { +>foo : Symbol(foo, Decl(doNotEmitPinnedDetachedComments.ts, 21, 1)) + + /*! Remove this */ + + return 0; +} + + +//======================== + diff --git a/tests/baselines/reference/doNotEmitPinnedDetachedComments.types b/tests/baselines/reference/doNotEmitPinnedDetachedComments.types new file mode 100644 index 00000000000..d9e78e2f980 --- /dev/null +++ b/tests/baselines/reference/doNotEmitPinnedDetachedComments.types @@ -0,0 +1,41 @@ +=== tests/cases/compiler/doNotEmitPinnedDetachedComments.ts === +var x = 10; +>x : number +>10 : number + +/*! Single Line comment */ + +function baz() { } +>baz : () => void + + +/*! + multi-line comment + +*/ + + +//======================== + + +function bar() { +>bar : () => void + + /*! + Remove this comment + */ + +} + +function foo() { +>foo : () => number + + /*! Remove this */ + + return 0; +>0 : number +} + + +//======================== + diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.js new file mode 100644 index 00000000000..f3b0888a78f --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts] //// + +//// [file0.ts] + + +//// [file1.ts] + +//// [file2.ts] +/// +/// +/// + +//// [file0.js] +//// [file1.js] +//// [file2.js] diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.symbols new file mode 100644 index 00000000000..d18810db280 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/file2.ts === +/// +No type information for this code./// +No type information for this code./// +No type information for this code.=== tests/cases/compiler/file0.ts === + +No type information for this code. +No type information for this code.=== tests/cases/compiler/file1.ts === + +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.types new file mode 100644 index 00000000000..d18810db280 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsInEmptyFile.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/file2.ts === +/// +No type information for this code./// +No type information for this code./// +No type information for this code.=== tests/cases/compiler/file0.ts === + +No type information for this code. +No type information for this code.=== tests/cases/compiler/file1.ts === + +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.js b/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.js new file mode 100644 index 00000000000..9067b5b80a9 --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts] //// + +//// [file0.ts] + +/// +declare var OData: any; + +//// [file1.ts] +/// +interface F { } + + + +//// [file0.js] +//// [file1.js] diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.symbols b/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.symbols new file mode 100644 index 00000000000..bb920d2ee1c --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/file1.ts === +/// +interface F { } +>F : Symbol(F, Decl(file1.ts, 0, 0)) + + +=== tests/cases/compiler/file0.ts === + +/// +declare var OData: any; +>OData : Symbol(OData, Decl(file0.ts, 2, 11)) + diff --git a/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.types b/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.types new file mode 100644 index 00000000000..59b63ea1a2f --- /dev/null +++ b/tests/baselines/reference/doNotEmitTripleSlashCommentsOnNotEmittedNode.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/file1.ts === +/// +interface F { } +>F : F + + +=== tests/cases/compiler/file0.ts === + +/// +declare var OData: any; +>OData : any + diff --git a/tests/baselines/reference/doNotemitTripleSlashComments.js b/tests/baselines/reference/doNotemitTripleSlashComments.js new file mode 100644 index 00000000000..fe17db54cb1 --- /dev/null +++ b/tests/baselines/reference/doNotemitTripleSlashComments.js @@ -0,0 +1,46 @@ +//// [tests/cases/compiler/doNotemitTripleSlashComments.ts] //// + +//// [file0.ts] + +/// +/// +/// +var x = 10; + +/// +var y = "hello"; + + +/// + +//// [file1.ts] +/// + +function foo() { } + + +/// + + +var z = "world"; + +//// [file2.ts] +/// + + +/// ==================================== + + +function bar() { } + + + + +//// [file0.js] +var x = 10; +var y = "hello"; +//// [file1.js] +function foo() { } +var z = "world"; +//// [file2.js] +function bar() { } diff --git a/tests/baselines/reference/doNotemitTripleSlashComments.symbols b/tests/baselines/reference/doNotemitTripleSlashComments.symbols new file mode 100644 index 00000000000..36b31842f8b --- /dev/null +++ b/tests/baselines/reference/doNotemitTripleSlashComments.symbols @@ -0,0 +1,40 @@ +=== tests/cases/compiler/file2.ts === +/// + + +/// ==================================== + + +function bar() { } +>bar : Symbol(bar, Decl(file2.ts, 0, 0)) + + + +=== tests/cases/compiler/file0.ts === + +/// +/// +/// +var x = 10; +>x : Symbol(x, Decl(file0.ts, 4, 3)) + +/// +var y = "hello"; +>y : Symbol(y, Decl(file0.ts, 7, 3)) + + +/// + +=== tests/cases/compiler/file1.ts === +/// + +function foo() { } +>foo : Symbol(foo, Decl(file1.ts, 0, 0)) + + +/// + + +var z = "world"; +>z : Symbol(z, Decl(file1.ts, 8, 3)) + diff --git a/tests/baselines/reference/doNotemitTripleSlashComments.types b/tests/baselines/reference/doNotemitTripleSlashComments.types new file mode 100644 index 00000000000..edebe5687f6 --- /dev/null +++ b/tests/baselines/reference/doNotemitTripleSlashComments.types @@ -0,0 +1,43 @@ +=== tests/cases/compiler/file2.ts === +/// + + +/// ==================================== + + +function bar() { } +>bar : () => void + + + +=== tests/cases/compiler/file0.ts === + +/// +/// +/// +var x = 10; +>x : number +>10 : number + +/// +var y = "hello"; +>y : string +>"hello" : string + + +/// + +=== tests/cases/compiler/file1.ts === +/// + +function foo() { } +>foo : () => void + + +/// + + +var z = "world"; +>z : string +>"world" : string + diff --git a/tests/baselines/reference/downlevelLetConst12.errors.txt b/tests/baselines/reference/downlevelLetConst12.errors.txt new file mode 100644 index 00000000000..0af224b017e --- /dev/null +++ b/tests/baselines/reference/downlevelLetConst12.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/downlevelLetConst12.ts(7,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/compiler/downlevelLetConst12.ts(10,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + + +==== tests/cases/compiler/downlevelLetConst12.ts (2 errors) ==== + + 'use strict' + // top level let\const should not be renamed + let foo; + const bar = 1; + + let [baz] = []; + ~~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + let {a: baz2} = { a: 1 }; + + const [baz3] = [] + ~~~~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + const {a: baz4} = { a: 1 }; \ No newline at end of file diff --git a/tests/baselines/reference/downlevelLetConst12.symbols b/tests/baselines/reference/downlevelLetConst12.symbols deleted file mode 100644 index 97d6d5eebf8..00000000000 --- a/tests/baselines/reference/downlevelLetConst12.symbols +++ /dev/null @@ -1,26 +0,0 @@ -=== tests/cases/compiler/downlevelLetConst12.ts === - -'use strict' -// top level let\const should not be renamed -let foo; ->foo : Symbol(foo, Decl(downlevelLetConst12.ts, 3, 3)) - -const bar = 1; ->bar : Symbol(bar, Decl(downlevelLetConst12.ts, 4, 5)) - -let [baz] = []; ->baz : Symbol(baz, Decl(downlevelLetConst12.ts, 6, 5)) - -let {a: baz2} = { a: 1 }; ->a : Symbol(a, Decl(downlevelLetConst12.ts, 7, 17)) ->baz2 : Symbol(baz2, Decl(downlevelLetConst12.ts, 7, 5)) ->a : Symbol(a, Decl(downlevelLetConst12.ts, 7, 17)) - -const [baz3] = [] ->baz3 : Symbol(baz3, Decl(downlevelLetConst12.ts, 9, 7)) - -const {a: baz4} = { a: 1 }; ->a : Symbol(a, Decl(downlevelLetConst12.ts, 10, 19)) ->baz4 : Symbol(baz4, Decl(downlevelLetConst12.ts, 10, 7)) ->a : Symbol(a, Decl(downlevelLetConst12.ts, 10, 19)) - diff --git a/tests/baselines/reference/downlevelLetConst12.types b/tests/baselines/reference/downlevelLetConst12.types deleted file mode 100644 index 51d3b8eb086..00000000000 --- a/tests/baselines/reference/downlevelLetConst12.types +++ /dev/null @@ -1,35 +0,0 @@ -=== tests/cases/compiler/downlevelLetConst12.ts === - -'use strict' ->'use strict' : string - -// top level let\const should not be renamed -let foo; ->foo : any - -const bar = 1; ->bar : number ->1 : number - -let [baz] = []; ->baz : any ->[] : undefined[] - -let {a: baz2} = { a: 1 }; ->a : any ->baz2 : number ->{ a: 1 } : { a: number; } ->a : number ->1 : number - -const [baz3] = [] ->baz3 : any ->[] : undefined[] - -const {a: baz4} = { a: 1 }; ->a : any ->baz4 : number ->{ a: 1 } : { a: number; } ->a : number ->1 : number - diff --git a/tests/baselines/reference/downlevelLetConst16.errors.txt b/tests/baselines/reference/downlevelLetConst16.errors.txt index 94c53360b87..905d1a607e8 100644 --- a/tests/baselines/reference/downlevelLetConst16.errors.txt +++ b/tests/baselines/reference/downlevelLetConst16.errors.txt @@ -1,10 +1,12 @@ +tests/cases/compiler/downlevelLetConst16.ts(151,15): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/compiler/downlevelLetConst16.ts(164,17): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/compiler/downlevelLetConst16.ts(195,14): error TS2461: Type 'undefined' is not an array type. tests/cases/compiler/downlevelLetConst16.ts(202,15): error TS2459: Type 'undefined' has no property 'a' and no string index signature. tests/cases/compiler/downlevelLetConst16.ts(216,16): error TS2461: Type 'undefined' is not an array type. tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefined' has no property 'a' and no string index signature. -==== tests/cases/compiler/downlevelLetConst16.ts (4 errors) ==== +==== tests/cases/compiler/downlevelLetConst16.ts (6 errors) ==== 'use strict' declare function use(a: any); @@ -156,6 +158,8 @@ tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefin use(x); } for (let [y] = []; ;) { + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. use(y); } for (let {a: z} = {a: 1}; ;) { @@ -169,6 +173,8 @@ tests/cases/compiler/downlevelLetConst16.ts(223,17): error TS2459: Type 'undefin use(x); } for (const [y] = []; ;) { + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. use(y); } for (const {a: z} = { a: 1 }; ;) { diff --git a/tests/baselines/reference/elidingImportNames.js b/tests/baselines/reference/elidingImportNames.js index 3c61789a1a7..e07ee6fa54a 100644 --- a/tests/baselines/reference/elidingImportNames.js +++ b/tests/baselines/reference/elidingImportNames.js @@ -2,10 +2,10 @@ //// [elidingImportNames_test.ts] -import a = require('elidingImportNames_main'); // alias used in typeof +import a = require('./elidingImportNames_main'); // alias used in typeof var b = a; var x: typeof a; -import a2 = require('elidingImportNames_main1'); // alias not used in typeof +import a2 = require('./elidingImportNames_main1'); // alias not used in typeof var b2 = a2; @@ -20,8 +20,8 @@ exports.main = 10; //// [elidingImportNames_main1.js] exports.main = 10; //// [elidingImportNames_test.js] -var a = require('elidingImportNames_main'); // alias used in typeof +var a = require('./elidingImportNames_main'); // alias used in typeof var b = a; var x; -var a2 = require('elidingImportNames_main1'); // alias not used in typeof +var a2 = require('./elidingImportNames_main1'); // alias not used in typeof var b2 = a2; diff --git a/tests/baselines/reference/elidingImportNames.symbols b/tests/baselines/reference/elidingImportNames.symbols index 02646b5c3e2..d9cdcd61ffe 100644 --- a/tests/baselines/reference/elidingImportNames.symbols +++ b/tests/baselines/reference/elidingImportNames.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/elidingImportNames_test.ts === -import a = require('elidingImportNames_main'); // alias used in typeof +import a = require('./elidingImportNames_main'); // alias used in typeof >a : Symbol(a, Decl(elidingImportNames_test.ts, 0, 0)) var b = a; @@ -11,7 +11,7 @@ var x: typeof a; >x : Symbol(x, Decl(elidingImportNames_test.ts, 3, 3)) >a : Symbol(a, Decl(elidingImportNames_test.ts, 0, 0)) -import a2 = require('elidingImportNames_main1'); // alias not used in typeof +import a2 = require('./elidingImportNames_main1'); // alias not used in typeof >a2 : Symbol(a2, Decl(elidingImportNames_test.ts, 3, 16)) var b2 = a2; diff --git a/tests/baselines/reference/elidingImportNames.types b/tests/baselines/reference/elidingImportNames.types index 65bd16a6d97..947cd38f6d4 100644 --- a/tests/baselines/reference/elidingImportNames.types +++ b/tests/baselines/reference/elidingImportNames.types @@ -1,6 +1,6 @@ === tests/cases/compiler/elidingImportNames_test.ts === -import a = require('elidingImportNames_main'); // alias used in typeof +import a = require('./elidingImportNames_main'); // alias used in typeof >a : typeof a var b = a; @@ -11,7 +11,7 @@ var x: typeof a; >x : typeof a >a : typeof a -import a2 = require('elidingImportNames_main1'); // alias not used in typeof +import a2 = require('./elidingImportNames_main1'); // alias not used in typeof >a2 : typeof a2 var b2 = a2; diff --git a/tests/baselines/reference/emitArrowFunctionES6.types b/tests/baselines/reference/emitArrowFunctionES6.types index e2ad176fd7d..cc48cecd96a 100644 --- a/tests/baselines/reference/emitArrowFunctionES6.types +++ b/tests/baselines/reference/emitArrowFunctionES6.types @@ -87,12 +87,12 @@ var p8 = ({ a = 1 }) => { }; >1 : number var p9 = ({ a: { b = 1 } = { b: 1 } }) => { }; ->p9 : ({ a: { b = 1 } = { b: 1 } }: { a?: { b: number; }; }) => void ->({ a: { b = 1 } = { b: 1 } }) => { } : ({ a: { b = 1 } = { b: 1 } }: { a?: { b: number; }; }) => void +>p9 : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void +>({ a: { b = 1 } = { b: 1 } }) => { } : ({ a: { b = 1 } = { b: 1 } }: { a?: { b?: number; }; }) => void >a : any >b : number >1 : number ->{ b: 1 } : { b: number; } +>{ b: 1 } : { b?: number; } >b : number >1 : number diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols index ad1482e7f1a..3e7770ccdda 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.symbols @@ -5,7 +5,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 4419, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) let arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols index 42db5aeaa85..c0ea901fbbf 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 4419, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) const arguments = 100; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols index 453e04d7521..3d09056c8c3 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.symbols @@ -8,7 +8,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 4419, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols index b686dd19592..22431e495cc 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.symbols @@ -9,7 +9,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 4419, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments[0]; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols index 707b99c82c1..6dbbe9501d0 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18_ES6.symbols @@ -10,7 +10,7 @@ function f() { if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) ->Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 1704, 60)) +>Math : Symbol(Math, Decl(lib.d.ts, 522, 1), Decl(lib.d.ts, 633, 11), Decl(lib.d.ts, 4419, 60)) >random : Symbol(Math.random, Decl(lib.d.ts, 608, 38)) return () => arguments; diff --git a/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.types b/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.types index ecb48cb3047..3bdf5af2ba5 100644 --- a/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.types @@ -38,7 +38,7 @@ class B { this.y = 10; >this.y = 10 : number >this.y : number ->this : B +>this : this >y : number >10 : number } @@ -53,7 +53,7 @@ class B { return this._bar; >this._bar : string ->this : B +>this : this >_bar : string } } diff --git a/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.types b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.types index b26d6b3dd81..292fb961b10 100644 --- a/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.types @@ -10,7 +10,7 @@ class C { return this._name; >this._name : string ->this : C +>this : this >_name : string } static get name2(): string { diff --git a/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types index d3e75c9235c..10ae930c244 100644 --- a/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types @@ -25,7 +25,7 @@ class D { return this._bar; >this._bar : string ->this : D +>this : this >_bar : string } baz(a: any, x: string): string { diff --git a/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types b/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types index f3504d655ed..ccf4ca3ca9d 100644 --- a/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types @@ -21,7 +21,7 @@ class D { this.y = 10; >this.y = 10 : number >this.y : number ->this : D +>this : this >y : number >10 : number } @@ -55,7 +55,7 @@ class F extends D{ this.j = "HI"; >this.j = "HI" : string >this.j : string ->this : F +>this : this >j : string >"HI" : string } diff --git a/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.types b/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.types index 14c57a60bc4..7c0159fbd63 100644 --- a/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.types @@ -10,7 +10,7 @@ class B { this.x = 10; >this.x = 10 : number >this.x : number ->this : B +>this : this >x : number >10 : number } @@ -27,7 +27,7 @@ class B { >B : typeof B >log : (a: number) => void >this.x : number ->this : B +>this : this >x : number } @@ -36,7 +36,7 @@ class B { return this.x; >this.x : number ->this : B +>this : this >x : number } @@ -47,7 +47,7 @@ class B { this.x = y; >this.x = y : number >this.x : number ->this : B +>this : this >x : number >y : number } diff --git a/tests/baselines/reference/emitClassDeclarationWithTypeArgumentAndOverloadInES6.types b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentAndOverloadInES6.types index ba515168a5d..4bc2bfdfa92 100644 --- a/tests/baselines/reference/emitClassDeclarationWithTypeArgumentAndOverloadInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentAndOverloadInES6.types @@ -24,7 +24,7 @@ class B { >T : T >this.B = a : T >this.B : T ->this : B +>this : this >B : T >a : T @@ -47,7 +47,7 @@ class B { return this.x; >this.x : T ->this : B +>this : this >x : T } @@ -57,7 +57,7 @@ class B { return this.B; >this.B : T ->this : B +>this : this >B : T } set BBWith(c: T) { @@ -68,7 +68,7 @@ class B { this.B = c; >this.B = c : T >this.B : T ->this : B +>this : this >B : T >c : T } diff --git a/tests/baselines/reference/emitClassDeclarationWithTypeArgumentInES6.types b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentInES6.types index 8081d044e35..b4d2df96712 100644 --- a/tests/baselines/reference/emitClassDeclarationWithTypeArgumentInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentInES6.types @@ -16,7 +16,7 @@ class B { >T : T >this.B = a : T >this.B : T ->this : B +>this : this >B : T >a : T @@ -26,7 +26,7 @@ class B { return this.x; >this.x : T ->this : B +>this : this >x : T } get BB(): T { @@ -35,7 +35,7 @@ class B { return this.B; >this.B : T ->this : B +>this : this >B : T } set BBWith(c: T) { @@ -46,7 +46,7 @@ class B { this.B = c; >this.B = c : T >this.B : T ->this : B +>this : this >B : T >c : T } diff --git a/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.js b/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.js new file mode 100644 index 00000000000..a30fcbf045d --- /dev/null +++ b/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.js @@ -0,0 +1,16 @@ +//// [emitPinnedCommentsOnTopOfFile.ts] +/*! + + multi line + comment +*/ + +var x = 10; + +//// [emitPinnedCommentsOnTopOfFile.js] +/*! + + multi line + comment +*/ +var x = 10; diff --git a/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.symbols b/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.symbols new file mode 100644 index 00000000000..c9eb5905303 --- /dev/null +++ b/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts === +/*! + + multi line + comment +*/ + +var x = 10; +>x : Symbol(x, Decl(emitPinnedCommentsOnTopOfFile.ts, 6, 3)) + diff --git a/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.types b/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.types new file mode 100644 index 00000000000..0ada89e2802 --- /dev/null +++ b/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts === +/*! + + multi line + comment +*/ + +var x = 10; +>x : number +>10 : number + diff --git a/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.js b/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.js new file mode 100644 index 00000000000..ff358518568 --- /dev/null +++ b/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.ts] //// + +//// [file0.ts] + +var x = 10 + +//// [file1.ts] +/// +declare var OData: any; + +/// +interface F { } + + + + +//// [file0.js] +var x = 10; +//// [file1.js] +/// diff --git a/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.symbols b/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.symbols new file mode 100644 index 00000000000..1c0e48e00f2 --- /dev/null +++ b/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/file1.ts === +/// +declare var OData: any; +>OData : Symbol(OData, Decl(file1.ts, 1, 11)) + +/// +interface F { } +>F : Symbol(F, Decl(file1.ts, 1, 23)) + + + +=== tests/cases/compiler/file0.ts === + +var x = 10 +>x : Symbol(x, Decl(file0.ts, 1, 3)) + diff --git a/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.types b/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.types new file mode 100644 index 00000000000..637196fdc22 --- /dev/null +++ b/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/file1.ts === +/// +declare var OData: any; +>OData : any + +/// +interface F { } +>F : F + + + +=== tests/cases/compiler/file0.ts === + +var x = 10 +>x : number +>10 : number + diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter01.js b/tests/baselines/reference/emptyArrayBindingPatternParameter01.js index 5723c74f117..1eb76741e84 100644 --- a/tests/baselines/reference/emptyArrayBindingPatternParameter01.js +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter01.js @@ -1,6 +1,5 @@ //// [emptyArrayBindingPatternParameter01.ts] - function f([]) { var x, y, z; } @@ -9,3 +8,7 @@ function f([]) { function f(_a) { var x, y, z; } + + +//// [emptyArrayBindingPatternParameter01.d.ts] +declare function f([]: any[]): void; diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter01.symbols b/tests/baselines/reference/emptyArrayBindingPatternParameter01.symbols index f5089ce5850..e1630be639b 100644 --- a/tests/baselines/reference/emptyArrayBindingPatternParameter01.symbols +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter01.symbols @@ -1,11 +1,10 @@ === tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts === - function f([]) { >f : Symbol(f, Decl(emptyArrayBindingPatternParameter01.ts, 0, 0)) var x, y, z; ->x : Symbol(x, Decl(emptyArrayBindingPatternParameter01.ts, 3, 7)) ->y : Symbol(y, Decl(emptyArrayBindingPatternParameter01.ts, 3, 10)) ->z : Symbol(z, Decl(emptyArrayBindingPatternParameter01.ts, 3, 13)) +>x : Symbol(x, Decl(emptyArrayBindingPatternParameter01.ts, 2, 7)) +>y : Symbol(y, Decl(emptyArrayBindingPatternParameter01.ts, 2, 10)) +>z : Symbol(z, Decl(emptyArrayBindingPatternParameter01.ts, 2, 13)) } diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter01.types b/tests/baselines/reference/emptyArrayBindingPatternParameter01.types index 7ef40d52d59..4ca0b892ecf 100644 --- a/tests/baselines/reference/emptyArrayBindingPatternParameter01.types +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter01.types @@ -1,6 +1,5 @@ === tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts === - function f([]) { >f : ([]: any[]) => void diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter02.js b/tests/baselines/reference/emptyArrayBindingPatternParameter02.js index dbd86e843a8..d6dda16e12f 100644 --- a/tests/baselines/reference/emptyArrayBindingPatternParameter02.js +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter02.js @@ -1,6 +1,5 @@ //// [emptyArrayBindingPatternParameter02.ts] - function f(a, []) { var x, y, z; } @@ -9,3 +8,7 @@ function f(a, []) { function f(a, _a) { var x, y, z; } + + +//// [emptyArrayBindingPatternParameter02.d.ts] +declare function f(a: any, []: any[]): void; diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter02.symbols b/tests/baselines/reference/emptyArrayBindingPatternParameter02.symbols index 48cdcfaf93d..3289c06f962 100644 --- a/tests/baselines/reference/emptyArrayBindingPatternParameter02.symbols +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter02.symbols @@ -1,12 +1,11 @@ === tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts === - function f(a, []) { >f : Symbol(f, Decl(emptyArrayBindingPatternParameter02.ts, 0, 0)) ->a : Symbol(a, Decl(emptyArrayBindingPatternParameter02.ts, 2, 11)) +>a : Symbol(a, Decl(emptyArrayBindingPatternParameter02.ts, 1, 11)) var x, y, z; ->x : Symbol(x, Decl(emptyArrayBindingPatternParameter02.ts, 3, 7)) ->y : Symbol(y, Decl(emptyArrayBindingPatternParameter02.ts, 3, 10)) ->z : Symbol(z, Decl(emptyArrayBindingPatternParameter02.ts, 3, 13)) +>x : Symbol(x, Decl(emptyArrayBindingPatternParameter02.ts, 2, 7)) +>y : Symbol(y, Decl(emptyArrayBindingPatternParameter02.ts, 2, 10)) +>z : Symbol(z, Decl(emptyArrayBindingPatternParameter02.ts, 2, 13)) } diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter02.types b/tests/baselines/reference/emptyArrayBindingPatternParameter02.types index a58fe6b91d3..34d9e7dde6b 100644 --- a/tests/baselines/reference/emptyArrayBindingPatternParameter02.types +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter02.types @@ -1,6 +1,5 @@ === tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts === - function f(a, []) { >f : (a: any, []: any[]) => void >a : any diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter03.js b/tests/baselines/reference/emptyArrayBindingPatternParameter03.js index e2c3f7196e6..4867b39ac2f 100644 --- a/tests/baselines/reference/emptyArrayBindingPatternParameter03.js +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter03.js @@ -1,6 +1,5 @@ //// [emptyArrayBindingPatternParameter03.ts] - function f(a, []) { var x, y, z; } @@ -9,3 +8,7 @@ function f(a, []) { function f(a, _a) { var x, y, z; } + + +//// [emptyArrayBindingPatternParameter03.d.ts] +declare function f(a: any, []: any[]): void; diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter03.symbols b/tests/baselines/reference/emptyArrayBindingPatternParameter03.symbols index d3ec078df78..86a95687310 100644 --- a/tests/baselines/reference/emptyArrayBindingPatternParameter03.symbols +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter03.symbols @@ -1,12 +1,11 @@ === tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts === - function f(a, []) { >f : Symbol(f, Decl(emptyArrayBindingPatternParameter03.ts, 0, 0)) ->a : Symbol(a, Decl(emptyArrayBindingPatternParameter03.ts, 2, 11)) +>a : Symbol(a, Decl(emptyArrayBindingPatternParameter03.ts, 1, 11)) var x, y, z; ->x : Symbol(x, Decl(emptyArrayBindingPatternParameter03.ts, 3, 7)) ->y : Symbol(y, Decl(emptyArrayBindingPatternParameter03.ts, 3, 10)) ->z : Symbol(z, Decl(emptyArrayBindingPatternParameter03.ts, 3, 13)) +>x : Symbol(x, Decl(emptyArrayBindingPatternParameter03.ts, 2, 7)) +>y : Symbol(y, Decl(emptyArrayBindingPatternParameter03.ts, 2, 10)) +>z : Symbol(z, Decl(emptyArrayBindingPatternParameter03.ts, 2, 13)) } diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter03.types b/tests/baselines/reference/emptyArrayBindingPatternParameter03.types index 43f0af63ace..1c5579ebe36 100644 --- a/tests/baselines/reference/emptyArrayBindingPatternParameter03.types +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter03.types @@ -1,6 +1,5 @@ === tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts === - function f(a, []) { >f : (a: any, []: any[]) => void >a : any diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter04.js b/tests/baselines/reference/emptyArrayBindingPatternParameter04.js index e0715499ffe..c9819c88f40 100644 --- a/tests/baselines/reference/emptyArrayBindingPatternParameter04.js +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter04.js @@ -1,6 +1,5 @@ //// [emptyArrayBindingPatternParameter04.ts] - function f([] = [1,2,3,4]) { var x, y, z; } @@ -10,3 +9,7 @@ function f(_a) { var _a = [1, 2, 3, 4]; var x, y, z; } + + +//// [emptyArrayBindingPatternParameter04.d.ts] +declare function f([]?: number[]): void; diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter04.symbols b/tests/baselines/reference/emptyArrayBindingPatternParameter04.symbols index bb76a2c5925..9f4c9bae0c6 100644 --- a/tests/baselines/reference/emptyArrayBindingPatternParameter04.symbols +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter04.symbols @@ -1,11 +1,10 @@ === tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts === - function f([] = [1,2,3,4]) { >f : Symbol(f, Decl(emptyArrayBindingPatternParameter04.ts, 0, 0)) var x, y, z; ->x : Symbol(x, Decl(emptyArrayBindingPatternParameter04.ts, 3, 7)) ->y : Symbol(y, Decl(emptyArrayBindingPatternParameter04.ts, 3, 10)) ->z : Symbol(z, Decl(emptyArrayBindingPatternParameter04.ts, 3, 13)) +>x : Symbol(x, Decl(emptyArrayBindingPatternParameter04.ts, 2, 7)) +>y : Symbol(y, Decl(emptyArrayBindingPatternParameter04.ts, 2, 10)) +>z : Symbol(z, Decl(emptyArrayBindingPatternParameter04.ts, 2, 13)) } diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter04.types b/tests/baselines/reference/emptyArrayBindingPatternParameter04.types index 6f00a994f7b..834eb41b34d 100644 --- a/tests/baselines/reference/emptyArrayBindingPatternParameter04.types +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter04.types @@ -1,6 +1,5 @@ === tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts === - function f([] = [1,2,3,4]) { >f : ([]?: number[]) => void >[1,2,3,4] : number[] diff --git a/tests/baselines/reference/emptyAssignmentPatterns01_ES5.js b/tests/baselines/reference/emptyAssignmentPatterns01_ES5.js index b89db88e5e5..fe0a642c51e 100644 --- a/tests/baselines/reference/emptyAssignmentPatterns01_ES5.js +++ b/tests/baselines/reference/emptyAssignmentPatterns01_ES5.js @@ -9,3 +9,7 @@ var a: any; var a; (a); (a); + + +//// [emptyAssignmentPatterns01_ES5.d.ts] +declare var a: any; diff --git a/tests/baselines/reference/emptyAssignmentPatterns01_ES6.js b/tests/baselines/reference/emptyAssignmentPatterns01_ES6.js index fe311ac9061..4cf33452d98 100644 --- a/tests/baselines/reference/emptyAssignmentPatterns01_ES6.js +++ b/tests/baselines/reference/emptyAssignmentPatterns01_ES6.js @@ -9,3 +9,7 @@ var a: any; var a; ({} = a); ([] = a); + + +//// [emptyAssignmentPatterns01_ES6.d.ts] +declare var a: any; diff --git a/tests/baselines/reference/emptyAssignmentPatterns02_ES5.js b/tests/baselines/reference/emptyAssignmentPatterns02_ES5.js index 7b9f1f402f9..27a0b5f9b61 100644 --- a/tests/baselines/reference/emptyAssignmentPatterns02_ES5.js +++ b/tests/baselines/reference/emptyAssignmentPatterns02_ES5.js @@ -11,3 +11,8 @@ var a; var x, y, z, a1, a2, a3; ((x = a.x, y = a.y, z = a.z, a)); ((a1 = a[0], a2 = a[1], a3 = a[2], a)); + + +//// [emptyAssignmentPatterns02_ES5.d.ts] +declare var a: any; +declare let x: any, y: any, z: any, a1: any, a2: any, a3: any; diff --git a/tests/baselines/reference/emptyAssignmentPatterns02_ES6.js b/tests/baselines/reference/emptyAssignmentPatterns02_ES6.js index e9783c7e57d..493246c9473 100644 --- a/tests/baselines/reference/emptyAssignmentPatterns02_ES6.js +++ b/tests/baselines/reference/emptyAssignmentPatterns02_ES6.js @@ -11,3 +11,8 @@ var a; let x, y, z, a1, a2, a3; ({} = { x, y, z } = a); ([] = [a1, a2, a3] = a); + + +//// [emptyAssignmentPatterns02_ES6.d.ts] +declare var a: any; +declare let x: any, y: any, z: any, a1: any, a2: any, a3: any; diff --git a/tests/baselines/reference/emptyAssignmentPatterns03_ES5.js b/tests/baselines/reference/emptyAssignmentPatterns03_ES5.js index d9ff8ba9ede..adaad2e3b63 100644 --- a/tests/baselines/reference/emptyAssignmentPatterns03_ES5.js +++ b/tests/baselines/reference/emptyAssignmentPatterns03_ES5.js @@ -9,3 +9,7 @@ var a: any; var a; (a); (a); + + +//// [emptyAssignmentPatterns03_ES5.d.ts] +declare var a: any; diff --git a/tests/baselines/reference/emptyAssignmentPatterns03_ES6.js b/tests/baselines/reference/emptyAssignmentPatterns03_ES6.js index 95bfdfefa52..8050cc1e47a 100644 --- a/tests/baselines/reference/emptyAssignmentPatterns03_ES6.js +++ b/tests/baselines/reference/emptyAssignmentPatterns03_ES6.js @@ -9,3 +9,7 @@ var a: any; var a; ({} = {} = a); ([] = [] = a); + + +//// [emptyAssignmentPatterns03_ES6.d.ts] +declare var a: any; diff --git a/tests/baselines/reference/emptyAssignmentPatterns04_ES5.js b/tests/baselines/reference/emptyAssignmentPatterns04_ES5.js index 7e342d08e39..e6b3cc7e3f2 100644 --- a/tests/baselines/reference/emptyAssignmentPatterns04_ES5.js +++ b/tests/baselines/reference/emptyAssignmentPatterns04_ES5.js @@ -12,3 +12,8 @@ var x, y, z, a1, a2, a3; (_a = a, x = _a.x, y = _a.y, z = _a.z, _a); (_b = a, a1 = _b[0], a2 = _b[1], a3 = _b[2], _b); var _a, _b; + + +//// [emptyAssignmentPatterns04_ES5.d.ts] +declare var a: any; +declare let x: any, y: any, z: any, a1: any, a2: any, a3: any; diff --git a/tests/baselines/reference/emptyAssignmentPatterns04_ES6.js b/tests/baselines/reference/emptyAssignmentPatterns04_ES6.js index eabc2678c05..fb52975d6d1 100644 --- a/tests/baselines/reference/emptyAssignmentPatterns04_ES6.js +++ b/tests/baselines/reference/emptyAssignmentPatterns04_ES6.js @@ -11,3 +11,8 @@ var a; let x, y, z, a1, a2, a3; ({ x, y, z } = {} = a); ([a1, a2, a3] = [] = a); + + +//// [emptyAssignmentPatterns04_ES6.d.ts] +declare var a: any; +declare let x: any, y: any, z: any, a1: any, a2: any, a3: any; diff --git a/tests/baselines/reference/emptyModuleName.errors.txt b/tests/baselines/reference/emptyModuleName.errors.txt new file mode 100644 index 00000000000..16f04b247ea --- /dev/null +++ b/tests/baselines/reference/emptyModuleName.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/emptyModuleName.ts(1,20): error TS2307: Cannot find module ''. + + +==== tests/cases/compiler/emptyModuleName.ts (1 errors) ==== + import * as A from ""; + ~~ +!!! error TS2307: Cannot find module ''. + class B extends A { + } \ No newline at end of file diff --git a/tests/baselines/reference/emptyModuleName.js b/tests/baselines/reference/emptyModuleName.js new file mode 100644 index 00000000000..bb870f717c1 --- /dev/null +++ b/tests/baselines/reference/emptyModuleName.js @@ -0,0 +1,19 @@ +//// [emptyModuleName.ts] +import * as A from ""; +class B extends A { +} + +//// [emptyModuleName.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = require(""); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter01.js b/tests/baselines/reference/emptyObjectBindingPatternParameter01.js index 28cc30d2a0b..6a8ec808cd0 100644 --- a/tests/baselines/reference/emptyObjectBindingPatternParameter01.js +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter01.js @@ -1,6 +1,5 @@ //// [emptyObjectBindingPatternParameter01.ts] - function f({}) { var x, y, z; } @@ -9,3 +8,7 @@ function f({}) { function f(_a) { var x, y, z; } + + +//// [emptyObjectBindingPatternParameter01.d.ts] +declare function f({}: {}): void; diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter01.symbols b/tests/baselines/reference/emptyObjectBindingPatternParameter01.symbols index 98829df994f..3ef5898c29a 100644 --- a/tests/baselines/reference/emptyObjectBindingPatternParameter01.symbols +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter01.symbols @@ -1,11 +1,10 @@ === tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts === - function f({}) { >f : Symbol(f, Decl(emptyObjectBindingPatternParameter01.ts, 0, 0)) var x, y, z; ->x : Symbol(x, Decl(emptyObjectBindingPatternParameter01.ts, 3, 7)) ->y : Symbol(y, Decl(emptyObjectBindingPatternParameter01.ts, 3, 10)) ->z : Symbol(z, Decl(emptyObjectBindingPatternParameter01.ts, 3, 13)) +>x : Symbol(x, Decl(emptyObjectBindingPatternParameter01.ts, 2, 7)) +>y : Symbol(y, Decl(emptyObjectBindingPatternParameter01.ts, 2, 10)) +>z : Symbol(z, Decl(emptyObjectBindingPatternParameter01.ts, 2, 13)) } diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter01.types b/tests/baselines/reference/emptyObjectBindingPatternParameter01.types index c46569ea770..05ddc54719c 100644 --- a/tests/baselines/reference/emptyObjectBindingPatternParameter01.types +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter01.types @@ -1,6 +1,5 @@ === tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts === - function f({}) { >f : ({}: {}) => void diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter02.js b/tests/baselines/reference/emptyObjectBindingPatternParameter02.js index 8488428ea51..be2bdcab298 100644 --- a/tests/baselines/reference/emptyObjectBindingPatternParameter02.js +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter02.js @@ -1,6 +1,5 @@ //// [emptyObjectBindingPatternParameter02.ts] - function f(a, {}) { var x, y, z; } @@ -9,3 +8,7 @@ function f(a, {}) { function f(a, _a) { var x, y, z; } + + +//// [emptyObjectBindingPatternParameter02.d.ts] +declare function f(a: any, {}: {}): void; diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter02.symbols b/tests/baselines/reference/emptyObjectBindingPatternParameter02.symbols index fb0fa946b6f..d5bb4f292aa 100644 --- a/tests/baselines/reference/emptyObjectBindingPatternParameter02.symbols +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter02.symbols @@ -1,12 +1,11 @@ === tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts === - function f(a, {}) { >f : Symbol(f, Decl(emptyObjectBindingPatternParameter02.ts, 0, 0)) ->a : Symbol(a, Decl(emptyObjectBindingPatternParameter02.ts, 2, 11)) +>a : Symbol(a, Decl(emptyObjectBindingPatternParameter02.ts, 1, 11)) var x, y, z; ->x : Symbol(x, Decl(emptyObjectBindingPatternParameter02.ts, 3, 7)) ->y : Symbol(y, Decl(emptyObjectBindingPatternParameter02.ts, 3, 10)) ->z : Symbol(z, Decl(emptyObjectBindingPatternParameter02.ts, 3, 13)) +>x : Symbol(x, Decl(emptyObjectBindingPatternParameter02.ts, 2, 7)) +>y : Symbol(y, Decl(emptyObjectBindingPatternParameter02.ts, 2, 10)) +>z : Symbol(z, Decl(emptyObjectBindingPatternParameter02.ts, 2, 13)) } diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter02.types b/tests/baselines/reference/emptyObjectBindingPatternParameter02.types index 0a77fac8588..e2b485538e6 100644 --- a/tests/baselines/reference/emptyObjectBindingPatternParameter02.types +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter02.types @@ -1,6 +1,5 @@ === tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts === - function f(a, {}) { >f : (a: any, {}: {}) => void >a : any diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter03.js b/tests/baselines/reference/emptyObjectBindingPatternParameter03.js index 0279744e386..320bfe2d0df 100644 --- a/tests/baselines/reference/emptyObjectBindingPatternParameter03.js +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter03.js @@ -1,6 +1,5 @@ //// [emptyObjectBindingPatternParameter03.ts] - function f({}, a) { var x, y, z; } @@ -9,3 +8,7 @@ function f({}, a) { function f(_a, a) { var x, y, z; } + + +//// [emptyObjectBindingPatternParameter03.d.ts] +declare function f({}: {}, a: any): void; diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter03.symbols b/tests/baselines/reference/emptyObjectBindingPatternParameter03.symbols index 4e658e21ccf..82a1bcee75b 100644 --- a/tests/baselines/reference/emptyObjectBindingPatternParameter03.symbols +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter03.symbols @@ -1,12 +1,11 @@ === tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts === - function f({}, a) { >f : Symbol(f, Decl(emptyObjectBindingPatternParameter03.ts, 0, 0)) ->a : Symbol(a, Decl(emptyObjectBindingPatternParameter03.ts, 2, 14)) +>a : Symbol(a, Decl(emptyObjectBindingPatternParameter03.ts, 1, 14)) var x, y, z; ->x : Symbol(x, Decl(emptyObjectBindingPatternParameter03.ts, 3, 7)) ->y : Symbol(y, Decl(emptyObjectBindingPatternParameter03.ts, 3, 10)) ->z : Symbol(z, Decl(emptyObjectBindingPatternParameter03.ts, 3, 13)) +>x : Symbol(x, Decl(emptyObjectBindingPatternParameter03.ts, 2, 7)) +>y : Symbol(y, Decl(emptyObjectBindingPatternParameter03.ts, 2, 10)) +>z : Symbol(z, Decl(emptyObjectBindingPatternParameter03.ts, 2, 13)) } diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter03.types b/tests/baselines/reference/emptyObjectBindingPatternParameter03.types index 873c748dd9b..0f89702402a 100644 --- a/tests/baselines/reference/emptyObjectBindingPatternParameter03.types +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter03.types @@ -1,6 +1,5 @@ === tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts === - function f({}, a) { >f : ({}: {}, a: any) => void >a : any diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter04.errors.txt b/tests/baselines/reference/emptyObjectBindingPatternParameter04.errors.txt new file mode 100644 index 00000000000..03b58378a0f --- /dev/null +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter04.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(2,18): error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{}'. +tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(2,24): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type '{}'. +tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts(2,32): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type '{}'. + + +==== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts (3 errors) ==== + + function f({} = {a: 1, b: "2", c: true}) { + ~ +!!! error TS2353: Object literal may only specify known properties, and 'a' does not exist in type '{}'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'b' does not exist in type '{}'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'c' does not exist in type '{}'. + var x, y, z; + } \ No newline at end of file diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter04.js b/tests/baselines/reference/emptyObjectBindingPatternParameter04.js index fc3e41d0709..8c128bb806e 100644 --- a/tests/baselines/reference/emptyObjectBindingPatternParameter04.js +++ b/tests/baselines/reference/emptyObjectBindingPatternParameter04.js @@ -1,6 +1,5 @@ //// [emptyObjectBindingPatternParameter04.ts] - function f({} = {a: 1, b: "2", c: true}) { var x, y, z; } @@ -10,3 +9,11 @@ function f(_a) { var _a = { a: 1, b: "2", c: true }; var x, y, z; } + + +//// [emptyObjectBindingPatternParameter04.d.ts] +declare function f({}?: { + a: number; + b: string; + c: boolean; +}): void; diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter04.symbols b/tests/baselines/reference/emptyObjectBindingPatternParameter04.symbols deleted file mode 100644 index 9922d4cd074..00000000000 --- a/tests/baselines/reference/emptyObjectBindingPatternParameter04.symbols +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts === - - -function f({} = {a: 1, b: "2", c: true}) { ->f : Symbol(f, Decl(emptyObjectBindingPatternParameter04.ts, 0, 0)) ->a : Symbol(a, Decl(emptyObjectBindingPatternParameter04.ts, 2, 17)) ->b : Symbol(b, Decl(emptyObjectBindingPatternParameter04.ts, 2, 22)) ->c : Symbol(c, Decl(emptyObjectBindingPatternParameter04.ts, 2, 30)) - - var x, y, z; ->x : Symbol(x, Decl(emptyObjectBindingPatternParameter04.ts, 3, 7)) ->y : Symbol(y, Decl(emptyObjectBindingPatternParameter04.ts, 3, 10)) ->z : Symbol(z, Decl(emptyObjectBindingPatternParameter04.ts, 3, 13)) -} diff --git a/tests/baselines/reference/emptyObjectBindingPatternParameter04.types b/tests/baselines/reference/emptyObjectBindingPatternParameter04.types deleted file mode 100644 index 5ee32d422a9..00000000000 --- a/tests/baselines/reference/emptyObjectBindingPatternParameter04.types +++ /dev/null @@ -1,18 +0,0 @@ -=== tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts === - - -function f({} = {a: 1, b: "2", c: true}) { ->f : ({}?: { a: number; b: string; c: boolean; }) => void ->{a: 1, b: "2", c: true} : { a: number; b: string; c: boolean; } ->a : number ->1 : number ->b : string ->"2" : string ->c : boolean ->true : boolean - - var x, y, z; ->x : any ->y : any ->z : any -} diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.js b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.js new file mode 100644 index 00000000000..11c4f4e1807 --- /dev/null +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.js @@ -0,0 +1,101 @@ +//// [emptyVariableDeclarationBindingPatterns01_ES5.ts] + +(function () { + var a: any; + + var {} = a; + let {} = a; + const {} = a; + + var [] = a; + let [] = a; + const [] = a; + + var {} = a, [] = a; + let {} = a, [] = a; + const {} = a, [] = a; + + var { p1: {}, p2: [] } = a; + let { p1: {}, p2: [] } = a; + const { p1: {}, p2: [] } = a; + + for (var {} = {}, {} = {}; false; void 0) { + } + + function f({} = a, [] = a, { p: {} = a} = a) { + return ({} = a, [] = a, { p: {} = a } = a) => a; + } +})(); + +(function () { + const ns: number[][] = []; + + for (var {} of ns) { + } + + for (let {} of ns) { + } + + for (const {} of ns) { + } + + for (var [] of ns) { + } + + for (let [] of ns) { + } + + for (const [] of ns) { + } +})(); + +//// [emptyVariableDeclarationBindingPatterns01_ES5.js] +(function () { + var a; + var _a = a; + var _b = a; + var _c = a; + var _d = a; + var _e = a; + var _f = a; + var _g = a, _h = a; + var _j = a, _k = a; + var _l = a, _m = a; + var _o = a.p1, _p = a.p2; + var _q = a.p1, _r = a.p2; + var _s = a.p1, _t = a.p2; + for (var _u = {}, _v = {}; false; void 0) { + } + function f(_a, _b, _c) { + var _a = a; + var _b = a; + var _d = (_c === void 0 ? a : _c).p, _e = _d === void 0 ? a : _d; + return function (_a, _b, _c) { + var _a = a; + var _b = a; + var _d = (_c === void 0 ? a : _c).p, _e = _d === void 0 ? a : _d; + return a; + }; + } +})(); +(function () { + var ns = []; + for (var _i = 0; _i < ns.length; _i++) { + var _a = ns[_i]; + } + for (var _b = 0; _b < ns.length; _b++) { + var _c = ns[_b]; + } + for (var _d = 0; _d < ns.length; _d++) { + var _e = ns[_d]; + } + for (var _f = 0; _f < ns.length; _f++) { + var _g = ns[_f]; + } + for (var _h = 0; _h < ns.length; _h++) { + var _j = ns[_h]; + } + for (var _k = 0; _k < ns.length; _k++) { + var _l = ns[_k]; + } +})(); diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.symbols b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.symbols new file mode 100644 index 00000000000..ddba9738e08 --- /dev/null +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.symbols @@ -0,0 +1,92 @@ +=== tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5.ts === + +(function () { + var a: any; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) + + var {} = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) + + let {} = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) + + const {} = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) + + var [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) + + let [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) + + const [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) + + var {} = a, [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) + + let {} = a, [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) + + const {} = a, [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) + + var { p1: {}, p2: [] } = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) + + let { p1: {}, p2: [] } = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) + + const { p1: {}, p2: [] } = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) + + for (var {} = {}, {} = {}; false; void 0) { + } + + function f({} = a, [] = a, { p: {} = a} = a) { +>f : Symbol(f, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 21, 5)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) + + return ({} = a, [] = a, { p: {} = a } = a) => a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 2, 7)) + } +})(); + +(function () { + const ns: number[][] = []; +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 29, 9)) + + for (var {} of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 29, 9)) + } + + for (let {} of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 29, 9)) + } + + for (const {} of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 29, 9)) + } + + for (var [] of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 29, 9)) + } + + for (let [] of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 29, 9)) + } + + for (const [] of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES5.ts, 29, 9)) + } +})(); diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types new file mode 100644 index 00000000000..ed6b935db0f --- /dev/null +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types @@ -0,0 +1,115 @@ +=== tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5.ts === + +(function () { +>(function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; }})() : void +>(function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; }}) : () => void +>function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; }} : () => void + + var a: any; +>a : any + + var {} = a; +>a : any + + let {} = a; +>a : any + + const {} = a; +>a : any + + var [] = a; +>a : any + + let [] = a; +>a : any + + const [] = a; +>a : any + + var {} = a, [] = a; +>a : any +>a : any + + let {} = a, [] = a; +>a : any +>a : any + + const {} = a, [] = a; +>a : any +>a : any + + var { p1: {}, p2: [] } = a; +>p1 : any +>p2 : any +>a : any + + let { p1: {}, p2: [] } = a; +>p1 : any +>p2 : any +>a : any + + const { p1: {}, p2: [] } = a; +>p1 : any +>p2 : any +>a : any + + for (var {} = {}, {} = {}; false; void 0) { +>{} : {} +>{} : {} +>false : boolean +>void 0 : undefined +>0 : number + } + + function f({} = a, [] = a, { p: {} = a} = a) { +>f : ({}?: any, []?: any, { p: {} = a}?: any) => ({}?: any, []?: any, { p: {} = a }?: any) => any +>a : any +>a : any +>p : any +>a : any +>a : any + + return ({} = a, [] = a, { p: {} = a } = a) => a; +>({} = a, [] = a, { p: {} = a } = a) => a : ({}?: any, []?: any, { p: {} = a }?: any) => any +>a : any +>a : any +>p : any +>a : any +>a : any +>a : any + } +})(); + +(function () { +>(function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { }})() : void +>(function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { }}) : () => void +>function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { }} : () => void + + const ns: number[][] = []; +>ns : number[][] +>[] : undefined[] + + for (var {} of ns) { +>ns : number[][] + } + + for (let {} of ns) { +>ns : number[][] + } + + for (const {} of ns) { +>ns : number[][] + } + + for (var [] of ns) { +>ns : number[][] + } + + for (let [] of ns) { +>ns : number[][] + } + + for (const [] of ns) { +>ns : number[][] + } +})(); diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.js b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.js new file mode 100644 index 00000000000..1303ab1e3d0 --- /dev/null +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.js @@ -0,0 +1,87 @@ +//// [emptyVariableDeclarationBindingPatterns01_ES6.ts] + +(function () { + var a: any; + + var {} = a; + let {} = a; + const {} = a; + + var [] = a; + let [] = a; + const [] = a; + + var {} = a, [] = a; + let {} = a, [] = a; + const {} = a, [] = a; + + var { p1: {}, p2: [] } = a; + let { p1: {}, p2: [] } = a; + const { p1: {}, p2: [] } = a; + + for (var {} = {}, {} = {}; false; void 0) { + } + + function f({} = a, [] = a, { p: {} = a} = a) { + return ({} = a, [] = a, { p: {} = a } = a) => a; + } +})(); + +(function () { + const ns: number[][] = []; + + for (var {} of ns) { + } + + for (let {} of ns) { + } + + for (const {} of ns) { + } + + for (var [] of ns) { + } + + for (let [] of ns) { + } + + for (const [] of ns) { + } +})(); + +//// [emptyVariableDeclarationBindingPatterns01_ES6.js] +(function () { + var a; + var { } = a; + let { } = a; + const { } = a; + var [] = a; + let [] = a; + const [] = a; + var { } = a, [] = a; + let { } = a, [] = a; + const { } = a, [] = a; + var { p1: { }, p2: [] } = a; + let { p1: { }, p2: [] } = a; + const { p1: { }, p2: [] } = a; + for (var { } = {}, { } = {}; false; void 0) { + } + function f({ } = a, [] = a, { p: { } = a } = a) { + return ({ } = a, [] = a, { p: { } = a } = a) => a; + } +})(); +(function () { + const ns = []; + for (var { } of ns) { + } + for (let { } of ns) { + } + for (const { } of ns) { + } + for (var [] of ns) { + } + for (let [] of ns) { + } + for (const [] of ns) { + } +})(); diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.symbols b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.symbols new file mode 100644 index 00000000000..6a826d4b6c9 --- /dev/null +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.symbols @@ -0,0 +1,92 @@ +=== tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES6.ts === + +(function () { + var a: any; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) + + var {} = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) + + let {} = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) + + const {} = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) + + var [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) + + let [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) + + const [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) + + var {} = a, [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) + + let {} = a, [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) + + const {} = a, [] = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) + + var { p1: {}, p2: [] } = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) + + let { p1: {}, p2: [] } = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) + + const { p1: {}, p2: [] } = a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) + + for (var {} = {}, {} = {}; false; void 0) { + } + + function f({} = a, [] = a, { p: {} = a} = a) { +>f : Symbol(f, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 21, 5)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) + + return ({} = a, [] = a, { p: {} = a } = a) => a; +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) +>a : Symbol(a, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 2, 7)) + } +})(); + +(function () { + const ns: number[][] = []; +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 29, 9)) + + for (var {} of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 29, 9)) + } + + for (let {} of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 29, 9)) + } + + for (const {} of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 29, 9)) + } + + for (var [] of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 29, 9)) + } + + for (let [] of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 29, 9)) + } + + for (const [] of ns) { +>ns : Symbol(ns, Decl(emptyVariableDeclarationBindingPatterns01_ES6.ts, 29, 9)) + } +})(); diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types new file mode 100644 index 00000000000..fcb48048148 --- /dev/null +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types @@ -0,0 +1,115 @@ +=== tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES6.ts === + +(function () { +>(function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; }})() : void +>(function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; }}) : () => void +>function () { var a: any; var {} = a; let {} = a; const {} = a; var [] = a; let [] = a; const [] = a; var {} = a, [] = a; let {} = a, [] = a; const {} = a, [] = a; var { p1: {}, p2: [] } = a; let { p1: {}, p2: [] } = a; const { p1: {}, p2: [] } = a; for (var {} = {}, {} = {}; false; void 0) { } function f({} = a, [] = a, { p: {} = a} = a) { return ({} = a, [] = a, { p: {} = a } = a) => a; }} : () => void + + var a: any; +>a : any + + var {} = a; +>a : any + + let {} = a; +>a : any + + const {} = a; +>a : any + + var [] = a; +>a : any + + let [] = a; +>a : any + + const [] = a; +>a : any + + var {} = a, [] = a; +>a : any +>a : any + + let {} = a, [] = a; +>a : any +>a : any + + const {} = a, [] = a; +>a : any +>a : any + + var { p1: {}, p2: [] } = a; +>p1 : any +>p2 : any +>a : any + + let { p1: {}, p2: [] } = a; +>p1 : any +>p2 : any +>a : any + + const { p1: {}, p2: [] } = a; +>p1 : any +>p2 : any +>a : any + + for (var {} = {}, {} = {}; false; void 0) { +>{} : {} +>{} : {} +>false : boolean +>void 0 : undefined +>0 : number + } + + function f({} = a, [] = a, { p: {} = a} = a) { +>f : ({}?: any, []?: any, { p: {} = a}?: any) => ({}?: any, []?: any, { p: {} = a }?: any) => any +>a : any +>a : any +>p : any +>a : any +>a : any + + return ({} = a, [] = a, { p: {} = a } = a) => a; +>({} = a, [] = a, { p: {} = a } = a) => a : ({}?: any, []?: any, { p: {} = a }?: any) => any +>a : any +>a : any +>p : any +>a : any +>a : any +>a : any + } +})(); + +(function () { +>(function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { }})() : void +>(function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { }}) : () => void +>function () { const ns: number[][] = []; for (var {} of ns) { } for (let {} of ns) { } for (const {} of ns) { } for (var [] of ns) { } for (let [] of ns) { } for (const [] of ns) { }} : () => void + + const ns: number[][] = []; +>ns : number[][] +>[] : undefined[] + + for (var {} of ns) { +>ns : number[][] + } + + for (let {} of ns) { +>ns : number[][] + } + + for (const {} of ns) { +>ns : number[][] + } + + for (var [] of ns) { +>ns : number[][] + } + + for (let [] of ns) { +>ns : number[][] + } + + for (const [] of ns) { +>ns : number[][] + } +})(); diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5.errors.txt b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5.errors.txt new file mode 100644 index 00000000000..b589b075ecb --- /dev/null +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5.errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts(3,9): error TS1182: A destructuring declaration must have an initializer. +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts(4,9): error TS1182: A destructuring declaration must have an initializer. +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts(5,11): error TS1182: A destructuring declaration must have an initializer. +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts(7,9): error TS1182: A destructuring declaration must have an initializer. +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts(8,9): error TS1182: A destructuring declaration must have an initializer. +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts(9,11): error TS1182: A destructuring declaration must have an initializer. + + +==== tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts (6 errors) ==== + + (function () { + var {}; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + let {}; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + const {}; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + + var []; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + let []; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + const []; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + })(); \ No newline at end of file diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5.js b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5.js new file mode 100644 index 00000000000..7710b5e26c1 --- /dev/null +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES5.js @@ -0,0 +1,24 @@ +//// [emptyVariableDeclarationBindingPatterns02_ES5.ts] + +(function () { + var {}; + let {}; + const {}; + + var []; + let []; + const []; +})(); + +//// [emptyVariableDeclarationBindingPatterns02_ES5.js] +(function () { + var _a = void 0; + var _b = void 0; + var _c = void 0; + var _d = void 0; + var _e = void 0; + var _f = void 0; +})(); + + +//// [emptyVariableDeclarationBindingPatterns02_ES5.d.ts] diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES6.errors.txt b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES6.errors.txt new file mode 100644 index 00000000000..81349584f47 --- /dev/null +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES6.errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts(3,9): error TS1182: A destructuring declaration must have an initializer. +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts(4,9): error TS1182: A destructuring declaration must have an initializer. +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts(5,11): error TS1182: A destructuring declaration must have an initializer. +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts(7,9): error TS1182: A destructuring declaration must have an initializer. +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts(8,9): error TS1182: A destructuring declaration must have an initializer. +tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts(9,11): error TS1182: A destructuring declaration must have an initializer. + + +==== tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts (6 errors) ==== + + (function () { + var {}; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + let {}; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + const {}; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + + var []; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + let []; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + const []; + ~~ +!!! error TS1182: A destructuring declaration must have an initializer. + })(); \ No newline at end of file diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES6.js b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES6.js new file mode 100644 index 00000000000..8b2df68ed70 --- /dev/null +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns02_ES6.js @@ -0,0 +1,24 @@ +//// [emptyVariableDeclarationBindingPatterns02_ES6.ts] + +(function () { + var {}; + let {}; + const {}; + + var []; + let []; + const []; +})(); + +//// [emptyVariableDeclarationBindingPatterns02_ES6.js] +(function () { + var { }; + let { }; + const { }; + var []; + let []; + const []; +})(); + + +//// [emptyVariableDeclarationBindingPatterns02_ES6.d.ts] diff --git a/tests/baselines/reference/enumConstantMembers.errors.txt b/tests/baselines/reference/enumConstantMembers.errors.txt deleted file mode 100644 index d425b7a6f4b..00000000000 --- a/tests/baselines/reference/enumConstantMembers.errors.txt +++ /dev/null @@ -1,28 +0,0 @@ -tests/cases/conformance/enums/enumConstantMembers.ts(12,5): error TS1061: Enum member must have initializer. -tests/cases/conformance/enums/enumConstantMembers.ts(18,5): error TS1066: Ambient enum elements can only have integer literal initializers. - - -==== tests/cases/conformance/enums/enumConstantMembers.ts (2 errors) ==== - // Constant members allow negatives, but not decimals. Also hex literals are allowed - enum E1 { - a = 1, - b - } - enum E2 { - a = - 1, - b - } - enum E3 { - a = 0.1, - b // Error because 0.1 is not a constant - ~ -!!! error TS1061: Enum member must have initializer. - } - - declare enum E4 { - a = 1, - b = -1, - c = 0.1 // Not a constant - ~ -!!! error TS1066: Ambient enum elements can only have integer literal initializers. - } \ No newline at end of file diff --git a/tests/baselines/reference/enumConstantMembers.symbols b/tests/baselines/reference/enumConstantMembers.symbols new file mode 100644 index 00000000000..6bf516cceef --- /dev/null +++ b/tests/baselines/reference/enumConstantMembers.symbols @@ -0,0 +1,42 @@ +=== tests/cases/conformance/enums/enumConstantMembers.ts === +// Constant members allow negatives, but not decimals. Also hex literals are allowed +enum E1 { +>E1 : Symbol(E1, Decl(enumConstantMembers.ts, 0, 0)) + + a = 1, +>a : Symbol(E1.a, Decl(enumConstantMembers.ts, 1, 9)) + + b +>b : Symbol(E1.b, Decl(enumConstantMembers.ts, 2, 10)) +} +enum E2 { +>E2 : Symbol(E2, Decl(enumConstantMembers.ts, 4, 1)) + + a = - 1, +>a : Symbol(E2.a, Decl(enumConstantMembers.ts, 5, 9)) + + b +>b : Symbol(E2.b, Decl(enumConstantMembers.ts, 6, 12)) +} +enum E3 { +>E3 : Symbol(E3, Decl(enumConstantMembers.ts, 8, 1)) + + a = 0.1, +>a : Symbol(E3.a, Decl(enumConstantMembers.ts, 9, 9)) + + b // Error because 0.1 is not a constant +>b : Symbol(E3.b, Decl(enumConstantMembers.ts, 10, 12)) +} + +declare enum E4 { +>E4 : Symbol(E4, Decl(enumConstantMembers.ts, 12, 1)) + + a = 1, +>a : Symbol(E4.a, Decl(enumConstantMembers.ts, 14, 17)) + + b = -1, +>b : Symbol(E4.b, Decl(enumConstantMembers.ts, 15, 10)) + + c = 0.1 // Not a constant +>c : Symbol(E4.c, Decl(enumConstantMembers.ts, 16, 11)) +} diff --git a/tests/baselines/reference/enumConstantMembers.types b/tests/baselines/reference/enumConstantMembers.types new file mode 100644 index 00000000000..c99b5eeb62f --- /dev/null +++ b/tests/baselines/reference/enumConstantMembers.types @@ -0,0 +1,50 @@ +=== tests/cases/conformance/enums/enumConstantMembers.ts === +// Constant members allow negatives, but not decimals. Also hex literals are allowed +enum E1 { +>E1 : E1 + + a = 1, +>a : E1 +>1 : number + + b +>b : E1 +} +enum E2 { +>E2 : E2 + + a = - 1, +>a : E2 +>- 1 : number +>1 : number + + b +>b : E2 +} +enum E3 { +>E3 : E3 + + a = 0.1, +>a : E3 +>0.1 : number + + b // Error because 0.1 is not a constant +>b : E3 +} + +declare enum E4 { +>E4 : E4 + + a = 1, +>a : E4 +>1 : number + + b = -1, +>b : E4 +>-1 : number +>1 : number + + c = 0.1 // Not a constant +>c : E4 +>0.1 : number +} diff --git a/tests/baselines/reference/enumFromExternalModule.js b/tests/baselines/reference/enumFromExternalModule.js index ed2a1f3926a..af04d9522b0 100644 --- a/tests/baselines/reference/enumFromExternalModule.js +++ b/tests/baselines/reference/enumFromExternalModule.js @@ -5,7 +5,7 @@ export enum Mode { Open } //// [enumFromExternalModule_1.ts] /// -import f = require('enumFromExternalModule_0'); +import f = require('./enumFromExternalModule_0'); var x = f.Mode.Open; @@ -17,5 +17,5 @@ var x = f.Mode.Open; var Mode = exports.Mode; //// [enumFromExternalModule_1.js] /// -var f = require('enumFromExternalModule_0'); +var f = require('./enumFromExternalModule_0'); var x = f.Mode.Open; diff --git a/tests/baselines/reference/enumFromExternalModule.symbols b/tests/baselines/reference/enumFromExternalModule.symbols index 90ff7cd7aac..3f2b1de5293 100644 --- a/tests/baselines/reference/enumFromExternalModule.symbols +++ b/tests/baselines/reference/enumFromExternalModule.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/enumFromExternalModule_1.ts === /// -import f = require('enumFromExternalModule_0'); +import f = require('./enumFromExternalModule_0'); >f : Symbol(f, Decl(enumFromExternalModule_1.ts, 0, 0)) var x = f.Mode.Open; diff --git a/tests/baselines/reference/enumFromExternalModule.types b/tests/baselines/reference/enumFromExternalModule.types index 554ac17ec67..05555572aa7 100644 --- a/tests/baselines/reference/enumFromExternalModule.types +++ b/tests/baselines/reference/enumFromExternalModule.types @@ -1,6 +1,6 @@ === tests/cases/compiler/enumFromExternalModule_1.ts === /// -import f = require('enumFromExternalModule_0'); +import f = require('./enumFromExternalModule_0'); >f : typeof f var x = f.Mode.Open; diff --git a/tests/baselines/reference/enumInitializersWithExponents.errors.txt b/tests/baselines/reference/enumInitializersWithExponents.errors.txt deleted file mode 100644 index c4338cdf78b..00000000000 --- a/tests/baselines/reference/enumInitializersWithExponents.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -tests/cases/compiler/enumInitializersWithExponents.ts(5,5): error TS1066: Ambient enum elements can only have integer literal initializers. -tests/cases/compiler/enumInitializersWithExponents.ts(6,5): error TS1066: Ambient enum elements can only have integer literal initializers. - - -==== tests/cases/compiler/enumInitializersWithExponents.ts (2 errors) ==== - // Must be integer literals. - declare enum E { - a = 1e3, // ok - b = 1e25, // ok - c = 1e-3, // error - ~ -!!! error TS1066: Ambient enum elements can only have integer literal initializers. - d = 1e-9, // error - ~ -!!! error TS1066: Ambient enum elements can only have integer literal initializers. - e = 1e0, // ok - f = 1e+25 // ok - } \ No newline at end of file diff --git a/tests/baselines/reference/enumInitializersWithExponents.symbols b/tests/baselines/reference/enumInitializersWithExponents.symbols new file mode 100644 index 00000000000..13f7141a322 --- /dev/null +++ b/tests/baselines/reference/enumInitializersWithExponents.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/enumInitializersWithExponents.ts === +// Must be integer literals. +declare enum E { +>E : Symbol(E, Decl(enumInitializersWithExponents.ts, 0, 0)) + + a = 1e3, // ok +>a : Symbol(E.a, Decl(enumInitializersWithExponents.ts, 1, 16)) + + b = 1e25, // ok +>b : Symbol(E.b, Decl(enumInitializersWithExponents.ts, 2, 12)) + + c = 1e-3, // error +>c : Symbol(E.c, Decl(enumInitializersWithExponents.ts, 3, 13)) + + d = 1e-9, // error +>d : Symbol(E.d, Decl(enumInitializersWithExponents.ts, 4, 13)) + + e = 1e0, // ok +>e : Symbol(E.e, Decl(enumInitializersWithExponents.ts, 5, 13)) + + f = 1e+25 // ok +>f : Symbol(E.f, Decl(enumInitializersWithExponents.ts, 6, 12)) +} diff --git a/tests/baselines/reference/enumInitializersWithExponents.types b/tests/baselines/reference/enumInitializersWithExponents.types new file mode 100644 index 00000000000..8da208e5f87 --- /dev/null +++ b/tests/baselines/reference/enumInitializersWithExponents.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/enumInitializersWithExponents.ts === +// Must be integer literals. +declare enum E { +>E : E + + a = 1e3, // ok +>a : E +>1e3 : number + + b = 1e25, // ok +>b : E +>1e25 : number + + c = 1e-3, // error +>c : E +>1e-3 : number + + d = 1e-9, // error +>d : E +>1e-9 : number + + e = 1e0, // ok +>e : E +>1e0 : number + + f = 1e+25 // ok +>f : E +>1e+25 : number +} diff --git a/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.errors.txt b/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.errors.txt deleted file mode 100644 index 876c04a0322..00000000000 --- a/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/enumWithoutInitializerAfterComputedMember.ts(4,5): error TS1061: Enum member must have initializer. - - -==== tests/cases/compiler/enumWithoutInitializerAfterComputedMember.ts (1 errors) ==== - enum E { - a, - b = a, - c - ~ -!!! error TS1061: Enum member must have initializer. - } \ No newline at end of file diff --git a/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.symbols b/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.symbols new file mode 100644 index 00000000000..54449b29399 --- /dev/null +++ b/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/enumWithoutInitializerAfterComputedMember.ts === +enum E { +>E : Symbol(E, Decl(enumWithoutInitializerAfterComputedMember.ts, 0, 0)) + + a, +>a : Symbol(E.a, Decl(enumWithoutInitializerAfterComputedMember.ts, 0, 8)) + + b = a, +>b : Symbol(E.b, Decl(enumWithoutInitializerAfterComputedMember.ts, 1, 6)) +>a : Symbol(E.a, Decl(enumWithoutInitializerAfterComputedMember.ts, 0, 8)) + + c +>c : Symbol(E.c, Decl(enumWithoutInitializerAfterComputedMember.ts, 2, 10)) +} diff --git a/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.types b/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.types new file mode 100644 index 00000000000..0ece7b76f1e --- /dev/null +++ b/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/enumWithoutInitializerAfterComputedMember.ts === +enum E { +>E : E + + a, +>a : E + + b = a, +>b : E +>a : E + + c +>c : E +} diff --git a/tests/baselines/reference/errorsOnImportedSymbol.errors.txt b/tests/baselines/reference/errorsOnImportedSymbol.errors.txt index ec108d48881..19839e4e544 100644 --- a/tests/baselines/reference/errorsOnImportedSymbol.errors.txt +++ b/tests/baselines/reference/errorsOnImportedSymbol.errors.txt @@ -3,7 +3,7 @@ tests/cases/compiler/errorsOnImportedSymbol_1.ts(3,9): error TS2304: Cannot find ==== tests/cases/compiler/errorsOnImportedSymbol_1.ts (2 errors) ==== - import Sammy = require("errorsOnImportedSymbol_0"); + import Sammy = require("./errorsOnImportedSymbol_0"); var x = new Sammy.Sammy(); ~~~~~ !!! error TS2304: Cannot find name 'Sammy'. diff --git a/tests/baselines/reference/errorsOnImportedSymbol.js b/tests/baselines/reference/errorsOnImportedSymbol.js index 6a001bcd0f1..2c991ecd821 100644 --- a/tests/baselines/reference/errorsOnImportedSymbol.js +++ b/tests/baselines/reference/errorsOnImportedSymbol.js @@ -9,7 +9,7 @@ interface Sammy { export = Sammy; //// [errorsOnImportedSymbol_1.ts] -import Sammy = require("errorsOnImportedSymbol_0"); +import Sammy = require("./errorsOnImportedSymbol_0"); var x = new Sammy.Sammy(); var y = Sammy.Sammy(); diff --git a/tests/baselines/reference/es3defaultAliasIsQuoted.js b/tests/baselines/reference/es3defaultAliasIsQuoted.js new file mode 100644 index 00000000000..3ca828c1b4c --- /dev/null +++ b/tests/baselines/reference/es3defaultAliasIsQuoted.js @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/es3defaultAliasIsQuoted.ts] //// + +//// [es3defaultAliasQuoted_file0.ts] + +export class Foo { + static CONSTANT = "Foo"; +} + +export default function assert(value: boolean) { + if (!value) throw new Error("Assertion failed!"); +} + +//// [es3defaultAliasQuoted_file1.ts] +import {Foo, default as assert} from "./es3defaultAliasQuoted_file0"; +assert(Foo.CONSTANT === "Foo"); + +//// [es3defaultAliasQuoted_file0.js] +var Foo = (function () { + function Foo() { + } + Foo.CONSTANT = "Foo"; + return Foo; +})(); +exports.Foo = Foo; +function assert(value) { + if (!value) + throw new Error("Assertion failed!"); +} +exports.__esModule = true; +exports["default"] = assert; +//// [es3defaultAliasQuoted_file1.js] +var es3defaultAliasQuoted_file0_1 = require("./es3defaultAliasQuoted_file0"); +es3defaultAliasQuoted_file0_1["default"](es3defaultAliasQuoted_file0_1.Foo.CONSTANT === "Foo"); diff --git a/tests/baselines/reference/es3defaultAliasIsQuoted.symbols b/tests/baselines/reference/es3defaultAliasIsQuoted.symbols new file mode 100644 index 00000000000..907f1d71b89 --- /dev/null +++ b/tests/baselines/reference/es3defaultAliasIsQuoted.symbols @@ -0,0 +1,30 @@ +=== tests/cases/compiler/es3defaultAliasQuoted_file0.ts === + +export class Foo { +>Foo : Symbol(Foo, Decl(es3defaultAliasQuoted_file0.ts, 0, 0)) + + static CONSTANT = "Foo"; +>CONSTANT : Symbol(Foo.CONSTANT, Decl(es3defaultAliasQuoted_file0.ts, 1, 18)) +} + +export default function assert(value: boolean) { +>assert : Symbol(assert, Decl(es3defaultAliasQuoted_file0.ts, 3, 1)) +>value : Symbol(value, Decl(es3defaultAliasQuoted_file0.ts, 5, 31)) + + if (!value) throw new Error("Assertion failed!"); +>value : Symbol(value, Decl(es3defaultAliasQuoted_file0.ts, 5, 31)) +>Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11)) +} + +=== tests/cases/compiler/es3defaultAliasQuoted_file1.ts === +import {Foo, default as assert} from "./es3defaultAliasQuoted_file0"; +>Foo : Symbol(Foo, Decl(es3defaultAliasQuoted_file1.ts, 0, 8)) +>default : Symbol(assert, Decl(es3defaultAliasQuoted_file1.ts, 0, 12)) +>assert : Symbol(assert, Decl(es3defaultAliasQuoted_file1.ts, 0, 12)) + +assert(Foo.CONSTANT === "Foo"); +>assert : Symbol(assert, Decl(es3defaultAliasQuoted_file1.ts, 0, 12)) +>Foo.CONSTANT : Symbol(Foo.CONSTANT, Decl(es3defaultAliasQuoted_file0.ts, 1, 18)) +>Foo : Symbol(Foo, Decl(es3defaultAliasQuoted_file1.ts, 0, 8)) +>CONSTANT : Symbol(Foo.CONSTANT, Decl(es3defaultAliasQuoted_file0.ts, 1, 18)) + diff --git a/tests/baselines/reference/es3defaultAliasIsQuoted.types b/tests/baselines/reference/es3defaultAliasIsQuoted.types new file mode 100644 index 00000000000..d3b1ebf105b --- /dev/null +++ b/tests/baselines/reference/es3defaultAliasIsQuoted.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/es3defaultAliasQuoted_file0.ts === + +export class Foo { +>Foo : Foo + + static CONSTANT = "Foo"; +>CONSTANT : string +>"Foo" : string +} + +export default function assert(value: boolean) { +>assert : (value: boolean) => void +>value : boolean + + if (!value) throw new Error("Assertion failed!"); +>!value : boolean +>value : boolean +>new Error("Assertion failed!") : Error +>Error : ErrorConstructor +>"Assertion failed!" : string +} + +=== tests/cases/compiler/es3defaultAliasQuoted_file1.ts === +import {Foo, default as assert} from "./es3defaultAliasQuoted_file0"; +>Foo : typeof Foo +>default : (value: boolean) => void +>assert : (value: boolean) => void + +assert(Foo.CONSTANT === "Foo"); +>assert(Foo.CONSTANT === "Foo") : void +>assert : (value: boolean) => void +>Foo.CONSTANT === "Foo" : boolean +>Foo.CONSTANT : string +>Foo : typeof Foo +>CONSTANT : string +>"Foo" : string + diff --git a/tests/baselines/reference/es5-umd2.js b/tests/baselines/reference/es5-umd2.js index 4267e7a3331..9b79f5f17b7 100644 --- a/tests/baselines/reference/es5-umd2.js +++ b/tests/baselines/reference/es5-umd2.js @@ -15,14 +15,14 @@ export class A //// [es5-umd2.js] -(function (deps, factory) { +(function (factory) { if (typeof module === 'object' && typeof module.exports === 'object') { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === 'function' && define.amd) { - define(deps, factory); + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { var A = (function () { function A() { } diff --git a/tests/baselines/reference/es5-umd3.js b/tests/baselines/reference/es5-umd3.js index 92ac306698a..042316b710e 100644 --- a/tests/baselines/reference/es5-umd3.js +++ b/tests/baselines/reference/es5-umd3.js @@ -15,14 +15,14 @@ export default class A //// [es5-umd3.js] -(function (deps, factory) { +(function (factory) { if (typeof module === 'object' && typeof module.exports === 'object') { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === 'function' && define.amd) { - define(deps, factory); + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { var A = (function () { function A() { } diff --git a/tests/baselines/reference/es5-umd4.js b/tests/baselines/reference/es5-umd4.js index 058ad545f42..81dcf440cb8 100644 --- a/tests/baselines/reference/es5-umd4.js +++ b/tests/baselines/reference/es5-umd4.js @@ -17,14 +17,14 @@ export = A; //// [es5-umd4.js] -(function (deps, factory) { +(function (factory) { if (typeof module === 'object' && typeof module.exports === 'object') { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === 'function' && define.amd) { - define(deps, factory); + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { var A = (function () { function A() { } diff --git a/tests/baselines/reference/es5andes6module.errors.txt b/tests/baselines/reference/es5andes6module.errors.txt new file mode 100644 index 00000000000..d5a672b9486 --- /dev/null +++ b/tests/baselines/reference/es5andes6module.errors.txt @@ -0,0 +1,19 @@ +error TS1204: Cannot compile modules into 'es6' when targeting 'ES5' or lower. + + +!!! error TS1204: Cannot compile modules into 'es6' when targeting 'ES5' or lower. +==== tests/cases/compiler/es5andes6module.ts (0 errors) ==== + + export default class A + { + constructor () + { + + } + + public B() + { + return 42; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/es5andes6module.js b/tests/baselines/reference/es5andes6module.js new file mode 100644 index 00000000000..0d489357852 --- /dev/null +++ b/tests/baselines/reference/es5andes6module.js @@ -0,0 +1,26 @@ +//// [es5andes6module.ts] + +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + + +//// [es5andes6module.js] +var A = (function () { + function A() { + } + A.prototype.B = function () { + return 42; + }; + return A; +})(); +exports.default = A; diff --git a/tests/baselines/reference/es6-amd.errors.txt b/tests/baselines/reference/es6-amd.errors.txt deleted file mode 100644 index b4a6442458b..00000000000 --- a/tests/baselines/reference/es6-amd.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6-amd.ts (0 errors) ==== - - class A - { - constructor () - { - - } - - public B() - { - return 42; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/es6-amd.symbols b/tests/baselines/reference/es6-amd.symbols new file mode 100644 index 00000000000..ad5cf38e7cd --- /dev/null +++ b/tests/baselines/reference/es6-amd.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/es6-amd.ts === + +class A +>A : Symbol(A, Decl(es6-amd.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es6-amd.ts, 6, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/es6-amd.types b/tests/baselines/reference/es6-amd.types new file mode 100644 index 00000000000..7a6fb6e32f5 --- /dev/null +++ b/tests/baselines/reference/es6-amd.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es6-amd.ts === + +class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} diff --git a/tests/baselines/reference/es6-declaration-amd.errors.txt b/tests/baselines/reference/es6-declaration-amd.errors.txt deleted file mode 100644 index fe5a254dd54..00000000000 --- a/tests/baselines/reference/es6-declaration-amd.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6-declaration-amd.ts (0 errors) ==== - - class A - { - constructor () - { - - } - - public B() - { - return 42; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/es6-declaration-amd.symbols b/tests/baselines/reference/es6-declaration-amd.symbols new file mode 100644 index 00000000000..f1a728396cc --- /dev/null +++ b/tests/baselines/reference/es6-declaration-amd.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/es6-declaration-amd.ts === + +class A +>A : Symbol(A, Decl(es6-declaration-amd.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es6-declaration-amd.ts, 6, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/es6-declaration-amd.types b/tests/baselines/reference/es6-declaration-amd.types new file mode 100644 index 00000000000..a46d22c82c5 --- /dev/null +++ b/tests/baselines/reference/es6-declaration-amd.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es6-declaration-amd.ts === + +class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} diff --git a/tests/baselines/reference/es6-sourcemap-amd.errors.txt b/tests/baselines/reference/es6-sourcemap-amd.errors.txt deleted file mode 100644 index 8ffa16aaa23..00000000000 --- a/tests/baselines/reference/es6-sourcemap-amd.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6-sourcemap-amd.ts (0 errors) ==== - - class A - { - constructor () - { - - } - - public B() - { - return 42; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/es6-sourcemap-amd.symbols b/tests/baselines/reference/es6-sourcemap-amd.symbols new file mode 100644 index 00000000000..13be6367ba0 --- /dev/null +++ b/tests/baselines/reference/es6-sourcemap-amd.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/es6-sourcemap-amd.ts === + +class A +>A : Symbol(A, Decl(es6-sourcemap-amd.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es6-sourcemap-amd.ts, 6, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/es6-sourcemap-amd.types b/tests/baselines/reference/es6-sourcemap-amd.types new file mode 100644 index 00000000000..580a688afab --- /dev/null +++ b/tests/baselines/reference/es6-sourcemap-amd.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es6-sourcemap-amd.ts === + +class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} diff --git a/tests/baselines/reference/es6-umd.errors.txt b/tests/baselines/reference/es6-umd.errors.txt deleted file mode 100644 index 72a58585073..00000000000 --- a/tests/baselines/reference/es6-umd.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6-umd.ts (0 errors) ==== - - class A - { - constructor () - { - - } - - public B() - { - return 42; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/es6-umd.symbols b/tests/baselines/reference/es6-umd.symbols new file mode 100644 index 00000000000..f7c57215ea6 --- /dev/null +++ b/tests/baselines/reference/es6-umd.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/es6-umd.ts === + +class A +>A : Symbol(A, Decl(es6-umd.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es6-umd.ts, 6, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/es6-umd.types b/tests/baselines/reference/es6-umd.types new file mode 100644 index 00000000000..f43c491e003 --- /dev/null +++ b/tests/baselines/reference/es6-umd.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es6-umd.ts === + +class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} diff --git a/tests/baselines/reference/es6-umd2.errors.txt b/tests/baselines/reference/es6-umd2.errors.txt deleted file mode 100644 index 00becfb105f..00000000000 --- a/tests/baselines/reference/es6-umd2.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6-umd2.ts (0 errors) ==== - - export class A - { - constructor () - { - - } - - public B() - { - return 42; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/es6-umd2.js b/tests/baselines/reference/es6-umd2.js index 416932d89bc..b87027b21b1 100644 --- a/tests/baselines/reference/es6-umd2.js +++ b/tests/baselines/reference/es6-umd2.js @@ -14,10 +14,20 @@ export class A } //// [es6-umd2.js] -export class A { - constructor() { +(function (factory) { + if (typeof module === 'object' && typeof module.exports === 'object') { + var v = factory(require, exports); if (v !== undefined) module.exports = v; } - B() { - return 42; + else if (typeof define === 'function' && define.amd) { + define(["require", "exports"], factory); } -} +})(function (require, exports) { + class A { + constructor() { + } + B() { + return 42; + } + } + exports.A = A; +}); diff --git a/tests/baselines/reference/es6-umd2.symbols b/tests/baselines/reference/es6-umd2.symbols new file mode 100644 index 00000000000..88acf127279 --- /dev/null +++ b/tests/baselines/reference/es6-umd2.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/es6-umd2.ts === + +export class A +>A : Symbol(A, Decl(es6-umd2.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es6-umd2.ts, 6, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/es6-umd2.types b/tests/baselines/reference/es6-umd2.types new file mode 100644 index 00000000000..eb66523c6ec --- /dev/null +++ b/tests/baselines/reference/es6-umd2.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es6-umd2.ts === + +export class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} diff --git a/tests/baselines/reference/es6ClassTest3.types b/tests/baselines/reference/es6ClassTest3.types index d73007f211b..208d8cdf4d9 100644 --- a/tests/baselines/reference/es6ClassTest3.types +++ b/tests/baselines/reference/es6ClassTest3.types @@ -24,14 +24,14 @@ module M { this.x = 1; >this.x = 1 : number >this.x : number ->this : Visibility +>this : this >x : number >1 : number this.y = 2; >this.y = 2 : number >this.y : number ->this : Visibility +>this : this >y : number >2 : number } diff --git a/tests/baselines/reference/es6ClassTest8.types b/tests/baselines/reference/es6ClassTest8.types index 622f81f1d10..b12d65e595f 100644 --- a/tests/baselines/reference/es6ClassTest8.types +++ b/tests/baselines/reference/es6ClassTest8.types @@ -119,7 +119,7 @@ class Camera { this.forward = Vector.norm(Vector.minus(lookAt,this.pos)); >this.forward = Vector.norm(Vector.minus(lookAt,this.pos)) : Vector >this.forward : Vector ->this : Camera +>this : this >forward : Vector >Vector.norm(Vector.minus(lookAt,this.pos)) : Vector >Vector.norm : (v: Vector) => Vector @@ -131,13 +131,13 @@ class Camera { >minus : (v1: Vector, v2: Vector) => Vector >lookAt : Vector >this.pos : Vector ->this : Camera +>this : this >pos : Vector this.right = Vector.times(down, Vector.norm(Vector.cross(this.forward, down))); >this.right = Vector.times(down, Vector.norm(Vector.cross(this.forward, down))) : Vector >this.right : Vector ->this : Camera +>this : this >right : Vector >Vector.times(down, Vector.norm(Vector.cross(this.forward, down))) : Vector >Vector.times : (v1: Vector, v2: Vector) => Vector @@ -153,14 +153,14 @@ class Camera { >Vector : typeof Vector >cross : (v1: Vector, v2: Vector) => Vector >this.forward : Vector ->this : Camera +>this : this >forward : Vector >down : Vector this.up = Vector.times(down, Vector.norm(Vector.cross(this.forward, this.right))); >this.up = Vector.times(down, Vector.norm(Vector.cross(this.forward, this.right))) : Vector >this.up : Vector ->this : Camera +>this : this >up : Vector >Vector.times(down, Vector.norm(Vector.cross(this.forward, this.right))) : Vector >Vector.times : (v1: Vector, v2: Vector) => Vector @@ -176,10 +176,10 @@ class Camera { >Vector : typeof Vector >cross : (v1: Vector, v2: Vector) => Vector >this.forward : Vector ->this : Camera +>this : this >forward : Vector >this.right : Vector ->this : Camera +>this : this >right : Vector } } diff --git a/tests/baselines/reference/es6ExportAllInEs5.js b/tests/baselines/reference/es6ExportAllInEs5.js index 1be3fa1f1b2..73689019ed4 100644 --- a/tests/baselines/reference/es6ExportAllInEs5.js +++ b/tests/baselines/reference/es6ExportAllInEs5.js @@ -14,7 +14,7 @@ export module uninstantiated { } //// [client.ts] -export * from "server"; +export * from "./server"; //// [server.js] var c = (function () { @@ -32,7 +32,7 @@ exports.x = 10; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } -__export(require("server")); +__export(require("./server")); //// [server.d.ts] @@ -47,4 +47,4 @@ export declare var x: number; export declare module uninstantiated { } //// [client.d.ts] -export * from "server"; +export * from "./server"; diff --git a/tests/baselines/reference/es6ExportAllInEs5.symbols b/tests/baselines/reference/es6ExportAllInEs5.symbols index c2a575f5e5c..26d47f63af3 100644 --- a/tests/baselines/reference/es6ExportAllInEs5.symbols +++ b/tests/baselines/reference/es6ExportAllInEs5.symbols @@ -20,5 +20,5 @@ export module uninstantiated { } === tests/cases/compiler/client.ts === -export * from "server"; +export * from "./server"; No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportAllInEs5.types b/tests/baselines/reference/es6ExportAllInEs5.types index 876ff152e2c..68187384602 100644 --- a/tests/baselines/reference/es6ExportAllInEs5.types +++ b/tests/baselines/reference/es6ExportAllInEs5.types @@ -22,5 +22,5 @@ export module uninstantiated { } === tests/cases/compiler/client.ts === -export * from "server"; +export * from "./server"; No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportAssignment.errors.txt b/tests/baselines/reference/es6ExportAssignment.errors.txt index 1db7d04e05e..970d2e184dc 100644 --- a/tests/baselines/reference/es6ExportAssignment.errors.txt +++ b/tests/baselines/reference/es6ExportAssignment.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/es6ExportAssignment.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. +tests/cases/compiler/es6ExportAssignment.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead. ==== tests/cases/compiler/es6ExportAssignment.ts (1 errors) ==== @@ -6,4 +6,4 @@ tests/cases/compiler/es6ExportAssignment.ts(3,1): error TS1203: Export assignmen var a = 10; export = a; ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. \ No newline at end of file +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportAssignment2.errors.txt b/tests/baselines/reference/es6ExportAssignment2.errors.txt index d5e1dfebd9d..248491f98c3 100644 --- a/tests/baselines/reference/es6ExportAssignment2.errors.txt +++ b/tests/baselines/reference/es6ExportAssignment2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/a.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. +tests/cases/compiler/a.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead. ==== tests/cases/compiler/a.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/a.ts(3,1): error TS1203: Export assignment cannot be used w var a = 10; export = a; // Error: export = not allowed in ES6 ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead. ==== tests/cases/compiler/b.ts (0 errors) ==== import * as a from "a"; diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js index 6250e0ce326..63ac2c04b3e 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.js @@ -14,11 +14,11 @@ export module uninstantiated { } //// [client.ts] -export { c } from "server"; -export { c as c2 } from "server"; -export { i, m as instantiatedModule } from "server"; -export { uninstantiated } from "server"; -export { x } from "server"; +export { c } from "./server"; +export { c as c2 } from "./server"; +export { i, m as instantiatedModule } from "./server"; +export { uninstantiated } from "./server"; +export { x } from "./server"; //// [server.js] var c = (function () { @@ -33,13 +33,13 @@ var m; })(m = exports.m || (exports.m = {})); exports.x = 10; //// [client.js] -var server_1 = require("server"); +var server_1 = require("./server"); exports.c = server_1.c; -var server_2 = require("server"); +var server_2 = require("./server"); exports.c2 = server_2.c; -var server_3 = require("server"); +var server_3 = require("./server"); exports.instantiatedModule = server_3.m; -var server_4 = require("server"); +var server_4 = require("./server"); exports.x = server_4.x; @@ -55,8 +55,8 @@ export declare var x: number; export declare module uninstantiated { } //// [client.d.ts] -export { c } from "server"; -export { c as c2 } from "server"; -export { i, m as instantiatedModule } from "server"; -export { uninstantiated } from "server"; -export { x } from "server"; +export { c } from "./server"; +export { c as c2 } from "./server"; +export { i, m as instantiatedModule } from "./server"; +export { uninstantiated } from "./server"; +export { x } from "./server"; diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.symbols b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.symbols index 731a0fdcc30..c8e279e65bf 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.symbols +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.symbols @@ -20,21 +20,21 @@ export module uninstantiated { } === tests/cases/compiler/client.ts === -export { c } from "server"; +export { c } from "./server"; >c : Symbol(c, Decl(client.ts, 0, 8)) -export { c as c2 } from "server"; +export { c as c2 } from "./server"; >c : Symbol(c2, Decl(client.ts, 1, 8)) >c2 : Symbol(c2, Decl(client.ts, 1, 8)) -export { i, m as instantiatedModule } from "server"; +export { i, m as instantiatedModule } from "./server"; >i : Symbol(i, Decl(client.ts, 2, 8)) >m : Symbol(instantiatedModule, Decl(client.ts, 2, 11)) >instantiatedModule : Symbol(instantiatedModule, Decl(client.ts, 2, 11)) -export { uninstantiated } from "server"; +export { uninstantiated } from "./server"; >uninstantiated : Symbol(uninstantiated, Decl(client.ts, 3, 8)) -export { x } from "server"; +export { x } from "./server"; >x : Symbol(x, Decl(client.ts, 4, 8)) diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types index 6b621f4c777..4bd93b39031 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types @@ -22,21 +22,21 @@ export module uninstantiated { } === tests/cases/compiler/client.ts === -export { c } from "server"; +export { c } from "./server"; >c : typeof c -export { c as c2 } from "server"; +export { c as c2 } from "./server"; >c : typeof c >c2 : typeof c -export { i, m as instantiatedModule } from "server"; +export { i, m as instantiatedModule } from "./server"; >i : any >m : typeof m >instantiatedModule : typeof m -export { uninstantiated } from "server"; +export { uninstantiated } from "./server"; >uninstantiated : any -export { x } from "server"; +export { x } from "./server"; >x : number diff --git a/tests/baselines/reference/es6ExportEquals.errors.txt b/tests/baselines/reference/es6ExportEquals.errors.txt index 174c72341f6..e8db09456d3 100644 --- a/tests/baselines/reference/es6ExportEquals.errors.txt +++ b/tests/baselines/reference/es6ExportEquals.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/es6ExportEquals.ts(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. +tests/cases/compiler/es6ExportEquals.ts(4,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead. tests/cases/compiler/es6ExportEquals.ts(4,1): error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -8,7 +8,7 @@ tests/cases/compiler/es6ExportEquals.ts(4,1): error TS2309: An export assignment export = f; ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead. ~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingDts.js index a5e8d509da1..5593d762f85 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.js @@ -6,9 +6,9 @@ class c { } export default c; //// [client.ts] -import defaultBinding from "server"; +import defaultBinding from "./server"; export var x = new defaultBinding(); -import defaultBinding2 from "server"; // elide this import since defaultBinding2 is not used +import defaultBinding2 from "./server"; // elide this import since defaultBinding2 is not used //// [server.js] @@ -20,7 +20,7 @@ var c = (function () { Object.defineProperty(exports, "__esModule", { value: true }); exports.default = c; //// [client.js] -var server_1 = require("server"); +var server_1 = require("./server"); exports.x = new server_1.default(); @@ -29,5 +29,5 @@ declare class c { } export default c; //// [client.d.ts] -import defaultBinding from "server"; +import defaultBinding from "./server"; export declare var x: defaultBinding; diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.symbols b/tests/baselines/reference/es6ImportDefaultBindingDts.symbols index 1ca93aa6641..f25be3eacad 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingDts.symbols +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.symbols @@ -7,13 +7,13 @@ export default c; >c : Symbol(c, Decl(server.ts, 0, 0)) === tests/cases/compiler/client.ts === -import defaultBinding from "server"; +import defaultBinding from "./server"; >defaultBinding : Symbol(defaultBinding, Decl(client.ts, 0, 6)) export var x = new defaultBinding(); >x : Symbol(x, Decl(client.ts, 1, 10)) >defaultBinding : Symbol(defaultBinding, Decl(client.ts, 0, 6)) -import defaultBinding2 from "server"; // elide this import since defaultBinding2 is not used +import defaultBinding2 from "./server"; // elide this import since defaultBinding2 is not used >defaultBinding2 : Symbol(defaultBinding2, Decl(client.ts, 2, 6)) diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.types b/tests/baselines/reference/es6ImportDefaultBindingDts.types index 65754d80680..8543c6845b2 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingDts.types +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.types @@ -7,7 +7,7 @@ export default c; >c : c === tests/cases/compiler/client.ts === -import defaultBinding from "server"; +import defaultBinding from "./server"; >defaultBinding : typeof defaultBinding export var x = new defaultBinding(); @@ -15,6 +15,6 @@ export var x = new defaultBinding(); >new defaultBinding() : defaultBinding >defaultBinding : typeof defaultBinding -import defaultBinding2 from "server"; // elide this import since defaultBinding2 is not used +import defaultBinding2 from "./server"; // elide this import since defaultBinding2 is not used >defaultBinding2 : typeof defaultBinding diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt deleted file mode 100644 index 2688d4af06f..00000000000 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0.ts (0 errors) ==== - - export var a = 10; - export var x = a; - export var m = a; - export default {}; - -==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts (0 errors) ==== - import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - var x1: number = a; - import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - var x1: number = b; - import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - var x1: number = x; - var x1: number = y; - import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - var x1: number = z; - import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; - var x1: number = m; - \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js index 641941db9e5..d6be494a8d1 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js @@ -8,37 +8,37 @@ export var m = a; export default {}; //// [es6ImportDefaultBindingFollowedWithNamedImport_1.ts] -import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = a; -import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = b; -import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = x; var x1: number = y; -import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = z; -import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = m; //// [es6ImportDefaultBindingFollowedWithNamedImport_0.js] -export var a = 10; -export var x = a; -export var m = a; -export default {}; +exports.a = 10; +exports.x = exports.a; +exports.m = exports.a; +exports.default = {}; //// [es6ImportDefaultBindingFollowedWithNamedImport_1.js] -import { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -var x1 = a; -import { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -var x1 = b; -import { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -var x1 = x; -var x1 = y; -import { x as z } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -var x1 = z; -import { m } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -var x1 = m; +var es6ImportDefaultBindingFollowedWithNamedImport_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0"); +var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_1.a; +var es6ImportDefaultBindingFollowedWithNamedImport_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0"); +var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_2.a; +var es6ImportDefaultBindingFollowedWithNamedImport_0_3 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0"); +var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_3.x; +var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_3.a; +var es6ImportDefaultBindingFollowedWithNamedImport_0_4 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0"); +var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_4.x; +var es6ImportDefaultBindingFollowedWithNamedImport_0_5 = require("./es6ImportDefaultBindingFollowedWithNamedImport_0"); +var x1 = es6ImportDefaultBindingFollowedWithNamedImport_0_5.m; //// [es6ImportDefaultBindingFollowedWithNamedImport_0.d.ts] diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.symbols b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.symbols new file mode 100644 index 00000000000..5da138f6c62 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.symbols @@ -0,0 +1,67 @@ +=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0.ts === + +export var a = 10; +>a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport_0.ts, 1, 10)) + +export var x = a; +>x : Symbol(x, Decl(es6ImportDefaultBindingFollowedWithNamedImport_0.ts, 2, 10)) +>a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport_0.ts, 1, 10)) + +export var m = a; +>m : Symbol(m, Decl(es6ImportDefaultBindingFollowedWithNamedImport_0.ts, 3, 10)) +>a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport_0.ts, 1, 10)) + +export default {}; + +=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts === +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding1 : Symbol(defaultBinding1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 0, 6)) + +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding2 : Symbol(defaultBinding2, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 1, 6)) +>a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 1, 25)) + +var x1: number = a; +>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3)) +>a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 1, 25)) + +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding3 : Symbol(defaultBinding3, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 3, 6)) +>a : Symbol(b, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 3, 25)) +>b : Symbol(b, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 3, 25)) + +var x1: number = b; +>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3)) +>b : Symbol(b, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 3, 25)) + +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding4 : Symbol(defaultBinding4, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 6)) +>x : Symbol(x, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 25)) +>a : Symbol(y, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 28)) +>y : Symbol(y, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 28)) + +var x1: number = x; +>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3)) +>x : Symbol(x, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 25)) + +var x1: number = y; +>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3)) +>y : Symbol(y, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 5, 28)) + +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding5 : Symbol(defaultBinding5, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 8, 6)) +>x : Symbol(z, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 8, 25)) +>z : Symbol(z, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 8, 25)) + +var x1: number = z; +>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3)) +>z : Symbol(z, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 8, 25)) + +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding6 : Symbol(defaultBinding6, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 10, 6)) +>m : Symbol(m, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 10, 25)) + +var x1: number = m; +>x1 : Symbol(x1, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 2, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 4, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 6, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 7, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 9, 3), Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 11, 3)) +>m : Symbol(m, Decl(es6ImportDefaultBindingFollowedWithNamedImport_1.ts, 10, 25)) + diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.types b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.types new file mode 100644 index 00000000000..fe0137403a9 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.types @@ -0,0 +1,69 @@ +=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0.ts === + +export var a = 10; +>a : number +>10 : number + +export var x = a; +>x : number +>a : number + +export var m = a; +>m : number +>a : number + +export default {}; +>{} : {} + +=== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts === +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding1 : {} + +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding2 : {} +>a : number + +var x1: number = a; +>x1 : number +>a : number + +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding3 : {} +>a : number +>b : number + +var x1: number = b; +>x1 : number +>b : number + +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding4 : {} +>x : number +>a : number +>y : number + +var x1: number = x; +>x1 : number +>x : number + +var x1: number = y; +>x1 : number +>y : number + +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding5 : {} +>x : number +>z : number + +var x1: number = z; +>x1 : number +>z : number + +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +>defaultBinding6 : {} +>m : number + +var x1: number = m; +>x1 : number +>m : number + diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.errors.txt index 5809e0874dc..c62ecb70c58 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.errors.txt @@ -12,27 +12,27 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts(1 export default a; ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts (6 errors) ==== - import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding1; - import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; ~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'a'. var x: number = defaultBinding2; - import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; ~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'a'. var x: number = defaultBinding3; - import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; ~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'x'. ~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'a'. var x: number = defaultBinding4; - import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; ~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'x'. var x: number = defaultBinding5; - import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; + import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; ~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"' has no exported member 'm'. var x: number = defaultBinding6; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js index 7090b7a0663..7eda76622de 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js @@ -6,17 +6,17 @@ var a = 10; export default a; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts] -import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding1; -import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding2; -import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding3; -import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding4; -import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding5; -import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding6; @@ -25,17 +25,17 @@ var a = 10; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.js] -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6 = require("es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6.default; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt index aa9e0cb3af3..76c424a74d4 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.errors.txt @@ -18,23 +18,23 @@ tests/cases/compiler/client.ts(11,34): error TS2305: Module '"tests/cases/compil export default a; ==== tests/cases/compiler/client.ts (12 errors) ==== - export import defaultBinding1, { } from "server"; + export import defaultBinding1, { } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var x1: number = defaultBinding1; - export import defaultBinding2, { a } from "server"; + export import defaultBinding2, { a } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. export var x1: number = defaultBinding2; - export import defaultBinding3, { a as b } from "server"; + export import defaultBinding3, { a as b } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. export var x1: number = defaultBinding3; - export import defaultBinding4, { x, a as y } from "server"; + export import defaultBinding4, { x, a as y } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~ @@ -42,13 +42,13 @@ tests/cases/compiler/client.ts(11,34): error TS2305: Module '"tests/cases/compil ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. export var x1: number = defaultBinding4; - export import defaultBinding5, { x as z, } from "server"; + export import defaultBinding5, { x as z, } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. export var x1: number = defaultBinding5; - export import defaultBinding6, { m, } from "server"; + export import defaultBinding6, { m, } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~ diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js index 2b0e3ebbeb5..b83571066f0 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js @@ -6,17 +6,17 @@ var a = 10; export default a; //// [client.ts] -export import defaultBinding1, { } from "server"; +export import defaultBinding1, { } from "./server"; export var x1: number = defaultBinding1; -export import defaultBinding2, { a } from "server"; +export import defaultBinding2, { a } from "./server"; export var x1: number = defaultBinding2; -export import defaultBinding3, { a as b } from "server"; +export import defaultBinding3, { a as b } from "./server"; export var x1: number = defaultBinding3; -export import defaultBinding4, { x, a as y } from "server"; +export import defaultBinding4, { x, a as y } from "./server"; export var x1: number = defaultBinding4; -export import defaultBinding5, { x as z, } from "server"; +export import defaultBinding5, { x as z, } from "./server"; export var x1: number = defaultBinding5; -export import defaultBinding6, { m, } from "server"; +export import defaultBinding6, { m, } from "./server"; export var x1: number = defaultBinding6; @@ -25,17 +25,17 @@ var a = 10; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [client.js] -var server_1 = require("server"); +var server_1 = require("./server"); exports.x1 = server_1.default; -var server_2 = require("server"); +var server_2 = require("./server"); exports.x1 = server_2.default; -var server_3 = require("server"); +var server_3 = require("./server"); exports.x1 = server_3.default; -var server_4 = require("server"); +var server_4 = require("./server"); exports.x1 = server_4.default; -var server_5 = require("server"); +var server_5 = require("./server"); exports.x1 = server_5.default; -var server_6 = require("server"); +var server_6 = require("./server"); exports.x1 = server_6.default; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt index 451543d78f5..47e0cb347f3 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt @@ -16,27 +16,27 @@ tests/cases/compiler/client.ts(11,8): error TS1192: Module '"tests/cases/compile export class x11 { } ==== tests/cases/compiler/client.ts (6 errors) ==== - import defaultBinding1, { } from "server"; + import defaultBinding1, { } from "./server"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/server"' has no default export. - import defaultBinding2, { a } from "server"; + import defaultBinding2, { a } from "./server"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/server"' has no default export. export var x1 = new a(); - import defaultBinding3, { a11 as b } from "server"; + import defaultBinding3, { a11 as b } from "./server"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/server"' has no default export. export var x2 = new b(); - import defaultBinding4, { x, a12 as y } from "server"; + import defaultBinding4, { x, a12 as y } from "./server"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/server"' has no default export. export var x4 = new x(); export var x5 = new y(); - import defaultBinding5, { x11 as z, } from "server"; + import defaultBinding5, { x11 as z, } from "./server"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/server"' has no default export. export var x3 = new z(); - import defaultBinding6, { m, } from "server"; + import defaultBinding6, { m, } from "./server"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/server"' has no default export. export var x6 = new m(); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js index 8cf9ab1ffb1..9314190e786 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts.js @@ -10,17 +10,17 @@ export class a12 { } export class x11 { } //// [client.ts] -import defaultBinding1, { } from "server"; -import defaultBinding2, { a } from "server"; +import defaultBinding1, { } from "./server"; +import defaultBinding2, { a } from "./server"; export var x1 = new a(); -import defaultBinding3, { a11 as b } from "server"; +import defaultBinding3, { a11 as b } from "./server"; export var x2 = new b(); -import defaultBinding4, { x, a12 as y } from "server"; +import defaultBinding4, { x, a12 as y } from "./server"; export var x4 = new x(); export var x5 = new y(); -import defaultBinding5, { x11 as z, } from "server"; +import defaultBinding5, { x11 as z, } from "./server"; export var x3 = new z(); -import defaultBinding6, { m, } from "server"; +import defaultBinding6, { m, } from "./server"; export var x6 = new m(); @@ -62,16 +62,16 @@ var x11 = (function () { })(); exports.x11 = x11; //// [client.js] -var server_1 = require("server"); +var server_1 = require("./server"); exports.x1 = new server_1.a(); -var server_2 = require("server"); +var server_2 = require("./server"); exports.x2 = new server_2.a11(); -var server_3 = require("server"); +var server_3 = require("./server"); exports.x4 = new server_3.x(); exports.x5 = new server_3.a12(); -var server_4 = require("server"); +var server_4 = require("./server"); exports.x3 = new server_4.x11(); -var server_5 = require("server"); +var server_5 = require("./server"); exports.x6 = new server_5.m(); @@ -89,14 +89,14 @@ export declare class a12 { export declare class x11 { } //// [client.d.ts] -import { a } from "server"; +import { a } from "./server"; export declare var x1: a; -import { a11 as b } from "server"; +import { a11 as b } from "./server"; export declare var x2: b; -import { x, a12 as y } from "server"; +import { x, a12 as y } from "./server"; export declare var x4: x; export declare var x5: y; -import { x11 as z } from "server"; +import { x11 as z } from "./server"; export declare var x3: z; -import { m } from "server"; +import { m } from "./server"; export declare var x6: m; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.errors.txt index 0e259f142b6..e939398632c 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.errors.txt @@ -12,27 +12,27 @@ tests/cases/compiler/client.ts(11,27): error TS2305: Module '"tests/cases/compil export default a; ==== tests/cases/compiler/client.ts (6 errors) ==== - import defaultBinding1, { } from "server"; + import defaultBinding1, { } from "./server"; export var x1 = new defaultBinding1(); - import defaultBinding2, { a } from "server"; + import defaultBinding2, { a } from "./server"; ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. export var x2 = new defaultBinding2(); - import defaultBinding3, { a as b } from "server"; + import defaultBinding3, { a as b } from "./server"; ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. export var x3 = new defaultBinding3(); - import defaultBinding4, { x, a as y } from "server"; + import defaultBinding4, { x, a as y } from "./server"; ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'a'. export var x4 = new defaultBinding4(); - import defaultBinding5, { x as z, } from "server"; + import defaultBinding5, { x as z, } from "./server"; ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'x'. export var x5 = new defaultBinding5(); - import defaultBinding6, { m, } from "server"; + import defaultBinding6, { m, } from "./server"; ~ !!! error TS2305: Module '"tests/cases/compiler/server"' has no exported member 'm'. export var x6 = new defaultBinding6(); \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js index dad034c618c..71d35fd85a1 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js @@ -6,17 +6,17 @@ class a { } export default a; //// [client.ts] -import defaultBinding1, { } from "server"; +import defaultBinding1, { } from "./server"; export var x1 = new defaultBinding1(); -import defaultBinding2, { a } from "server"; +import defaultBinding2, { a } from "./server"; export var x2 = new defaultBinding2(); -import defaultBinding3, { a as b } from "server"; +import defaultBinding3, { a as b } from "./server"; export var x3 = new defaultBinding3(); -import defaultBinding4, { x, a as y } from "server"; +import defaultBinding4, { x, a as y } from "./server"; export var x4 = new defaultBinding4(); -import defaultBinding5, { x as z, } from "server"; +import defaultBinding5, { x as z, } from "./server"; export var x5 = new defaultBinding5(); -import defaultBinding6, { m, } from "server"; +import defaultBinding6, { m, } from "./server"; export var x6 = new defaultBinding6(); //// [server.js] @@ -28,17 +28,17 @@ var a = (function () { Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [client.js] -var server_1 = require("server"); +var server_1 = require("./server"); exports.x1 = new server_1.default(); -var server_2 = require("server"); +var server_2 = require("./server"); exports.x2 = new server_2.default(); -var server_3 = require("server"); +var server_3 = require("./server"); exports.x3 = new server_3.default(); -var server_4 = require("server"); +var server_4 = require("./server"); exports.x4 = new server_4.default(); -var server_5 = require("server"); +var server_5 = require("./server"); exports.x5 = new server_5.default(); -var server_6 = require("server"); +var server_6 = require("./server"); exports.x6 = new server_6.default(); @@ -47,7 +47,7 @@ declare class a { } export default a; //// [client.d.ts] -import defaultBinding1 from "server"; +import defaultBinding1 from "./server"; export declare var x1: defaultBinding1; export declare var x2: defaultBinding1; export declare var x3: defaultBinding1; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt index c1c28416ec7..7c5080241f1 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt @@ -13,27 +13,27 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(11 export var m = a; ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts (6 errors) ==== - import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. - import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. var x1: number = a; - import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. var x1: number = b; - import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. var x1: number = x; var x1: number = y; - import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. var x1: number = z; - import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; ~~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. var x1: number = m; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js index 1c65fadbe1d..9674f8c12f4 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js @@ -7,17 +7,17 @@ export var x = a; export var m = a; //// [es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts] -import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = a; -import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = b; -import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = x; var x1: number = y; -import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = z; -import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = m; @@ -26,16 +26,16 @@ exports.a = 10; exports.x = exports.a; exports.m = exports.a; //// [es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.js] -var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_1.a; -var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_2.a; -var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3.x; var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_3.a; -var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_4.x; -var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5 = require("es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5 = require("./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"); var x1 = es6ImportDefaultBindingFollowedWithNamedImportInEs5_0_5.m; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js index 4a987110224..ada6e423e73 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js @@ -6,7 +6,7 @@ var a = 10; export default a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts] -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; var x: number = defaultBinding; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.js] @@ -14,7 +14,7 @@ var a = 10; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] -var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; +var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; var x = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1.default; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.symbols b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.symbols index d4a9c289e60..4262dd3c61b 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.symbols +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.symbols @@ -7,7 +7,7 @@ export default a; >a : Symbol(a, Decl(es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.ts, 1, 3)) === tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts === -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; >defaultBinding : Symbol(defaultBinding, Decl(es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts, 0, 6)) >nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts, 0, 22)) diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types index 4a05b57e304..4f9c618f10c 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types @@ -8,7 +8,7 @@ export default a; >a : number === tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts === -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; >defaultBinding : number >nameSpaceBinding : typeof nameSpaceBinding diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt index 19fa0383d52..1fc12619017 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/client.ts(1,8): error TS1192: Module '"tests/cases/compiler export class a { } ==== tests/cases/compiler/client.ts (1 errors) ==== - import defaultBinding, * as nameSpaceBinding from "server"; + import defaultBinding, * as nameSpaceBinding from "./server"; ~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/server"' has no default export. export var x = new nameSpaceBinding.a(); \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js index 31ef01c464c..93918f6171a 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js @@ -5,7 +5,7 @@ export class a { } //// [client.ts] -import defaultBinding, * as nameSpaceBinding from "server"; +import defaultBinding, * as nameSpaceBinding from "./server"; export var x = new nameSpaceBinding.a(); //// [server.js] @@ -16,7 +16,7 @@ var a = (function () { })(); exports.a = a; //// [client.js] -var server_1 = require("server"), nameSpaceBinding = server_1; +var server_1 = require("./server"), nameSpaceBinding = server_1; exports.x = new nameSpaceBinding.a(); @@ -24,5 +24,5 @@ exports.x = new nameSpaceBinding.a(); export declare class a { } //// [client.d.ts] -import * as nameSpaceBinding from "server"; +import * as nameSpaceBinding from "./server"; export declare var x: nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt index dbbbf67118e..f14af87315c 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1. export var a = 10; ==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts (1 errors) ==== - import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; + import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; ~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"' has no default export. var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js index 4a49d3c2d6f..49717c588b7 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js @@ -5,13 +5,13 @@ export var a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts] -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; var x: number = nameSpaceBinding.a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.js] exports.a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] -var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; +var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt index 3da1cf3fda8..d0eee527356 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt @@ -7,7 +7,7 @@ tests/cases/compiler/client.ts(1,15): error TS1192: Module '"tests/cases/compile export var a = 10; ==== tests/cases/compiler/client.ts (2 errors) ==== - export import defaultBinding, * as nameSpaceBinding from "server"; + export import defaultBinding, * as nameSpaceBinding from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. ~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js index df233fe18a5..dec9b8cfebe 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js @@ -5,13 +5,13 @@ export var a = 10; //// [client.ts] -export import defaultBinding, * as nameSpaceBinding from "server"; +export import defaultBinding, * as nameSpaceBinding from "./server"; export var x: number = nameSpaceBinding.a; //// [server.js] exports.a = 10; //// [client.js] -var server_1 = require("server"), nameSpaceBinding = server_1; +var server_1 = require("./server"), nameSpaceBinding = server_1; exports.x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt index 109b322f4bb..18f634d7b73 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt @@ -7,6 +7,6 @@ tests/cases/compiler/es6ImportDefaultBindingInEs5_1.ts(1,8): error TS1192: Modul export = a; ==== tests/cases/compiler/es6ImportDefaultBindingInEs5_1.ts (1 errors) ==== - import defaultBinding from "es6ImportDefaultBindingInEs5_0"; + import defaultBinding from "./es6ImportDefaultBindingInEs5_0"; ~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingInEs5_0"' has no default export. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingInEs5.js index 0b703f829ca..34323b2752b 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingInEs5.js @@ -6,7 +6,7 @@ var a = 10; export = a; //// [es6ImportDefaultBindingInEs5_1.ts] -import defaultBinding from "es6ImportDefaultBindingInEs5_0"; +import defaultBinding from "./es6ImportDefaultBindingInEs5_0"; //// [es6ImportDefaultBindingInEs5_0.js] var a = 10; diff --git a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt index cd0550609c7..8b67ddfeac3 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt @@ -9,18 +9,18 @@ tests/cases/compiler/es6ImportDefaultBindingMergeErrors_1.ts(8,8): error TS2300: export default a; ==== tests/cases/compiler/es6ImportDefaultBindingMergeErrors_1.ts (3 errors) ==== - import defaultBinding from "es6ImportDefaultBindingMergeErrors_0"; + import defaultBinding from "./es6ImportDefaultBindingMergeErrors_0"; interface defaultBinding { // This is ok } var x = defaultBinding; - import defaultBinding2 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error + import defaultBinding2 from "./es6ImportDefaultBindingMergeErrors_0"; // Should be error ~~~~~~~~~~~~~~~ !!! error TS2440: Import declaration conflicts with local declaration of 'defaultBinding2' var defaultBinding2 = "hello world"; - import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error + import defaultBinding3 from "./es6ImportDefaultBindingMergeErrors_0"; // Should be error ~~~~~~~~~~~~~~~ !!! error TS2300: Duplicate identifier 'defaultBinding3'. - import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // SHould be error + import defaultBinding3 from "./es6ImportDefaultBindingMergeErrors_0"; // SHould be error ~~~~~~~~~~~~~~~ !!! error TS2300: Duplicate identifier 'defaultBinding3'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js index 10b8bec03c7..fb80fdd3e4f 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js +++ b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js @@ -6,14 +6,14 @@ var a = 10; export default a; //// [es6ImportDefaultBindingMergeErrors_1.ts] -import defaultBinding from "es6ImportDefaultBindingMergeErrors_0"; +import defaultBinding from "./es6ImportDefaultBindingMergeErrors_0"; interface defaultBinding { // This is ok } var x = defaultBinding; -import defaultBinding2 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error +import defaultBinding2 from "./es6ImportDefaultBindingMergeErrors_0"; // Should be error var defaultBinding2 = "hello world"; -import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error -import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // SHould be error +import defaultBinding3 from "./es6ImportDefaultBindingMergeErrors_0"; // Should be error +import defaultBinding3 from "./es6ImportDefaultBindingMergeErrors_0"; // SHould be error //// [es6ImportDefaultBindingMergeErrors_0.js] @@ -21,6 +21,6 @@ var a = 10; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [es6ImportDefaultBindingMergeErrors_1.js] -var es6ImportDefaultBindingMergeErrors_0_1 = require("es6ImportDefaultBindingMergeErrors_0"); +var es6ImportDefaultBindingMergeErrors_0_1 = require("./es6ImportDefaultBindingMergeErrors_0"); var x = es6ImportDefaultBindingMergeErrors_0_1.default; var defaultBinding2 = "hello world"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt index a37a71e7378..9d0e46ceb97 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt +++ b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_1.ts(1,8): error T export var a = 10; ==== tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_1.ts (1 errors) ==== - import defaultBinding from "es6ImportDefaultBindingNoDefaultProperty_0"; + import defaultBinding from "./es6ImportDefaultBindingNoDefaultProperty_0"; ~~~~~~~~~~~~~~ !!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty_0"' has no default export. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js index f824dbf71d5..1c9ec4eeae5 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js +++ b/tests/baselines/reference/es6ImportDefaultBindingNoDefaultProperty.js @@ -5,7 +5,7 @@ export var a = 10; //// [es6ImportDefaultBindingNoDefaultProperty_1.ts] -import defaultBinding from "es6ImportDefaultBindingNoDefaultProperty_0"; +import defaultBinding from "./es6ImportDefaultBindingNoDefaultProperty_0"; //// [es6ImportDefaultBindingNoDefaultProperty_0.js] diff --git a/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt b/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt index d3351ee97b2..7de5d7f0e3d 100644 --- a/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt +++ b/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt @@ -1,15 +1,15 @@ -tests/cases/compiler/client.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead. -tests/cases/compiler/server.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. +tests/cases/compiler/client.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. +tests/cases/compiler/server.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead. ==== tests/cases/compiler/client.ts (1 errors) ==== import a = require("server"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead. +!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. ==== tests/cases/compiler/server.ts (1 errors) ==== var a = 10; export = a; ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt b/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt deleted file mode 100644 index 00a6dcb2cfd..00000000000 --- a/tests/baselines/reference/es6ImportNameSpaceImport.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6ImportNameSpaceImport_0.ts (0 errors) ==== - - export var a = 10; - -==== tests/cases/compiler/es6ImportNameSpaceImport_1.ts (0 errors) ==== - import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; - var x = nameSpaceBinding.a; - import * as nameSpaceBinding2 from "es6ImportNameSpaceImport_0"; // elide this - \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.js b/tests/baselines/reference/es6ImportNameSpaceImport.js index 653feeb22b7..32bdd78b329 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImport.js +++ b/tests/baselines/reference/es6ImportNameSpaceImport.js @@ -5,15 +5,15 @@ export var a = 10; //// [es6ImportNameSpaceImport_1.ts] -import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0"; var x = nameSpaceBinding.a; -import * as nameSpaceBinding2 from "es6ImportNameSpaceImport_0"; // elide this +import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this //// [es6ImportNameSpaceImport_0.js] -export var a = 10; +exports.a = 10; //// [es6ImportNameSpaceImport_1.js] -import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; +var nameSpaceBinding = require("./es6ImportNameSpaceImport_0"); var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.symbols b/tests/baselines/reference/es6ImportNameSpaceImport.symbols new file mode 100644 index 00000000000..add2b792d49 --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImport.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/es6ImportNameSpaceImport_0.ts === + +export var a = 10; +>a : Symbol(a, Decl(es6ImportNameSpaceImport_0.ts, 1, 10)) + +=== tests/cases/compiler/es6ImportNameSpaceImport_1.ts === +import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0"; +>nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportNameSpaceImport_1.ts, 0, 6)) + +var x = nameSpaceBinding.a; +>x : Symbol(x, Decl(es6ImportNameSpaceImport_1.ts, 1, 3)) +>nameSpaceBinding.a : Symbol(nameSpaceBinding.a, Decl(es6ImportNameSpaceImport_0.ts, 1, 10)) +>nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportNameSpaceImport_1.ts, 0, 6)) +>a : Symbol(nameSpaceBinding.a, Decl(es6ImportNameSpaceImport_0.ts, 1, 10)) + +import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this +>nameSpaceBinding2 : Symbol(nameSpaceBinding2, Decl(es6ImportNameSpaceImport_1.ts, 2, 6)) + diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.types b/tests/baselines/reference/es6ImportNameSpaceImport.types new file mode 100644 index 00000000000..56ee0c4d87a --- /dev/null +++ b/tests/baselines/reference/es6ImportNameSpaceImport.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/es6ImportNameSpaceImport_0.ts === + +export var a = 10; +>a : number +>10 : number + +=== tests/cases/compiler/es6ImportNameSpaceImport_1.ts === +import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0"; +>nameSpaceBinding : typeof nameSpaceBinding + +var x = nameSpaceBinding.a; +>x : number +>nameSpaceBinding.a : number +>nameSpaceBinding : typeof nameSpaceBinding +>a : number + +import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this +>nameSpaceBinding2 : typeof nameSpaceBinding + diff --git a/tests/baselines/reference/es6ImportNameSpaceImportDts.js b/tests/baselines/reference/es6ImportNameSpaceImportDts.js index 91e927428a1..dfdfe2602a3 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportDts.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportDts.js @@ -5,9 +5,9 @@ export class c { }; //// [client.ts] -import * as nameSpaceBinding from "server"; +import * as nameSpaceBinding from "./server"; export var x = new nameSpaceBinding.c(); -import * as nameSpaceBinding2 from "server"; // unreferenced +import * as nameSpaceBinding2 from "./server"; // unreferenced //// [server.js] var c = (function () { @@ -18,7 +18,7 @@ var c = (function () { exports.c = c; ; //// [client.js] -var nameSpaceBinding = require("server"); +var nameSpaceBinding = require("./server"); exports.x = new nameSpaceBinding.c(); @@ -26,5 +26,5 @@ exports.x = new nameSpaceBinding.c(); export declare class c { } //// [client.d.ts] -import * as nameSpaceBinding from "server"; +import * as nameSpaceBinding from "./server"; export declare var x: nameSpaceBinding.c; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportDts.symbols b/tests/baselines/reference/es6ImportNameSpaceImportDts.symbols index 8104cbcce50..5f6fea374be 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportDts.symbols +++ b/tests/baselines/reference/es6ImportNameSpaceImportDts.symbols @@ -4,7 +4,7 @@ export class c { }; >c : Symbol(c, Decl(server.ts, 0, 0)) === tests/cases/compiler/client.ts === -import * as nameSpaceBinding from "server"; +import * as nameSpaceBinding from "./server"; >nameSpaceBinding : Symbol(nameSpaceBinding, Decl(client.ts, 0, 6)) export var x = new nameSpaceBinding.c(); @@ -13,6 +13,6 @@ export var x = new nameSpaceBinding.c(); >nameSpaceBinding : Symbol(nameSpaceBinding, Decl(client.ts, 0, 6)) >c : Symbol(nameSpaceBinding.c, Decl(server.ts, 0, 0)) -import * as nameSpaceBinding2 from "server"; // unreferenced +import * as nameSpaceBinding2 from "./server"; // unreferenced >nameSpaceBinding2 : Symbol(nameSpaceBinding2, Decl(client.ts, 2, 6)) diff --git a/tests/baselines/reference/es6ImportNameSpaceImportDts.types b/tests/baselines/reference/es6ImportNameSpaceImportDts.types index 345d593b143..e49f3ace57a 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportDts.types +++ b/tests/baselines/reference/es6ImportNameSpaceImportDts.types @@ -4,7 +4,7 @@ export class c { }; >c : c === tests/cases/compiler/client.ts === -import * as nameSpaceBinding from "server"; +import * as nameSpaceBinding from "./server"; >nameSpaceBinding : typeof nameSpaceBinding export var x = new nameSpaceBinding.c(); @@ -14,6 +14,6 @@ export var x = new nameSpaceBinding.c(); >nameSpaceBinding : typeof nameSpaceBinding >c : typeof nameSpaceBinding.c -import * as nameSpaceBinding2 from "server"; // unreferenced +import * as nameSpaceBinding2 from "./server"; // unreferenced >nameSpaceBinding2 : typeof nameSpaceBinding diff --git a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js index 50a03972cc2..dfc90c3e9af 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js @@ -5,15 +5,15 @@ export var a = 10; //// [es6ImportNameSpaceImportInEs5_1.ts] -import * as nameSpaceBinding from "es6ImportNameSpaceImportInEs5_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImportInEs5_0"; var x = nameSpaceBinding.a; -import * as nameSpaceBinding2 from "es6ImportNameSpaceImportInEs5_0"; // elide this +import * as nameSpaceBinding2 from "./es6ImportNameSpaceImportInEs5_0"; // elide this //// [es6ImportNameSpaceImportInEs5_0.js] exports.a = 10; //// [es6ImportNameSpaceImportInEs5_1.js] -var nameSpaceBinding = require("es6ImportNameSpaceImportInEs5_0"); +var nameSpaceBinding = require("./es6ImportNameSpaceImportInEs5_0"); var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.symbols b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.symbols index 119787de817..7be619dcc7e 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.symbols +++ b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.symbols @@ -4,7 +4,7 @@ export var a = 10; >a : Symbol(a, Decl(es6ImportNameSpaceImportInEs5_0.ts, 1, 10)) === tests/cases/compiler/es6ImportNameSpaceImportInEs5_1.ts === -import * as nameSpaceBinding from "es6ImportNameSpaceImportInEs5_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImportInEs5_0"; >nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportNameSpaceImportInEs5_1.ts, 0, 6)) var x = nameSpaceBinding.a; @@ -13,6 +13,6 @@ var x = nameSpaceBinding.a; >nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportNameSpaceImportInEs5_1.ts, 0, 6)) >a : Symbol(nameSpaceBinding.a, Decl(es6ImportNameSpaceImportInEs5_0.ts, 1, 10)) -import * as nameSpaceBinding2 from "es6ImportNameSpaceImportInEs5_0"; // elide this +import * as nameSpaceBinding2 from "./es6ImportNameSpaceImportInEs5_0"; // elide this >nameSpaceBinding2 : Symbol(nameSpaceBinding2, Decl(es6ImportNameSpaceImportInEs5_1.ts, 2, 6)) diff --git a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.types b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.types index 01531cd233d..13631060813 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.types +++ b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.types @@ -5,7 +5,7 @@ export var a = 10; >10 : number === tests/cases/compiler/es6ImportNameSpaceImportInEs5_1.ts === -import * as nameSpaceBinding from "es6ImportNameSpaceImportInEs5_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImportInEs5_0"; >nameSpaceBinding : typeof nameSpaceBinding var x = nameSpaceBinding.a; @@ -14,6 +14,6 @@ var x = nameSpaceBinding.a; >nameSpaceBinding : typeof nameSpaceBinding >a : number -import * as nameSpaceBinding2 from "es6ImportNameSpaceImportInEs5_0"; // elide this +import * as nameSpaceBinding2 from "./es6ImportNameSpaceImportInEs5_0"; // elide this >nameSpaceBinding2 : typeof nameSpaceBinding diff --git a/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.errors.txt b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.errors.txt index 98a68870833..b8b22ce3ed1 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.errors.txt +++ b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.errors.txt @@ -8,17 +8,17 @@ tests/cases/compiler/es6ImportNameSpaceImportMergeErrors_1.ts(7,8): error TS2440 export var a = 10; ==== tests/cases/compiler/es6ImportNameSpaceImportMergeErrors_1.ts (3 errors) ==== - import * as nameSpaceBinding from "es6ImportNameSpaceImportMergeErrors_0"; + import * as nameSpaceBinding from "./es6ImportNameSpaceImportMergeErrors_0"; interface nameSpaceBinding { } // this should be ok - import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error + import * as nameSpaceBinding1 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error ~~~~~~~~~~~~~~~~~ !!! error TS2300: Duplicate identifier 'nameSpaceBinding1'. - import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error + import * as nameSpaceBinding1 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error ~~~~~~~~~~~~~~~~~ !!! error TS2300: Duplicate identifier 'nameSpaceBinding1'. - import * as nameSpaceBinding3 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error + import * as nameSpaceBinding3 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2440: Import declaration conflicts with local declaration of 'nameSpaceBinding3' var nameSpaceBinding3 = 10; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js index 3c8461fba2b..b94640349c0 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportMergeErrors.js @@ -5,13 +5,13 @@ export var a = 10; //// [es6ImportNameSpaceImportMergeErrors_1.ts] -import * as nameSpaceBinding from "es6ImportNameSpaceImportMergeErrors_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImportMergeErrors_0"; interface nameSpaceBinding { } // this should be ok -import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error -import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error +import * as nameSpaceBinding1 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error +import * as nameSpaceBinding1 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error -import * as nameSpaceBinding3 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error +import * as nameSpaceBinding3 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error var nameSpaceBinding3 = 10; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js index 3d6dab17785..efa3a04bc9a 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js @@ -6,7 +6,7 @@ var a = 10; export = a; //// [es6ImportNameSpaceImportNoNamedExports_1.ts] -import * as nameSpaceBinding from "es6ImportNameSpaceImportNoNamedExports_0"; // error +import * as nameSpaceBinding from "./es6ImportNameSpaceImportNoNamedExports_0"; // error //// [es6ImportNameSpaceImportNoNamedExports_0.js] var a = 10; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.symbols b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.symbols index 6a443d1fa00..8767c1a4add 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.symbols +++ b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.symbols @@ -7,6 +7,6 @@ export = a; >a : Symbol(a, Decl(es6ImportNameSpaceImportNoNamedExports_0.ts, 1, 3)) === tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports_1.ts === -import * as nameSpaceBinding from "es6ImportNameSpaceImportNoNamedExports_0"; // error +import * as nameSpaceBinding from "./es6ImportNameSpaceImportNoNamedExports_0"; // error >nameSpaceBinding : Symbol(nameSpaceBinding, Decl(es6ImportNameSpaceImportNoNamedExports_1.ts, 0, 6)) diff --git a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types index 2cc4844dd42..4aaf33d5930 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types +++ b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types @@ -8,6 +8,6 @@ export = a; >a : number === tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports_1.ts === -import * as nameSpaceBinding from "es6ImportNameSpaceImportNoNamedExports_0"; // error +import * as nameSpaceBinding from "./es6ImportNameSpaceImportNoNamedExports_0"; // error >nameSpaceBinding : number diff --git a/tests/baselines/reference/es6ImportNamedImport.errors.txt b/tests/baselines/reference/es6ImportNamedImport.errors.txt deleted file mode 100644 index 12dcf331967..00000000000 --- a/tests/baselines/reference/es6ImportNamedImport.errors.txt +++ /dev/null @@ -1,44 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6ImportNamedImport_0.ts (0 errors) ==== - - export var a = 10; - export var x = a; - export var m = a; - export var a1 = 10; - export var x1 = 10; - export var z1 = 10; - export var z2 = 10; - export var aaaa = 10; - -==== tests/cases/compiler/es6ImportNamedImport_1.ts (0 errors) ==== - import { } from "es6ImportNamedImport_0"; - import { a } from "es6ImportNamedImport_0"; - var xxxx = a; - import { a as b } from "es6ImportNamedImport_0"; - var xxxx = b; - import { x, a as y } from "es6ImportNamedImport_0"; - var xxxx = x; - var xxxx = y; - import { x as z, } from "es6ImportNamedImport_0"; - var xxxx = z; - import { m, } from "es6ImportNamedImport_0"; - var xxxx = m; - import { a1, x1 } from "es6ImportNamedImport_0"; - var xxxx = a1; - var xxxx = x1; - import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; - var xxxx = a11; - var xxxx = x11; - import { z1 } from "es6ImportNamedImport_0"; - var z111 = z1; - import { z2 as z3 } from "es6ImportNamedImport_0"; - var z2 = z3; // z2 shouldn't give redeclare error - - // These are elided - import { aaaa } from "es6ImportNamedImport_0"; - // These are elided - import { aaaa as bbbb } from "es6ImportNamedImport_0"; - \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImport.js b/tests/baselines/reference/es6ImportNamedImport.js index 9606c59351b..3ed7a6adeb0 100644 --- a/tests/baselines/reference/es6ImportNamedImport.js +++ b/tests/baselines/reference/es6ImportNamedImport.js @@ -12,66 +12,66 @@ export var z2 = 10; export var aaaa = 10; //// [es6ImportNamedImport_1.ts] -import { } from "es6ImportNamedImport_0"; -import { a } from "es6ImportNamedImport_0"; +import { } from "./es6ImportNamedImport_0"; +import { a } from "./es6ImportNamedImport_0"; var xxxx = a; -import { a as b } from "es6ImportNamedImport_0"; +import { a as b } from "./es6ImportNamedImport_0"; var xxxx = b; -import { x, a as y } from "es6ImportNamedImport_0"; +import { x, a as y } from "./es6ImportNamedImport_0"; var xxxx = x; var xxxx = y; -import { x as z, } from "es6ImportNamedImport_0"; +import { x as z, } from "./es6ImportNamedImport_0"; var xxxx = z; -import { m, } from "es6ImportNamedImport_0"; +import { m, } from "./es6ImportNamedImport_0"; var xxxx = m; -import { a1, x1 } from "es6ImportNamedImport_0"; +import { a1, x1 } from "./es6ImportNamedImport_0"; var xxxx = a1; var xxxx = x1; -import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImport_0"; var xxxx = a11; var xxxx = x11; -import { z1 } from "es6ImportNamedImport_0"; +import { z1 } from "./es6ImportNamedImport_0"; var z111 = z1; -import { z2 as z3 } from "es6ImportNamedImport_0"; +import { z2 as z3 } from "./es6ImportNamedImport_0"; var z2 = z3; // z2 shouldn't give redeclare error // These are elided -import { aaaa } from "es6ImportNamedImport_0"; +import { aaaa } from "./es6ImportNamedImport_0"; // These are elided -import { aaaa as bbbb } from "es6ImportNamedImport_0"; +import { aaaa as bbbb } from "./es6ImportNamedImport_0"; //// [es6ImportNamedImport_0.js] -export var a = 10; -export var x = a; -export var m = a; -export var a1 = 10; -export var x1 = 10; -export var z1 = 10; -export var z2 = 10; -export var aaaa = 10; +exports.a = 10; +exports.x = exports.a; +exports.m = exports.a; +exports.a1 = 10; +exports.x1 = 10; +exports.z1 = 10; +exports.z2 = 10; +exports.aaaa = 10; //// [es6ImportNamedImport_1.js] -import { a } from "es6ImportNamedImport_0"; -var xxxx = a; -import { a as b } from "es6ImportNamedImport_0"; -var xxxx = b; -import { x, a as y } from "es6ImportNamedImport_0"; -var xxxx = x; -var xxxx = y; -import { x as z } from "es6ImportNamedImport_0"; -var xxxx = z; -import { m } from "es6ImportNamedImport_0"; -var xxxx = m; -import { a1, x1 } from "es6ImportNamedImport_0"; -var xxxx = a1; -var xxxx = x1; -import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; -var xxxx = a11; -var xxxx = x11; -import { z1 } from "es6ImportNamedImport_0"; -var z111 = z1; -import { z2 as z3 } from "es6ImportNamedImport_0"; -var z2 = z3; // z2 shouldn't give redeclare error +var es6ImportNamedImport_0_1 = require("./es6ImportNamedImport_0"); +var xxxx = es6ImportNamedImport_0_1.a; +var es6ImportNamedImport_0_2 = require("./es6ImportNamedImport_0"); +var xxxx = es6ImportNamedImport_0_2.a; +var es6ImportNamedImport_0_3 = require("./es6ImportNamedImport_0"); +var xxxx = es6ImportNamedImport_0_3.x; +var xxxx = es6ImportNamedImport_0_3.a; +var es6ImportNamedImport_0_4 = require("./es6ImportNamedImport_0"); +var xxxx = es6ImportNamedImport_0_4.x; +var es6ImportNamedImport_0_5 = require("./es6ImportNamedImport_0"); +var xxxx = es6ImportNamedImport_0_5.m; +var es6ImportNamedImport_0_6 = require("./es6ImportNamedImport_0"); +var xxxx = es6ImportNamedImport_0_6.a1; +var xxxx = es6ImportNamedImport_0_6.x1; +var es6ImportNamedImport_0_7 = require("./es6ImportNamedImport_0"); +var xxxx = es6ImportNamedImport_0_7.a1; +var xxxx = es6ImportNamedImport_0_7.x1; +var es6ImportNamedImport_0_8 = require("./es6ImportNamedImport_0"); +var z111 = es6ImportNamedImport_0_8.z1; +var es6ImportNamedImport_0_9 = require("./es6ImportNamedImport_0"); +var z2 = es6ImportNamedImport_0_9.z2; // z2 shouldn't give redeclare error //// [es6ImportNamedImport_0.d.ts] diff --git a/tests/baselines/reference/es6ImportNamedImport.symbols b/tests/baselines/reference/es6ImportNamedImport.symbols new file mode 100644 index 00000000000..0d30db6113f --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImport.symbols @@ -0,0 +1,123 @@ +=== tests/cases/compiler/es6ImportNamedImport_0.ts === + +export var a = 10; +>a : Symbol(a, Decl(es6ImportNamedImport_0.ts, 1, 10)) + +export var x = a; +>x : Symbol(x, Decl(es6ImportNamedImport_0.ts, 2, 10)) +>a : Symbol(a, Decl(es6ImportNamedImport_0.ts, 1, 10)) + +export var m = a; +>m : Symbol(m, Decl(es6ImportNamedImport_0.ts, 3, 10)) +>a : Symbol(a, Decl(es6ImportNamedImport_0.ts, 1, 10)) + +export var a1 = 10; +>a1 : Symbol(a1, Decl(es6ImportNamedImport_0.ts, 4, 10)) + +export var x1 = 10; +>x1 : Symbol(x1, Decl(es6ImportNamedImport_0.ts, 5, 10)) + +export var z1 = 10; +>z1 : Symbol(z1, Decl(es6ImportNamedImport_0.ts, 6, 10)) + +export var z2 = 10; +>z2 : Symbol(z2, Decl(es6ImportNamedImport_0.ts, 7, 10)) + +export var aaaa = 10; +>aaaa : Symbol(aaaa, Decl(es6ImportNamedImport_0.ts, 8, 10)) + +=== tests/cases/compiler/es6ImportNamedImport_1.ts === +import { } from "./es6ImportNamedImport_0"; +import { a } from "./es6ImportNamedImport_0"; +>a : Symbol(a, Decl(es6ImportNamedImport_1.ts, 1, 8)) + +var xxxx = a; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>a : Symbol(a, Decl(es6ImportNamedImport_1.ts, 1, 8)) + +import { a as b } from "./es6ImportNamedImport_0"; +>a : Symbol(b, Decl(es6ImportNamedImport_1.ts, 3, 8)) +>b : Symbol(b, Decl(es6ImportNamedImport_1.ts, 3, 8)) + +var xxxx = b; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>b : Symbol(b, Decl(es6ImportNamedImport_1.ts, 3, 8)) + +import { x, a as y } from "./es6ImportNamedImport_0"; +>x : Symbol(x, Decl(es6ImportNamedImport_1.ts, 5, 8)) +>a : Symbol(y, Decl(es6ImportNamedImport_1.ts, 5, 11)) +>y : Symbol(y, Decl(es6ImportNamedImport_1.ts, 5, 11)) + +var xxxx = x; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>x : Symbol(x, Decl(es6ImportNamedImport_1.ts, 5, 8)) + +var xxxx = y; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>y : Symbol(y, Decl(es6ImportNamedImport_1.ts, 5, 11)) + +import { x as z, } from "./es6ImportNamedImport_0"; +>x : Symbol(z, Decl(es6ImportNamedImport_1.ts, 8, 8)) +>z : Symbol(z, Decl(es6ImportNamedImport_1.ts, 8, 8)) + +var xxxx = z; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>z : Symbol(z, Decl(es6ImportNamedImport_1.ts, 8, 8)) + +import { m, } from "./es6ImportNamedImport_0"; +>m : Symbol(m, Decl(es6ImportNamedImport_1.ts, 10, 8)) + +var xxxx = m; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>m : Symbol(m, Decl(es6ImportNamedImport_1.ts, 10, 8)) + +import { a1, x1 } from "./es6ImportNamedImport_0"; +>a1 : Symbol(a1, Decl(es6ImportNamedImport_1.ts, 12, 8)) +>x1 : Symbol(x1, Decl(es6ImportNamedImport_1.ts, 12, 12)) + +var xxxx = a1; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>a1 : Symbol(a1, Decl(es6ImportNamedImport_1.ts, 12, 8)) + +var xxxx = x1; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>x1 : Symbol(x1, Decl(es6ImportNamedImport_1.ts, 12, 12)) + +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImport_0"; +>a1 : Symbol(a11, Decl(es6ImportNamedImport_1.ts, 15, 8)) +>a11 : Symbol(a11, Decl(es6ImportNamedImport_1.ts, 15, 8)) +>x1 : Symbol(x11, Decl(es6ImportNamedImport_1.ts, 15, 19)) +>x11 : Symbol(x11, Decl(es6ImportNamedImport_1.ts, 15, 19)) + +var xxxx = a11; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>a11 : Symbol(a11, Decl(es6ImportNamedImport_1.ts, 15, 8)) + +var xxxx = x11; +>xxxx : Symbol(xxxx, Decl(es6ImportNamedImport_1.ts, 2, 3), Decl(es6ImportNamedImport_1.ts, 4, 3), Decl(es6ImportNamedImport_1.ts, 6, 3), Decl(es6ImportNamedImport_1.ts, 7, 3), Decl(es6ImportNamedImport_1.ts, 9, 3), Decl(es6ImportNamedImport_1.ts, 11, 3), Decl(es6ImportNamedImport_1.ts, 13, 3), Decl(es6ImportNamedImport_1.ts, 14, 3), Decl(es6ImportNamedImport_1.ts, 16, 3), Decl(es6ImportNamedImport_1.ts, 17, 3)) +>x11 : Symbol(x11, Decl(es6ImportNamedImport_1.ts, 15, 19)) + +import { z1 } from "./es6ImportNamedImport_0"; +>z1 : Symbol(z1, Decl(es6ImportNamedImport_1.ts, 18, 8)) + +var z111 = z1; +>z111 : Symbol(z111, Decl(es6ImportNamedImport_1.ts, 19, 3)) +>z1 : Symbol(z1, Decl(es6ImportNamedImport_1.ts, 18, 8)) + +import { z2 as z3 } from "./es6ImportNamedImport_0"; +>z2 : Symbol(z3, Decl(es6ImportNamedImport_1.ts, 20, 8)) +>z3 : Symbol(z3, Decl(es6ImportNamedImport_1.ts, 20, 8)) + +var z2 = z3; // z2 shouldn't give redeclare error +>z2 : Symbol(z2, Decl(es6ImportNamedImport_1.ts, 21, 3)) +>z3 : Symbol(z3, Decl(es6ImportNamedImport_1.ts, 20, 8)) + +// These are elided +import { aaaa } from "./es6ImportNamedImport_0"; +>aaaa : Symbol(aaaa, Decl(es6ImportNamedImport_1.ts, 24, 8)) + +// These are elided +import { aaaa as bbbb } from "./es6ImportNamedImport_0"; +>aaaa : Symbol(bbbb, Decl(es6ImportNamedImport_1.ts, 26, 8)) +>bbbb : Symbol(bbbb, Decl(es6ImportNamedImport_1.ts, 26, 8)) + diff --git a/tests/baselines/reference/es6ImportNamedImport.types b/tests/baselines/reference/es6ImportNamedImport.types new file mode 100644 index 00000000000..bd7c43d7031 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImport.types @@ -0,0 +1,129 @@ +=== tests/cases/compiler/es6ImportNamedImport_0.ts === + +export var a = 10; +>a : number +>10 : number + +export var x = a; +>x : number +>a : number + +export var m = a; +>m : number +>a : number + +export var a1 = 10; +>a1 : number +>10 : number + +export var x1 = 10; +>x1 : number +>10 : number + +export var z1 = 10; +>z1 : number +>10 : number + +export var z2 = 10; +>z2 : number +>10 : number + +export var aaaa = 10; +>aaaa : number +>10 : number + +=== tests/cases/compiler/es6ImportNamedImport_1.ts === +import { } from "./es6ImportNamedImport_0"; +import { a } from "./es6ImportNamedImport_0"; +>a : number + +var xxxx = a; +>xxxx : number +>a : number + +import { a as b } from "./es6ImportNamedImport_0"; +>a : number +>b : number + +var xxxx = b; +>xxxx : number +>b : number + +import { x, a as y } from "./es6ImportNamedImport_0"; +>x : number +>a : number +>y : number + +var xxxx = x; +>xxxx : number +>x : number + +var xxxx = y; +>xxxx : number +>y : number + +import { x as z, } from "./es6ImportNamedImport_0"; +>x : number +>z : number + +var xxxx = z; +>xxxx : number +>z : number + +import { m, } from "./es6ImportNamedImport_0"; +>m : number + +var xxxx = m; +>xxxx : number +>m : number + +import { a1, x1 } from "./es6ImportNamedImport_0"; +>a1 : number +>x1 : number + +var xxxx = a1; +>xxxx : number +>a1 : number + +var xxxx = x1; +>xxxx : number +>x1 : number + +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImport_0"; +>a1 : number +>a11 : number +>x1 : number +>x11 : number + +var xxxx = a11; +>xxxx : number +>a11 : number + +var xxxx = x11; +>xxxx : number +>x11 : number + +import { z1 } from "./es6ImportNamedImport_0"; +>z1 : number + +var z111 = z1; +>z111 : number +>z1 : number + +import { z2 as z3 } from "./es6ImportNamedImport_0"; +>z2 : number +>z3 : number + +var z2 = z3; // z2 shouldn't give redeclare error +>z2 : number +>z3 : number + +// These are elided +import { aaaa } from "./es6ImportNamedImport_0"; +>aaaa : number + +// These are elided +import { aaaa as bbbb } from "./es6ImportNamedImport_0"; +>aaaa : number +>bbbb : number + diff --git a/tests/baselines/reference/es6ImportNamedImportDts.js b/tests/baselines/reference/es6ImportNamedImportDts.js index a72632a737e..59b47635ba9 100644 --- a/tests/baselines/reference/es6ImportNamedImportDts.js +++ b/tests/baselines/reference/es6ImportNamedImportDts.js @@ -18,32 +18,32 @@ export class aaaa { } export class aaaa1 { } //// [client.ts] -import { } from "server"; -import { a } from "server"; +import { } from "./server"; +import { a } from "./server"; export var xxxx = new a(); -import { a11 as b } from "server"; +import { a11 as b } from "./server"; export var xxxx1 = new b(); -import { x, a12 as y } from "server"; +import { x, a12 as y } from "./server"; export var xxxx2 = new x(); export var xxxx3 = new y(); -import { x11 as z, } from "server"; +import { x11 as z, } from "./server"; export var xxxx4 = new z(); -import { m, } from "server"; +import { m, } from "./server"; export var xxxx5 = new m(); -import { a1, x1 } from "server"; +import { a1, x1 } from "./server"; export var xxxx6 = new a1(); export var xxxx7 = new x1(); -import { a111 as a11, x111 as x11 } from "server"; +import { a111 as a11, x111 as x11 } from "./server"; export var xxxx8 = new a11(); export var xxxx9 = new x11(); -import { z1 } from "server"; +import { z1 } from "./server"; export var z111 = new z1(); -import { z2 as z3 } from "server"; +import { z2 as z3 } from "./server"; export var z2 = new z3(); // z2 shouldn't give redeclare error // not referenced -import { aaaa } from "server"; -import { aaaa1 as bbbb } from "server"; +import { aaaa } from "./server"; +import { aaaa1 as bbbb } from "./server"; //// [server.js] @@ -132,26 +132,26 @@ var aaaa1 = (function () { })(); exports.aaaa1 = aaaa1; //// [client.js] -var server_1 = require("server"); +var server_1 = require("./server"); exports.xxxx = new server_1.a(); -var server_2 = require("server"); +var server_2 = require("./server"); exports.xxxx1 = new server_2.a11(); -var server_3 = require("server"); +var server_3 = require("./server"); exports.xxxx2 = new server_3.x(); exports.xxxx3 = new server_3.a12(); -var server_4 = require("server"); +var server_4 = require("./server"); exports.xxxx4 = new server_4.x11(); -var server_5 = require("server"); +var server_5 = require("./server"); exports.xxxx5 = new server_5.m(); -var server_6 = require("server"); +var server_6 = require("./server"); exports.xxxx6 = new server_6.a1(); exports.xxxx7 = new server_6.x1(); -var server_7 = require("server"); +var server_7 = require("./server"); exports.xxxx8 = new server_7.a111(); exports.xxxx9 = new server_7.x111(); -var server_8 = require("server"); +var server_8 = require("./server"); exports.z111 = new server_8.z1(); -var server_9 = require("server"); +var server_9 = require("./server"); exports.z2 = new server_9.z2(); // z2 shouldn't give redeclare error @@ -185,24 +185,24 @@ export declare class aaaa { export declare class aaaa1 { } //// [client.d.ts] -import { a } from "server"; +import { a } from "./server"; export declare var xxxx: a; -import { a11 as b } from "server"; +import { a11 as b } from "./server"; export declare var xxxx1: b; -import { x, a12 as y } from "server"; +import { x, a12 as y } from "./server"; export declare var xxxx2: x; export declare var xxxx3: y; -import { x11 as z } from "server"; +import { x11 as z } from "./server"; export declare var xxxx4: z; -import { m } from "server"; +import { m } from "./server"; export declare var xxxx5: m; -import { a1, x1 } from "server"; +import { a1, x1 } from "./server"; export declare var xxxx6: a1; export declare var xxxx7: x1; -import { a111 as a11, x111 as x11 } from "server"; +import { a111 as a11, x111 as x11 } from "./server"; export declare var xxxx8: a11; export declare var xxxx9: x11; -import { z1 } from "server"; +import { z1 } from "./server"; export declare var z111: z1; -import { z2 as z3 } from "server"; +import { z2 as z3 } from "./server"; export declare var z2: z3; diff --git a/tests/baselines/reference/es6ImportNamedImportDts.symbols b/tests/baselines/reference/es6ImportNamedImportDts.symbols index 2e3b2735b3d..dab2e13d0f6 100644 --- a/tests/baselines/reference/es6ImportNamedImportDts.symbols +++ b/tests/baselines/reference/es6ImportNamedImportDts.symbols @@ -43,15 +43,15 @@ export class aaaa1 { } >aaaa1 : Symbol(aaaa1, Decl(server.ts, 13, 21)) === tests/cases/compiler/client.ts === -import { } from "server"; -import { a } from "server"; +import { } from "./server"; +import { a } from "./server"; >a : Symbol(a, Decl(client.ts, 1, 8)) export var xxxx = new a(); >xxxx : Symbol(xxxx, Decl(client.ts, 2, 10)) >a : Symbol(a, Decl(client.ts, 1, 8)) -import { a11 as b } from "server"; +import { a11 as b } from "./server"; >a11 : Symbol(b, Decl(client.ts, 3, 8)) >b : Symbol(b, Decl(client.ts, 3, 8)) @@ -59,7 +59,7 @@ export var xxxx1 = new b(); >xxxx1 : Symbol(xxxx1, Decl(client.ts, 4, 10)) >b : Symbol(b, Decl(client.ts, 3, 8)) -import { x, a12 as y } from "server"; +import { x, a12 as y } from "./server"; >x : Symbol(x, Decl(client.ts, 5, 8)) >a12 : Symbol(y, Decl(client.ts, 5, 11)) >y : Symbol(y, Decl(client.ts, 5, 11)) @@ -72,7 +72,7 @@ export var xxxx3 = new y(); >xxxx3 : Symbol(xxxx3, Decl(client.ts, 7, 10)) >y : Symbol(y, Decl(client.ts, 5, 11)) -import { x11 as z, } from "server"; +import { x11 as z, } from "./server"; >x11 : Symbol(z, Decl(client.ts, 8, 8)) >z : Symbol(z, Decl(client.ts, 8, 8)) @@ -80,14 +80,14 @@ export var xxxx4 = new z(); >xxxx4 : Symbol(xxxx4, Decl(client.ts, 9, 10)) >z : Symbol(z, Decl(client.ts, 8, 8)) -import { m, } from "server"; +import { m, } from "./server"; >m : Symbol(m, Decl(client.ts, 10, 8)) export var xxxx5 = new m(); >xxxx5 : Symbol(xxxx5, Decl(client.ts, 11, 10)) >m : Symbol(m, Decl(client.ts, 10, 8)) -import { a1, x1 } from "server"; +import { a1, x1 } from "./server"; >a1 : Symbol(a1, Decl(client.ts, 12, 8)) >x1 : Symbol(x1, Decl(client.ts, 12, 12)) @@ -99,7 +99,7 @@ export var xxxx7 = new x1(); >xxxx7 : Symbol(xxxx7, Decl(client.ts, 14, 10)) >x1 : Symbol(x1, Decl(client.ts, 12, 12)) -import { a111 as a11, x111 as x11 } from "server"; +import { a111 as a11, x111 as x11 } from "./server"; >a111 : Symbol(a11, Decl(client.ts, 15, 8)) >a11 : Symbol(a11, Decl(client.ts, 15, 8)) >x111 : Symbol(x11, Decl(client.ts, 15, 21)) @@ -113,14 +113,14 @@ export var xxxx9 = new x11(); >xxxx9 : Symbol(xxxx9, Decl(client.ts, 17, 10)) >x11 : Symbol(x11, Decl(client.ts, 15, 21)) -import { z1 } from "server"; +import { z1 } from "./server"; >z1 : Symbol(z1, Decl(client.ts, 18, 8)) export var z111 = new z1(); >z111 : Symbol(z111, Decl(client.ts, 19, 10)) >z1 : Symbol(z1, Decl(client.ts, 18, 8)) -import { z2 as z3 } from "server"; +import { z2 as z3 } from "./server"; >z2 : Symbol(z3, Decl(client.ts, 20, 8)) >z3 : Symbol(z3, Decl(client.ts, 20, 8)) @@ -129,10 +129,10 @@ export var z2 = new z3(); // z2 shouldn't give redeclare error >z3 : Symbol(z3, Decl(client.ts, 20, 8)) // not referenced -import { aaaa } from "server"; +import { aaaa } from "./server"; >aaaa : Symbol(aaaa, Decl(client.ts, 24, 8)) -import { aaaa1 as bbbb } from "server"; +import { aaaa1 as bbbb } from "./server"; >aaaa1 : Symbol(bbbb, Decl(client.ts, 25, 8)) >bbbb : Symbol(bbbb, Decl(client.ts, 25, 8)) diff --git a/tests/baselines/reference/es6ImportNamedImportDts.types b/tests/baselines/reference/es6ImportNamedImportDts.types index 93bd55716a5..9aba1012117 100644 --- a/tests/baselines/reference/es6ImportNamedImportDts.types +++ b/tests/baselines/reference/es6ImportNamedImportDts.types @@ -43,8 +43,8 @@ export class aaaa1 { } >aaaa1 : aaaa1 === tests/cases/compiler/client.ts === -import { } from "server"; -import { a } from "server"; +import { } from "./server"; +import { a } from "./server"; >a : typeof a export var xxxx = new a(); @@ -52,7 +52,7 @@ export var xxxx = new a(); >new a() : a >a : typeof a -import { a11 as b } from "server"; +import { a11 as b } from "./server"; >a11 : typeof b >b : typeof b @@ -61,7 +61,7 @@ export var xxxx1 = new b(); >new b() : b >b : typeof b -import { x, a12 as y } from "server"; +import { x, a12 as y } from "./server"; >x : typeof x >a12 : typeof y >y : typeof y @@ -76,7 +76,7 @@ export var xxxx3 = new y(); >new y() : y >y : typeof y -import { x11 as z, } from "server"; +import { x11 as z, } from "./server"; >x11 : typeof z >z : typeof z @@ -85,7 +85,7 @@ export var xxxx4 = new z(); >new z() : z >z : typeof z -import { m, } from "server"; +import { m, } from "./server"; >m : typeof m export var xxxx5 = new m(); @@ -93,7 +93,7 @@ export var xxxx5 = new m(); >new m() : m >m : typeof m -import { a1, x1 } from "server"; +import { a1, x1 } from "./server"; >a1 : typeof a1 >x1 : typeof x1 @@ -107,7 +107,7 @@ export var xxxx7 = new x1(); >new x1() : x1 >x1 : typeof x1 -import { a111 as a11, x111 as x11 } from "server"; +import { a111 as a11, x111 as x11 } from "./server"; >a111 : typeof a11 >a11 : typeof a11 >x111 : typeof x11 @@ -123,7 +123,7 @@ export var xxxx9 = new x11(); >new x11() : x11 >x11 : typeof x11 -import { z1 } from "server"; +import { z1 } from "./server"; >z1 : typeof z1 export var z111 = new z1(); @@ -131,7 +131,7 @@ export var z111 = new z1(); >new z1() : z1 >z1 : typeof z1 -import { z2 as z3 } from "server"; +import { z2 as z3 } from "./server"; >z2 : typeof z3 >z3 : typeof z3 @@ -141,10 +141,10 @@ export var z2 = new z3(); // z2 shouldn't give redeclare error >z3 : typeof z3 // not referenced -import { aaaa } from "server"; +import { aaaa } from "./server"; >aaaa : typeof aaaa -import { aaaa1 as bbbb } from "server"; +import { aaaa1 as bbbb } from "./server"; >aaaa1 : typeof bbbb >bbbb : typeof bbbb diff --git a/tests/baselines/reference/es6ImportNamedImportInEs5.js b/tests/baselines/reference/es6ImportNamedImportInEs5.js index 9992508c00b..ce2cbea3d3d 100644 --- a/tests/baselines/reference/es6ImportNamedImportInEs5.js +++ b/tests/baselines/reference/es6ImportNamedImportInEs5.js @@ -12,33 +12,33 @@ export var z2 = 10; export var aaaa = 10; //// [es6ImportNamedImportInEs5_1.ts] -import { } from "es6ImportNamedImportInEs5_0"; -import { a } from "es6ImportNamedImportInEs5_0"; +import { } from "./es6ImportNamedImportInEs5_0"; +import { a } from "./es6ImportNamedImportInEs5_0"; var xxxx = a; -import { a as b } from "es6ImportNamedImportInEs5_0"; +import { a as b } from "./es6ImportNamedImportInEs5_0"; var xxxx = b; -import { x, a as y } from "es6ImportNamedImportInEs5_0"; +import { x, a as y } from "./es6ImportNamedImportInEs5_0"; var xxxx = x; var xxxx = y; -import { x as z, } from "es6ImportNamedImportInEs5_0"; +import { x as z, } from "./es6ImportNamedImportInEs5_0"; var xxxx = z; -import { m, } from "es6ImportNamedImportInEs5_0"; +import { m, } from "./es6ImportNamedImportInEs5_0"; var xxxx = m; -import { a1, x1 } from "es6ImportNamedImportInEs5_0"; +import { a1, x1 } from "./es6ImportNamedImportInEs5_0"; var xxxx = a1; var xxxx = x1; -import { a1 as a11, x1 as x11 } from "es6ImportNamedImportInEs5_0"; +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImportInEs5_0"; var xxxx = a11; var xxxx = x11; -import { z1 } from "es6ImportNamedImportInEs5_0"; +import { z1 } from "./es6ImportNamedImportInEs5_0"; var z111 = z1; -import { z2 as z3 } from "es6ImportNamedImportInEs5_0"; +import { z2 as z3 } from "./es6ImportNamedImportInEs5_0"; var z2 = z3; // z2 shouldn't give redeclare error // These are elided -import { aaaa } from "es6ImportNamedImportInEs5_0"; +import { aaaa } from "./es6ImportNamedImportInEs5_0"; // These are elided -import { aaaa as bbbb } from "es6ImportNamedImportInEs5_0"; +import { aaaa as bbbb } from "./es6ImportNamedImportInEs5_0"; //// [es6ImportNamedImportInEs5_0.js] @@ -51,26 +51,26 @@ exports.z1 = 10; exports.z2 = 10; exports.aaaa = 10; //// [es6ImportNamedImportInEs5_1.js] -var es6ImportNamedImportInEs5_0_1 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_1 = require("./es6ImportNamedImportInEs5_0"); var xxxx = es6ImportNamedImportInEs5_0_1.a; -var es6ImportNamedImportInEs5_0_2 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_2 = require("./es6ImportNamedImportInEs5_0"); var xxxx = es6ImportNamedImportInEs5_0_2.a; -var es6ImportNamedImportInEs5_0_3 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_3 = require("./es6ImportNamedImportInEs5_0"); var xxxx = es6ImportNamedImportInEs5_0_3.x; var xxxx = es6ImportNamedImportInEs5_0_3.a; -var es6ImportNamedImportInEs5_0_4 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_4 = require("./es6ImportNamedImportInEs5_0"); var xxxx = es6ImportNamedImportInEs5_0_4.x; -var es6ImportNamedImportInEs5_0_5 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_5 = require("./es6ImportNamedImportInEs5_0"); var xxxx = es6ImportNamedImportInEs5_0_5.m; -var es6ImportNamedImportInEs5_0_6 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_6 = require("./es6ImportNamedImportInEs5_0"); var xxxx = es6ImportNamedImportInEs5_0_6.a1; var xxxx = es6ImportNamedImportInEs5_0_6.x1; -var es6ImportNamedImportInEs5_0_7 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_7 = require("./es6ImportNamedImportInEs5_0"); var xxxx = es6ImportNamedImportInEs5_0_7.a1; var xxxx = es6ImportNamedImportInEs5_0_7.x1; -var es6ImportNamedImportInEs5_0_8 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_8 = require("./es6ImportNamedImportInEs5_0"); var z111 = es6ImportNamedImportInEs5_0_8.z1; -var es6ImportNamedImportInEs5_0_9 = require("es6ImportNamedImportInEs5_0"); +var es6ImportNamedImportInEs5_0_9 = require("./es6ImportNamedImportInEs5_0"); var z2 = es6ImportNamedImportInEs5_0_9.z2; // z2 shouldn't give redeclare error diff --git a/tests/baselines/reference/es6ImportNamedImportInEs5.symbols b/tests/baselines/reference/es6ImportNamedImportInEs5.symbols index 546487514ce..f9e949e7efb 100644 --- a/tests/baselines/reference/es6ImportNamedImportInEs5.symbols +++ b/tests/baselines/reference/es6ImportNamedImportInEs5.symbols @@ -27,15 +27,15 @@ export var aaaa = 10; >aaaa : Symbol(aaaa, Decl(es6ImportNamedImportInEs5_0.ts, 8, 10)) === tests/cases/compiler/es6ImportNamedImportInEs5_1.ts === -import { } from "es6ImportNamedImportInEs5_0"; -import { a } from "es6ImportNamedImportInEs5_0"; +import { } from "./es6ImportNamedImportInEs5_0"; +import { a } from "./es6ImportNamedImportInEs5_0"; >a : Symbol(a, Decl(es6ImportNamedImportInEs5_1.ts, 1, 8)) var xxxx = a; >xxxx : Symbol(xxxx, Decl(es6ImportNamedImportInEs5_1.ts, 2, 3), Decl(es6ImportNamedImportInEs5_1.ts, 4, 3), Decl(es6ImportNamedImportInEs5_1.ts, 6, 3), Decl(es6ImportNamedImportInEs5_1.ts, 7, 3), Decl(es6ImportNamedImportInEs5_1.ts, 9, 3), Decl(es6ImportNamedImportInEs5_1.ts, 11, 3), Decl(es6ImportNamedImportInEs5_1.ts, 13, 3), Decl(es6ImportNamedImportInEs5_1.ts, 14, 3), Decl(es6ImportNamedImportInEs5_1.ts, 16, 3), Decl(es6ImportNamedImportInEs5_1.ts, 17, 3)) >a : Symbol(a, Decl(es6ImportNamedImportInEs5_1.ts, 1, 8)) -import { a as b } from "es6ImportNamedImportInEs5_0"; +import { a as b } from "./es6ImportNamedImportInEs5_0"; >a : Symbol(b, Decl(es6ImportNamedImportInEs5_1.ts, 3, 8)) >b : Symbol(b, Decl(es6ImportNamedImportInEs5_1.ts, 3, 8)) @@ -43,7 +43,7 @@ var xxxx = b; >xxxx : Symbol(xxxx, Decl(es6ImportNamedImportInEs5_1.ts, 2, 3), Decl(es6ImportNamedImportInEs5_1.ts, 4, 3), Decl(es6ImportNamedImportInEs5_1.ts, 6, 3), Decl(es6ImportNamedImportInEs5_1.ts, 7, 3), Decl(es6ImportNamedImportInEs5_1.ts, 9, 3), Decl(es6ImportNamedImportInEs5_1.ts, 11, 3), Decl(es6ImportNamedImportInEs5_1.ts, 13, 3), Decl(es6ImportNamedImportInEs5_1.ts, 14, 3), Decl(es6ImportNamedImportInEs5_1.ts, 16, 3), Decl(es6ImportNamedImportInEs5_1.ts, 17, 3)) >b : Symbol(b, Decl(es6ImportNamedImportInEs5_1.ts, 3, 8)) -import { x, a as y } from "es6ImportNamedImportInEs5_0"; +import { x, a as y } from "./es6ImportNamedImportInEs5_0"; >x : Symbol(x, Decl(es6ImportNamedImportInEs5_1.ts, 5, 8)) >a : Symbol(y, Decl(es6ImportNamedImportInEs5_1.ts, 5, 11)) >y : Symbol(y, Decl(es6ImportNamedImportInEs5_1.ts, 5, 11)) @@ -56,7 +56,7 @@ var xxxx = y; >xxxx : Symbol(xxxx, Decl(es6ImportNamedImportInEs5_1.ts, 2, 3), Decl(es6ImportNamedImportInEs5_1.ts, 4, 3), Decl(es6ImportNamedImportInEs5_1.ts, 6, 3), Decl(es6ImportNamedImportInEs5_1.ts, 7, 3), Decl(es6ImportNamedImportInEs5_1.ts, 9, 3), Decl(es6ImportNamedImportInEs5_1.ts, 11, 3), Decl(es6ImportNamedImportInEs5_1.ts, 13, 3), Decl(es6ImportNamedImportInEs5_1.ts, 14, 3), Decl(es6ImportNamedImportInEs5_1.ts, 16, 3), Decl(es6ImportNamedImportInEs5_1.ts, 17, 3)) >y : Symbol(y, Decl(es6ImportNamedImportInEs5_1.ts, 5, 11)) -import { x as z, } from "es6ImportNamedImportInEs5_0"; +import { x as z, } from "./es6ImportNamedImportInEs5_0"; >x : Symbol(z, Decl(es6ImportNamedImportInEs5_1.ts, 8, 8)) >z : Symbol(z, Decl(es6ImportNamedImportInEs5_1.ts, 8, 8)) @@ -64,14 +64,14 @@ var xxxx = z; >xxxx : Symbol(xxxx, Decl(es6ImportNamedImportInEs5_1.ts, 2, 3), Decl(es6ImportNamedImportInEs5_1.ts, 4, 3), Decl(es6ImportNamedImportInEs5_1.ts, 6, 3), Decl(es6ImportNamedImportInEs5_1.ts, 7, 3), Decl(es6ImportNamedImportInEs5_1.ts, 9, 3), Decl(es6ImportNamedImportInEs5_1.ts, 11, 3), Decl(es6ImportNamedImportInEs5_1.ts, 13, 3), Decl(es6ImportNamedImportInEs5_1.ts, 14, 3), Decl(es6ImportNamedImportInEs5_1.ts, 16, 3), Decl(es6ImportNamedImportInEs5_1.ts, 17, 3)) >z : Symbol(z, Decl(es6ImportNamedImportInEs5_1.ts, 8, 8)) -import { m, } from "es6ImportNamedImportInEs5_0"; +import { m, } from "./es6ImportNamedImportInEs5_0"; >m : Symbol(m, Decl(es6ImportNamedImportInEs5_1.ts, 10, 8)) var xxxx = m; >xxxx : Symbol(xxxx, Decl(es6ImportNamedImportInEs5_1.ts, 2, 3), Decl(es6ImportNamedImportInEs5_1.ts, 4, 3), Decl(es6ImportNamedImportInEs5_1.ts, 6, 3), Decl(es6ImportNamedImportInEs5_1.ts, 7, 3), Decl(es6ImportNamedImportInEs5_1.ts, 9, 3), Decl(es6ImportNamedImportInEs5_1.ts, 11, 3), Decl(es6ImportNamedImportInEs5_1.ts, 13, 3), Decl(es6ImportNamedImportInEs5_1.ts, 14, 3), Decl(es6ImportNamedImportInEs5_1.ts, 16, 3), Decl(es6ImportNamedImportInEs5_1.ts, 17, 3)) >m : Symbol(m, Decl(es6ImportNamedImportInEs5_1.ts, 10, 8)) -import { a1, x1 } from "es6ImportNamedImportInEs5_0"; +import { a1, x1 } from "./es6ImportNamedImportInEs5_0"; >a1 : Symbol(a1, Decl(es6ImportNamedImportInEs5_1.ts, 12, 8)) >x1 : Symbol(x1, Decl(es6ImportNamedImportInEs5_1.ts, 12, 12)) @@ -83,7 +83,7 @@ var xxxx = x1; >xxxx : Symbol(xxxx, Decl(es6ImportNamedImportInEs5_1.ts, 2, 3), Decl(es6ImportNamedImportInEs5_1.ts, 4, 3), Decl(es6ImportNamedImportInEs5_1.ts, 6, 3), Decl(es6ImportNamedImportInEs5_1.ts, 7, 3), Decl(es6ImportNamedImportInEs5_1.ts, 9, 3), Decl(es6ImportNamedImportInEs5_1.ts, 11, 3), Decl(es6ImportNamedImportInEs5_1.ts, 13, 3), Decl(es6ImportNamedImportInEs5_1.ts, 14, 3), Decl(es6ImportNamedImportInEs5_1.ts, 16, 3), Decl(es6ImportNamedImportInEs5_1.ts, 17, 3)) >x1 : Symbol(x1, Decl(es6ImportNamedImportInEs5_1.ts, 12, 12)) -import { a1 as a11, x1 as x11 } from "es6ImportNamedImportInEs5_0"; +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImportInEs5_0"; >a1 : Symbol(a11, Decl(es6ImportNamedImportInEs5_1.ts, 15, 8)) >a11 : Symbol(a11, Decl(es6ImportNamedImportInEs5_1.ts, 15, 8)) >x1 : Symbol(x11, Decl(es6ImportNamedImportInEs5_1.ts, 15, 19)) @@ -97,14 +97,14 @@ var xxxx = x11; >xxxx : Symbol(xxxx, Decl(es6ImportNamedImportInEs5_1.ts, 2, 3), Decl(es6ImportNamedImportInEs5_1.ts, 4, 3), Decl(es6ImportNamedImportInEs5_1.ts, 6, 3), Decl(es6ImportNamedImportInEs5_1.ts, 7, 3), Decl(es6ImportNamedImportInEs5_1.ts, 9, 3), Decl(es6ImportNamedImportInEs5_1.ts, 11, 3), Decl(es6ImportNamedImportInEs5_1.ts, 13, 3), Decl(es6ImportNamedImportInEs5_1.ts, 14, 3), Decl(es6ImportNamedImportInEs5_1.ts, 16, 3), Decl(es6ImportNamedImportInEs5_1.ts, 17, 3)) >x11 : Symbol(x11, Decl(es6ImportNamedImportInEs5_1.ts, 15, 19)) -import { z1 } from "es6ImportNamedImportInEs5_0"; +import { z1 } from "./es6ImportNamedImportInEs5_0"; >z1 : Symbol(z1, Decl(es6ImportNamedImportInEs5_1.ts, 18, 8)) var z111 = z1; >z111 : Symbol(z111, Decl(es6ImportNamedImportInEs5_1.ts, 19, 3)) >z1 : Symbol(z1, Decl(es6ImportNamedImportInEs5_1.ts, 18, 8)) -import { z2 as z3 } from "es6ImportNamedImportInEs5_0"; +import { z2 as z3 } from "./es6ImportNamedImportInEs5_0"; >z2 : Symbol(z3, Decl(es6ImportNamedImportInEs5_1.ts, 20, 8)) >z3 : Symbol(z3, Decl(es6ImportNamedImportInEs5_1.ts, 20, 8)) @@ -113,11 +113,11 @@ var z2 = z3; // z2 shouldn't give redeclare error >z3 : Symbol(z3, Decl(es6ImportNamedImportInEs5_1.ts, 20, 8)) // These are elided -import { aaaa } from "es6ImportNamedImportInEs5_0"; +import { aaaa } from "./es6ImportNamedImportInEs5_0"; >aaaa : Symbol(aaaa, Decl(es6ImportNamedImportInEs5_1.ts, 24, 8)) // These are elided -import { aaaa as bbbb } from "es6ImportNamedImportInEs5_0"; +import { aaaa as bbbb } from "./es6ImportNamedImportInEs5_0"; >aaaa : Symbol(bbbb, Decl(es6ImportNamedImportInEs5_1.ts, 26, 8)) >bbbb : Symbol(bbbb, Decl(es6ImportNamedImportInEs5_1.ts, 26, 8)) diff --git a/tests/baselines/reference/es6ImportNamedImportInEs5.types b/tests/baselines/reference/es6ImportNamedImportInEs5.types index 95f784c5eac..1d55b4bf51e 100644 --- a/tests/baselines/reference/es6ImportNamedImportInEs5.types +++ b/tests/baselines/reference/es6ImportNamedImportInEs5.types @@ -33,15 +33,15 @@ export var aaaa = 10; >10 : number === tests/cases/compiler/es6ImportNamedImportInEs5_1.ts === -import { } from "es6ImportNamedImportInEs5_0"; -import { a } from "es6ImportNamedImportInEs5_0"; +import { } from "./es6ImportNamedImportInEs5_0"; +import { a } from "./es6ImportNamedImportInEs5_0"; >a : number var xxxx = a; >xxxx : number >a : number -import { a as b } from "es6ImportNamedImportInEs5_0"; +import { a as b } from "./es6ImportNamedImportInEs5_0"; >a : number >b : number @@ -49,7 +49,7 @@ var xxxx = b; >xxxx : number >b : number -import { x, a as y } from "es6ImportNamedImportInEs5_0"; +import { x, a as y } from "./es6ImportNamedImportInEs5_0"; >x : number >a : number >y : number @@ -62,7 +62,7 @@ var xxxx = y; >xxxx : number >y : number -import { x as z, } from "es6ImportNamedImportInEs5_0"; +import { x as z, } from "./es6ImportNamedImportInEs5_0"; >x : number >z : number @@ -70,14 +70,14 @@ var xxxx = z; >xxxx : number >z : number -import { m, } from "es6ImportNamedImportInEs5_0"; +import { m, } from "./es6ImportNamedImportInEs5_0"; >m : number var xxxx = m; >xxxx : number >m : number -import { a1, x1 } from "es6ImportNamedImportInEs5_0"; +import { a1, x1 } from "./es6ImportNamedImportInEs5_0"; >a1 : number >x1 : number @@ -89,7 +89,7 @@ var xxxx = x1; >xxxx : number >x1 : number -import { a1 as a11, x1 as x11 } from "es6ImportNamedImportInEs5_0"; +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImportInEs5_0"; >a1 : number >a11 : number >x1 : number @@ -103,14 +103,14 @@ var xxxx = x11; >xxxx : number >x11 : number -import { z1 } from "es6ImportNamedImportInEs5_0"; +import { z1 } from "./es6ImportNamedImportInEs5_0"; >z1 : number var z111 = z1; >z111 : number >z1 : number -import { z2 as z3 } from "es6ImportNamedImportInEs5_0"; +import { z2 as z3 } from "./es6ImportNamedImportInEs5_0"; >z2 : number >z3 : number @@ -119,11 +119,11 @@ var z2 = z3; // z2 shouldn't give redeclare error >z3 : number // These are elided -import { aaaa } from "es6ImportNamedImportInEs5_0"; +import { aaaa } from "./es6ImportNamedImportInEs5_0"; >aaaa : number // These are elided -import { aaaa as bbbb } from "es6ImportNamedImportInEs5_0"; +import { aaaa as bbbb } from "./es6ImportNamedImportInEs5_0"; >aaaa : number >bbbb : number diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt deleted file mode 100644 index 970c51973b2..00000000000 --- a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6ImportNamedImportInExportAssignment_0.ts (0 errors) ==== - - export var a = 10; - -==== tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts (1 errors) ==== - import { a } from "es6ImportNamedImportInExportAssignment_0"; - export = a; - ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js index eab345e4e7f..5bdbd89df07 100644 --- a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.js @@ -5,17 +5,18 @@ export var a = 10; //// [es6ImportNamedImportInExportAssignment_1.ts] -import { a } from "es6ImportNamedImportInExportAssignment_0"; +import { a } from "./es6ImportNamedImportInExportAssignment_0"; export = a; //// [es6ImportNamedImportInExportAssignment_0.js] -export var a = 10; +exports.a = 10; //// [es6ImportNamedImportInExportAssignment_1.js] -import { a } from "es6ImportNamedImportInExportAssignment_0"; +var es6ImportNamedImportInExportAssignment_0_1 = require("./es6ImportNamedImportInExportAssignment_0"); +module.exports = es6ImportNamedImportInExportAssignment_0_1.a; //// [es6ImportNamedImportInExportAssignment_0.d.ts] export declare var a: number; //// [es6ImportNamedImportInExportAssignment_1.d.ts] -import { a } from "es6ImportNamedImportInExportAssignment_0"; +import { a } from "./es6ImportNamedImportInExportAssignment_0"; export = a; diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.symbols b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.symbols new file mode 100644 index 00000000000..03ca0740f08 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/es6ImportNamedImportInExportAssignment_0.ts === + +export var a = 10; +>a : Symbol(a, Decl(es6ImportNamedImportInExportAssignment_0.ts, 1, 10)) + +=== tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts === +import { a } from "./es6ImportNamedImportInExportAssignment_0"; +>a : Symbol(a, Decl(es6ImportNamedImportInExportAssignment_1.ts, 0, 8)) + +export = a; +>a : Symbol(a, Decl(es6ImportNamedImportInExportAssignment_1.ts, 0, 8)) + diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.types b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.types new file mode 100644 index 00000000000..09023b6dd80 --- /dev/null +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/es6ImportNamedImportInExportAssignment_0.ts === + +export var a = 10; +>a : number +>10 : number + +=== tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts === +import { a } from "./es6ImportNamedImportInExportAssignment_0"; +>a : number + +export = a; +>a : number + diff --git a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js index f457e31f53c..418cd76c907 100644 --- a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js +++ b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.js @@ -8,7 +8,7 @@ export module a { } //// [es6ImportNamedImportInIndirectExportAssignment_1.ts] -import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; +import { a } from "./es6ImportNamedImportInIndirectExportAssignment_0"; import x = a; export = x; @@ -23,7 +23,7 @@ var a; a.c = c; })(a = exports.a || (exports.a = {})); //// [es6ImportNamedImportInIndirectExportAssignment_1.js] -var es6ImportNamedImportInIndirectExportAssignment_0_1 = require("es6ImportNamedImportInIndirectExportAssignment_0"); +var es6ImportNamedImportInIndirectExportAssignment_0_1 = require("./es6ImportNamedImportInIndirectExportAssignment_0"); var x = es6ImportNamedImportInIndirectExportAssignment_0_1.a; module.exports = x; @@ -34,6 +34,6 @@ export declare module a { } } //// [es6ImportNamedImportInIndirectExportAssignment_1.d.ts] -import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; +import { a } from "./es6ImportNamedImportInIndirectExportAssignment_0"; import x = a; export = x; diff --git a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.symbols b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.symbols index 2598735d6d8..24eab96f54b 100644 --- a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.symbols +++ b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.symbols @@ -9,13 +9,13 @@ export module a { } === tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment_1.ts === -import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; +import { a } from "./es6ImportNamedImportInIndirectExportAssignment_0"; >a : Symbol(a, Decl(es6ImportNamedImportInIndirectExportAssignment_1.ts, 0, 8)) import x = a; ->x : Symbol(x, Decl(es6ImportNamedImportInIndirectExportAssignment_1.ts, 0, 69)) +>x : Symbol(x, Decl(es6ImportNamedImportInIndirectExportAssignment_1.ts, 0, 71)) >a : Symbol(a, Decl(es6ImportNamedImportInIndirectExportAssignment_0.ts, 0, 0)) export = x; ->x : Symbol(x, Decl(es6ImportNamedImportInIndirectExportAssignment_1.ts, 0, 69)) +>x : Symbol(x, Decl(es6ImportNamedImportInIndirectExportAssignment_1.ts, 0, 71)) diff --git a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.types b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.types index 36792ece82e..d4dd62aacb2 100644 --- a/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.types +++ b/tests/baselines/reference/es6ImportNamedImportInIndirectExportAssignment.types @@ -9,7 +9,7 @@ export module a { } === tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment_1.ts === -import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; +import { a } from "./es6ImportNamedImportInIndirectExportAssignment_0"; >a : typeof a import x = a; diff --git a/tests/baselines/reference/es6ImportNamedImportMergeErrors.errors.txt b/tests/baselines/reference/es6ImportNamedImportMergeErrors.errors.txt index b9461b6caca..4fca12ee8e1 100644 --- a/tests/baselines/reference/es6ImportNamedImportMergeErrors.errors.txt +++ b/tests/baselines/reference/es6ImportNamedImportMergeErrors.errors.txt @@ -12,22 +12,22 @@ tests/cases/compiler/es6ImportNamedImportMergeErrors_1.ts(10,16): error TS2300: export var z1 = a; ==== tests/cases/compiler/es6ImportNamedImportMergeErrors_1.ts (4 errors) ==== - import { a } from "es6ImportNamedImportMergeErrors_0"; + import { a } from "./es6ImportNamedImportMergeErrors_0"; interface a { } // shouldnt be error - import { x as x1 } from "es6ImportNamedImportMergeErrors_0"; + import { x as x1 } from "./es6ImportNamedImportMergeErrors_0"; interface x1 { } // shouldnt be error - import { x } from "es6ImportNamedImportMergeErrors_0"; // should be error + import { x } from "./es6ImportNamedImportMergeErrors_0"; // should be error ~ !!! error TS2440: Import declaration conflicts with local declaration of 'x' var x = 10; - import { x as x44 } from "es6ImportNamedImportMergeErrors_0"; // should be error + import { x as x44 } from "./es6ImportNamedImportMergeErrors_0"; // should be error ~~~~~~~~ !!! error TS2440: Import declaration conflicts with local declaration of 'x44' var x44 = 10; - import { z } from "es6ImportNamedImportMergeErrors_0"; // should be error + import { z } from "./es6ImportNamedImportMergeErrors_0"; // should be error ~ !!! error TS2300: Duplicate identifier 'z'. - import { z1 as z } from "es6ImportNamedImportMergeErrors_0"; // should be error + import { z1 as z } from "./es6ImportNamedImportMergeErrors_0"; // should be error ~ !!! error TS2300: Duplicate identifier 'z'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportMergeErrors.js b/tests/baselines/reference/es6ImportNamedImportMergeErrors.js index fad411f557d..63bf1127a53 100644 --- a/tests/baselines/reference/es6ImportNamedImportMergeErrors.js +++ b/tests/baselines/reference/es6ImportNamedImportMergeErrors.js @@ -8,16 +8,16 @@ export var z = a; export var z1 = a; //// [es6ImportNamedImportMergeErrors_1.ts] -import { a } from "es6ImportNamedImportMergeErrors_0"; +import { a } from "./es6ImportNamedImportMergeErrors_0"; interface a { } // shouldnt be error -import { x as x1 } from "es6ImportNamedImportMergeErrors_0"; +import { x as x1 } from "./es6ImportNamedImportMergeErrors_0"; interface x1 { } // shouldnt be error -import { x } from "es6ImportNamedImportMergeErrors_0"; // should be error +import { x } from "./es6ImportNamedImportMergeErrors_0"; // should be error var x = 10; -import { x as x44 } from "es6ImportNamedImportMergeErrors_0"; // should be error +import { x as x44 } from "./es6ImportNamedImportMergeErrors_0"; // should be error var x44 = 10; -import { z } from "es6ImportNamedImportMergeErrors_0"; // should be error -import { z1 as z } from "es6ImportNamedImportMergeErrors_0"; // should be error +import { z } from "./es6ImportNamedImportMergeErrors_0"; // should be error +import { z1 as z } from "./es6ImportNamedImportMergeErrors_0"; // should be error //// [es6ImportNamedImportMergeErrors_0.js] diff --git a/tests/baselines/reference/es6ImportNamedImportNoExportMember.errors.txt b/tests/baselines/reference/es6ImportNamedImportNoExportMember.errors.txt index 57a77410cb2..47a836fd422 100644 --- a/tests/baselines/reference/es6ImportNamedImportNoExportMember.errors.txt +++ b/tests/baselines/reference/es6ImportNamedImportNoExportMember.errors.txt @@ -8,9 +8,9 @@ tests/cases/compiler/es6ImportNamedImport_1.ts(2,10): error TS2305: Module '"tes export var x = a; ==== tests/cases/compiler/es6ImportNamedImport_1.ts (2 errors) ==== - import { a1 } from "es6ImportNamedImportNoExportMember_0"; + import { a1 } from "./es6ImportNamedImportNoExportMember_0"; ~~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoExportMember_0"' has no exported member 'a1'. - import { x1 as x } from "es6ImportNamedImportNoExportMember_0"; + import { x1 as x } from "./es6ImportNamedImportNoExportMember_0"; ~~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoExportMember_0"' has no exported member 'x1'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportNoExportMember.js b/tests/baselines/reference/es6ImportNamedImportNoExportMember.js index da473fa42a3..ba607b4626f 100644 --- a/tests/baselines/reference/es6ImportNamedImportNoExportMember.js +++ b/tests/baselines/reference/es6ImportNamedImportNoExportMember.js @@ -6,8 +6,8 @@ export var a = 10; export var x = a; //// [es6ImportNamedImport_1.ts] -import { a1 } from "es6ImportNamedImportNoExportMember_0"; -import { x1 as x } from "es6ImportNamedImportNoExportMember_0"; +import { a1 } from "./es6ImportNamedImportNoExportMember_0"; +import { x1 as x } from "./es6ImportNamedImportNoExportMember_0"; //// [es6ImportNamedImportNoExportMember_0.js] exports.a = 10; diff --git a/tests/baselines/reference/es6ImportNamedImportNoNamedExports.errors.txt b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.errors.txt index a5abd986ee8..e2cacba59e8 100644 --- a/tests/baselines/reference/es6ImportNamedImportNoNamedExports.errors.txt +++ b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.errors.txt @@ -8,9 +8,9 @@ tests/cases/compiler/es6ImportNamedImportNoNamedExports_1.ts(2,10): error TS2305 export = a; ==== tests/cases/compiler/es6ImportNamedImportNoNamedExports_1.ts (2 errors) ==== - import { a } from "es6ImportNamedImportNoNamedExports_0"; + import { a } from "./es6ImportNamedImportNoNamedExports_0"; ~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoNamedExports_0"' has no exported member 'a'. - import { a as x } from "es6ImportNamedImportNoNamedExports_0"; + import { a as x } from "./es6ImportNamedImportNoNamedExports_0"; ~ !!! error TS2305: Module '"tests/cases/compiler/es6ImportNamedImportNoNamedExports_0"' has no exported member 'a'. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js index 524860827e6..273f9a3fc3a 100644 --- a/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js +++ b/tests/baselines/reference/es6ImportNamedImportNoNamedExports.js @@ -6,8 +6,8 @@ var a = 10; export = a; //// [es6ImportNamedImportNoNamedExports_1.ts] -import { a } from "es6ImportNamedImportNoNamedExports_0"; -import { a as x } from "es6ImportNamedImportNoNamedExports_0"; +import { a } from "./es6ImportNamedImportNoNamedExports_0"; +import { a as x } from "./es6ImportNamedImportNoNamedExports_0"; //// [es6ImportNamedImportNoNamedExports_0.js] var a = 10; diff --git a/tests/baselines/reference/es6ImportNamedImportWithExport.errors.txt b/tests/baselines/reference/es6ImportNamedImportWithExport.errors.txt index ff8fe604622..a5a4301683e 100644 --- a/tests/baselines/reference/es6ImportNamedImportWithExport.errors.txt +++ b/tests/baselines/reference/es6ImportNamedImportWithExport.errors.txt @@ -24,54 +24,54 @@ tests/cases/compiler/client.ts(26,1): error TS1191: An import declaration cannot export var aaaa = 10; ==== tests/cases/compiler/client.ts (12 errors) ==== - export import { } from "server"; + export import { } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. - export import { a } from "server"; + export import { a } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = a; - export import { a as b } from "server"; + export import { a as b } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = b; - export import { x, a as y } from "server"; + export import { x, a as y } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = x; export var xxxx = y; - export import { x as z, } from "server"; + export import { x as z, } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = z; - export import { m, } from "server"; + export import { m, } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = m; - export import { a1, x1 } from "server"; + export import { a1, x1 } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = a1; export var xxxx = x1; - export import { a1 as a11, x1 as x11 } from "server"; + export import { a1 as a11, x1 as x11 } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var xxxx = a11; export var xxxx = x11; - export import { z1 } from "server"; + export import { z1 } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var z111 = z1; - export import { z2 as z3 } from "server"; + export import { z2 as z3 } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. export var z2 = z3; // z2 shouldn't give redeclare error // Non referenced imports - export import { aaaa } from "server"; + export import { aaaa } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. - export import { aaaa as bbbb } from "server"; + export import { aaaa as bbbb } from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportNamedImportWithExport.js b/tests/baselines/reference/es6ImportNamedImportWithExport.js index 60ba6bf706b..5175554f0f9 100644 --- a/tests/baselines/reference/es6ImportNamedImportWithExport.js +++ b/tests/baselines/reference/es6ImportNamedImportWithExport.js @@ -12,32 +12,32 @@ export var z2 = 10; export var aaaa = 10; //// [client.ts] -export import { } from "server"; -export import { a } from "server"; +export import { } from "./server"; +export import { a } from "./server"; export var xxxx = a; -export import { a as b } from "server"; +export import { a as b } from "./server"; export var xxxx = b; -export import { x, a as y } from "server"; +export import { x, a as y } from "./server"; export var xxxx = x; export var xxxx = y; -export import { x as z, } from "server"; +export import { x as z, } from "./server"; export var xxxx = z; -export import { m, } from "server"; +export import { m, } from "./server"; export var xxxx = m; -export import { a1, x1 } from "server"; +export import { a1, x1 } from "./server"; export var xxxx = a1; export var xxxx = x1; -export import { a1 as a11, x1 as x11 } from "server"; +export import { a1 as a11, x1 as x11 } from "./server"; export var xxxx = a11; export var xxxx = x11; -export import { z1 } from "server"; +export import { z1 } from "./server"; export var z111 = z1; -export import { z2 as z3 } from "server"; +export import { z2 as z3 } from "./server"; export var z2 = z3; // z2 shouldn't give redeclare error // Non referenced imports -export import { aaaa } from "server"; -export import { aaaa as bbbb } from "server"; +export import { aaaa } from "./server"; +export import { aaaa as bbbb } from "./server"; //// [server.js] @@ -50,26 +50,26 @@ exports.z1 = 10; exports.z2 = 10; exports.aaaa = 10; //// [client.js] -var server_1 = require("server"); +var server_1 = require("./server"); exports.xxxx = server_1.a; -var server_2 = require("server"); +var server_2 = require("./server"); exports.xxxx = server_2.a; -var server_3 = require("server"); +var server_3 = require("./server"); exports.xxxx = server_3.x; exports.xxxx = server_3.a; -var server_4 = require("server"); +var server_4 = require("./server"); exports.xxxx = server_4.x; -var server_5 = require("server"); +var server_5 = require("./server"); exports.xxxx = server_5.m; -var server_6 = require("server"); +var server_6 = require("./server"); exports.xxxx = server_6.a1; exports.xxxx = server_6.x1; -var server_7 = require("server"); +var server_7 = require("./server"); exports.xxxx = server_7.a1; exports.xxxx = server_7.x1; -var server_8 = require("server"); +var server_8 = require("./server"); exports.z111 = server_8.z1; -var server_9 = require("server"); +var server_9 = require("./server"); exports.z2 = server_9.z2; // z2 shouldn't give redeclare error diff --git a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js index dcf99c5359a..8593f4e6343 100644 --- a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js +++ b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.js @@ -16,7 +16,7 @@ export class C2 implements I2 { } //// [client.ts] -import { C, I, C2 } from "server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file +import { C, I, C2 } from "./server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file export type cValInterface = I; export var cVal = new C(); @@ -36,7 +36,7 @@ var C2 = (function () { })(); exports.C2 = C2; //// [client.js] -var server_1 = require("server"); // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file +var server_1 = require("./server"); // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file exports.cVal = new server_1.C(); @@ -54,6 +54,6 @@ export declare class C2 implements I2 { prop2: string; } //// [client.d.ts] -import { C, I } from "server"; +import { C, I } from "./server"; export declare type cValInterface = I; export declare var cVal: C; diff --git a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.symbols b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.symbols index e294124c6f4..cff0406b220 100644 --- a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.symbols +++ b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.symbols @@ -28,13 +28,13 @@ export class C2 implements I2 { } === tests/cases/compiler/client.ts === -import { C, I, C2 } from "server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file +import { C, I, C2 } from "./server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file >C : Symbol(C, Decl(client.ts, 0, 8)) >I : Symbol(I, Decl(client.ts, 0, 11)) >C2 : Symbol(C2, Decl(client.ts, 0, 14)) export type cValInterface = I; ->cValInterface : Symbol(cValInterface, Decl(client.ts, 0, 34)) +>cValInterface : Symbol(cValInterface, Decl(client.ts, 0, 36)) >I : Symbol(I, Decl(client.ts, 0, 11)) export var cVal = new C(); diff --git a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.types b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.types index 12e5271c8b0..a65a2978e1b 100644 --- a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.types +++ b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.types @@ -30,7 +30,7 @@ export class C2 implements I2 { } === tests/cases/compiler/client.ts === -import { C, I, C2 } from "server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file +import { C, I, C2 } from "./server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file >C : typeof C >I : any >C2 : typeof C2 diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.errors.txt b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.errors.txt deleted file mode 100644 index 9592a9f899e..00000000000 --- a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts (0 errors) ==== - export class A - { - constructor () - { - } - - public B() - { - return 42; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js index 8757bd1c88f..dec8de1e36e 100644 --- a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js @@ -12,10 +12,13 @@ export class A } //// [es6ModuleWithModuleGenTargetAmd.js] -export class A { - constructor() { +define(["require", "exports"], function (require, exports) { + class A { + constructor() { + } + B() { + return 42; + } } - B() { - return 42; - } -} + exports.A = A; +}); diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.symbols b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.symbols new file mode 100644 index 00000000000..24367cc28ad --- /dev/null +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts === +export class A +>A : Symbol(A, Decl(es6ModuleWithModuleGenTargetAmd.ts, 0, 0)) +{ + constructor () + { + } + + public B() +>B : Symbol(B, Decl(es6ModuleWithModuleGenTargetAmd.ts, 4, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.types b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.types new file mode 100644 index 00000000000..067ceb005e8 --- /dev/null +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts === +export class A +>A : A +{ + constructor () + { + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.errors.txt b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.errors.txt deleted file mode 100644 index b7401040099..00000000000 --- a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts (0 errors) ==== - export class A - { - constructor () - { - } - - public B() - { - return 42; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.js b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.js index 2df98e20826..36e66cb5721 100644 --- a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.js +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.js @@ -12,10 +12,11 @@ export class A } //// [es6ModuleWithModuleGenTargetCommonjs.js] -export class A { +class A { constructor() { } B() { return 42; } } +exports.A = A; diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.symbols b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.symbols new file mode 100644 index 00000000000..4a84c00c48f --- /dev/null +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts === +export class A +>A : Symbol(A, Decl(es6ModuleWithModuleGenTargetCommonjs.ts, 0, 0)) +{ + constructor () + { + } + + public B() +>B : Symbol(B, Decl(es6ModuleWithModuleGenTargetCommonjs.ts, 4, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.types b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.types new file mode 100644 index 00000000000..58f0f89f955 --- /dev/null +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts === +export class A +>A : A +{ + constructor () + { + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} diff --git a/tests/baselines/reference/es6modulekind.js b/tests/baselines/reference/es6modulekind.js new file mode 100644 index 00000000000..96b315389d1 --- /dev/null +++ b/tests/baselines/reference/es6modulekind.js @@ -0,0 +1,23 @@ +//// [es6modulekind.ts] + +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + +//// [es6modulekind.js] +export default class A { + constructor() { + } + B() { + return 42; + } +} diff --git a/tests/baselines/reference/es6modulekind.symbols b/tests/baselines/reference/es6modulekind.symbols new file mode 100644 index 00000000000..0b5eeb2a6fb --- /dev/null +++ b/tests/baselines/reference/es6modulekind.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/es6modulekind.ts === + +export default class A +>A : Symbol(A, Decl(es6modulekind.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(B, Decl(es6modulekind.ts, 6, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/es6modulekind.types b/tests/baselines/reference/es6modulekind.types new file mode 100644 index 00000000000..d7fde0c7d44 --- /dev/null +++ b/tests/baselines/reference/es6modulekind.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/es6modulekind.ts === + +export default class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : number + } +} diff --git a/tests/baselines/reference/excessPropertyErrorsSuppressed.js b/tests/baselines/reference/excessPropertyErrorsSuppressed.js new file mode 100644 index 00000000000..1673674c5f3 --- /dev/null +++ b/tests/baselines/reference/excessPropertyErrorsSuppressed.js @@ -0,0 +1,7 @@ +//// [excessPropertyErrorsSuppressed.ts] + +var x: { a: string } = { a: "hello", b: 42 }; // No error + + +//// [excessPropertyErrorsSuppressed.js] +var x = { a: "hello", b: 42 }; // No error diff --git a/tests/baselines/reference/excessPropertyErrorsSuppressed.symbols b/tests/baselines/reference/excessPropertyErrorsSuppressed.symbols new file mode 100644 index 00000000000..01c2846d3e1 --- /dev/null +++ b/tests/baselines/reference/excessPropertyErrorsSuppressed.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/excessPropertyErrorsSuppressed.ts === + +var x: { a: string } = { a: "hello", b: 42 }; // No error +>x : Symbol(x, Decl(excessPropertyErrorsSuppressed.ts, 1, 3)) +>a : Symbol(a, Decl(excessPropertyErrorsSuppressed.ts, 1, 8)) +>a : Symbol(a, Decl(excessPropertyErrorsSuppressed.ts, 1, 24)) +>b : Symbol(b, Decl(excessPropertyErrorsSuppressed.ts, 1, 36)) + diff --git a/tests/baselines/reference/excessPropertyErrorsSuppressed.types b/tests/baselines/reference/excessPropertyErrorsSuppressed.types new file mode 100644 index 00000000000..47a4dbf92a9 --- /dev/null +++ b/tests/baselines/reference/excessPropertyErrorsSuppressed.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/excessPropertyErrorsSuppressed.ts === + +var x: { a: string } = { a: "hello", b: 42 }; // No error +>x : { a: string; } +>a : string +>{ a: "hello", b: 42 } : { a: string; b: number; } +>a : string +>"hello" : string +>b : number +>42 : number + diff --git a/tests/baselines/reference/exportAssignClassAndModule.js b/tests/baselines/reference/exportAssignClassAndModule.js index 37fecdcc53f..d440fb9a8e5 100644 --- a/tests/baselines/reference/exportAssignClassAndModule.js +++ b/tests/baselines/reference/exportAssignClassAndModule.js @@ -12,7 +12,7 @@ export = Foo; //// [exportAssignClassAndModule_1.ts] /// -import Foo = require('exportAssignClassAndModule_0'); +import Foo = require('./exportAssignClassAndModule_0'); var z: Foo.Bar; var zz: Foo; diff --git a/tests/baselines/reference/exportAssignClassAndModule.symbols b/tests/baselines/reference/exportAssignClassAndModule.symbols index 9f38ed80b1b..016e91f79a2 100644 --- a/tests/baselines/reference/exportAssignClassAndModule.symbols +++ b/tests/baselines/reference/exportAssignClassAndModule.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/exportAssignClassAndModule_1.ts === /// -import Foo = require('exportAssignClassAndModule_0'); +import Foo = require('./exportAssignClassAndModule_0'); >Foo : Symbol(Foo, Decl(exportAssignClassAndModule_1.ts, 0, 0)) var z: Foo.Bar; diff --git a/tests/baselines/reference/exportAssignClassAndModule.types b/tests/baselines/reference/exportAssignClassAndModule.types index aa1ede6b2d4..5517d32badc 100644 --- a/tests/baselines/reference/exportAssignClassAndModule.types +++ b/tests/baselines/reference/exportAssignClassAndModule.types @@ -1,6 +1,6 @@ === tests/cases/compiler/exportAssignClassAndModule_1.ts === /// -import Foo = require('exportAssignClassAndModule_0'); +import Foo = require('./exportAssignClassAndModule_0'); >Foo : typeof Foo var z: Foo.Bar; diff --git a/tests/baselines/reference/exportAssignmentEnum.js b/tests/baselines/reference/exportAssignmentEnum.js index a484e43738f..06438fb2b53 100644 --- a/tests/baselines/reference/exportAssignmentEnum.js +++ b/tests/baselines/reference/exportAssignmentEnum.js @@ -10,7 +10,7 @@ enum E { export = E; //// [exportAssignmentEnum_B.ts] -import EnumE = require("exportAssignmentEnum_A"); +import EnumE = require("./exportAssignmentEnum_A"); var a = EnumE.A; var b = EnumE.B; @@ -25,7 +25,7 @@ var E; })(E || (E = {})); module.exports = E; //// [exportAssignmentEnum_B.js] -var EnumE = require("exportAssignmentEnum_A"); +var EnumE = require("./exportAssignmentEnum_A"); var a = EnumE.A; var b = EnumE.B; var c = EnumE.C; diff --git a/tests/baselines/reference/exportAssignmentEnum.symbols b/tests/baselines/reference/exportAssignmentEnum.symbols index 07eb5f7b907..dea194b3508 100644 --- a/tests/baselines/reference/exportAssignmentEnum.symbols +++ b/tests/baselines/reference/exportAssignmentEnum.symbols @@ -1,5 +1,5 @@ === tests/cases/compiler/exportAssignmentEnum_B.ts === -import EnumE = require("exportAssignmentEnum_A"); +import EnumE = require("./exportAssignmentEnum_A"); >EnumE : Symbol(EnumE, Decl(exportAssignmentEnum_B.ts, 0, 0)) var a = EnumE.A; diff --git a/tests/baselines/reference/exportAssignmentEnum.types b/tests/baselines/reference/exportAssignmentEnum.types index 9dfa34d3777..a186cf6f255 100644 --- a/tests/baselines/reference/exportAssignmentEnum.types +++ b/tests/baselines/reference/exportAssignmentEnum.types @@ -1,5 +1,5 @@ === tests/cases/compiler/exportAssignmentEnum_B.ts === -import EnumE = require("exportAssignmentEnum_A"); +import EnumE = require("./exportAssignmentEnum_A"); >EnumE : typeof EnumE var a = EnumE.A; diff --git a/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt b/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt index f6736e468f0..b0bfac0adfd 100644 --- a/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt +++ b/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(4,9): error T ==== tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts (2 errors) ==== /// - import Sammy = require('exportAssignmentOfDeclaredExternalModule_0'); + import Sammy = require('./exportAssignmentOfDeclaredExternalModule_0'); var x = new Sammy(); // error to use as constructor as there is not constructor symbol ~~~~~ !!! error TS2304: Cannot find name 'Sammy'. diff --git a/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.js b/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.js index c8ba8324ad2..460707a3502 100644 --- a/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.js +++ b/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.js @@ -9,7 +9,7 @@ export = Sammy; //// [exportAssignmentOfDeclaredExternalModule_1.ts] /// -import Sammy = require('exportAssignmentOfDeclaredExternalModule_0'); +import Sammy = require('./exportAssignmentOfDeclaredExternalModule_0'); var x = new Sammy(); // error to use as constructor as there is not constructor symbol var y = Sammy(); // error to use interface name as call target var z: Sammy; // no error - z is of type interface Sammy from module 'M' diff --git a/tests/baselines/reference/exportAssignmentVariable.js b/tests/baselines/reference/exportAssignmentVariable.js index c20e6ec4f7b..8afbf222e6d 100644 --- a/tests/baselines/reference/exportAssignmentVariable.js +++ b/tests/baselines/reference/exportAssignmentVariable.js @@ -6,7 +6,7 @@ var x = 0; export = x; //// [exportAssignmentVariable_B.ts] -import y = require("exportAssignmentVariable_A"); +import y = require("./exportAssignmentVariable_A"); var n: number = y; @@ -14,5 +14,5 @@ var n: number = y; var x = 0; module.exports = x; //// [exportAssignmentVariable_B.js] -var y = require("exportAssignmentVariable_A"); +var y = require("./exportAssignmentVariable_A"); var n = y; diff --git a/tests/baselines/reference/exportAssignmentVariable.symbols b/tests/baselines/reference/exportAssignmentVariable.symbols index b819678d080..919a96ded33 100644 --- a/tests/baselines/reference/exportAssignmentVariable.symbols +++ b/tests/baselines/reference/exportAssignmentVariable.symbols @@ -1,5 +1,5 @@ === tests/cases/compiler/exportAssignmentVariable_B.ts === -import y = require("exportAssignmentVariable_A"); +import y = require("./exportAssignmentVariable_A"); >y : Symbol(y, Decl(exportAssignmentVariable_B.ts, 0, 0)) var n: number = y; diff --git a/tests/baselines/reference/exportAssignmentVariable.types b/tests/baselines/reference/exportAssignmentVariable.types index 71f0afdea68..7c6d9b45cce 100644 --- a/tests/baselines/reference/exportAssignmentVariable.types +++ b/tests/baselines/reference/exportAssignmentVariable.types @@ -1,5 +1,5 @@ === tests/cases/compiler/exportAssignmentVariable_B.ts === -import y = require("exportAssignmentVariable_A"); +import y = require("./exportAssignmentVariable_A"); >y : number var n: number = y; diff --git a/tests/baselines/reference/exportDeclareClass1.errors.txt b/tests/baselines/reference/exportDeclareClass1.errors.txt index 247b0511ed1..8ff0cb52b5f 100644 --- a/tests/baselines/reference/exportDeclareClass1.errors.txt +++ b/tests/baselines/reference/exportDeclareClass1.errors.txt @@ -1,15 +1,15 @@ -tests/cases/compiler/exportDeclareClass1.ts(2,21): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/exportDeclareClass1.ts(3,31): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/exportDeclareClass1.ts(2,21): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/exportDeclareClass1.ts(3,31): error TS1183: An implementation cannot be declared in ambient contexts. ==== tests/cases/compiler/exportDeclareClass1.ts (2 errors) ==== export declare class eaC { static tF() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. static tsF(param:any) { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. }; export declare class eaC2 { diff --git a/tests/baselines/reference/exportEqualMemberMissing.errors.txt b/tests/baselines/reference/exportEqualMemberMissing.errors.txt index 3e6e7a35a12..4cd142668b9 100644 --- a/tests/baselines/reference/exportEqualMemberMissing.errors.txt +++ b/tests/baselines/reference/exportEqualMemberMissing.errors.txt @@ -3,7 +3,7 @@ tests/cases/compiler/exportEqualMemberMissing_1.ts(3,23): error TS2339: Property ==== tests/cases/compiler/exportEqualMemberMissing_1.ts (1 errors) ==== /// - import connect = require('exportEqualMemberMissing_0'); + import connect = require('./exportEqualMemberMissing_0'); connect().use(connect.static('foo')); // Error 1 The property 'static' does not exist on value of type ''. ~~~~~~ !!! error TS2339: Property 'static' does not exist on type '{ (): connectExport; foo: Date; }'. diff --git a/tests/baselines/reference/exportEqualMemberMissing.js b/tests/baselines/reference/exportEqualMemberMissing.js index 583176f12f3..85972ce0945 100644 --- a/tests/baselines/reference/exportEqualMemberMissing.js +++ b/tests/baselines/reference/exportEqualMemberMissing.js @@ -17,7 +17,7 @@ export = server; //// [exportEqualMemberMissing_1.ts] /// -import connect = require('exportEqualMemberMissing_0'); +import connect = require('./exportEqualMemberMissing_0'); connect().use(connect.static('foo')); // Error 1 The property 'static' does not exist on value of type ''. @@ -26,5 +26,5 @@ var server; module.exports = server; //// [exportEqualMemberMissing_1.js] /// -var connect = require('exportEqualMemberMissing_0'); +var connect = require('./exportEqualMemberMissing_0'); connect().use(connect.static('foo')); // Error 1 The property 'static' does not exist on value of type ''. diff --git a/tests/baselines/reference/exportNonInitializedVariablesUMD.js b/tests/baselines/reference/exportNonInitializedVariablesUMD.js index 1e8b3ce4446..4b1e671669c 100644 --- a/tests/baselines/reference/exportNonInitializedVariablesUMD.js +++ b/tests/baselines/reference/exportNonInitializedVariablesUMD.js @@ -35,14 +35,14 @@ export let h1: D = new D; //// [exportNonInitializedVariablesUMD.js] -(function (deps, factory) { +(function (factory) { if (typeof module === 'object' && typeof module.exports === 'object') { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === 'function' && define.amd) { - define(deps, factory); + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { var ; let; var ; diff --git a/tests/baselines/reference/exportStarFromEmptyModule.errors.txt b/tests/baselines/reference/exportStarFromEmptyModule.errors.txt index c88ac3b3f19..9d781da2707 100644 --- a/tests/baselines/reference/exportStarFromEmptyModule.errors.txt +++ b/tests/baselines/reference/exportStarFromEmptyModule.errors.txt @@ -12,17 +12,17 @@ tests/cases/compiler/exportStarFromEmptyModule_module4.ts(4,5): error TS2339: Pr // empty ==== tests/cases/compiler/exportStarFromEmptyModule_module3.ts (1 errors) ==== - export * from "exportStarFromEmptyModule_module2"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + export * from "./exportStarFromEmptyModule_module2"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2306: File 'exportStarFromEmptyModule_module2.ts' is not a module. - export * from "exportStarFromEmptyModule_module1"; + export * from "./exportStarFromEmptyModule_module1"; export class A { static q; } ==== tests/cases/compiler/exportStarFromEmptyModule_module4.ts (1 errors) ==== - import * as X from "exportStarFromEmptyModule_module3"; + import * as X from "./exportStarFromEmptyModule_module3"; var s: X.A; X.A.q; X.A.r; // Error diff --git a/tests/baselines/reference/exportStarFromEmptyModule.js b/tests/baselines/reference/exportStarFromEmptyModule.js index 9b486af4eae..d433e7b3682 100644 --- a/tests/baselines/reference/exportStarFromEmptyModule.js +++ b/tests/baselines/reference/exportStarFromEmptyModule.js @@ -10,15 +10,15 @@ export class A { // empty //// [exportStarFromEmptyModule_module3.ts] -export * from "exportStarFromEmptyModule_module2"; -export * from "exportStarFromEmptyModule_module1"; +export * from "./exportStarFromEmptyModule_module2"; +export * from "./exportStarFromEmptyModule_module1"; export class A { static q; } //// [exportStarFromEmptyModule_module4.ts] -import * as X from "exportStarFromEmptyModule_module3"; +import * as X from "./exportStarFromEmptyModule_module3"; var s: X.A; X.A.q; X.A.r; // Error @@ -36,8 +36,8 @@ exports.A = A; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } -__export(require("exportStarFromEmptyModule_module2")); -__export(require("exportStarFromEmptyModule_module1")); +__export(require("./exportStarFromEmptyModule_module2")); +__export(require("./exportStarFromEmptyModule_module1")); var A = (function () { function A() { } @@ -45,7 +45,7 @@ var A = (function () { })(); exports.A = A; //// [exportStarFromEmptyModule_module4.js] -var X = require("exportStarFromEmptyModule_module3"); +var X = require("./exportStarFromEmptyModule_module3"); var s; X.A.q; X.A.r; // Error @@ -57,8 +57,8 @@ export declare class A { } //// [exportStarFromEmptyModule_module2.d.ts] //// [exportStarFromEmptyModule_module3.d.ts] -export * from "exportStarFromEmptyModule_module2"; -export * from "exportStarFromEmptyModule_module1"; +export * from "./exportStarFromEmptyModule_module2"; +export * from "./exportStarFromEmptyModule_module1"; export declare class A { static q: any; } diff --git a/tests/baselines/reference/exportsInAmbientModules1.js b/tests/baselines/reference/exportsInAmbientModules1.js new file mode 100644 index 00000000000..4370b197403 --- /dev/null +++ b/tests/baselines/reference/exportsInAmbientModules1.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/exportsInAmbientModules1.ts] //// + +//// [external.d.ts] + +export var x: number + +//// [main.ts] + +declare module "M" { + export {x} from "external" +} + +//// [main.js] diff --git a/tests/baselines/reference/exportsInAmbientModules1.symbols b/tests/baselines/reference/exportsInAmbientModules1.symbols new file mode 100644 index 00000000000..58cdf8663a7 --- /dev/null +++ b/tests/baselines/reference/exportsInAmbientModules1.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/external.d.ts === + +export var x: number +>x : Symbol(x, Decl(external.d.ts, 1, 10)) + +=== tests/cases/compiler/main.ts === + +declare module "M" { + export {x} from "external" +>x : Symbol(x, Decl(main.ts, 2, 12)) +} diff --git a/tests/baselines/reference/exportsInAmbientModules1.types b/tests/baselines/reference/exportsInAmbientModules1.types new file mode 100644 index 00000000000..490a63caf92 --- /dev/null +++ b/tests/baselines/reference/exportsInAmbientModules1.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/external.d.ts === + +export var x: number +>x : number + +=== tests/cases/compiler/main.ts === + +declare module "M" { + export {x} from "external" +>x : number +} diff --git a/tests/baselines/reference/exportsInAmbientModules2.js b/tests/baselines/reference/exportsInAmbientModules2.js new file mode 100644 index 00000000000..f08ff17f8ba --- /dev/null +++ b/tests/baselines/reference/exportsInAmbientModules2.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/exportsInAmbientModules2.ts] //// + +//// [external.d.ts] + +export default class C {} + +//// [main.ts] + +declare module "M" { + export * from "external" +} + +//// [main.js] diff --git a/tests/baselines/reference/exportsInAmbientModules2.symbols b/tests/baselines/reference/exportsInAmbientModules2.symbols new file mode 100644 index 00000000000..54e8b44ec34 --- /dev/null +++ b/tests/baselines/reference/exportsInAmbientModules2.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/external.d.ts === + +export default class C {} +>C : Symbol(C, Decl(external.d.ts, 0, 0)) + +=== tests/cases/compiler/main.ts === + +No type information for this code.declare module "M" { +No type information for this code. export * from "external" +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/exportsInAmbientModules2.types b/tests/baselines/reference/exportsInAmbientModules2.types new file mode 100644 index 00000000000..3472a35bf75 --- /dev/null +++ b/tests/baselines/reference/exportsInAmbientModules2.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/external.d.ts === + +export default class C {} +>C : C + +=== tests/cases/compiler/main.ts === + +No type information for this code.declare module "M" { +No type information for this code. export * from "external" +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/extendClassExpressionFromModule.symbols b/tests/baselines/reference/extendClassExpressionFromModule.symbols index c131ea8fa28..78d483b5d7d 100644 --- a/tests/baselines/reference/extendClassExpressionFromModule.symbols +++ b/tests/baselines/reference/extendClassExpressionFromModule.symbols @@ -8,6 +8,7 @@ var x = foo1; class y extends x {} >y : Symbol(y, Decl(foo2.ts, 1, 13)) +>x : Symbol(x, Decl(foo2.ts, 1, 3)) === tests/cases/conformance/classes/classExpressions/foo1.ts === class x{} diff --git a/tests/baselines/reference/extendNonClassSymbol1.symbols b/tests/baselines/reference/extendNonClassSymbol1.symbols index 02291ebb181..7c03ef3a97f 100644 --- a/tests/baselines/reference/extendNonClassSymbol1.symbols +++ b/tests/baselines/reference/extendNonClassSymbol1.symbols @@ -9,4 +9,5 @@ var x = A; class C extends x { } // error, could not find symbol xs >C : Symbol(C, Decl(extendNonClassSymbol1.ts, 1, 10)) +>x : Symbol(x, Decl(extendNonClassSymbol1.ts, 1, 3)) diff --git a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js index 297a7527ec0..3c05ccc6866 100644 --- a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js +++ b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.js @@ -6,21 +6,21 @@ export class Model { } //// [extendingClassFromAliasAndUsageInIndexer_moduleA.ts] -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } //// [extendingClassFromAliasAndUsageInIndexer_moduleB.ts] -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); export class VisualizationModel extends Backbone.Model { // different interesting stuff here } //// [extendingClassFromAliasAndUsageInIndexer_main.ts] -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); -import moduleA = require("extendingClassFromAliasAndUsageInIndexer_moduleA"); -import moduleB = require("extendingClassFromAliasAndUsageInIndexer_moduleB"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); +import moduleA = require("./extendingClassFromAliasAndUsageInIndexer_moduleA"); +import moduleB = require("./extendingClassFromAliasAndUsageInIndexer_moduleB"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } @@ -45,7 +45,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +var Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -60,7 +60,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +var Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); var VisualizationModel = (function (_super) { __extends(VisualizationModel, _super); function VisualizationModel() { @@ -70,8 +70,8 @@ var VisualizationModel = (function (_super) { })(Backbone.Model); exports.VisualizationModel = VisualizationModel; //// [extendingClassFromAliasAndUsageInIndexer_main.js] -var moduleA = require("extendingClassFromAliasAndUsageInIndexer_moduleA"); -var moduleB = require("extendingClassFromAliasAndUsageInIndexer_moduleB"); +var moduleA = require("./extendingClassFromAliasAndUsageInIndexer_moduleA"); +var moduleB = require("./extendingClassFromAliasAndUsageInIndexer_moduleB"); var moduleATyped = moduleA; var moduleMap = { "moduleA": moduleA, diff --git a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.symbols b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.symbols index 02d57509a55..33e0c226e67 100644 --- a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.symbols +++ b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.symbols @@ -1,15 +1,15 @@ === tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer_main.ts === -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); >Backbone : Symbol(Backbone, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 0, 0)) -import moduleA = require("extendingClassFromAliasAndUsageInIndexer_moduleA"); ->moduleA : Symbol(moduleA, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 0, 79)) +import moduleA = require("./extendingClassFromAliasAndUsageInIndexer_moduleA"); +>moduleA : Symbol(moduleA, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 0, 81)) -import moduleB = require("extendingClassFromAliasAndUsageInIndexer_moduleB"); ->moduleB : Symbol(moduleB, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 1, 77)) +import moduleB = require("./extendingClassFromAliasAndUsageInIndexer_moduleB"); +>moduleB : Symbol(moduleB, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 1, 79)) interface IHasVisualizationModel { ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 2, 77)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 2, 79)) VisualizationModel: typeof Backbone.Model; >VisualizationModel : Symbol(VisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 3, 34)) @@ -19,19 +19,19 @@ interface IHasVisualizationModel { } var moduleATyped: IHasVisualizationModel = moduleA; >moduleATyped : Symbol(moduleATyped, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 6, 3)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 2, 77)) ->moduleA : Symbol(moduleA, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 0, 79)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 2, 79)) +>moduleA : Symbol(moduleA, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 0, 81)) var moduleMap: { [key: string]: IHasVisualizationModel } = { >moduleMap : Symbol(moduleMap, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 7, 3)) >key : Symbol(key, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 7, 18)) ->IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 2, 77)) +>IHasVisualizationModel : Symbol(IHasVisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 2, 79)) "moduleA": moduleA, ->moduleA : Symbol(moduleA, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 0, 79)) +>moduleA : Symbol(moduleA, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 0, 81)) "moduleB": moduleB ->moduleB : Symbol(moduleB, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 1, 77)) +>moduleB : Symbol(moduleB, Decl(extendingClassFromAliasAndUsageInIndexer_main.ts, 1, 79)) }; var moduleName: string; @@ -53,11 +53,11 @@ export class Model { } === tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer_moduleA.ts === -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); >Backbone : Symbol(Backbone, Decl(extendingClassFromAliasAndUsageInIndexer_moduleA.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_moduleA.ts, 0, 79)) +>VisualizationModel : Symbol(VisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_moduleA.ts, 0, 81)) >Backbone.Model : Symbol(Backbone.Model, Decl(extendingClassFromAliasAndUsageInIndexer_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(extendingClassFromAliasAndUsageInIndexer_moduleA.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(extendingClassFromAliasAndUsageInIndexer_backbone.ts, 0, 0)) @@ -66,11 +66,11 @@ export class VisualizationModel extends Backbone.Model { } === tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer_moduleB.ts === -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); >Backbone : Symbol(Backbone, Decl(extendingClassFromAliasAndUsageInIndexer_moduleB.ts, 0, 0)) export class VisualizationModel extends Backbone.Model { ->VisualizationModel : Symbol(VisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_moduleB.ts, 0, 79)) +>VisualizationModel : Symbol(VisualizationModel, Decl(extendingClassFromAliasAndUsageInIndexer_moduleB.ts, 0, 81)) >Backbone.Model : Symbol(Backbone.Model, Decl(extendingClassFromAliasAndUsageInIndexer_backbone.ts, 0, 0)) >Backbone : Symbol(Backbone, Decl(extendingClassFromAliasAndUsageInIndexer_moduleB.ts, 0, 0)) >Model : Symbol(Backbone.Model, Decl(extendingClassFromAliasAndUsageInIndexer_backbone.ts, 0, 0)) diff --git a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types index b5323ae5c85..e1bfd195698 100644 --- a/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types +++ b/tests/baselines/reference/extendingClassFromAliasAndUsageInIndexer.types @@ -1,11 +1,11 @@ === tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer_main.ts === -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); >Backbone : typeof Backbone -import moduleA = require("extendingClassFromAliasAndUsageInIndexer_moduleA"); +import moduleA = require("./extendingClassFromAliasAndUsageInIndexer_moduleA"); >moduleA : typeof moduleA -import moduleB = require("extendingClassFromAliasAndUsageInIndexer_moduleB"); +import moduleB = require("./extendingClassFromAliasAndUsageInIndexer_moduleB"); >moduleB : typeof moduleB interface IHasVisualizationModel { @@ -56,7 +56,7 @@ export class Model { } === tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer_moduleA.ts === -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { @@ -69,7 +69,7 @@ export class VisualizationModel extends Backbone.Model { } === tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer_moduleB.ts === -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); >Backbone : typeof Backbone export class VisualizationModel extends Backbone.Model { diff --git a/tests/baselines/reference/externSyntax.errors.txt b/tests/baselines/reference/externSyntax.errors.txt index 1d3380b99d5..464bfcd55e4 100644 --- a/tests/baselines/reference/externSyntax.errors.txt +++ b/tests/baselines/reference/externSyntax.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/externSyntax.ts(8,20): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/externSyntax.ts(8,20): error TS1183: An implementation cannot be declared in ambient contexts. ==== tests/cases/compiler/externSyntax.ts (1 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/externSyntax.ts(8,20): error TS1184: An implementation cann public f(); public g() { } // error body ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. } } diff --git a/tests/baselines/reference/externalModuleExportingGenericClass.errors.txt b/tests/baselines/reference/externalModuleExportingGenericClass.errors.txt index c8712b20864..7825345a1b5 100644 --- a/tests/baselines/reference/externalModuleExportingGenericClass.errors.txt +++ b/tests/baselines/reference/externalModuleExportingGenericClass.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/externalModuleExportingGenericClass_file1.ts(2,8): error TS ==== tests/cases/compiler/externalModuleExportingGenericClass_file1.ts (1 errors) ==== - import a = require('externalModuleExportingGenericClass_file0'); + import a = require('./externalModuleExportingGenericClass_file0'); var v: a; // this should report error ~ !!! error TS2314: Generic type 'C' requires 1 type argument(s). diff --git a/tests/baselines/reference/externalModuleExportingGenericClass.js b/tests/baselines/reference/externalModuleExportingGenericClass.js index 14f18ddfc04..5dc1e9bea1d 100644 --- a/tests/baselines/reference/externalModuleExportingGenericClass.js +++ b/tests/baselines/reference/externalModuleExportingGenericClass.js @@ -9,7 +9,7 @@ export = C; //// [externalModuleExportingGenericClass_file1.ts] -import a = require('externalModuleExportingGenericClass_file0'); +import a = require('./externalModuleExportingGenericClass_file0'); var v: a; // this should report error var v2: any = (new a()).foo; var v3: number = (new a()).foo; @@ -23,7 +23,7 @@ var C = (function () { })(); module.exports = C; //// [externalModuleExportingGenericClass_file1.js] -var a = require('externalModuleExportingGenericClass_file0'); +var a = require('./externalModuleExportingGenericClass_file0'); var v; // this should report error var v2 = (new a()).foo; var v3 = (new a()).foo; diff --git a/tests/baselines/reference/externalModuleImmutableBindings.errors.txt b/tests/baselines/reference/externalModuleImmutableBindings.errors.txt index 8ab07c26851..a6040c154f0 100644 --- a/tests/baselines/reference/externalModuleImmutableBindings.errors.txt +++ b/tests/baselines/reference/externalModuleImmutableBindings.errors.txt @@ -16,7 +16,7 @@ tests/cases/compiler/f2.ts(41,13): error TS2339: Property 'blah' does not exist ==== tests/cases/compiler/f2.ts (10 errors) ==== // all mutations below are illegal and should be fixed - import * as stuff from 'f1'; + import * as stuff from './f1'; var n = 'baz'; diff --git a/tests/baselines/reference/externalModuleImmutableBindings.js b/tests/baselines/reference/externalModuleImmutableBindings.js index 5e5ba6c2294..47d83ded80c 100644 --- a/tests/baselines/reference/externalModuleImmutableBindings.js +++ b/tests/baselines/reference/externalModuleImmutableBindings.js @@ -6,7 +6,7 @@ export var x = 1; //// [f2.ts] // all mutations below are illegal and should be fixed -import * as stuff from 'f1'; +import * as stuff from './f1'; var n = 'baz'; @@ -55,7 +55,7 @@ for ((stuff[n]) of []) {} exports.x = 1; //// [f2.js] // all mutations below are illegal and should be fixed -var stuff = require('f1'); +var stuff = require('./f1'); var n = 'baz'; stuff.x = 0; stuff['x'] = 1; diff --git a/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.errors.txt b/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.errors.txt index 588183c6283..a0b34ecbee1 100644 --- a/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.errors.txt +++ b/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.errors.txt @@ -1,13 +1,13 @@ -tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file3.ts(3,7): error TS2339: Property 'foo' does not exist on type 'typeof "externalModuleRefernceResolutionOrderInImportDeclaration_file1"'. +tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file3.ts(4,7): error TS2339: Property 'bar' does not exist on type 'typeof "tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file1"'. ==== tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file3.ts (1 errors) ==== /// - import file1 = require('externalModuleRefernceResolutionOrderInImportDeclaration_file1'); + import file1 = require('./externalModuleRefernceResolutionOrderInImportDeclaration_file1'); file1.foo(); - ~~~ -!!! error TS2339: Property 'foo' does not exist on type 'typeof "externalModuleRefernceResolutionOrderInImportDeclaration_file1"'. file1.bar(); + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'typeof "tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file1"'. ==== tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration_file1.ts (0 errors) ==== diff --git a/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.js b/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.js index f1d1d9fb561..48411da4a02 100644 --- a/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.js +++ b/tests/baselines/reference/externalModuleRefernceResolutionOrderInImportDeclaration.js @@ -11,7 +11,7 @@ declare module "externalModuleRefernceResolutionOrderInImportDeclaration_file1" //// [externalModuleRefernceResolutionOrderInImportDeclaration_file3.ts] /// -import file1 = require('externalModuleRefernceResolutionOrderInImportDeclaration_file1'); +import file1 = require('./externalModuleRefernceResolutionOrderInImportDeclaration_file1'); file1.foo(); file1.bar(); @@ -24,6 +24,6 @@ exports.foo = foo; ; //// [externalModuleRefernceResolutionOrderInImportDeclaration_file3.js] /// -var file1 = require('externalModuleRefernceResolutionOrderInImportDeclaration_file1'); +var file1 = require('./externalModuleRefernceResolutionOrderInImportDeclaration_file1'); file1.foo(); file1.bar(); diff --git a/tests/baselines/reference/fatArrowSelf.types b/tests/baselines/reference/fatArrowSelf.types index c4b2936fd37..574262265bc 100644 --- a/tests/baselines/reference/fatArrowSelf.types +++ b/tests/baselines/reference/fatArrowSelf.types @@ -38,7 +38,7 @@ module Consumer { >this.emitter.addListener('change', (e) => { this.changed(); }) : void >this.emitter.addListener : (type: string, listener: Events.ListenerCallback) => void >this.emitter : Events.EventEmitter ->this : EventEmitterConsummer +>this : this >emitter : Events.EventEmitter >addListener : (type: string, listener: Events.ListenerCallback) => void >'change' : string @@ -48,7 +48,7 @@ module Consumer { this.changed(); >this.changed() : void >this.changed : () => void ->this : EventEmitterConsummer +>this : this >changed : () => void }); diff --git a/tests/baselines/reference/fluentClasses.js b/tests/baselines/reference/fluentClasses.js new file mode 100644 index 00000000000..12f3cfff48d --- /dev/null +++ b/tests/baselines/reference/fluentClasses.js @@ -0,0 +1,56 @@ +//// [fluentClasses.ts] +class A { + foo() { + return this; + } +} +class B extends A { + bar() { + return this; + } +} +class C extends B { + baz() { + return this; + } +} +var c: C; +var z = c.foo().bar().baz(); // Fluent pattern + + +//// [fluentClasses.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + A.prototype.foo = function () { + return this; + }; + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + B.prototype.bar = function () { + return this; + }; + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + C.prototype.baz = function () { + return this; + }; + return C; +})(B); +var c; +var z = c.foo().bar().baz(); // Fluent pattern diff --git a/tests/baselines/reference/fluentClasses.symbols b/tests/baselines/reference/fluentClasses.symbols new file mode 100644 index 00000000000..3125235b6b1 --- /dev/null +++ b/tests/baselines/reference/fluentClasses.symbols @@ -0,0 +1,47 @@ +=== tests/cases/conformance/types/thisType/fluentClasses.ts === +class A { +>A : Symbol(A, Decl(fluentClasses.ts, 0, 0)) + + foo() { +>foo : Symbol(foo, Decl(fluentClasses.ts, 0, 9)) + + return this; +>this : Symbol(A, Decl(fluentClasses.ts, 0, 0)) + } +} +class B extends A { +>B : Symbol(B, Decl(fluentClasses.ts, 4, 1)) +>A : Symbol(A, Decl(fluentClasses.ts, 0, 0)) + + bar() { +>bar : Symbol(bar, Decl(fluentClasses.ts, 5, 19)) + + return this; +>this : Symbol(B, Decl(fluentClasses.ts, 4, 1)) + } +} +class C extends B { +>C : Symbol(C, Decl(fluentClasses.ts, 9, 1)) +>B : Symbol(B, Decl(fluentClasses.ts, 4, 1)) + + baz() { +>baz : Symbol(baz, Decl(fluentClasses.ts, 10, 19)) + + return this; +>this : Symbol(C, Decl(fluentClasses.ts, 9, 1)) + } +} +var c: C; +>c : Symbol(c, Decl(fluentClasses.ts, 15, 3)) +>C : Symbol(C, Decl(fluentClasses.ts, 9, 1)) + +var z = c.foo().bar().baz(); // Fluent pattern +>z : Symbol(z, Decl(fluentClasses.ts, 16, 3)) +>c.foo().bar().baz : Symbol(C.baz, Decl(fluentClasses.ts, 10, 19)) +>c.foo().bar : Symbol(B.bar, Decl(fluentClasses.ts, 5, 19)) +>c.foo : Symbol(A.foo, Decl(fluentClasses.ts, 0, 9)) +>c : Symbol(c, Decl(fluentClasses.ts, 15, 3)) +>foo : Symbol(A.foo, Decl(fluentClasses.ts, 0, 9)) +>bar : Symbol(B.bar, Decl(fluentClasses.ts, 5, 19)) +>baz : Symbol(C.baz, Decl(fluentClasses.ts, 10, 19)) + diff --git a/tests/baselines/reference/fluentClasses.types b/tests/baselines/reference/fluentClasses.types new file mode 100644 index 00000000000..31ed6aafa01 --- /dev/null +++ b/tests/baselines/reference/fluentClasses.types @@ -0,0 +1,50 @@ +=== tests/cases/conformance/types/thisType/fluentClasses.ts === +class A { +>A : A + + foo() { +>foo : () => this + + return this; +>this : this + } +} +class B extends A { +>B : B +>A : A + + bar() { +>bar : () => this + + return this; +>this : this + } +} +class C extends B { +>C : C +>B : B + + baz() { +>baz : () => this + + return this; +>this : this + } +} +var c: C; +>c : C +>C : C + +var z = c.foo().bar().baz(); // Fluent pattern +>z : C +>c.foo().bar().baz() : C +>c.foo().bar().baz : () => C +>c.foo().bar() : C +>c.foo().bar : () => C +>c.foo() : C +>c.foo : () => C +>c : C +>foo : () => C +>bar : () => C +>baz : () => C + diff --git a/tests/baselines/reference/fluentInterfaces.js b/tests/baselines/reference/fluentInterfaces.js new file mode 100644 index 00000000000..1be15923d6c --- /dev/null +++ b/tests/baselines/reference/fluentInterfaces.js @@ -0,0 +1,17 @@ +//// [fluentInterfaces.ts] +interface A { + foo(): this; +} +interface B extends A { + bar(): this; +} +interface C extends B { + baz(): this; +} +var c: C; +var z = c.foo().bar().baz(); // Fluent pattern + + +//// [fluentInterfaces.js] +var c; +var z = c.foo().bar().baz(); // Fluent pattern diff --git a/tests/baselines/reference/fluentInterfaces.symbols b/tests/baselines/reference/fluentInterfaces.symbols new file mode 100644 index 00000000000..e059cdc127e --- /dev/null +++ b/tests/baselines/reference/fluentInterfaces.symbols @@ -0,0 +1,35 @@ +=== tests/cases/conformance/types/thisType/fluentInterfaces.ts === +interface A { +>A : Symbol(A, Decl(fluentInterfaces.ts, 0, 0)) + + foo(): this; +>foo : Symbol(foo, Decl(fluentInterfaces.ts, 0, 13)) +} +interface B extends A { +>B : Symbol(B, Decl(fluentInterfaces.ts, 2, 1)) +>A : Symbol(A, Decl(fluentInterfaces.ts, 0, 0)) + + bar(): this; +>bar : Symbol(bar, Decl(fluentInterfaces.ts, 3, 23)) +} +interface C extends B { +>C : Symbol(C, Decl(fluentInterfaces.ts, 5, 1)) +>B : Symbol(B, Decl(fluentInterfaces.ts, 2, 1)) + + baz(): this; +>baz : Symbol(baz, Decl(fluentInterfaces.ts, 6, 23)) +} +var c: C; +>c : Symbol(c, Decl(fluentInterfaces.ts, 9, 3)) +>C : Symbol(C, Decl(fluentInterfaces.ts, 5, 1)) + +var z = c.foo().bar().baz(); // Fluent pattern +>z : Symbol(z, Decl(fluentInterfaces.ts, 10, 3)) +>c.foo().bar().baz : Symbol(C.baz, Decl(fluentInterfaces.ts, 6, 23)) +>c.foo().bar : Symbol(B.bar, Decl(fluentInterfaces.ts, 3, 23)) +>c.foo : Symbol(A.foo, Decl(fluentInterfaces.ts, 0, 13)) +>c : Symbol(c, Decl(fluentInterfaces.ts, 9, 3)) +>foo : Symbol(A.foo, Decl(fluentInterfaces.ts, 0, 13)) +>bar : Symbol(B.bar, Decl(fluentInterfaces.ts, 3, 23)) +>baz : Symbol(C.baz, Decl(fluentInterfaces.ts, 6, 23)) + diff --git a/tests/baselines/reference/fluentInterfaces.types b/tests/baselines/reference/fluentInterfaces.types new file mode 100644 index 00000000000..26e5a74c188 --- /dev/null +++ b/tests/baselines/reference/fluentInterfaces.types @@ -0,0 +1,38 @@ +=== tests/cases/conformance/types/thisType/fluentInterfaces.ts === +interface A { +>A : A + + foo(): this; +>foo : () => this +} +interface B extends A { +>B : B +>A : A + + bar(): this; +>bar : () => this +} +interface C extends B { +>C : C +>B : B + + baz(): this; +>baz : () => this +} +var c: C; +>c : C +>C : C + +var z = c.foo().bar().baz(); // Fluent pattern +>z : C +>c.foo().bar().baz() : C +>c.foo().bar().baz : () => C +>c.foo().bar() : C +>c.foo().bar : () => C +>c.foo() : C +>c.foo : () => C +>c : C +>foo : () => C +>bar : () => C +>baz : () => C + diff --git a/tests/baselines/reference/for-of13.symbols b/tests/baselines/reference/for-of13.symbols index 08e5f4ff468..09a7e06cc21 100644 --- a/tests/baselines/reference/for-of13.symbols +++ b/tests/baselines/reference/for-of13.symbols @@ -4,6 +4,6 @@ var v: string; for (v of [""].values()) { } >v : Symbol(v, Decl(for-of13.ts, 0, 3)) ->[""].values : Symbol(Array.values, Decl(lib.d.ts, 1466, 37)) ->values : Symbol(Array.values, Decl(lib.d.ts, 1466, 37)) +>[""].values : Symbol(Array.values, Decl(lib.d.ts, 4146, 37)) +>values : Symbol(Array.values, Decl(lib.d.ts, 4146, 37)) diff --git a/tests/baselines/reference/for-of18.symbols b/tests/baselines/reference/for-of18.symbols index 066d9534051..76621026a00 100644 --- a/tests/baselines/reference/for-of18.symbols +++ b/tests/baselines/reference/for-of18.symbols @@ -22,9 +22,9 @@ class StringIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(StringIterator, Decl(for-of18.ts, 1, 33)) diff --git a/tests/baselines/reference/for-of18.types b/tests/baselines/reference/for-of18.types index 5b2be7edc3e..415f2b11568 100644 --- a/tests/baselines/reference/for-of18.types +++ b/tests/baselines/reference/for-of18.types @@ -32,6 +32,6 @@ class StringIterator { >iterator : symbol return this; ->this : StringIterator +>this : this } } diff --git a/tests/baselines/reference/for-of19.symbols b/tests/baselines/reference/for-of19.symbols index 8c34f6f0d7a..35892922df3 100644 --- a/tests/baselines/reference/for-of19.symbols +++ b/tests/baselines/reference/for-of19.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(for-of19.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of19.types b/tests/baselines/reference/for-of19.types index 02ef786ddd9..5128617bf24 100644 --- a/tests/baselines/reference/for-of19.types +++ b/tests/baselines/reference/for-of19.types @@ -37,6 +37,6 @@ class FooIterator { >iterator : symbol return this; ->this : FooIterator +>this : this } } diff --git a/tests/baselines/reference/for-of20.symbols b/tests/baselines/reference/for-of20.symbols index 4e7aaf7e362..f01969e23bb 100644 --- a/tests/baselines/reference/for-of20.symbols +++ b/tests/baselines/reference/for-of20.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(for-of20.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of20.types b/tests/baselines/reference/for-of20.types index 3da6fd484b1..de12979c650 100644 --- a/tests/baselines/reference/for-of20.types +++ b/tests/baselines/reference/for-of20.types @@ -37,6 +37,6 @@ class FooIterator { >iterator : symbol return this; ->this : FooIterator +>this : this } } diff --git a/tests/baselines/reference/for-of21.symbols b/tests/baselines/reference/for-of21.symbols index 70c1132afbd..c740cf62446 100644 --- a/tests/baselines/reference/for-of21.symbols +++ b/tests/baselines/reference/for-of21.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(for-of21.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of21.types b/tests/baselines/reference/for-of21.types index a0cc50e99d7..cab24c525d9 100644 --- a/tests/baselines/reference/for-of21.types +++ b/tests/baselines/reference/for-of21.types @@ -37,6 +37,6 @@ class FooIterator { >iterator : symbol return this; ->this : FooIterator +>this : this } } diff --git a/tests/baselines/reference/for-of22.symbols b/tests/baselines/reference/for-of22.symbols index 46507255937..bf4304a8216 100644 --- a/tests/baselines/reference/for-of22.symbols +++ b/tests/baselines/reference/for-of22.symbols @@ -28,9 +28,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(for-of22.ts, 5, 13)) diff --git a/tests/baselines/reference/for-of22.types b/tests/baselines/reference/for-of22.types index 09e85798554..f15a1d7e114 100644 --- a/tests/baselines/reference/for-of22.types +++ b/tests/baselines/reference/for-of22.types @@ -38,6 +38,6 @@ class FooIterator { >iterator : symbol return this; ->this : FooIterator +>this : this } } diff --git a/tests/baselines/reference/for-of23.symbols b/tests/baselines/reference/for-of23.symbols index 8401de024d9..a45775127b0 100644 --- a/tests/baselines/reference/for-of23.symbols +++ b/tests/baselines/reference/for-of23.symbols @@ -27,9 +27,9 @@ class FooIterator { }; } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(for-of23.ts, 4, 13)) diff --git a/tests/baselines/reference/for-of23.types b/tests/baselines/reference/for-of23.types index 37515c0b70a..87f1eeabbb7 100644 --- a/tests/baselines/reference/for-of23.types +++ b/tests/baselines/reference/for-of23.types @@ -38,6 +38,6 @@ class FooIterator { >iterator : symbol return this; ->this : FooIterator +>this : this } } diff --git a/tests/baselines/reference/for-of25.symbols b/tests/baselines/reference/for-of25.symbols index 93e918c4bcd..ef08deb568d 100644 --- a/tests/baselines/reference/for-of25.symbols +++ b/tests/baselines/reference/for-of25.symbols @@ -10,9 +10,9 @@ class StringIterator { >StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 1, 37)) [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return x; >x : Symbol(x, Decl(for-of25.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of26.symbols b/tests/baselines/reference/for-of26.symbols index 04445f50171..abaa0a92dcc 100644 --- a/tests/baselines/reference/for-of26.symbols +++ b/tests/baselines/reference/for-of26.symbols @@ -16,9 +16,9 @@ class StringIterator { >x : Symbol(x, Decl(for-of26.ts, 0, 3)) } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(StringIterator, Decl(for-of26.ts, 1, 37)) diff --git a/tests/baselines/reference/for-of26.types b/tests/baselines/reference/for-of26.types index d2608fbf154..fe930e2e57f 100644 --- a/tests/baselines/reference/for-of26.types +++ b/tests/baselines/reference/for-of26.types @@ -22,6 +22,6 @@ class StringIterator { >iterator : symbol return this; ->this : StringIterator +>this : this } } diff --git a/tests/baselines/reference/for-of27.symbols b/tests/baselines/reference/for-of27.symbols index 4c645d359dd..727574805b9 100644 --- a/tests/baselines/reference/for-of27.symbols +++ b/tests/baselines/reference/for-of27.symbols @@ -7,7 +7,7 @@ class StringIterator { >StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 37)) [Symbol.iterator]: any; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) } diff --git a/tests/baselines/reference/for-of28.symbols b/tests/baselines/reference/for-of28.symbols index 6887b46a44d..4e1bf8ad3dc 100644 --- a/tests/baselines/reference/for-of28.symbols +++ b/tests/baselines/reference/for-of28.symbols @@ -10,9 +10,9 @@ class StringIterator { >next : Symbol(next, Decl(for-of28.ts, 2, 22)) [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(StringIterator, Decl(for-of28.ts, 0, 37)) diff --git a/tests/baselines/reference/for-of28.types b/tests/baselines/reference/for-of28.types index 91b77a55a4d..882d2df6186 100644 --- a/tests/baselines/reference/for-of28.types +++ b/tests/baselines/reference/for-of28.types @@ -16,6 +16,6 @@ class StringIterator { >iterator : symbol return this; ->this : StringIterator +>this : this } } diff --git a/tests/baselines/reference/for-of37.symbols b/tests/baselines/reference/for-of37.symbols index a726b7eedc2..b0a39571f6f 100644 --- a/tests/baselines/reference/for-of37.symbols +++ b/tests/baselines/reference/for-of37.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of37.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of37.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4635, 1), Decl(lib.d.ts, 4658, 11)) for (var v of map) { >v : Symbol(v, Decl(for-of37.ts, 1, 8)) diff --git a/tests/baselines/reference/for-of38.symbols b/tests/baselines/reference/for-of38.symbols index 11ff91e1162..67ee08bbb5f 100644 --- a/tests/baselines/reference/for-of38.symbols +++ b/tests/baselines/reference/for-of38.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of38.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of38.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4635, 1), Decl(lib.d.ts, 4658, 11)) for (var [k, v] of map) { >k : Symbol(k, Decl(for-of38.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of40.symbols b/tests/baselines/reference/for-of40.symbols index f6619ff753d..2f3a2a9a574 100644 --- a/tests/baselines/reference/for-of40.symbols +++ b/tests/baselines/reference/for-of40.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of40.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of40.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4635, 1), Decl(lib.d.ts, 4658, 11)) for (var [k = "", v = false] of map) { >k : Symbol(k, Decl(for-of40.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of44.symbols b/tests/baselines/reference/for-of44.symbols index a9ea283d673..839de020702 100644 --- a/tests/baselines/reference/for-of44.symbols +++ b/tests/baselines/reference/for-of44.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of44.ts === var array: [number, string | boolean | symbol][] = [[0, ""], [0, true], [1, Symbol()]] >array : Symbol(array, Decl(for-of44.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) for (var [num, strBoolSym] of array) { >num : Symbol(num, Decl(for-of44.ts, 1, 10)) diff --git a/tests/baselines/reference/for-of45.symbols b/tests/baselines/reference/for-of45.symbols index 1d447ea87cc..6f75dd6311d 100644 --- a/tests/baselines/reference/for-of45.symbols +++ b/tests/baselines/reference/for-of45.symbols @@ -5,7 +5,7 @@ var k: string, v: boolean; var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of45.ts, 1, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4635, 1), Decl(lib.d.ts, 4658, 11)) for ([k = "", v = false] of map) { >k : Symbol(k, Decl(for-of45.ts, 0, 3)) diff --git a/tests/baselines/reference/for-of50.symbols b/tests/baselines/reference/for-of50.symbols index 6b8012c7929..7fb77790ef7 100644 --- a/tests/baselines/reference/for-of50.symbols +++ b/tests/baselines/reference/for-of50.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of50.ts === var map = new Map([["", true]]); >map : Symbol(map, Decl(for-of50.ts, 0, 3)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4635, 1), Decl(lib.d.ts, 4658, 11)) for (const [k, v] of map) { >k : Symbol(k, Decl(for-of50.ts, 1, 12)) diff --git a/tests/baselines/reference/for-of57.symbols b/tests/baselines/reference/for-of57.symbols index b8d01d3bd1b..9aadb415e8f 100644 --- a/tests/baselines/reference/for-of57.symbols +++ b/tests/baselines/reference/for-of57.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/for-ofStatements/for-of57.ts === var iter: Iterable; >iter : Symbol(iter, Decl(for-of57.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4396, 1)) for (let num of iter) { } >num : Symbol(num, Decl(for-of57.ts, 1, 8)) diff --git a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt index 098afe94b47..53ecb88363d 100644 --- a/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt +++ b/tests/baselines/reference/forStatementsMultipleInvalidDecl.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(40,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(43,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(46,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. -tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. +tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(47,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(50,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D[]', but here has type 'D[]'. tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDecl.ts(53,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'. @@ -79,7 +79,7 @@ tests/cases/conformance/statements/forStatements/forStatementsMultipleInvalidDec !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. for( var arr = [new C(), new C2(), new D()];;){} ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. for(var arr2 = [new D()];;){} for( var arr2 = new Array>();;){} diff --git a/tests/baselines/reference/forwardRefInEnum.errors.txt b/tests/baselines/reference/forwardRefInEnum.errors.txt new file mode 100644 index 00000000000..0f2c359402f --- /dev/null +++ b/tests/baselines/reference/forwardRefInEnum.errors.txt @@ -0,0 +1,29 @@ +tests/cases/compiler/forwardRefInEnum.ts(4,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. +tests/cases/compiler/forwardRefInEnum.ts(5,10): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. +tests/cases/compiler/forwardRefInEnum.ts(7,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. +tests/cases/compiler/forwardRefInEnum.ts(8,10): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + + +==== tests/cases/compiler/forwardRefInEnum.ts (4 errors) ==== + enum E1 { + // illegal case + // forward reference to the element of the same enum + X = Y, + ~ +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + X1 = E1["Y"], + ~~~~~~~ +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + // forward reference to the element of the same enum + Y = E1.Z, + ~~~~ +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + Y1 = E1["Z"] + ~~~~~~~ +!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. + } + + enum E1 { + Z = 4 + } + \ No newline at end of file diff --git a/tests/baselines/reference/forwardRefInEnum.js b/tests/baselines/reference/forwardRefInEnum.js new file mode 100644 index 00000000000..76e2575ec8d --- /dev/null +++ b/tests/baselines/reference/forwardRefInEnum.js @@ -0,0 +1,31 @@ +//// [forwardRefInEnum.ts] +enum E1 { + // illegal case + // forward reference to the element of the same enum + X = Y, + X1 = E1["Y"], + // forward reference to the element of the same enum + Y = E1.Z, + Y1 = E1["Z"] +} + +enum E1 { + Z = 4 +} + + +//// [forwardRefInEnum.js] +var E1; +(function (E1) { + // illegal case + // forward reference to the element of the same enum + E1[E1["X"] = E1.Y] = "X"; + E1[E1["X1"] = E1["Y"]] = "X1"; + // forward reference to the element of the same enum + E1[E1["Y"] = E1.Z] = "Y"; + E1[E1["Y1"] = E1["Z"]] = "Y1"; +})(E1 || (E1 = {})); +var E1; +(function (E1) { + E1[E1["Z"] = 4] = "Z"; +})(E1 || (E1 = {})); diff --git a/tests/baselines/reference/functionImplementations.types b/tests/baselines/reference/functionImplementations.types index 4facd65bda7..1398e2974f0 100644 --- a/tests/baselines/reference/functionImplementations.types +++ b/tests/baselines/reference/functionImplementations.types @@ -342,7 +342,7 @@ var f7: (x: number) => string | number = x => { // should be (x: number) => numb var f8: (x: number) => any = x => { // should be (x: number) => Base >f8 : (x: number) => any >x : number ->x => { // should be (x: number) => Base return new Base(); return new Derived2();} : (x: number) => Base | Derived2 +>x => { // should be (x: number) => Base return new Base(); return new Derived2();} : (x: number) => Base >x : number return new Base(); @@ -356,7 +356,7 @@ var f8: (x: number) => any = x => { // should be (x: number) => Base var f9: (x: number) => any = x => { // should be (x: number) => Base >f9 : (x: number) => any >x : number ->x => { // should be (x: number) => Base return new Base(); return new Derived(); return new Derived2();} : (x: number) => Base | Derived | Derived2 +>x => { // should be (x: number) => Base return new Base(); return new Derived(); return new Derived2();} : (x: number) => Base >x : number return new Base(); diff --git a/tests/baselines/reference/functionOverloads7.types b/tests/baselines/reference/functionOverloads7.types index c57f042b354..7160068126f 100644 --- a/tests/baselines/reference/functionOverloads7.types +++ b/tests/baselines/reference/functionOverloads7.types @@ -21,7 +21,7 @@ class foo { >foo : any >this.bar() : any >this.bar : { (): any; (foo: string): any; } ->this : foo +>this : this >bar : { (): any; (foo: string): any; } foo = this.bar("test"); @@ -29,7 +29,7 @@ class foo { >foo : any >this.bar("test") : any >this.bar : { (): any; (foo: string): any; } ->this : foo +>this : this >bar : { (): any; (foo: string): any; } >"test" : string } diff --git a/tests/baselines/reference/functionSubtypingOfVarArgs.types b/tests/baselines/reference/functionSubtypingOfVarArgs.types index ebd706e94cf..ec48ff26c66 100644 --- a/tests/baselines/reference/functionSubtypingOfVarArgs.types +++ b/tests/baselines/reference/functionSubtypingOfVarArgs.types @@ -15,7 +15,7 @@ class EventBase { >this._listeners.push(listener) : number >this._listeners.push : (...items: any[]) => number >this._listeners : any[] ->this : EventBase +>this : this >_listeners : any[] >push : (...items: any[]) => number >listener : (...args: any[]) => void diff --git a/tests/baselines/reference/functionSubtypingOfVarArgs2.types b/tests/baselines/reference/functionSubtypingOfVarArgs2.types index 5e2b14ffc7a..3aa5b7a7a00 100644 --- a/tests/baselines/reference/functionSubtypingOfVarArgs2.types +++ b/tests/baselines/reference/functionSubtypingOfVarArgs2.types @@ -16,7 +16,7 @@ class EventBase { >this._listeners.push(listener) : number >this._listeners.push : (...items: ((...args: any[]) => void)[]) => number >this._listeners : ((...args: any[]) => void)[] ->this : EventBase +>this : this >_listeners : ((...args: any[]) => void)[] >push : (...items: ((...args: any[]) => void)[]) => number >listener : (...args: any[]) => void diff --git a/tests/baselines/reference/functionsWithModifiersInBlocks1.errors.txt b/tests/baselines/reference/functionsWithModifiersInBlocks1.errors.txt index f6240f5e697..e3137740937 100644 --- a/tests/baselines/reference/functionsWithModifiersInBlocks1.errors.txt +++ b/tests/baselines/reference/functionsWithModifiersInBlocks1.errors.txt @@ -1,11 +1,11 @@ tests/cases/compiler/functionsWithModifiersInBlocks1.ts(2,4): error TS1184: Modifiers cannot appear here. tests/cases/compiler/functionsWithModifiersInBlocks1.ts(2,21): error TS2393: Duplicate function implementation. -tests/cases/compiler/functionsWithModifiersInBlocks1.ts(2,25): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/functionsWithModifiersInBlocks1.ts(2,25): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/functionsWithModifiersInBlocks1.ts(3,4): error TS1184: Modifiers cannot appear here. tests/cases/compiler/functionsWithModifiersInBlocks1.ts(3,20): error TS2393: Duplicate function implementation. tests/cases/compiler/functionsWithModifiersInBlocks1.ts(4,4): error TS1184: Modifiers cannot appear here. tests/cases/compiler/functionsWithModifiersInBlocks1.ts(4,28): error TS2393: Duplicate function implementation. -tests/cases/compiler/functionsWithModifiersInBlocks1.ts(4,32): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/functionsWithModifiersInBlocks1.ts(4,32): error TS1183: An implementation cannot be declared in ambient contexts. ==== tests/cases/compiler/functionsWithModifiersInBlocks1.ts (8 errors) ==== @@ -16,7 +16,7 @@ tests/cases/compiler/functionsWithModifiersInBlocks1.ts(4,32): error TS1184: An ~ !!! error TS2393: Duplicate function implementation. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. export function f() { } ~~~~~~ !!! error TS1184: Modifiers cannot appear here. @@ -28,5 +28,5 @@ tests/cases/compiler/functionsWithModifiersInBlocks1.ts(4,32): error TS1184: An ~ !!! error TS2393: Duplicate function implementation. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. } \ No newline at end of file diff --git a/tests/baselines/reference/fuzzy.errors.txt b/tests/baselines/reference/fuzzy.errors.txt index 699841f8870..72ac4c816f9 100644 --- a/tests/baselines/reference/fuzzy.errors.txt +++ b/tests/baselines/reference/fuzzy.errors.txt @@ -1,10 +1,11 @@ tests/cases/compiler/fuzzy.ts(13,18): error TS2420: Class 'C' incorrectly implements interface 'I'. Property 'alsoWorks' is missing in type 'C'. -tests/cases/compiler/fuzzy.ts(21,20): error TS2322: Type '{ anything: number; oneI: C; }' is not assignable to type 'R'. +tests/cases/compiler/fuzzy.ts(21,20): error TS2322: Type '{ anything: number; oneI: this; }' is not assignable to type 'R'. Types of property 'oneI' are incompatible. - Type 'C' is not assignable to type 'I'. -tests/cases/compiler/fuzzy.ts(25,20): error TS2352: Neither type '{ oneI: C; }' nor type 'R' is assignable to the other. - Property 'anything' is missing in type '{ oneI: C; }'. + Type 'this' is not assignable to type 'I'. + Type 'C' is not assignable to type 'I'. +tests/cases/compiler/fuzzy.ts(25,20): error TS2352: Neither type '{ oneI: this; }' nor type 'R' is assignable to the other. + Property 'anything' is missing in type '{ oneI: this; }'. ==== tests/cases/compiler/fuzzy.ts (3 errors) ==== @@ -33,16 +34,17 @@ tests/cases/compiler/fuzzy.ts(25,20): error TS2352: Neither type '{ oneI: C; }' doesntWork():R { return { anything:1, oneI:this }; ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ anything: number; oneI: C; }' is not assignable to type 'R'. +!!! error TS2322: Type '{ anything: number; oneI: this; }' is not assignable to type 'R'. !!! error TS2322: Types of property 'oneI' are incompatible. -!!! error TS2322: Type 'C' is not assignable to type 'I'. +!!! error TS2322: Type 'this' is not assignable to type 'I'. +!!! error TS2322: Type 'C' is not assignable to type 'I'. } worksToo():R { return ({ oneI: this }); ~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Neither type '{ oneI: C; }' nor type 'R' is assignable to the other. -!!! error TS2352: Property 'anything' is missing in type '{ oneI: C; }'. +!!! error TS2352: Neither type '{ oneI: this; }' nor type 'R' is assignable to the other. +!!! error TS2352: Property 'anything' is missing in type '{ oneI: this; }'. } } } diff --git a/tests/baselines/reference/generatedContextualTyping.types b/tests/baselines/reference/generatedContextualTyping.types index 06745d0d7aa..e8f434d31a8 100644 --- a/tests/baselines/reference/generatedContextualTyping.types +++ b/tests/baselines/reference/generatedContextualTyping.types @@ -2125,8 +2125,8 @@ var x216 = >{ func: n => { return [d1, d2]; } }; >d2 : Derived2 var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; ->x217 : (() => Base[]) | (() => (Derived1 | Derived2)[]) ->(<() => Base[]>undefined) || function() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>x217 : () => Base[] +>(<() => Base[]>undefined) || function() { return [d1, d2] } : () => Base[] >(<() => Base[]>undefined) : () => Base[] ><() => Base[]>undefined : () => Base[] >Base : Base @@ -2137,8 +2137,8 @@ var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] }; >d2 : Derived2 var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; ->x218 : (() => Base[]) | (() => (Derived1 | Derived2)[]) ->(<() => Base[]>undefined) || function named() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>x218 : () => Base[] +>(<() => Base[]>undefined) || function named() { return [d1, d2] } : () => Base[] >(<() => Base[]>undefined) : () => Base[] ><() => Base[]>undefined : () => Base[] >Base : Base @@ -2150,8 +2150,8 @@ var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] }; >d2 : Derived2 var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; ->x219 : (() => Base[]) | (() => (Derived1 | Derived2)[]) ->(<{ (): Base[]; }>undefined) || function() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>x219 : () => Base[] +>(<{ (): Base[]; }>undefined) || function() { return [d1, d2] } : () => Base[] >(<{ (): Base[]; }>undefined) : () => Base[] ><{ (): Base[]; }>undefined : () => Base[] >Base : Base @@ -2162,8 +2162,8 @@ var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] }; >d2 : Derived2 var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; ->x220 : (() => Base[]) | (() => (Derived1 | Derived2)[]) ->(<{ (): Base[]; }>undefined) || function named() { return [d1, d2] } : (() => Base[]) | (() => (Derived1 | Derived2)[]) +>x220 : () => Base[] +>(<{ (): Base[]; }>undefined) || function named() { return [d1, d2] } : () => Base[] >(<{ (): Base[]; }>undefined) : () => Base[] ><{ (): Base[]; }>undefined : () => Base[] >Base : Base @@ -2175,8 +2175,8 @@ var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] }; >d2 : Derived2 var x221 = (undefined) || [d1, d2]; ->x221 : Base[] | (Derived1 | Derived2)[] ->(undefined) || [d1, d2] : Base[] | (Derived1 | Derived2)[] +>x221 : Base[] +>(undefined) || [d1, d2] : Base[] >(undefined) : Base[] >undefined : Base[] >Base : Base @@ -2186,8 +2186,8 @@ var x221 = (undefined) || [d1, d2]; >d2 : Derived2 var x222 = (>undefined) || [d1, d2]; ->x222 : Base[] | (Derived1 | Derived2)[] ->(>undefined) || [d1, d2] : Base[] | (Derived1 | Derived2)[] +>x222 : Base[] +>(>undefined) || [d1, d2] : Base[] >(>undefined) : Base[] >>undefined : Base[] >Array : T[] @@ -2198,8 +2198,8 @@ var x222 = (>undefined) || [d1, d2]; >d2 : Derived2 var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; ->x223 : { [n: number]: Base; } | (Derived1 | Derived2)[] ->(<{ [n: number]: Base; }>undefined) || [d1, d2] : { [n: number]: Base; } | (Derived1 | Derived2)[] +>x223 : { [n: number]: Base; } +>(<{ [n: number]: Base; }>undefined) || [d1, d2] : { [n: number]: Base; } >(<{ [n: number]: Base; }>undefined) : { [n: number]: Base; } ><{ [n: number]: Base; }>undefined : { [n: number]: Base; } >n : number @@ -2210,8 +2210,8 @@ var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2]; >d2 : Derived2 var x224 = (<{n: Base[]; } >undefined) || { n: [d1, d2] }; ->x224 : { n: Base[]; } | { n: (Derived1 | Derived2)[]; } ->(<{n: Base[]; } >undefined) || { n: [d1, d2] } : { n: Base[]; } | { n: (Derived1 | Derived2)[]; } +>x224 : { n: Base[]; } +>(<{n: Base[]; } >undefined) || { n: [d1, d2] } : { n: Base[]; } >(<{n: Base[]; } >undefined) : { n: Base[]; } ><{n: Base[]; } >undefined : { n: Base[]; } >n : Base[] diff --git a/tests/baselines/reference/generatorES6_6.symbols b/tests/baselines/reference/generatorES6_6.symbols index 7f30b4f6797..f424048eeec 100644 --- a/tests/baselines/reference/generatorES6_6.symbols +++ b/tests/baselines/reference/generatorES6_6.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(generatorES6_6.ts, 0, 0)) *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) let a = yield 1; >a : Symbol(a, Decl(generatorES6_6.ts, 2, 7)) diff --git a/tests/baselines/reference/generatorOverloads4.symbols b/tests/baselines/reference/generatorOverloads4.symbols index c4fb9401517..233af97ee59 100644 --- a/tests/baselines/reference/generatorOverloads4.symbols +++ b/tests/baselines/reference/generatorOverloads4.symbols @@ -5,15 +5,15 @@ class C { f(s: string): Iterable; >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 1, 6)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4396, 1)) f(s: number): Iterable; >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 2, 6)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4396, 1)) *f(s: any): Iterable { } >f : Symbol(f, Decl(generatorOverloads4.ts, 0, 9), Decl(generatorOverloads4.ts, 1, 32), Decl(generatorOverloads4.ts, 2, 32)) >s : Symbol(s, Decl(generatorOverloads4.ts, 3, 7)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4396, 1)) } diff --git a/tests/baselines/reference/generatorOverloads5.symbols b/tests/baselines/reference/generatorOverloads5.symbols index 509ed22d197..e3b14d76cd0 100644 --- a/tests/baselines/reference/generatorOverloads5.symbols +++ b/tests/baselines/reference/generatorOverloads5.symbols @@ -5,15 +5,15 @@ module M { function f(s: string): Iterable; >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 1, 15)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4396, 1)) function f(s: number): Iterable; >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 2, 15)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4396, 1)) function* f(s: any): Iterable { } >f : Symbol(f, Decl(generatorOverloads5.ts, 0, 10), Decl(generatorOverloads5.ts, 1, 41), Decl(generatorOverloads5.ts, 2, 41)) >s : Symbol(s, Decl(generatorOverloads5.ts, 3, 16)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4396, 1)) } diff --git a/tests/baselines/reference/generatorTypeCheck1.symbols b/tests/baselines/reference/generatorTypeCheck1.symbols index 79cc3e275ad..3353182c7db 100644 --- a/tests/baselines/reference/generatorTypeCheck1.symbols +++ b/tests/baselines/reference/generatorTypeCheck1.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck1.ts === function* g1(): Iterator { } >g1 : Symbol(g1, Decl(generatorTypeCheck1.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 4390, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck10.symbols b/tests/baselines/reference/generatorTypeCheck10.symbols index 6247bd7b85c..9dc3d726f8d 100644 --- a/tests/baselines/reference/generatorTypeCheck10.symbols +++ b/tests/baselines/reference/generatorTypeCheck10.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck10.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck10.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4400, 1)) return; } diff --git a/tests/baselines/reference/generatorTypeCheck11.symbols b/tests/baselines/reference/generatorTypeCheck11.symbols index dce2524d1ba..fabd19cd199 100644 --- a/tests/baselines/reference/generatorTypeCheck11.symbols +++ b/tests/baselines/reference/generatorTypeCheck11.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck11.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck11.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4400, 1)) return 0; } diff --git a/tests/baselines/reference/generatorTypeCheck12.symbols b/tests/baselines/reference/generatorTypeCheck12.symbols index f9c9b7b6e22..4fe733933bb 100644 --- a/tests/baselines/reference/generatorTypeCheck12.symbols +++ b/tests/baselines/reference/generatorTypeCheck12.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck12.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck12.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4400, 1)) return ""; } diff --git a/tests/baselines/reference/generatorTypeCheck13.symbols b/tests/baselines/reference/generatorTypeCheck13.symbols index bc43ea8c8f9..8a720da6ee5 100644 --- a/tests/baselines/reference/generatorTypeCheck13.symbols +++ b/tests/baselines/reference/generatorTypeCheck13.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck13.ts === function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck13.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4400, 1)) yield 0; return ""; diff --git a/tests/baselines/reference/generatorTypeCheck17.symbols b/tests/baselines/reference/generatorTypeCheck17.symbols index 789eb22347c..28c4bb60055 100644 --- a/tests/baselines/reference/generatorTypeCheck17.symbols +++ b/tests/baselines/reference/generatorTypeCheck17.symbols @@ -10,7 +10,7 @@ class Bar extends Foo { y: string } function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck17.ts, 1, 35)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4400, 1)) >Foo : Symbol(Foo, Decl(generatorTypeCheck17.ts, 0, 0)) yield; diff --git a/tests/baselines/reference/generatorTypeCheck19.symbols b/tests/baselines/reference/generatorTypeCheck19.symbols index e7a5898099f..0c6bbbb462e 100644 --- a/tests/baselines/reference/generatorTypeCheck19.symbols +++ b/tests/baselines/reference/generatorTypeCheck19.symbols @@ -10,7 +10,7 @@ class Bar extends Foo { y: string } function* g(): IterableIterator { >g : Symbol(g, Decl(generatorTypeCheck19.ts, 1, 35)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4400, 1)) >Foo : Symbol(Foo, Decl(generatorTypeCheck19.ts, 0, 0)) yield; diff --git a/tests/baselines/reference/generatorTypeCheck2.symbols b/tests/baselines/reference/generatorTypeCheck2.symbols index 5a0aec4d592..99d9a0f0505 100644 --- a/tests/baselines/reference/generatorTypeCheck2.symbols +++ b/tests/baselines/reference/generatorTypeCheck2.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck2.ts === function* g1(): Iterable { } >g1 : Symbol(g1, Decl(generatorTypeCheck2.ts, 0, 0)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4396, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck26.symbols b/tests/baselines/reference/generatorTypeCheck26.symbols index 08cc7289ef8..f2c13cf6199 100644 --- a/tests/baselines/reference/generatorTypeCheck26.symbols +++ b/tests/baselines/reference/generatorTypeCheck26.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck26.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck26.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4400, 1)) >x : Symbol(x, Decl(generatorTypeCheck26.ts, 0, 33)) yield x => x.length; diff --git a/tests/baselines/reference/generatorTypeCheck27.symbols b/tests/baselines/reference/generatorTypeCheck27.symbols index fcee922d1e9..e05147aa4b5 100644 --- a/tests/baselines/reference/generatorTypeCheck27.symbols +++ b/tests/baselines/reference/generatorTypeCheck27.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck27.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck27.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4400, 1)) >x : Symbol(x, Decl(generatorTypeCheck27.ts, 0, 33)) yield * function* () { diff --git a/tests/baselines/reference/generatorTypeCheck28.symbols b/tests/baselines/reference/generatorTypeCheck28.symbols index 27b246515f6..b157d464292 100644 --- a/tests/baselines/reference/generatorTypeCheck28.symbols +++ b/tests/baselines/reference/generatorTypeCheck28.symbols @@ -1,14 +1,14 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck28.ts === function* g(): IterableIterator<(x: string) => number> { >g : Symbol(g, Decl(generatorTypeCheck28.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4400, 1)) >x : Symbol(x, Decl(generatorTypeCheck28.ts, 0, 33)) yield * { *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) yield x => x.length; >x : Symbol(x, Decl(generatorTypeCheck28.ts, 3, 17)) diff --git a/tests/baselines/reference/generatorTypeCheck29.symbols b/tests/baselines/reference/generatorTypeCheck29.symbols index 260137dd1cf..54a5cc0fdb6 100644 --- a/tests/baselines/reference/generatorTypeCheck29.symbols +++ b/tests/baselines/reference/generatorTypeCheck29.symbols @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck29.ts === function* g2(): Iterator number>> { >g2 : Symbol(g2, Decl(generatorTypeCheck29.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 4390, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4396, 1)) >x : Symbol(x, Decl(generatorTypeCheck29.ts, 0, 35)) yield function* () { diff --git a/tests/baselines/reference/generatorTypeCheck3.symbols b/tests/baselines/reference/generatorTypeCheck3.symbols index a149a592e3d..5fdef53c6f3 100644 --- a/tests/baselines/reference/generatorTypeCheck3.symbols +++ b/tests/baselines/reference/generatorTypeCheck3.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck3.ts === function* g1(): IterableIterator { } >g1 : Symbol(g1, Decl(generatorTypeCheck3.ts, 0, 0)) ->IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 1685, 1)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.d.ts, 4400, 1)) diff --git a/tests/baselines/reference/generatorTypeCheck30.symbols b/tests/baselines/reference/generatorTypeCheck30.symbols index 086c65685a8..d107c4bde19 100644 --- a/tests/baselines/reference/generatorTypeCheck30.symbols +++ b/tests/baselines/reference/generatorTypeCheck30.symbols @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck30.ts === function* g2(): Iterator number>> { >g2 : Symbol(g2, Decl(generatorTypeCheck30.ts, 0, 0)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 4390, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4396, 1)) >x : Symbol(x, Decl(generatorTypeCheck30.ts, 0, 35)) yield function* () { diff --git a/tests/baselines/reference/generatorTypeCheck39.js b/tests/baselines/reference/generatorTypeCheck39.js index e6d25045a7e..43df3b8e205 100644 --- a/tests/baselines/reference/generatorTypeCheck39.js +++ b/tests/baselines/reference/generatorTypeCheck39.js @@ -11,12 +11,10 @@ function* g() { //// [generatorTypeCheck39.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; function decorator(x) { return y => { }; diff --git a/tests/baselines/reference/generatorTypeCheck45.symbols b/tests/baselines/reference/generatorTypeCheck45.symbols index 89c01ff0203..bb24ffb1eb6 100644 --- a/tests/baselines/reference/generatorTypeCheck45.symbols +++ b/tests/baselines/reference/generatorTypeCheck45.symbols @@ -6,7 +6,7 @@ declare function foo(x: T, fun: () => Iterator<(x: T) => U>, fun2: (y: U) >x : Symbol(x, Decl(generatorTypeCheck45.ts, 0, 27)) >T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) >fun : Symbol(fun, Decl(generatorTypeCheck45.ts, 0, 32)) ->Iterator : Symbol(Iterator, Decl(lib.d.ts, 1675, 1)) +>Iterator : Symbol(Iterator, Decl(lib.d.ts, 4390, 1)) >x : Symbol(x, Decl(generatorTypeCheck45.ts, 0, 54)) >T : Symbol(T, Decl(generatorTypeCheck45.ts, 0, 21)) >U : Symbol(U, Decl(generatorTypeCheck45.ts, 0, 23)) diff --git a/tests/baselines/reference/generatorTypeCheck46.symbols b/tests/baselines/reference/generatorTypeCheck46.symbols index 72d8ebf57a1..a6dd01be70f 100644 --- a/tests/baselines/reference/generatorTypeCheck46.symbols +++ b/tests/baselines/reference/generatorTypeCheck46.symbols @@ -6,7 +6,7 @@ declare function foo(x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) >x : Symbol(x, Decl(generatorTypeCheck46.ts, 0, 27)) >T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) >fun : Symbol(fun, Decl(generatorTypeCheck46.ts, 0, 32)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4396, 1)) >x : Symbol(x, Decl(generatorTypeCheck46.ts, 0, 54)) >T : Symbol(T, Decl(generatorTypeCheck46.ts, 0, 21)) >U : Symbol(U, Decl(generatorTypeCheck46.ts, 0, 23)) @@ -21,9 +21,9 @@ foo("", function* () { yield* { *[Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) yield x => x.length >x : Symbol(x, Decl(generatorTypeCheck46.ts, 5, 17)) diff --git a/tests/baselines/reference/generatorTypeCheck59.js b/tests/baselines/reference/generatorTypeCheck59.js index 5b3b70386f8..8fd32e7730a 100644 --- a/tests/baselines/reference/generatorTypeCheck59.js +++ b/tests/baselines/reference/generatorTypeCheck59.js @@ -8,20 +8,17 @@ function* g() { //// [generatorTypeCheck59.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; function* g() { class C { m() { } } - Object.defineProperty(C.prototype, "m", - __decorate([ - (yield "") - ], C.prototype, "m", Object.getOwnPropertyDescriptor(C.prototype, "m"))); + __decorate([ + (yield "") + ], C.prototype, "m", null); ; } diff --git a/tests/baselines/reference/generatorTypeCheck61.js b/tests/baselines/reference/generatorTypeCheck61.js index 9e2f067f9fb..b2434ee590c 100644 --- a/tests/baselines/reference/generatorTypeCheck61.js +++ b/tests/baselines/reference/generatorTypeCheck61.js @@ -6,12 +6,10 @@ function * g() { //// [generatorTypeCheck61.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; function* g() { let C = class { diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty.types b/tests/baselines/reference/genericBaseClassLiteralProperty.types index 87f1c55c42d..69468f9b679 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty.types +++ b/tests/baselines/reference/genericBaseClassLiteralProperty.types @@ -23,14 +23,14 @@ class SubClass extends BaseClass { >x : number >this._getValue1() : number >this._getValue1 : () => number ->this : SubClass +>this : this >_getValue1 : () => number var y : number = this._getValue2(); >y : number >this._getValue2() : number >this._getValue2 : () => number ->this : SubClass +>this : this >_getValue2 : () => number } } diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty2.types b/tests/baselines/reference/genericBaseClassLiteralProperty2.types index 271aa190037..d7d512165f0 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty2.types +++ b/tests/baselines/reference/genericBaseClassLiteralProperty2.types @@ -16,7 +16,7 @@ class BaseCollection2 { this._itemsByKey = {}; >this._itemsByKey = {} : { [x: string]: undefined; } >this._itemsByKey : { [key: string]: TItem; } ->this : BaseCollection2 +>this : this >_itemsByKey : { [key: string]: TItem; } >{} : { [x: string]: undefined; } } @@ -36,7 +36,7 @@ class DataView2 extends BaseCollection2 { >this._itemsByKey['dummy'] = item : CollectionItem2 >this._itemsByKey['dummy'] : CollectionItem2 >this._itemsByKey : { [key: string]: CollectionItem2; } ->this : DataView2 +>this : this >_itemsByKey : { [key: string]: CollectionItem2; } >'dummy' : string >item : CollectionItem2 diff --git a/tests/baselines/reference/genericClassWithStaticFactory.symbols b/tests/baselines/reference/genericClassWithStaticFactory.symbols index 37ee9c638e9..47b7f5f736b 100644 --- a/tests/baselines/reference/genericClassWithStaticFactory.symbols +++ b/tests/baselines/reference/genericClassWithStaticFactory.symbols @@ -52,23 +52,23 @@ module Editor { >data : Symbol(data, Decl(genericClassWithStaticFactory.ts, 12, 19)) this.prev.next = entry; ->this.prev.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>this.prev.next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >this.prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) >prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) ->next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 13, 15)) entry.next = this; ->entry.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>entry.next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 13, 15)) ->next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) entry.prev = this.prev; ->entry.prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>entry.prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 13, 15)) ->prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >this.prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) >prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) @@ -102,16 +102,16 @@ module Editor { for (i = 0; !(entry.isHead); i++) { >i : Symbol(i, Decl(genericClassWithStaticFactory.ts, 24, 15)) ->entry.isHead : Symbol(isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) +>entry.isHead : Symbol(List.isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 23, 15)) ->isHead : Symbol(isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) +>isHead : Symbol(List.isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) >i : Symbol(i, Decl(genericClassWithStaticFactory.ts, 24, 15)) entry = entry.next; >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 23, 15)) ->entry.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>entry.next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 23, 15)) ->next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) } return (i); @@ -138,11 +138,11 @@ module Editor { >isEmpty : Symbol(isEmpty, Decl(genericClassWithStaticFactory.ts, 32, 9)) { return this.next.data; ->this.next.data : Symbol(data, Decl(genericClassWithStaticFactory.ts, 7, 43)) +>this.next.data : Symbol(List.data, Decl(genericClassWithStaticFactory.ts, 7, 43)) >this.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) >next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) ->data : Symbol(data, Decl(genericClassWithStaticFactory.ts, 7, 43)) +>data : Symbol(List.data, Decl(genericClassWithStaticFactory.ts, 7, 43)) } else { return null; @@ -156,22 +156,22 @@ module Editor { >T : Symbol(T, Decl(genericClassWithStaticFactory.ts, 2, 22)) entry.isHead = false; ->entry.isHead : Symbol(isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) +>entry.isHead : Symbol(List.isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 48, 25)) ->isHead : Symbol(isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) +>isHead : Symbol(List.isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) entry.next = this.next; ->entry.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>entry.next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 48, 25)) ->next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >this.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) >next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) entry.prev = this; ->entry.prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>entry.prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 48, 25)) ->prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) this.next = entry; @@ -181,11 +181,11 @@ module Editor { >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 48, 25)) entry.next.prev = entry; // entry.next.prev does not show intellisense, but entry.prev.prev does ->entry.next.prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) ->entry.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>entry.next.prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>entry.next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 48, 25)) ->next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) ->prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 48, 25)) } @@ -204,28 +204,28 @@ module Editor { >data : Symbol(data, Decl(genericClassWithStaticFactory.ts, 56, 20)) entry.data = data; ->entry.data : Symbol(data, Decl(genericClassWithStaticFactory.ts, 7, 43)) +>entry.data : Symbol(List.data, Decl(genericClassWithStaticFactory.ts, 7, 43)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 57, 15)) ->data : Symbol(data, Decl(genericClassWithStaticFactory.ts, 7, 43)) +>data : Symbol(List.data, Decl(genericClassWithStaticFactory.ts, 7, 43)) >data : Symbol(data, Decl(genericClassWithStaticFactory.ts, 56, 20)) entry.isHead = false; ->entry.isHead : Symbol(isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) +>entry.isHead : Symbol(List.isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 57, 15)) ->isHead : Symbol(isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) +>isHead : Symbol(List.isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) entry.next = this.next; ->entry.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>entry.next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 57, 15)) ->next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >this.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) >next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) entry.prev = this; ->entry.prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>entry.prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 57, 15)) ->prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) this.next = entry; @@ -235,11 +235,11 @@ module Editor { >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 57, 15)) entry.next.prev = entry; // entry.next.prev does not show intellisense, but entry.prev.prev does ->entry.next.prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) ->entry.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>entry.next.prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>entry.next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 57, 15)) ->next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) ->prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 57, 15)) } @@ -252,11 +252,11 @@ module Editor { >T : Symbol(T, Decl(genericClassWithStaticFactory.ts, 2, 22)) if (this.next.isHead) { ->this.next.isHead : Symbol(isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) +>this.next.isHead : Symbol(List.isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) >this.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) >next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) ->isHead : Symbol(isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) +>isHead : Symbol(List.isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) return null; } @@ -282,28 +282,28 @@ module Editor { >T : Symbol(T, Decl(genericClassWithStaticFactory.ts, 2, 22)) entry.isHead = false; ->entry.isHead : Symbol(isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) +>entry.isHead : Symbol(List.isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 75, 27)) ->isHead : Symbol(isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) +>isHead : Symbol(List.isHead, Decl(genericClassWithStaticFactory.ts, 7, 20)) this.prev.next = entry; ->this.prev.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>this.prev.next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >this.prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) >prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) ->next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 75, 27)) entry.next = this; ->entry.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>entry.next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 75, 27)) ->next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) entry.prev = this.prev; ->entry.prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>entry.prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 75, 27)) ->prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >this.prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) >prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) @@ -337,17 +337,17 @@ module Editor { >data : Symbol(data, Decl(genericClassWithStaticFactory.ts, 84, 27)) entry.next = this.next; ->entry.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>entry.next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 85, 15)) ->next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >this.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) >next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) entry.prev = this; ->entry.prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>entry.prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 85, 15)) ->prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) this.next = entry; @@ -357,11 +357,11 @@ module Editor { >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 85, 15)) entry.next.prev = entry;// entry.next.prev does not show intellisense, but entry.prev.prev does ->entry.next.prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) ->entry.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>entry.next.prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>entry.next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 85, 15)) ->next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) ->prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 85, 15)) return entry; @@ -377,23 +377,23 @@ module Editor { >T : Symbol(T, Decl(genericClassWithStaticFactory.ts, 2, 22)) this.prev.next = entry; ->this.prev.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>this.prev.next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >this.prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) >prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) ->next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 93, 33)) entry.next = this; ->entry.next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>entry.next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 93, 33)) ->next : Symbol(next, Decl(genericClassWithStaticFactory.ts, 2, 26)) +>next : Symbol(List.next, Decl(genericClassWithStaticFactory.ts, 2, 26)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) entry.prev = this.prev; ->entry.prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>entry.prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >entry : Symbol(entry, Decl(genericClassWithStaticFactory.ts, 93, 33)) ->prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) +>prev : Symbol(List.prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >this.prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) >this : Symbol(List, Decl(genericClassWithStaticFactory.ts, 0, 15)) >prev : Symbol(prev, Decl(genericClassWithStaticFactory.ts, 3, 29)) diff --git a/tests/baselines/reference/genericClassWithStaticFactory.types b/tests/baselines/reference/genericClassWithStaticFactory.types index 34d0c4aeaae..2daad9003eb 100644 --- a/tests/baselines/reference/genericClassWithStaticFactory.types +++ b/tests/baselines/reference/genericClassWithStaticFactory.types @@ -29,7 +29,7 @@ module Editor { this.listFactory = new ListFactory(); >this.listFactory = new ListFactory() : ListFactory >this.listFactory : ListFactory ->this : List +>this : this >listFactory : ListFactory >new ListFactory() : ListFactory >ListFactory : typeof ListFactory @@ -49,7 +49,7 @@ module Editor { >this.listFactory.MakeEntry(data) : List >this.listFactory.MakeEntry : (data: T) => List >this.listFactory : ListFactory ->this : List +>this : this >listFactory : ListFactory >MakeEntry : (data: T) => List >data : T @@ -58,17 +58,17 @@ module Editor { >this.prev.next = entry : List >this.prev.next : List >this.prev : List ->this : List +>this : this >prev : List >next : List >entry : List entry.next = this; ->entry.next = this : List +>entry.next = this : this >entry.next : List >entry : List >next : List ->this : List +>this : this entry.prev = this.prev; >entry.prev = this.prev : List @@ -76,13 +76,13 @@ module Editor { >entry : List >prev : List >this.prev : List ->this : List +>this : this >prev : List this.prev = entry; >this.prev = entry : List >this.prev : List ->this : List +>this : this >prev : List >entry : List @@ -105,7 +105,7 @@ module Editor { >entry = this.next : List >entry : List >this.next : List ->this : List +>this : this >next : List for (i = 0; !(entry.isHead); i++) { @@ -140,9 +140,9 @@ module Editor { >(this.next == this) : boolean >this.next == this : boolean >this.next : List ->this : List +>this : this >next : List ->this : List +>this : this } public first(): T { @@ -152,13 +152,13 @@ module Editor { if (this.isEmpty()) >this.isEmpty() : boolean >this.isEmpty : () => boolean ->this : List +>this : this >isEmpty : () => boolean { return this.next.data; >this.next.data : T >this.next : List ->this : List +>this : this >next : List >data : T } @@ -187,20 +187,20 @@ module Editor { >entry : List >next : List >this.next : List ->this : List +>this : this >next : List entry.prev = this; ->entry.prev = this : List +>entry.prev = this : this >entry.prev : List >entry : List >prev : List ->this : List +>this : this this.next = entry; >this.next = entry : List >this.next : List ->this : List +>this : this >next : List >entry : List @@ -224,7 +224,7 @@ module Editor { >this.listFactory.MakeEntry(data) : List >this.listFactory.MakeEntry : (data: T) => List >this.listFactory : ListFactory ->this : List +>this : this >listFactory : ListFactory >MakeEntry : (data: T) => List >data : T @@ -249,20 +249,20 @@ module Editor { >entry : List >next : List >this.next : List ->this : List +>this : this >next : List entry.prev = this; ->entry.prev = this : List +>entry.prev = this : this >entry.prev : List >entry : List >prev : List ->this : List +>this : this this.next = entry; >this.next = entry : List >this.next : List ->this : List +>this : this >next : List >entry : List @@ -287,7 +287,7 @@ module Editor { if (this.next.isHead) { >this.next.isHead : boolean >this.next : List ->this : List +>this : this >next : List >isHead : boolean @@ -299,11 +299,11 @@ module Editor { >this.listFactory.RemoveEntry(this.next) : List >this.listFactory.RemoveEntry : (entry: List) => List >this.listFactory : ListFactory ->this : List +>this : this >listFactory : ListFactory >RemoveEntry : (entry: List) => List >this.next : List ->this : List +>this : this >next : List } } @@ -327,17 +327,17 @@ module Editor { >this.prev.next = entry : List >this.prev.next : List >this.prev : List ->this : List +>this : this >prev : List >next : List >entry : List entry.next = this; ->entry.next = this : List +>entry.next = this : this >entry.next : List >entry : List >next : List ->this : List +>this : this entry.prev = this.prev; >entry.prev = this.prev : List @@ -345,13 +345,13 @@ module Editor { >entry : List >prev : List >this.prev : List ->this : List +>this : this >prev : List this.prev = entry; >this.prev = entry : List >this.prev : List ->this : List +>this : this >prev : List >entry : List @@ -373,7 +373,7 @@ module Editor { >this.listFactory.MakeEntry(data) : List >this.listFactory.MakeEntry : (data: T) => List >this.listFactory : ListFactory ->this : List +>this : this >listFactory : ListFactory >MakeEntry : (data: T) => List >data : T @@ -384,20 +384,20 @@ module Editor { >entry : List >next : List >this.next : List ->this : List +>this : this >next : List entry.prev = this; ->entry.prev = this : List +>entry.prev = this : this >entry.prev : List >entry : List >prev : List ->this : List +>this : this this.next = entry; >this.next = entry : List >this.next : List ->this : List +>this : this >next : List >entry : List @@ -426,17 +426,17 @@ module Editor { >this.prev.next = entry : List >this.prev.next : List >this.prev : List ->this : List +>this : this >prev : List >next : List >entry : List entry.next = this; ->entry.next = this : List +>entry.next = this : this >entry.next : List >entry : List >next : List ->this : List +>this : this entry.prev = this.prev; >entry.prev = this.prev : List @@ -444,13 +444,13 @@ module Editor { >entry : List >prev : List >this.prev : List ->this : List +>this : this >prev : List this.prev = entry; >this.prev = entry : List >this.prev : List ->this : List +>this : this >prev : List >entry : List @@ -470,7 +470,7 @@ module Editor { >this.listFactory.MakeEntry(data) : List >this.listFactory.MakeEntry : (data: T) => List >this.listFactory : ListFactory ->this : List +>this : this >listFactory : ListFactory >MakeEntry : (data: T) => List >data : T @@ -478,7 +478,7 @@ module Editor { return this.insertEntryBefore(entry); >this.insertEntryBefore(entry) : List >this.insertEntryBefore : (entry: List) => List ->this : List +>this : this >insertEntryBefore : (entry: List) => List >entry : List } diff --git a/tests/baselines/reference/genericClasses4.types b/tests/baselines/reference/genericClasses4.types index ac3d05be84d..3a2ae3b997c 100644 --- a/tests/baselines/reference/genericClasses4.types +++ b/tests/baselines/reference/genericClasses4.types @@ -26,7 +26,7 @@ class Vec2_T >f(this.x) : B >f : (a: A) => B >this.x : A ->this : Vec2_T +>this : this >x : A var y:B = f(this.y); @@ -35,7 +35,7 @@ class Vec2_T >f(this.y) : B >f : (a: A) => B >this.y : A ->this : Vec2_T +>this : this >y : A var retval: Vec2_T = new Vec2_T(x, y); @@ -69,7 +69,7 @@ class Vec2_T >f : Vec2_T<(a: A) => B> >x : (a: A) => B >this.x : A ->this : Vec2_T +>this : this >x : A var y:B = f.y(this.y); @@ -80,7 +80,7 @@ class Vec2_T >f : Vec2_T<(a: A) => B> >y : (a: A) => B >this.y : A ->this : Vec2_T +>this : this >y : A var retval: Vec2_T = new Vec2_T(x, y); diff --git a/tests/baselines/reference/genericClassesInModule2.types b/tests/baselines/reference/genericClassesInModule2.types index 5da8c43097f..18c83d9d725 100644 --- a/tests/baselines/reference/genericClassesInModule2.types +++ b/tests/baselines/reference/genericClassesInModule2.types @@ -10,10 +10,10 @@ export class A{ >T1 : T1 var child = new B(this); ->child : B> ->new B(this) : B> +>child : B +>new B(this) : B >B : typeof B ->this : A +>this : this } AAA( callback: (self: A) => void) { >AAA : (callback: (self: A) => void) => void @@ -23,10 +23,10 @@ export class A{ >T1 : T1 var child = new B(this); ->child : B> ->new B(this) : B> +>child : B +>new B(this) : B >B : typeof B ->this : A +>this : this } } diff --git a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.types b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.types index 9a4b209bc97..f0396074b94 100644 --- a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.types +++ b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes.types @@ -37,7 +37,7 @@ module EndGate.Tweening { this._from = from.Clone(); >this._from = from.Clone() : any >this._from : T ->this : Tween +>this : this >_from : T >from.Clone() : any >from.Clone : () => any diff --git a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.types b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.types index ba42e42ae0c..3745a5f6a17 100644 --- a/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.types +++ b/tests/baselines/reference/genericConstraintOnExtendedBuiltinTypes2.types @@ -36,7 +36,7 @@ module EndGate.Tweening { this._from = from.Clone(); >this._from = from.Clone() : any >this._from : T ->this : Tween +>this : this >_from : T >from.Clone() : any >from.Clone : () => any diff --git a/tests/baselines/reference/genericInstanceOf.types b/tests/baselines/reference/genericInstanceOf.types index 726fa38fbf8..3c08c35e44a 100644 --- a/tests/baselines/reference/genericInstanceOf.types +++ b/tests/baselines/reference/genericInstanceOf.types @@ -21,10 +21,10 @@ class C { if (this.a instanceof this.b) { >this.a instanceof this.b : boolean >this.a : T ->this : C +>this : this >a : T >this.b : F ->this : C +>this : this >b : F } } diff --git a/tests/baselines/reference/genericTypeWithCallableMembers.types b/tests/baselines/reference/genericTypeWithCallableMembers.types index e0068d5ff2b..8f62f077d54 100644 --- a/tests/baselines/reference/genericTypeWithCallableMembers.types +++ b/tests/baselines/reference/genericTypeWithCallableMembers.types @@ -24,14 +24,14 @@ class C { >x : Constructable >new this.data() : Constructable >this.data : T ->this : C +>this : this >data : T var x2 = new this.data2(); // was error, shouldn't be >x2 : Constructable >new this.data2() : Constructable >this.data2 : Constructable ->this : C +>this : this >data2 : Constructable } } diff --git a/tests/baselines/reference/genericWithCallSignatures1.types b/tests/baselines/reference/genericWithCallSignatures1.types index b55b4bbc64b..b4a12129027 100644 --- a/tests/baselines/reference/genericWithCallSignatures1.types +++ b/tests/baselines/reference/genericWithCallSignatures1.types @@ -15,7 +15,7 @@ class MyClass { > this.callableThing() : string >this.callableThing() : string >this.callableThing : CallableExtention ->this : MyClass +>this : this >callableThing : CallableExtention } } diff --git a/tests/baselines/reference/genericWithIndexerOfTypeParameterType1.types b/tests/baselines/reference/genericWithIndexerOfTypeParameterType1.types index 3e281f6072a..337993dc2a6 100644 --- a/tests/baselines/reference/genericWithIndexerOfTypeParameterType1.types +++ b/tests/baselines/reference/genericWithIndexerOfTypeParameterType1.types @@ -15,7 +15,7 @@ class LazyArray { return this.objects; >this.objects : { [objectId: string]: T; } ->this : LazyArray +>this : this >objects : { [objectId: string]: T; } } } diff --git a/tests/baselines/reference/getEmitOutputOutFile.baseline b/tests/baselines/reference/getEmitOutputOutFile.baseline new file mode 100644 index 00000000000..702097a7c03 --- /dev/null +++ b/tests/baselines/reference/getEmitOutputOutFile.baseline @@ -0,0 +1,26 @@ +EmitSkipped: false +FileName : outFile.js +var x = 5; +var Bar = (function () { + function Bar() { + } + return Bar; +})(); +var x1 = "hello world"; +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +FileName : outFile.d.ts +declare var x: number; +declare class Bar { + x: string; + y: number; +} +declare var x1: string; +declare class Foo { + x: string; + y: number; +} + diff --git a/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline b/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline new file mode 100644 index 00000000000..2ae820dd538 --- /dev/null +++ b/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline @@ -0,0 +1,26 @@ +EmitSkipped: false +FileName : tests/cases/fourslash/inputFile1.js.map +{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":["Bar","Bar.constructor"],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAAA;IAGAC,CAACA;IAADD,UAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile1.js +// regular ts file +var t = 5; +var Bar = (function () { + function Bar() { + } + return Bar; +})(); +//# sourceMappingURL=inputFile1.js.mapFileName : tests/cases/fourslash/inputFile1.d.ts +declare var t: number; +declare class Bar { + x: string; + y: number; +} + +EmitSkipped: false +FileName : tests/cases/fourslash/inputFile2.jsx.map +{"version":3,"file":"inputFile2.jsx","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,EAAG,CAAA"}FileName : tests/cases/fourslash/inputFile2.jsx +var y = "my div"; +var x =
; +//# sourceMappingURL=inputFile2.jsx.mapFileName : tests/cases/fourslash/inputFile2.d.ts +declare var y: string; +declare var x: any; + diff --git a/tests/baselines/reference/getEmitOutputTsxFile_React.baseline b/tests/baselines/reference/getEmitOutputTsxFile_React.baseline new file mode 100644 index 00000000000..c796f8e78bc --- /dev/null +++ b/tests/baselines/reference/getEmitOutputTsxFile_React.baseline @@ -0,0 +1,26 @@ +EmitSkipped: false +FileName : tests/cases/fourslash/inputFile1.js.map +{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":["Bar","Bar.constructor"],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAAA;IAGAC,CAACA;IAADD,UAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile1.js +// regular ts file +var t = 5; +var Bar = (function () { + function Bar() { + } + return Bar; +})(); +//# sourceMappingURL=inputFile1.js.mapFileName : tests/cases/fourslash/inputFile1.d.ts +declare var t: number; +declare class Bar { + x: string; + y: number; +} + +EmitSkipped: false +FileName : tests/cases/fourslash/inputFile2.js.map +{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,qBAAC,GAAG,KAAC,IAAI,GAAG,CAAE,EAAG,CAAA"}FileName : tests/cases/fourslash/inputFile2.js +var y = "my div"; +var x = React.createElement("div", {"name": y}); +//# sourceMappingURL=inputFile2.js.mapFileName : tests/cases/fourslash/inputFile2.d.ts +declare var y: string; +declare var x: any; + diff --git a/tests/baselines/reference/giant.errors.txt b/tests/baselines/reference/giant.errors.txt index 1d623870d63..2c7e6f505bd 100644 --- a/tests/baselines/reference/giant.errors.txt +++ b/tests/baselines/reference/giant.errors.txt @@ -44,7 +44,7 @@ tests/cases/compiler/giant.ts(125,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(126,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(127,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(140,9): error TS2386: Overload signatures must all be optional or required. -tests/cases/compiler/giant.ts(154,39): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(154,39): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(166,16): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(167,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(167,20): error TS2300: Duplicate identifier 'pgF'. @@ -68,39 +68,39 @@ tests/cases/compiler/giant.ts(204,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(205,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(206,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(219,9): error TS2386: Overload signatures must all be optional or required. -tests/cases/compiler/giant.ts(233,39): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(238,35): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(240,24): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(243,21): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(244,22): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(233,39): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(238,35): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(240,24): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(243,21): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(244,22): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(245,16): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(245,22): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(245,22): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(246,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(246,20): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(247,16): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(247,31): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(247,31): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(248,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(248,20): error TS2300: Duplicate identifier 'psF'. tests/cases/compiler/giant.ts(249,17): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(249,23): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(249,23): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(250,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(250,21): error TS2300: Duplicate identifier 'rgF'. tests/cases/compiler/giant.ts(251,17): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(251,32): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(251,32): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(252,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(252,21): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(254,21): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(254,21): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(255,16): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(255,31): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(255,31): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(256,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(256,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(257,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(257,22): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(257,22): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(258,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(258,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(262,22): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(262,22): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(262,25): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/giant.ts(267,30): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(267,30): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(281,12): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(282,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(282,16): error TS2300: Duplicate identifier 'pgF'. @@ -147,7 +147,7 @@ tests/cases/compiler/giant.ts(383,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(384,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(385,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(398,9): error TS2386: Overload signatures must all be optional or required. -tests/cases/compiler/giant.ts(412,39): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(412,39): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(424,16): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(425,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(425,20): error TS2300: Duplicate identifier 'pgF'. @@ -171,98 +171,98 @@ tests/cases/compiler/giant.ts(462,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(463,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(464,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(477,9): error TS2386: Overload signatures must all be optional or required. -tests/cases/compiler/giant.ts(491,39): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(496,35): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(498,24): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(501,21): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(502,22): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(491,39): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(496,35): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(498,24): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(501,21): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(502,22): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(503,16): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(503,22): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(503,22): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(504,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(504,20): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(505,16): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(505,31): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(505,31): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(506,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(506,20): error TS2300: Duplicate identifier 'psF'. tests/cases/compiler/giant.ts(507,17): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(507,23): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(507,23): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(508,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(508,21): error TS2300: Duplicate identifier 'rgF'. tests/cases/compiler/giant.ts(509,17): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(509,32): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(509,32): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(510,21): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(510,21): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(512,21): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(512,21): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(513,16): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(513,31): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(513,31): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(514,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(514,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(515,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(515,22): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(515,22): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(516,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(516,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(520,22): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(520,22): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(520,25): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/giant.ts(525,30): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(532,31): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(534,20): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(537,17): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(538,18): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(525,30): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(532,31): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(534,20): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(537,17): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(538,18): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(539,12): error TS2300: Duplicate identifier 'pgF'. -tests/cases/compiler/giant.ts(539,18): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(539,18): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(540,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(540,16): error TS2300: Duplicate identifier 'pgF'. tests/cases/compiler/giant.ts(541,12): error TS2300: Duplicate identifier 'psF'. -tests/cases/compiler/giant.ts(541,27): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(541,27): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(542,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(542,16): error TS2300: Duplicate identifier 'psF'. tests/cases/compiler/giant.ts(543,13): error TS2300: Duplicate identifier 'rgF'. -tests/cases/compiler/giant.ts(543,19): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(543,19): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(544,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(544,17): error TS2300: Duplicate identifier 'rgF'. tests/cases/compiler/giant.ts(545,13): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(545,28): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(545,28): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(546,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(546,17): error TS2300: Duplicate identifier 'rsF'. -tests/cases/compiler/giant.ts(548,17): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(548,17): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(549,12): error TS2300: Duplicate identifier 'tsF'. -tests/cases/compiler/giant.ts(549,27): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(549,27): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(550,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(550,16): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(551,12): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(551,18): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(551,18): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(552,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(552,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(556,18): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(556,18): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(556,21): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/giant.ts(558,24): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(561,21): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(563,21): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(558,24): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(561,21): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(563,21): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(587,9): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. tests/cases/compiler/giant.ts(587,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(588,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(589,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(602,9): error TS2386: Overload signatures must all be optional or required. -tests/cases/compiler/giant.ts(606,22): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(606,22): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(606,25): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/giant.ts(611,30): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(611,30): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(615,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context. tests/cases/compiler/giant.ts(616,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context. -tests/cases/compiler/giant.ts(616,39): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(616,39): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(617,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context. tests/cases/compiler/giant.ts(618,16): error TS1038: A 'declare' modifier cannot be used in an already ambient context. -tests/cases/compiler/giant.ts(621,26): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(623,24): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(626,21): error TS1184: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(628,21): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(621,26): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(623,24): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(626,21): error TS1183: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(628,21): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(653,9): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. tests/cases/compiler/giant.ts(653,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(654,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(655,10): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/giant.ts(668,9): error TS2386: Overload signatures must all be optional or required. -tests/cases/compiler/giant.ts(672,22): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(672,22): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(672,25): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/giant.ts(676,30): error TS1183: An implementation cannot be declared in ambient contexts. ==== tests/cases/compiler/giant.ts (265 errors) ==== @@ -513,7 +513,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be export declare var eaV; export declare function eaF() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. export declare class eaC { }; export declare module eaM { }; } @@ -640,31 +640,31 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be export declare var eaV; export declare function eaF() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. export declare class eaC { }; export declare module eaM { }; } export declare var eaV; export declare function eaF() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. export declare class eaC { constructor () { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. public pV; private rV; public pF() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. private rF() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. public pgF() { } ~~~ !!! error TS2300: Duplicate identifier 'pgF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. public get pgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -674,7 +674,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'psF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. public set psF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -684,7 +684,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'rgF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. private get rgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -694,7 +694,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'rsF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. private set rsF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -703,12 +703,12 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be static tV; static tF() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. static tsF(param:any) { } ~~~ !!! error TS2300: Duplicate identifier 'tsF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. static set tsF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -718,7 +718,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'tgF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. static get tgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -729,7 +729,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be var V; function F() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. ~ !!! error TS1036: Statements are not allowed in ambient contexts. class C { } @@ -738,7 +738,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be export var eV; export function eF() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. export class eC { } export interface eI { } export module eM { } @@ -977,7 +977,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be export declare var eaV; export declare function eaF() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. export declare class eaC { }; export declare module eaM { }; } @@ -1104,31 +1104,31 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be export declare var eaV; export declare function eaF() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. export declare class eaC { }; export declare module eaM { }; } export declare var eaV; export declare function eaF() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. export declare class eaC { constructor () { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. public pV; private rV; public pF() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. private rF() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. public pgF() { } ~~~ !!! error TS2300: Duplicate identifier 'pgF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. public get pgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1138,7 +1138,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'psF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. public set psF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1148,7 +1148,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'rgF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. private get rgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1158,7 +1158,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'rsF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. private set rsF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1167,12 +1167,12 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be static tV; static tF() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. static tsF(param:any) { } ~~~ !!! error TS2300: Duplicate identifier 'tsF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. static set tsF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1182,7 +1182,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'tgF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. static get tgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1193,7 +1193,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be var V; function F() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. ~ !!! error TS1036: Statements are not allowed in ambient contexts. class C { } @@ -1202,7 +1202,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be export var eV; export function eF() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. export class eC { } export interface eI { } export module eM { } @@ -1211,24 +1211,24 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be export declare var eaV; export declare function eaF() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. export declare class eaC { constructor () { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. public pV; private rV; public pF() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. private rF() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. public pgF() { } ~~~ !!! error TS2300: Duplicate identifier 'pgF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. public get pgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1238,7 +1238,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'psF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. public set psF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1248,7 +1248,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'rgF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. private get rgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1258,7 +1258,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'rsF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. private set rsF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1267,12 +1267,12 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be static tV; static tF() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. static tsF(param:any) { } ~~~ !!! error TS2300: Duplicate identifier 'tsF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. static set tsF(param:any) ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1282,7 +1282,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~ !!! error TS2300: Duplicate identifier 'tgF'. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. static get tgF() ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -1293,22 +1293,22 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be var V; function F() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. ~ !!! error TS1036: Statements are not allowed in ambient contexts. class C { constructor () { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. public pV; private rV; public pF() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. static tV; static tF() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. } interface I { //Call Signature @@ -1363,7 +1363,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be var V; function F() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. ~ !!! error TS1036: Statements are not allowed in ambient contexts. class C { } @@ -1372,7 +1372,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be export var eV; export function eF() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. export class eC { } export interface eI { } export module eM { } @@ -1383,7 +1383,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be ~~~~~~~ !!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. export declare class eaC { } ~~~~~~~ !!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. @@ -1394,20 +1394,20 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be export var eV; export function eF() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. export class eC { constructor () { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. public pV; private rV; public pF() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. static tV static tF() { } ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. } export interface eI { //Call Signature @@ -1463,7 +1463,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be var V; function F() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. ~ !!! error TS1036: Statements are not allowed in ambient contexts. class C { } @@ -1471,7 +1471,7 @@ tests/cases/compiler/giant.ts(676,30): error TS1184: An implementation cannot be export var eV; export function eF() { }; ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. export class eC { } export interface eI { } export module eM { } diff --git a/tests/baselines/reference/heterogeneousArrayLiterals.types b/tests/baselines/reference/heterogeneousArrayLiterals.types index 952200d74f8..c760e5a566f 100644 --- a/tests/baselines/reference/heterogeneousArrayLiterals.types +++ b/tests/baselines/reference/heterogeneousArrayLiterals.types @@ -21,14 +21,14 @@ var c = [1, '', null]; // {}[] >null : null var d = [{}, 1]; // {}[] ->d : ({} | number)[] ->[{}, 1] : ({} | number)[] +>d : {}[] +>[{}, 1] : {}[] >{} : {} >1 : number var e = [{}, Object]; // {}[] ->e : ({} | ObjectConstructor)[] ->[{}, Object] : ({} | ObjectConstructor)[] +>e : {}[] +>[{}, Object] : {}[] >{} : {} >Object : ObjectConstructor @@ -88,16 +88,16 @@ var k = [() => 1, () => 1]; // { (): number }[] >1 : number var l = [() => 1, () => null]; // { (): any }[] ->l : ((() => number) | (() => any))[] ->[() => 1, () => null] : ((() => number) | (() => any))[] +>l : (() => any)[] +>[() => 1, () => null] : (() => any)[] >() => 1 : () => number >1 : number >() => null : () => any >null : null var m = [() => 1, () => '', () => null]; // { (): any }[] ->m : ((() => number) | (() => string) | (() => any))[] ->[() => 1, () => '', () => null] : ((() => number) | (() => string) | (() => any))[] +>m : (() => any)[] +>[() => 1, () => '', () => null] : (() => any)[] >() => 1 : () => number >1 : number >() => '' : () => string @@ -169,8 +169,8 @@ module Derived { >derived : Derived var j = [() => base, () => derived]; // { {}: Base } ->j : ((() => Base) | (() => Derived))[] ->[() => base, () => derived] : ((() => Base) | (() => Derived))[] +>j : (() => Base)[] +>[() => base, () => derived] : (() => Base)[] >() => base : () => Base >base : Base >() => derived : () => Derived @@ -185,16 +185,16 @@ module Derived { >1 : number var l = [() => base, () => null]; // { (): any }[] ->l : ((() => Base) | (() => any))[] ->[() => base, () => null] : ((() => Base) | (() => any))[] +>l : (() => any)[] +>[() => base, () => null] : (() => any)[] >() => base : () => Base >base : Base >() => null : () => any >null : null var m = [() => base, () => derived, () => null]; // { (): any }[] ->m : ((() => Base) | (() => Derived) | (() => any))[] ->[() => base, () => derived, () => null] : ((() => Base) | (() => Derived) | (() => any))[] +>m : (() => any)[] +>[() => base, () => derived, () => null] : (() => any)[] >() => base : () => Base >base : Base >() => derived : () => Derived @@ -203,8 +203,8 @@ module Derived { >null : null var n = [[() => base], [() => derived]]; // { (): Base }[] ->n : ((() => Base)[] | (() => Derived)[])[] ->[[() => base], [() => derived]] : ((() => Base)[] | (() => Derived)[])[] +>n : (() => Base)[][] +>[[() => base], [() => derived]] : (() => Base)[][] >[() => base] : (() => Base)[] >() => base : () => Base >base : Base @@ -219,8 +219,8 @@ module Derived { >derived2 : Derived2 var p = [derived, derived2, base]; // Base[] ->p : (Derived | Derived2 | Base)[] ->[derived, derived2, base] : (Derived | Derived2 | Base)[] +>p : Base[] +>[derived, derived2, base] : Base[] >derived : Derived >derived2 : Derived2 >base : Base @@ -310,8 +310,8 @@ function foo(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : ((() => T) | (() => U) | (() => any))[] ->[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -364,8 +364,8 @@ function foo2(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : ((() => T) | (() => U) | (() => any))[] ->[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -374,8 +374,8 @@ function foo2(t: T, u: U) { >null : null var g = [t, base]; // Base[] ->g : (T | Base)[] ->[t, base] : (T | Base)[] +>g : Base[] +>[t, base] : Base[] >t : T >base : Base @@ -386,14 +386,14 @@ function foo2(t: T, u: U) { >derived : Derived var i = [u, base]; // Base[] ->i : (U | Base)[] ->[u, base] : (U | Base)[] +>i : Base[] +>[u, base] : Base[] >u : U >base : Base var j = [u, derived]; // Derived[] ->j : (U | Derived)[] ->[u, derived] : (U | Derived)[] +>j : Derived[] +>[u, derived] : Derived[] >u : U >derived : Derived } @@ -442,8 +442,8 @@ function foo3(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : ((() => T) | (() => U) | (() => any))[] ->[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -452,26 +452,26 @@ function foo3(t: T, u: U) { >null : null var g = [t, base]; // Base[] ->g : (T | Base)[] ->[t, base] : (T | Base)[] +>g : Base[] +>[t, base] : Base[] >t : T >base : Base var h = [t, derived]; // Derived[] ->h : (T | Derived)[] ->[t, derived] : (T | Derived)[] +>h : Derived[] +>[t, derived] : Derived[] >t : T >derived : Derived var i = [u, base]; // Base[] ->i : (U | Base)[] ->[u, base] : (U | Base)[] +>i : Base[] +>[u, base] : Base[] >u : U >base : Base var j = [u, derived]; // Derived[] ->j : (U | Derived)[] ->[u, derived] : (U | Derived)[] +>j : Derived[] +>[u, derived] : Derived[] >u : U >derived : Derived } @@ -520,8 +520,8 @@ function foo4(t: T, u: U) { >u : U var f = [() => t, () => u, () => null]; // { (): any }[] ->f : ((() => T) | (() => U) | (() => any))[] ->[() => t, () => u, () => null] : ((() => T) | (() => U) | (() => any))[] +>f : (() => any)[] +>[() => t, () => u, () => null] : (() => any)[] >() => t : () => T >t : T >() => u : () => U @@ -530,8 +530,8 @@ function foo4(t: T, u: U) { >null : null var g = [t, base]; // Base[] ->g : (T | Base)[] ->[t, base] : (T | Base)[] +>g : Base[] +>[t, base] : Base[] >t : T >base : Base @@ -542,8 +542,8 @@ function foo4(t: T, u: U) { >derived : Derived var i = [u, base]; // Base[] ->i : (U | Base)[] ->[u, base] : (U | Base)[] +>i : Base[] +>[u, base] : Base[] >u : U >base : Base diff --git a/tests/baselines/reference/implementsInClassExpression.js b/tests/baselines/reference/implementsInClassExpression.js new file mode 100644 index 00000000000..9ac092289f5 --- /dev/null +++ b/tests/baselines/reference/implementsInClassExpression.js @@ -0,0 +1,16 @@ +//// [implementsInClassExpression.ts] +interface Foo { + doThing(): void; +} + +let cls = class implements Foo { + doThing() { } +} + +//// [implementsInClassExpression.js] +var cls = (function () { + function class_1() { + } + class_1.prototype.doThing = function () { }; + return class_1; +})(); diff --git a/tests/baselines/reference/implementsInClassExpression.symbols b/tests/baselines/reference/implementsInClassExpression.symbols new file mode 100644 index 00000000000..f65c3456320 --- /dev/null +++ b/tests/baselines/reference/implementsInClassExpression.symbols @@ -0,0 +1,15 @@ +=== tests/cases/compiler/implementsInClassExpression.ts === +interface Foo { +>Foo : Symbol(Foo, Decl(implementsInClassExpression.ts, 0, 0)) + + doThing(): void; +>doThing : Symbol(doThing, Decl(implementsInClassExpression.ts, 0, 15)) +} + +let cls = class implements Foo { +>cls : Symbol(cls, Decl(implementsInClassExpression.ts, 4, 3)) +>Foo : Symbol(Foo, Decl(implementsInClassExpression.ts, 0, 0)) + + doThing() { } +>doThing : Symbol((Anonymous class).doThing, Decl(implementsInClassExpression.ts, 4, 32)) +} diff --git a/tests/baselines/reference/implementsInClassExpression.types b/tests/baselines/reference/implementsInClassExpression.types new file mode 100644 index 00000000000..d3647c30ff1 --- /dev/null +++ b/tests/baselines/reference/implementsInClassExpression.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/implementsInClassExpression.ts === +interface Foo { +>Foo : Foo + + doThing(): void; +>doThing : () => void +} + +let cls = class implements Foo { +>cls : typeof (Anonymous class) +>class implements Foo { doThing() { }} : typeof (Anonymous class) +>Foo : Foo + + doThing() { } +>doThing : () => void +} diff --git a/tests/baselines/reference/implicitAnyInCatch.types b/tests/baselines/reference/implicitAnyInCatch.types index b0fbd4e7f12..cd0dd2d2423 100644 --- a/tests/baselines/reference/implicitAnyInCatch.types +++ b/tests/baselines/reference/implicitAnyInCatch.types @@ -23,7 +23,7 @@ class C { for (var x in this) { >x : any ->this : C +>this : this } } } diff --git a/tests/baselines/reference/importAsBaseClass.errors.txt b/tests/baselines/reference/importAsBaseClass.errors.txt index 835fd143f70..8f23baad543 100644 --- a/tests/baselines/reference/importAsBaseClass.errors.txt +++ b/tests/baselines/reference/importAsBaseClass.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/importAsBaseClass_1.ts(2,21): error TS2507: Type 'typeof "t ==== tests/cases/compiler/importAsBaseClass_1.ts (1 errors) ==== - import Greeter = require("importAsBaseClass_0"); + import Greeter = require("./importAsBaseClass_0"); class Hello extends Greeter { } ~~~~~~~ !!! error TS2507: Type 'typeof "tests/cases/compiler/importAsBaseClass_0"' is not a constructor function type. diff --git a/tests/baselines/reference/importAsBaseClass.js b/tests/baselines/reference/importAsBaseClass.js index b79905911b1..57d71af2cda 100644 --- a/tests/baselines/reference/importAsBaseClass.js +++ b/tests/baselines/reference/importAsBaseClass.js @@ -6,7 +6,7 @@ export class Greeter { } //// [importAsBaseClass_1.ts] -import Greeter = require("importAsBaseClass_0"); +import Greeter = require("./importAsBaseClass_0"); class Hello extends Greeter { } @@ -24,7 +24,7 @@ var __extends = (this && this.__extends) || function (d, b) { function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; -var Greeter = require("importAsBaseClass_0"); +var Greeter = require("./importAsBaseClass_0"); var Hello = (function (_super) { __extends(Hello, _super); function Hello() { diff --git a/tests/baselines/reference/importDecl.js b/tests/baselines/reference/importDecl.js index fb2aa6e0d1f..4b2672c4135 100644 --- a/tests/baselines/reference/importDecl.js +++ b/tests/baselines/reference/importDecl.js @@ -29,7 +29,7 @@ export var x: d; export function foo(): d { return null; } //// [importDecl_require4.ts] -import m4 = require("importDecl_require"); +import m4 = require("./importDecl_require"); export function foo2(): m4.d { return null; } //// [importDecl_1.ts] @@ -38,7 +38,7 @@ export function foo2(): m4.d { return null; } /// /// /// -import m4 = require("importDecl_require"); // Emit used +import m4 = require("./importDecl_require"); // Emit used export var x4 = m4.x; export var d4 = m4.d; export var f4 = m4.foo(); @@ -54,16 +54,16 @@ export module m1 { } //Emit global only usage -import glo_m4 = require("importDecl_require1"); +import glo_m4 = require("./importDecl_require1"); export var useGlo_m4_d4 = glo_m4.d; export var useGlo_m4_f4 = glo_m4.foo(); //Emit even when used just in function type -import fncOnly_m4 = require("importDecl_require2"); +import fncOnly_m4 = require("./importDecl_require2"); export var useFncOnly_m4_f4 = fncOnly_m4.foo(); // only used privately no need to emit -import private_m4 = require("importDecl_require3"); +import private_m4 = require("./importDecl_require3"); export module usePrivate_m4_m1 { var x3 = private_m4.x; var d3 = private_m4.d; @@ -71,11 +71,11 @@ export module usePrivate_m4_m1 { } // Do not emit unused import -import m5 = require("importDecl_require4"); +import m5 = require("./importDecl_require4"); export var d = m5.foo2(); // Do not emit multiple used import statements -import multiImport_m4 = require("importDecl_require"); // Emit used +import multiImport_m4 = require("./importDecl_require"); // Emit used export var useMultiImport_m4_x4 = multiImport_m4.x; export var useMultiImport_m4_d4 = multiImport_m4.d; export var useMultiImport_m4_f4 = multiImport_m4.foo(); @@ -127,7 +127,7 @@ exports.foo2 = foo2; /// /// /// -var m4 = require("importDecl_require"); // Emit used +var m4 = require("./importDecl_require"); // Emit used exports.x4 = m4.x; exports.d4 = m4.d; exports.f4 = m4.foo(); @@ -141,14 +141,14 @@ var m1; var f3 = m4.foo(); })(m1 = exports.m1 || (exports.m1 = {})); //Emit global only usage -var glo_m4 = require("importDecl_require1"); +var glo_m4 = require("./importDecl_require1"); exports.useGlo_m4_d4 = glo_m4.d; exports.useGlo_m4_f4 = glo_m4.foo(); //Emit even when used just in function type -var fncOnly_m4 = require("importDecl_require2"); +var fncOnly_m4 = require("./importDecl_require2"); exports.useFncOnly_m4_f4 = fncOnly_m4.foo(); // only used privately no need to emit -var private_m4 = require("importDecl_require3"); +var private_m4 = require("./importDecl_require3"); var usePrivate_m4_m1; (function (usePrivate_m4_m1) { var x3 = private_m4.x; @@ -156,10 +156,10 @@ var usePrivate_m4_m1; var f3 = private_m4.foo(); })(usePrivate_m4_m1 = exports.usePrivate_m4_m1 || (exports.usePrivate_m4_m1 = {})); // Do not emit unused import -var m5 = require("importDecl_require4"); +var m5 = require("./importDecl_require4"); exports.d = m5.foo2(); // Do not emit multiple used import statements -var multiImport_m4 = require("importDecl_require"); // Emit used +var multiImport_m4 = require("./importDecl_require"); // Emit used exports.useMultiImport_m4_x4 = multiImport_m4.x; exports.useMultiImport_m4_d4 = multiImport_m4.d; exports.useMultiImport_m4_f4 = multiImport_m4.foo(); @@ -189,7 +189,7 @@ export declare class d { export declare var x: d; export declare function foo(): d; //// [importDecl_require4.d.ts] -import m4 = require("importDecl_require"); +import m4 = require("./importDecl_require"); export declare function foo2(): m4.d; //// [importDecl_1.d.ts] /// @@ -197,7 +197,7 @@ export declare function foo2(): m4.d; /// /// /// -import m4 = require("importDecl_require"); +import m4 = require("./importDecl_require"); export declare var x4: m4.d; export declare var d4: typeof m4.d; export declare var f4: m4.d; @@ -206,10 +206,10 @@ export declare module m1 { var d2: typeof m4.d; var f2: m4.d; } -import glo_m4 = require("importDecl_require1"); +import glo_m4 = require("./importDecl_require1"); export declare var useGlo_m4_d4: typeof glo_m4.d; export declare var useGlo_m4_f4: glo_m4.d; -import fncOnly_m4 = require("importDecl_require2"); +import fncOnly_m4 = require("./importDecl_require2"); export declare var useFncOnly_m4_f4: fncOnly_m4.d; export declare module usePrivate_m4_m1 { } diff --git a/tests/baselines/reference/importDecl.symbols b/tests/baselines/reference/importDecl.symbols index 2341101b672..32b9f3bb2a7 100644 --- a/tests/baselines/reference/importDecl.symbols +++ b/tests/baselines/reference/importDecl.symbols @@ -4,7 +4,7 @@ /// /// /// -import m4 = require("importDecl_require"); // Emit used +import m4 = require("./importDecl_require"); // Emit used >m4 : Symbol(m4, Decl(importDecl_1.ts, 0, 0)) export var x4 = m4.x; @@ -66,7 +66,7 @@ export module m1 { } //Emit global only usage -import glo_m4 = require("importDecl_require1"); +import glo_m4 = require("./importDecl_require1"); >glo_m4 : Symbol(glo_m4, Decl(importDecl_1.ts, 18, 1)) export var useGlo_m4_d4 = glo_m4.d; @@ -82,7 +82,7 @@ export var useGlo_m4_f4 = glo_m4.foo(); >foo : Symbol(glo_m4.foo, Decl(importDecl_require1.ts, 3, 9)) //Emit even when used just in function type -import fncOnly_m4 = require("importDecl_require2"); +import fncOnly_m4 = require("./importDecl_require2"); >fncOnly_m4 : Symbol(fncOnly_m4, Decl(importDecl_1.ts, 23, 39)) export var useFncOnly_m4_f4 = fncOnly_m4.foo(); @@ -92,11 +92,11 @@ export var useFncOnly_m4_f4 = fncOnly_m4.foo(); >foo : Symbol(fncOnly_m4.foo, Decl(importDecl_require2.ts, 3, 16)) // only used privately no need to emit -import private_m4 = require("importDecl_require3"); +import private_m4 = require("./importDecl_require3"); >private_m4 : Symbol(private_m4, Decl(importDecl_1.ts, 27, 47)) export module usePrivate_m4_m1 { ->usePrivate_m4_m1 : Symbol(usePrivate_m4_m1, Decl(importDecl_1.ts, 30, 51)) +>usePrivate_m4_m1 : Symbol(usePrivate_m4_m1, Decl(importDecl_1.ts, 30, 53)) var x3 = private_m4.x; >x3 : Symbol(x3, Decl(importDecl_1.ts, 32, 7)) @@ -118,17 +118,17 @@ export module usePrivate_m4_m1 { } // Do not emit unused import -import m5 = require("importDecl_require4"); +import m5 = require("./importDecl_require4"); >m5 : Symbol(m5, Decl(importDecl_1.ts, 35, 1)) export var d = m5.foo2(); >d : Symbol(d, Decl(importDecl_1.ts, 39, 10)) ->m5.foo2 : Symbol(m5.foo2, Decl(importDecl_require4.ts, 0, 42)) +>m5.foo2 : Symbol(m5.foo2, Decl(importDecl_require4.ts, 0, 44)) >m5 : Symbol(m5, Decl(importDecl_1.ts, 35, 1)) ->foo2 : Symbol(m5.foo2, Decl(importDecl_require4.ts, 0, 42)) +>foo2 : Symbol(m5.foo2, Decl(importDecl_require4.ts, 0, 44)) // Do not emit multiple used import statements -import multiImport_m4 = require("importDecl_require"); // Emit used +import multiImport_m4 = require("./importDecl_require"); // Emit used >multiImport_m4 : Symbol(multiImport_m4, Decl(importDecl_1.ts, 39, 25)) export var useMultiImport_m4_x4 = multiImport_m4.x; @@ -210,11 +210,11 @@ export function foo(): d { return null; } >d : Symbol(d, Decl(importDecl_require3.ts, 0, 0)) === tests/cases/compiler/importDecl_require4.ts === -import m4 = require("importDecl_require"); +import m4 = require("./importDecl_require"); >m4 : Symbol(m4, Decl(importDecl_require4.ts, 0, 0)) export function foo2(): m4.d { return null; } ->foo2 : Symbol(foo2, Decl(importDecl_require4.ts, 0, 42)) +>foo2 : Symbol(foo2, Decl(importDecl_require4.ts, 0, 44)) >m4 : Symbol(m4, Decl(importDecl_require4.ts, 0, 0)) >d : Symbol(m4.d, Decl(importDecl_require.ts, 0, 0)) diff --git a/tests/baselines/reference/importDecl.types b/tests/baselines/reference/importDecl.types index 58a56281bae..7bf4da78121 100644 --- a/tests/baselines/reference/importDecl.types +++ b/tests/baselines/reference/importDecl.types @@ -4,7 +4,7 @@ /// /// /// -import m4 = require("importDecl_require"); // Emit used +import m4 = require("./importDecl_require"); // Emit used >m4 : typeof m4 export var x4 = m4.x; @@ -69,7 +69,7 @@ export module m1 { } //Emit global only usage -import glo_m4 = require("importDecl_require1"); +import glo_m4 = require("./importDecl_require1"); >glo_m4 : typeof glo_m4 export var useGlo_m4_d4 = glo_m4.d; @@ -86,7 +86,7 @@ export var useGlo_m4_f4 = glo_m4.foo(); >foo : () => glo_m4.d //Emit even when used just in function type -import fncOnly_m4 = require("importDecl_require2"); +import fncOnly_m4 = require("./importDecl_require2"); >fncOnly_m4 : typeof fncOnly_m4 export var useFncOnly_m4_f4 = fncOnly_m4.foo(); @@ -97,7 +97,7 @@ export var useFncOnly_m4_f4 = fncOnly_m4.foo(); >foo : () => fncOnly_m4.d // only used privately no need to emit -import private_m4 = require("importDecl_require3"); +import private_m4 = require("./importDecl_require3"); >private_m4 : typeof private_m4 export module usePrivate_m4_m1 { @@ -124,7 +124,7 @@ export module usePrivate_m4_m1 { } // Do not emit unused import -import m5 = require("importDecl_require4"); +import m5 = require("./importDecl_require4"); >m5 : typeof m5 export var d = m5.foo2(); @@ -135,7 +135,7 @@ export var d = m5.foo2(); >foo2 : () => m4.d // Do not emit multiple used import statements -import multiImport_m4 = require("importDecl_require"); // Emit used +import multiImport_m4 = require("./importDecl_require"); // Emit used >multiImport_m4 : typeof m4 export var useMultiImport_m4_x4 = multiImport_m4.x; @@ -222,7 +222,7 @@ export function foo(): d { return null; } >null : null === tests/cases/compiler/importDecl_require4.ts === -import m4 = require("importDecl_require"); +import m4 = require("./importDecl_require"); >m4 : typeof m4 export function foo2(): m4.d { return null; } diff --git a/tests/baselines/reference/importDeclRefereingExternalModuleWithNoResolve.errors.txt b/tests/baselines/reference/importDeclRefereingExternalModuleWithNoResolve.errors.txt index e46ff8bea13..74f532d0c1e 100644 --- a/tests/baselines/reference/importDeclRefereingExternalModuleWithNoResolve.errors.txt +++ b/tests/baselines/reference/importDeclRefereingExternalModuleWithNoResolve.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(1,20): error TS2307: Cannot find module 'externalModule'. -tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(2,16): error TS2435: Ambient modules cannot be nested in other modules. +tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(2,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(3,26): error TS2307: Cannot find module 'externalModule'. @@ -12,7 +12,7 @@ tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(3,26): er !!! error TS2307: Cannot find module 'externalModule'. declare module "m1" { ~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. import im2 = require("externalModule"); ~~~~~~~~~~~~~~~~ !!! error TS2307: Cannot find module 'externalModule'. diff --git a/tests/baselines/reference/importDeclarationUsedAsTypeQuery.js b/tests/baselines/reference/importDeclarationUsedAsTypeQuery.js index 70244f47381..51839c35df2 100644 --- a/tests/baselines/reference/importDeclarationUsedAsTypeQuery.js +++ b/tests/baselines/reference/importDeclarationUsedAsTypeQuery.js @@ -7,7 +7,7 @@ export class B { //// [importDeclarationUsedAsTypeQuery_1.ts] /// -import a = require('importDeclarationUsedAsTypeQuery_require'); +import a = require('./importDeclarationUsedAsTypeQuery_require'); export var x: typeof a; @@ -27,5 +27,5 @@ export declare class B { } //// [importDeclarationUsedAsTypeQuery_1.d.ts] /// -import a = require('importDeclarationUsedAsTypeQuery_require'); +import a = require('./importDeclarationUsedAsTypeQuery_require'); export declare var x: typeof a; diff --git a/tests/baselines/reference/importDeclarationUsedAsTypeQuery.symbols b/tests/baselines/reference/importDeclarationUsedAsTypeQuery.symbols index 2664691972f..0cd2498e2af 100644 --- a/tests/baselines/reference/importDeclarationUsedAsTypeQuery.symbols +++ b/tests/baselines/reference/importDeclarationUsedAsTypeQuery.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/importDeclarationUsedAsTypeQuery_1.ts === /// -import a = require('importDeclarationUsedAsTypeQuery_require'); +import a = require('./importDeclarationUsedAsTypeQuery_require'); >a : Symbol(a, Decl(importDeclarationUsedAsTypeQuery_1.ts, 0, 0)) export var x: typeof a; diff --git a/tests/baselines/reference/importDeclarationUsedAsTypeQuery.types b/tests/baselines/reference/importDeclarationUsedAsTypeQuery.types index 2f449c2aa87..5d4c8efc7d4 100644 --- a/tests/baselines/reference/importDeclarationUsedAsTypeQuery.types +++ b/tests/baselines/reference/importDeclarationUsedAsTypeQuery.types @@ -1,6 +1,6 @@ === tests/cases/compiler/importDeclarationUsedAsTypeQuery_1.ts === /// -import a = require('importDeclarationUsedAsTypeQuery_require'); +import a = require('./importDeclarationUsedAsTypeQuery_require'); >a : typeof a export var x: typeof a; diff --git a/tests/baselines/reference/importUsedInExtendsList1.js b/tests/baselines/reference/importUsedInExtendsList1.js index e86b1a41456..129e7b44fd7 100644 --- a/tests/baselines/reference/importUsedInExtendsList1.js +++ b/tests/baselines/reference/importUsedInExtendsList1.js @@ -5,7 +5,7 @@ export class Super { foo: string; } //// [importUsedInExtendsList1_1.ts] /// -import foo = require('importUsedInExtendsList1_require'); +import foo = require('./importUsedInExtendsList1_require'); class Sub extends foo.Super { } var s: Sub; var r: string = s.foo; @@ -25,7 +25,7 @@ var __extends = (this && this.__extends) || function (d, b) { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /// -var foo = require('importUsedInExtendsList1_require'); +var foo = require('./importUsedInExtendsList1_require'); var Sub = (function (_super) { __extends(Sub, _super); function Sub() { diff --git a/tests/baselines/reference/importUsedInExtendsList1.symbols b/tests/baselines/reference/importUsedInExtendsList1.symbols index 1b3ac99ee9d..263b4f50ed8 100644 --- a/tests/baselines/reference/importUsedInExtendsList1.symbols +++ b/tests/baselines/reference/importUsedInExtendsList1.symbols @@ -1,17 +1,17 @@ === tests/cases/compiler/importUsedInExtendsList1_1.ts === /// -import foo = require('importUsedInExtendsList1_require'); +import foo = require('./importUsedInExtendsList1_require'); >foo : Symbol(foo, Decl(importUsedInExtendsList1_1.ts, 0, 0)) class Sub extends foo.Super { } ->Sub : Symbol(Sub, Decl(importUsedInExtendsList1_1.ts, 1, 57)) +>Sub : Symbol(Sub, Decl(importUsedInExtendsList1_1.ts, 1, 59)) >foo.Super : Symbol(foo.Super, Decl(importUsedInExtendsList1_require.ts, 0, 0)) >foo : Symbol(foo, Decl(importUsedInExtendsList1_1.ts, 0, 0)) >Super : Symbol(foo.Super, Decl(importUsedInExtendsList1_require.ts, 0, 0)) var s: Sub; >s : Symbol(s, Decl(importUsedInExtendsList1_1.ts, 3, 3)) ->Sub : Symbol(Sub, Decl(importUsedInExtendsList1_1.ts, 1, 57)) +>Sub : Symbol(Sub, Decl(importUsedInExtendsList1_1.ts, 1, 59)) var r: string = s.foo; >r : Symbol(r, Decl(importUsedInExtendsList1_1.ts, 4, 3)) diff --git a/tests/baselines/reference/importUsedInExtendsList1.types b/tests/baselines/reference/importUsedInExtendsList1.types index 3c1b69f5a83..752f4764976 100644 --- a/tests/baselines/reference/importUsedInExtendsList1.types +++ b/tests/baselines/reference/importUsedInExtendsList1.types @@ -1,6 +1,6 @@ === tests/cases/compiler/importUsedInExtendsList1_1.ts === /// -import foo = require('importUsedInExtendsList1_require'); +import foo = require('./importUsedInExtendsList1_require'); >foo : typeof foo class Sub extends foo.Super { } diff --git a/tests/baselines/reference/importsInAmbientModules1.js b/tests/baselines/reference/importsInAmbientModules1.js new file mode 100644 index 00000000000..4c888f2dfe5 --- /dev/null +++ b/tests/baselines/reference/importsInAmbientModules1.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/importsInAmbientModules1.ts] //// + +//// [external.d.ts] + +export var x: number + +//// [main.ts] + +declare module "M" { + import {x} from "external" +} + +//// [main.js] diff --git a/tests/baselines/reference/importsInAmbientModules1.symbols b/tests/baselines/reference/importsInAmbientModules1.symbols new file mode 100644 index 00000000000..d220ba2bf45 --- /dev/null +++ b/tests/baselines/reference/importsInAmbientModules1.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/external.d.ts === + +export var x: number +>x : Symbol(x, Decl(external.d.ts, 1, 10)) + +=== tests/cases/compiler/main.ts === + +declare module "M" { + import {x} from "external" +>x : Symbol(x, Decl(main.ts, 2, 12)) +} diff --git a/tests/baselines/reference/importsInAmbientModules1.types b/tests/baselines/reference/importsInAmbientModules1.types new file mode 100644 index 00000000000..634de9f1f0f --- /dev/null +++ b/tests/baselines/reference/importsInAmbientModules1.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/external.d.ts === + +export var x: number +>x : number + +=== tests/cases/compiler/main.ts === + +declare module "M" { + import {x} from "external" +>x : number +} diff --git a/tests/baselines/reference/importsInAmbientModules2.js b/tests/baselines/reference/importsInAmbientModules2.js new file mode 100644 index 00000000000..84d5dd84f10 --- /dev/null +++ b/tests/baselines/reference/importsInAmbientModules2.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/importsInAmbientModules2.ts] //// + +//// [external.d.ts] + +export default class C {} + +//// [main.ts] + +declare module "M" { + import C from "external" +} + +//// [main.js] diff --git a/tests/baselines/reference/importsInAmbientModules2.symbols b/tests/baselines/reference/importsInAmbientModules2.symbols new file mode 100644 index 00000000000..02333798e8b --- /dev/null +++ b/tests/baselines/reference/importsInAmbientModules2.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/external.d.ts === + +export default class C {} +>C : Symbol(C, Decl(external.d.ts, 0, 0)) + +=== tests/cases/compiler/main.ts === + +declare module "M" { + import C from "external" +>C : Symbol(C, Decl(main.ts, 2, 10)) +} diff --git a/tests/baselines/reference/importsInAmbientModules2.types b/tests/baselines/reference/importsInAmbientModules2.types new file mode 100644 index 00000000000..d6c4eddc07c --- /dev/null +++ b/tests/baselines/reference/importsInAmbientModules2.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/external.d.ts === + +export default class C {} +>C : C + +=== tests/cases/compiler/main.ts === + +declare module "M" { + import C from "external" +>C : typeof C +} diff --git a/tests/baselines/reference/importsInAmbientModules3.js b/tests/baselines/reference/importsInAmbientModules3.js new file mode 100644 index 00000000000..2a8e09b53e1 --- /dev/null +++ b/tests/baselines/reference/importsInAmbientModules3.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/importsInAmbientModules3.ts] //// + +//// [external.d.ts] + +export default class C {} + +//// [main.ts] + +declare module "M" { + import C = require("external"); +} + +//// [main.js] diff --git a/tests/baselines/reference/importsInAmbientModules3.symbols b/tests/baselines/reference/importsInAmbientModules3.symbols new file mode 100644 index 00000000000..15b2c7173dc --- /dev/null +++ b/tests/baselines/reference/importsInAmbientModules3.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/main.ts === + +declare module "M" { + import C = require("external"); +>C : Symbol(C, Decl(main.ts, 1, 20)) +} +=== tests/cases/compiler/external.d.ts === + +export default class C {} +>C : Symbol(C, Decl(external.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/importsInAmbientModules3.types b/tests/baselines/reference/importsInAmbientModules3.types new file mode 100644 index 00000000000..6c613687b08 --- /dev/null +++ b/tests/baselines/reference/importsInAmbientModules3.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/main.ts === + +declare module "M" { + import C = require("external"); +>C : typeof C +} +=== tests/cases/compiler/external.d.ts === + +export default class C {} +>C : C + diff --git a/tests/baselines/reference/incompatibleTypes.errors.txt b/tests/baselines/reference/incompatibleTypes.errors.txt index e8763b0d54c..e612600a7f8 100644 --- a/tests/baselines/reference/incompatibleTypes.errors.txt +++ b/tests/baselines/reference/incompatibleTypes.errors.txt @@ -18,9 +18,9 @@ tests/cases/compiler/incompatibleTypes.ts(42,5): error TS2345: Argument of type Types of property 'p1' are incompatible. Type '() => string' is not assignable to type '(s: string) => number'. Type 'string' is not assignable to type 'number'. -tests/cases/compiler/incompatibleTypes.ts(49,5): error TS2345: Argument of type '{ e: number; f: number; }' is not assignable to parameter of type '{ c: { b: string; }; d: string; }'. +tests/cases/compiler/incompatibleTypes.ts(49,7): error TS2345: Argument of type '{ e: number; f: number; }' is not assignable to parameter of type '{ c: { b: string; }; d: string; }'. Object literal may only specify known properties, and 'e' does not exist in type '{ c: { b: string; }; d: string; }'. -tests/cases/compiler/incompatibleTypes.ts(66,5): error TS2322: Type '{ e: number; f: number; }' is not assignable to type '{ a: { a: string; }; b: string; }'. +tests/cases/compiler/incompatibleTypes.ts(66,47): error TS2322: Type '{ e: number; f: number; }' is not assignable to type '{ a: { a: string; }; b: string; }'. Object literal may only specify known properties, and 'e' does not exist in type '{ a: { a: string; }; b: string; }'. tests/cases/compiler/incompatibleTypes.ts(72,5): error TS2322: Type 'number' is not assignable to type '() => string'. tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => number' is not assignable to type '() => any'. @@ -101,7 +101,7 @@ tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => function of1(a: any) { return null; } of1({ e: 0, f: 0 }); - ~~~~~~~~~~~~~~ + ~~~~ !!! error TS2345: Argument of type '{ e: number; f: number; }' is not assignable to parameter of type '{ c: { b: string; }; d: string; }'. !!! error TS2345: Object literal may only specify known properties, and 'e' does not exist in type '{ c: { b: string; }; d: string; }'. @@ -121,7 +121,7 @@ tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => } var o1: { a: { a: string; }; b: string; } = { e: 0, f: 0 }; - ~~ + ~~~~ !!! error TS2322: Type '{ e: number; f: number; }' is not assignable to type '{ a: { a: string; }; b: string; }'. !!! error TS2322: Object literal may only specify known properties, and 'e' does not exist in type '{ a: { a: string; }; b: string; }'. diff --git a/tests/baselines/reference/indexTypeCheck.errors.txt b/tests/baselines/reference/indexTypeCheck.errors.txt index 9e003197e41..2ea5a2f413a 100644 --- a/tests/baselines/reference/indexTypeCheck.errors.txt +++ b/tests/baselines/reference/indexTypeCheck.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/indexTypeCheck.ts(17,2): error TS2413: Numeric index type ' tests/cases/compiler/indexTypeCheck.ts(27,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'. tests/cases/compiler/indexTypeCheck.ts(32,3): error TS1096: An index signature must have exactly one parameter. tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string' or 'number'. -tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. ==== tests/cases/compiler/indexTypeCheck.ts (7 errors) ==== @@ -72,7 +72,7 @@ tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression yellow[blue]; // error ~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. var x:number[]; x[0]; diff --git a/tests/baselines/reference/indexersInClassType.types b/tests/baselines/reference/indexersInClassType.types index 8e06bdfbfd3..496526776d9 100644 --- a/tests/baselines/reference/indexersInClassType.types +++ b/tests/baselines/reference/indexersInClassType.types @@ -16,10 +16,10 @@ class C { 'a': {} fn() { ->fn : () => C +>fn : () => this return this; ->this : C +>this : this } } diff --git a/tests/baselines/reference/inheritance1.errors.txt b/tests/baselines/reference/inheritance1.errors.txt index f33dd120e76..d980b884ebf 100644 --- a/tests/baselines/reference/inheritance1.errors.txt +++ b/tests/baselines/reference/inheritance1.errors.txt @@ -7,9 +7,11 @@ tests/cases/compiler/inheritance1.ts(31,1): error TS2322: Type 'Control' is not tests/cases/compiler/inheritance1.ts(37,1): error TS2322: Type 'Control' is not assignable to type 'TextBox'. Property 'select' is missing in type 'Control'. tests/cases/compiler/inheritance1.ts(40,1): error TS2322: Type 'ImageBase' is not assignable to type 'SelectableControl'. + Property 'select' is missing in type 'ImageBase'. tests/cases/compiler/inheritance1.ts(46,1): error TS2322: Type 'Image1' is not assignable to type 'SelectableControl'. Property 'select' is missing in type 'Image1'. tests/cases/compiler/inheritance1.ts(52,1): error TS2322: Type 'Locations' is not assignable to type 'SelectableControl'. + Property 'state' is missing in type 'Locations'. tests/cases/compiler/inheritance1.ts(53,1): error TS2322: Type 'Locations' is not assignable to type 'Control'. Property 'state' is missing in type 'Locations'. tests/cases/compiler/inheritance1.ts(55,1): error TS2322: Type 'Control' is not assignable to type 'Locations'. @@ -77,6 +79,7 @@ tests/cases/compiler/inheritance1.ts(61,1): error TS2322: Type 'Control' is not sc = i; ~~ !!! error TS2322: Type 'ImageBase' is not assignable to type 'SelectableControl'. +!!! error TS2322: Property 'select' is missing in type 'ImageBase'. c = i; i = sc; i = c; @@ -94,6 +97,7 @@ tests/cases/compiler/inheritance1.ts(61,1): error TS2322: Type 'Control' is not sc = l; ~~ !!! error TS2322: Type 'Locations' is not assignable to type 'SelectableControl'. +!!! error TS2322: Property 'state' is missing in type 'Locations'. c = l; ~ !!! error TS2322: Type 'Locations' is not assignable to type 'Control'. diff --git a/tests/baselines/reference/initializersInAmbientEnums.js b/tests/baselines/reference/initializersInAmbientEnums.js new file mode 100644 index 00000000000..21e13ade9c4 --- /dev/null +++ b/tests/baselines/reference/initializersInAmbientEnums.js @@ -0,0 +1,8 @@ +//// [initializersInAmbientEnums.ts] +declare enum E { + a = 10, + b = a, + e = 10 << 2 * 8, +} + +//// [initializersInAmbientEnums.js] diff --git a/tests/baselines/reference/initializersInAmbientEnums.symbols b/tests/baselines/reference/initializersInAmbientEnums.symbols new file mode 100644 index 00000000000..fc4f01b9096 --- /dev/null +++ b/tests/baselines/reference/initializersInAmbientEnums.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/initializersInAmbientEnums.ts === +declare enum E { +>E : Symbol(E, Decl(initializersInAmbientEnums.ts, 0, 0)) + + a = 10, +>a : Symbol(E.a, Decl(initializersInAmbientEnums.ts, 0, 16)) + + b = a, +>b : Symbol(E.b, Decl(initializersInAmbientEnums.ts, 1, 11)) +>a : Symbol(E.a, Decl(initializersInAmbientEnums.ts, 0, 16)) + + e = 10 << 2 * 8, +>e : Symbol(E.e, Decl(initializersInAmbientEnums.ts, 2, 10)) +} diff --git a/tests/baselines/reference/initializersInAmbientEnums.types b/tests/baselines/reference/initializersInAmbientEnums.types new file mode 100644 index 00000000000..40996e9b40a --- /dev/null +++ b/tests/baselines/reference/initializersInAmbientEnums.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/initializersInAmbientEnums.ts === +declare enum E { +>E : E + + a = 10, +>a : E +>10 : number + + b = a, +>b : E +>a : E + + e = 10 << 2 * 8, +>e : E +>10 << 2 * 8 : number +>10 : number +>2 * 8 : number +>2 : number +>8 : number +} diff --git a/tests/baselines/reference/initializersInDeclarations.errors.txt b/tests/baselines/reference/initializersInDeclarations.errors.txt index 9840181e092..a3eeecfe253 100644 --- a/tests/baselines/reference/initializersInDeclarations.errors.txt +++ b/tests/baselines/reference/initializersInDeclarations.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/externalModules/initializersInDeclarations.ts(5,9): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(6,16): error TS1039: Initializers are not allowed in ambient contexts. -tests/cases/conformance/externalModules/initializersInDeclarations.ts(7,16): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/externalModules/initializersInDeclarations.ts(7,16): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(12,15): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(13,15): error TS1039: Initializers are not allowed in ambient contexts. tests/cases/conformance/externalModules/initializersInDeclarations.ts(16,2): error TS1036: Statements are not allowed in ambient contexts. @@ -20,7 +20,7 @@ tests/cases/conformance/externalModules/initializersInDeclarations.ts(18,16): er !!! error TS1039: Initializers are not allowed in ambient contexts. fn(): boolean { ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. return false; } } diff --git a/tests/baselines/reference/inlineSourceMap2.errors.txt b/tests/baselines/reference/inlineSourceMap2.errors.txt index 2d8bc4be0c1..24b0fddf942 100644 --- a/tests/baselines/reference/inlineSourceMap2.errors.txt +++ b/tests/baselines/reference/inlineSourceMap2.errors.txt @@ -1,12 +1,12 @@ -error TS5048: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. -error TS5049: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'. -error TS5050: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. +error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. +error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. +error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'. tests/cases/compiler/inlineSourceMap2.ts(5,1): error TS2304: Cannot find name 'console'. -!!! error TS5048: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. -!!! error TS5049: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'. -!!! error TS5050: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. +!!! error TS5053: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. +!!! error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. +!!! error TS5053: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'. ==== tests/cases/compiler/inlineSourceMap2.ts (1 errors) ==== // configuration errors diff --git a/tests/baselines/reference/instanceAndStaticDeclarations1.symbols b/tests/baselines/reference/instanceAndStaticDeclarations1.symbols index 518d899eabf..d6b4789232c 100644 --- a/tests/baselines/reference/instanceAndStaticDeclarations1.symbols +++ b/tests/baselines/reference/instanceAndStaticDeclarations1.symbols @@ -18,18 +18,18 @@ class Point { >this.x : Symbol(x, Decl(instanceAndStaticDeclarations1.ts, 3, 16)) >this : Symbol(Point, Decl(instanceAndStaticDeclarations1.ts, 0, 0)) >x : Symbol(x, Decl(instanceAndStaticDeclarations1.ts, 3, 16)) ->p.x : Symbol(x, Decl(instanceAndStaticDeclarations1.ts, 3, 16)) +>p.x : Symbol(Point.x, Decl(instanceAndStaticDeclarations1.ts, 3, 16)) >p : Symbol(p, Decl(instanceAndStaticDeclarations1.ts, 4, 20)) ->x : Symbol(x, Decl(instanceAndStaticDeclarations1.ts, 3, 16)) +>x : Symbol(Point.x, Decl(instanceAndStaticDeclarations1.ts, 3, 16)) var dy = this.y - p.y; >dy : Symbol(dy, Decl(instanceAndStaticDeclarations1.ts, 6, 11)) >this.y : Symbol(y, Decl(instanceAndStaticDeclarations1.ts, 3, 33)) >this : Symbol(Point, Decl(instanceAndStaticDeclarations1.ts, 0, 0)) >y : Symbol(y, Decl(instanceAndStaticDeclarations1.ts, 3, 33)) ->p.y : Symbol(y, Decl(instanceAndStaticDeclarations1.ts, 3, 33)) +>p.y : Symbol(Point.y, Decl(instanceAndStaticDeclarations1.ts, 3, 33)) >p : Symbol(p, Decl(instanceAndStaticDeclarations1.ts, 4, 20)) ->y : Symbol(y, Decl(instanceAndStaticDeclarations1.ts, 3, 33)) +>y : Symbol(Point.y, Decl(instanceAndStaticDeclarations1.ts, 3, 33)) return Math.sqrt(dx * dx + dy * dy); >Math.sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, 620, 27)) @@ -50,8 +50,8 @@ class Point { >Point : Symbol(Point, Decl(instanceAndStaticDeclarations1.ts, 0, 0)) >p2 : Symbol(p2, Decl(instanceAndStaticDeclarations1.ts, 10, 30)) >Point : Symbol(Point, Decl(instanceAndStaticDeclarations1.ts, 0, 0)) ->p1.distance : Symbol(distance, Decl(instanceAndStaticDeclarations1.ts, 3, 55)) +>p1.distance : Symbol(Point.distance, Decl(instanceAndStaticDeclarations1.ts, 3, 55)) >p1 : Symbol(p1, Decl(instanceAndStaticDeclarations1.ts, 10, 20)) ->distance : Symbol(distance, Decl(instanceAndStaticDeclarations1.ts, 3, 55)) +>distance : Symbol(Point.distance, Decl(instanceAndStaticDeclarations1.ts, 3, 55)) >p2 : Symbol(p2, Decl(instanceAndStaticDeclarations1.ts, 10, 30)) } diff --git a/tests/baselines/reference/instanceAndStaticDeclarations1.types b/tests/baselines/reference/instanceAndStaticDeclarations1.types index 9d6ba692735..cbed990690d 100644 --- a/tests/baselines/reference/instanceAndStaticDeclarations1.types +++ b/tests/baselines/reference/instanceAndStaticDeclarations1.types @@ -17,7 +17,7 @@ class Point { >dx : number >this.x - p.x : number >this.x : number ->this : Point +>this : this >x : number >p.x : number >p : Point @@ -27,7 +27,7 @@ class Point { >dy : number >this.y - p.y : number >this.y : number ->this : Point +>this : this >y : number >p.y : number >p : Point diff --git a/tests/baselines/reference/interfaceContextualType.types b/tests/baselines/reference/interfaceContextualType.types index 4b932a71538..e827f9a9d9b 100644 --- a/tests/baselines/reference/interfaceContextualType.types +++ b/tests/baselines/reference/interfaceContextualType.types @@ -29,7 +29,7 @@ class Bug { this.values = {}; >this.values = {} : { [x: string]: undefined; } >this.values : IMap ->this : Bug +>this : this >values : IMap >{} : { [x: string]: undefined; } @@ -37,7 +37,7 @@ class Bug { >this.values['comments'] = { italic: true } : { italic: boolean; } >this.values['comments'] : IOptions >this.values : IMap ->this : Bug +>this : this >values : IMap >'comments' : string >{ italic: true } : { italic: boolean; } @@ -50,7 +50,7 @@ class Bug { this.values = { >this.values = { comments: { italic: true } } : { [x: string]: { italic: boolean; }; comments: { italic: boolean; }; } >this.values : IMap ->this : Bug +>this : this >values : IMap >{ comments: { italic: true } } : { [x: string]: { italic: boolean; }; comments: { italic: boolean; }; } diff --git a/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt b/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt index 0c4b95214b0..3ec718f3b25 100644 --- a/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt +++ b/tests/baselines/reference/invalidMultipleVariableDeclarations.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDec tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(40,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'b' must be of type 'I', but here has type 'C2'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(43,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: string) => number', but here has type '(x: number) => string'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(46,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. -tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(47,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. +tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(47,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(50,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'arr2' must be of type 'D[]', but here has type 'D[]'. tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDeclarations.ts(53,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'm' must be of type 'typeof M', but here has type 'typeof A'. @@ -79,7 +79,7 @@ tests/cases/conformance/statements/VariableStatements/invalidMultipleVariableDec !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type 'number[]'. var arr = [new C(), new C2(), new D()]; ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | C2 | D)[]'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'arr' must be of type 'string[]', but here has type '(C | D)[]'. var arr2 = [new D()]; var arr2 = new Array>(); diff --git a/tests/baselines/reference/isolatedModulesDeclaration.errors.txt b/tests/baselines/reference/isolatedModulesDeclaration.errors.txt index de5cb97586c..749e86116e8 100644 --- a/tests/baselines/reference/isolatedModulesDeclaration.errors.txt +++ b/tests/baselines/reference/isolatedModulesDeclaration.errors.txt @@ -1,7 +1,7 @@ -error TS5044: Option 'declaration' cannot be specified with option 'isolatedModules'. +error TS5053: Option 'declaration' cannot be specified with option 'isolatedModules'. -!!! error TS5044: Option 'declaration' cannot be specified with option 'isolatedModules'. +!!! error TS5053: Option 'declaration' cannot be specified with option 'isolatedModules'. ==== tests/cases/compiler/isolatedModulesDeclaration.ts (0 errors) ==== export var x; \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesNoEmitOnError.errors.txt b/tests/baselines/reference/isolatedModulesNoEmitOnError.errors.txt index 68b2747cf6b..337fcb16ba3 100644 --- a/tests/baselines/reference/isolatedModulesNoEmitOnError.errors.txt +++ b/tests/baselines/reference/isolatedModulesNoEmitOnError.errors.txt @@ -1,7 +1,7 @@ -error TS5045: Option 'noEmitOnError' cannot be specified with option 'isolatedModules'. +error TS5053: Option 'noEmitOnError' cannot be specified with option 'isolatedModules'. -!!! error TS5045: Option 'noEmitOnError' cannot be specified with option 'isolatedModules'. +!!! error TS5053: Option 'noEmitOnError' cannot be specified with option 'isolatedModules'. ==== tests/cases/compiler/isolatedModulesNoEmitOnError.ts (0 errors) ==== export var x; \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesOut.errors.txt b/tests/baselines/reference/isolatedModulesOut.errors.txt index 8234ba94585..7d16ac94666 100644 --- a/tests/baselines/reference/isolatedModulesOut.errors.txt +++ b/tests/baselines/reference/isolatedModulesOut.errors.txt @@ -1,8 +1,8 @@ -error TS5046: Option 'out' cannot be specified with option 'isolatedModules'. +error TS5053: Option 'out' cannot be specified with option 'isolatedModules'. tests/cases/compiler/file2.ts(1,1): error TS1208: Cannot compile namespaces when the '--isolatedModules' flag is provided. -!!! error TS5046: Option 'out' cannot be specified with option 'isolatedModules'. +!!! error TS5053: Option 'out' cannot be specified with option 'isolatedModules'. ==== tests/cases/compiler/file1.ts (0 errors) ==== export var x; diff --git a/tests/baselines/reference/isolatedModulesPlainFile-UMD.js b/tests/baselines/reference/isolatedModulesPlainFile-UMD.js index 0ed6e83a37f..b4f8cf436ec 100644 --- a/tests/baselines/reference/isolatedModulesPlainFile-UMD.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-UMD.js @@ -5,13 +5,13 @@ run(1); //// [isolatedModulesPlainFile-UMD.js] -(function (deps, factory) { +(function (factory) { if (typeof module === 'object' && typeof module.exports === 'object') { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === 'function' && define.amd) { - define(deps, factory); + define(["require", "exports"], factory); } -})(["require", "exports"], function (require, exports) { +})(function (require, exports) { run(1); }); diff --git a/tests/baselines/reference/iterableArrayPattern1.symbols b/tests/baselines/reference/iterableArrayPattern1.symbols index 3920dc1cef4..fae627e9c95 100644 --- a/tests/baselines/reference/iterableArrayPattern1.symbols +++ b/tests/baselines/reference/iterableArrayPattern1.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern1.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern1.ts, 4, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 32)) diff --git a/tests/baselines/reference/iterableArrayPattern1.types b/tests/baselines/reference/iterableArrayPattern1.types index 2cfd2354f31..a2c9807d26a 100644 --- a/tests/baselines/reference/iterableArrayPattern1.types +++ b/tests/baselines/reference/iterableArrayPattern1.types @@ -32,6 +32,6 @@ class SymbolIterator { >iterator : symbol return this; ->this : SymbolIterator +>this : this } } diff --git a/tests/baselines/reference/iterableArrayPattern11.symbols b/tests/baselines/reference/iterableArrayPattern11.symbols index 06e38c57af4..fefeaced83f 100644 --- a/tests/baselines/reference/iterableArrayPattern11.symbols +++ b/tests/baselines/reference/iterableArrayPattern11.symbols @@ -36,9 +36,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern11.types b/tests/baselines/reference/iterableArrayPattern11.types index 3118e748d6f..5ec182ec397 100644 --- a/tests/baselines/reference/iterableArrayPattern11.types +++ b/tests/baselines/reference/iterableArrayPattern11.types @@ -48,6 +48,6 @@ class FooIterator { >iterator : symbol return this; ->this : FooIterator +>this : this } } diff --git a/tests/baselines/reference/iterableArrayPattern12.symbols b/tests/baselines/reference/iterableArrayPattern12.symbols index e16fe5255e4..fd00059449a 100644 --- a/tests/baselines/reference/iterableArrayPattern12.symbols +++ b/tests/baselines/reference/iterableArrayPattern12.symbols @@ -36,9 +36,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern12.types b/tests/baselines/reference/iterableArrayPattern12.types index b32c2ff7dc8..89af4d47d01 100644 --- a/tests/baselines/reference/iterableArrayPattern12.types +++ b/tests/baselines/reference/iterableArrayPattern12.types @@ -48,6 +48,6 @@ class FooIterator { >iterator : symbol return this; ->this : FooIterator +>this : this } } diff --git a/tests/baselines/reference/iterableArrayPattern13.symbols b/tests/baselines/reference/iterableArrayPattern13.symbols index b8709197829..8271e564f9e 100644 --- a/tests/baselines/reference/iterableArrayPattern13.symbols +++ b/tests/baselines/reference/iterableArrayPattern13.symbols @@ -35,9 +35,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern13.types b/tests/baselines/reference/iterableArrayPattern13.types index 556a871f5a8..e8873a74b72 100644 --- a/tests/baselines/reference/iterableArrayPattern13.types +++ b/tests/baselines/reference/iterableArrayPattern13.types @@ -46,6 +46,6 @@ class FooIterator { >iterator : symbol return this; ->this : FooIterator +>this : this } } diff --git a/tests/baselines/reference/iterableArrayPattern2.symbols b/tests/baselines/reference/iterableArrayPattern2.symbols index 17ac6a1feac..d4f2949e24f 100644 --- a/tests/baselines/reference/iterableArrayPattern2.symbols +++ b/tests/baselines/reference/iterableArrayPattern2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iterableArrayPattern2.ts, 3, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iterableArrayPattern2.ts, 4, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 35)) diff --git a/tests/baselines/reference/iterableArrayPattern2.types b/tests/baselines/reference/iterableArrayPattern2.types index bd58cb86b79..48f44443591 100644 --- a/tests/baselines/reference/iterableArrayPattern2.types +++ b/tests/baselines/reference/iterableArrayPattern2.types @@ -32,6 +32,6 @@ class SymbolIterator { >iterator : symbol return this; ->this : SymbolIterator +>this : this } } diff --git a/tests/baselines/reference/iterableArrayPattern3.symbols b/tests/baselines/reference/iterableArrayPattern3.symbols index 468866ca324..9e38c52ad70 100644 --- a/tests/baselines/reference/iterableArrayPattern3.symbols +++ b/tests/baselines/reference/iterableArrayPattern3.symbols @@ -37,9 +37,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern3.types b/tests/baselines/reference/iterableArrayPattern3.types index fed5c7f07d3..dd001d46376 100644 --- a/tests/baselines/reference/iterableArrayPattern3.types +++ b/tests/baselines/reference/iterableArrayPattern3.types @@ -49,6 +49,6 @@ class FooIterator { >iterator : symbol return this; ->this : FooIterator +>this : this } } diff --git a/tests/baselines/reference/iterableArrayPattern30.symbols b/tests/baselines/reference/iterableArrayPattern30.symbols index 6f0d347d9b4..5a991f0d5b3 100644 --- a/tests/baselines/reference/iterableArrayPattern30.symbols +++ b/tests/baselines/reference/iterableArrayPattern30.symbols @@ -4,5 +4,5 @@ const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]]) >v1 : Symbol(v1, Decl(iterableArrayPattern30.ts, 0, 11)) >k2 : Symbol(k2, Decl(iterableArrayPattern30.ts, 0, 18)) >v2 : Symbol(v2, Decl(iterableArrayPattern30.ts, 0, 21)) ->Map : Symbol(Map, Decl(lib.d.ts, 1877, 1), Decl(lib.d.ts, 1900, 11)) +>Map : Symbol(Map, Decl(lib.d.ts, 4635, 1), Decl(lib.d.ts, 4658, 11)) diff --git a/tests/baselines/reference/iterableArrayPattern4.symbols b/tests/baselines/reference/iterableArrayPattern4.symbols index 10225e183e6..d3a7f4fb1d7 100644 --- a/tests/baselines/reference/iterableArrayPattern4.symbols +++ b/tests/baselines/reference/iterableArrayPattern4.symbols @@ -37,9 +37,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 3, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern4.types b/tests/baselines/reference/iterableArrayPattern4.types index 8f05a454b53..2d6531494a4 100644 --- a/tests/baselines/reference/iterableArrayPattern4.types +++ b/tests/baselines/reference/iterableArrayPattern4.types @@ -50,6 +50,6 @@ class FooIterator { >iterator : symbol return this; ->this : FooIterator +>this : this } } diff --git a/tests/baselines/reference/iterableArrayPattern9.symbols b/tests/baselines/reference/iterableArrayPattern9.symbols index 86c46812688..efb88d2e608 100644 --- a/tests/baselines/reference/iterableArrayPattern9.symbols +++ b/tests/baselines/reference/iterableArrayPattern9.symbols @@ -32,9 +32,9 @@ class FooIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(FooIterator, Decl(iterableArrayPattern9.ts, 2, 27)) diff --git a/tests/baselines/reference/iterableArrayPattern9.types b/tests/baselines/reference/iterableArrayPattern9.types index 03cfa31b621..e9e342e7775 100644 --- a/tests/baselines/reference/iterableArrayPattern9.types +++ b/tests/baselines/reference/iterableArrayPattern9.types @@ -42,6 +42,6 @@ class FooIterator { >iterator : symbol return this; ->this : FooIterator +>this : this } } diff --git a/tests/baselines/reference/iterableContextualTyping1.symbols b/tests/baselines/reference/iterableContextualTyping1.symbols index ae99a4b5255..f23d571d072 100644 --- a/tests/baselines/reference/iterableContextualTyping1.symbols +++ b/tests/baselines/reference/iterableContextualTyping1.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/expressions/contextualTyping/iterableContextualTyping1.ts === var iter: Iterable<(x: string) => number> = [s => s.length]; >iter : Symbol(iter, Decl(iterableContextualTyping1.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4396, 1)) >x : Symbol(x, Decl(iterableContextualTyping1.ts, 0, 20)) >s : Symbol(s, Decl(iterableContextualTyping1.ts, 0, 45)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) diff --git a/tests/baselines/reference/iteratorSpreadInArray.symbols b/tests/baselines/reference/iteratorSpreadInArray.symbols index c4a2459e262..03099b124c9 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 36)) diff --git a/tests/baselines/reference/iteratorSpreadInArray.types b/tests/baselines/reference/iteratorSpreadInArray.types index 2c4a1d207ef..780acf32fab 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.types +++ b/tests/baselines/reference/iteratorSpreadInArray.types @@ -33,6 +33,6 @@ class SymbolIterator { >iterator : symbol return this; ->this : SymbolIterator +>this : this } } diff --git a/tests/baselines/reference/iteratorSpreadInArray11.symbols b/tests/baselines/reference/iteratorSpreadInArray11.symbols index c2fce062fb0..a46d22a481a 100644 --- a/tests/baselines/reference/iteratorSpreadInArray11.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray11.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray11.ts === var iter: Iterable; >iter : Symbol(iter, Decl(iteratorSpreadInArray11.ts, 0, 3)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4396, 1)) var array = [...iter]; >array : Symbol(array, Decl(iteratorSpreadInArray11.ts, 1, 3)) diff --git a/tests/baselines/reference/iteratorSpreadInArray2.symbols b/tests/baselines/reference/iteratorSpreadInArray2.symbols index cdc7bb3e2bc..906e8288af0 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray2.symbols @@ -13,7 +13,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 5, 28)) @@ -22,9 +22,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 59)) @@ -48,9 +48,9 @@ class NumberIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 13, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInArray2.types b/tests/baselines/reference/iteratorSpreadInArray2.types index a59c2cf6c67..f2e64e5282e 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.types +++ b/tests/baselines/reference/iteratorSpreadInArray2.types @@ -36,7 +36,7 @@ class SymbolIterator { >iterator : symbol return this; ->this : SymbolIterator +>this : this } } @@ -66,6 +66,6 @@ class NumberIterator { >iterator : symbol return this; ->this : NumberIterator +>this : this } } diff --git a/tests/baselines/reference/iteratorSpreadInArray3.symbols b/tests/baselines/reference/iteratorSpreadInArray3.symbols index e4d1b508bb5..e25374c80a8 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray3.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray3.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray3.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 47)) diff --git a/tests/baselines/reference/iteratorSpreadInArray3.types b/tests/baselines/reference/iteratorSpreadInArray3.types index 0374f28b6b9..a59da81e157 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.types +++ b/tests/baselines/reference/iteratorSpreadInArray3.types @@ -37,6 +37,6 @@ class SymbolIterator { >iterator : symbol return this; ->this : SymbolIterator +>this : this } } diff --git a/tests/baselines/reference/iteratorSpreadInArray4.symbols b/tests/baselines/reference/iteratorSpreadInArray4.symbols index bd6760dd0aa..1856d1bb682 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray4.symbols @@ -12,7 +12,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray4.ts, 4, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray4.ts, 5, 28)) @@ -21,9 +21,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 42)) diff --git a/tests/baselines/reference/iteratorSpreadInArray4.types b/tests/baselines/reference/iteratorSpreadInArray4.types index d9a304421ba..0e16758acf4 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.types +++ b/tests/baselines/reference/iteratorSpreadInArray4.types @@ -35,6 +35,6 @@ class SymbolIterator { >iterator : symbol return this; ->this : SymbolIterator +>this : this } } diff --git a/tests/baselines/reference/iteratorSpreadInArray7.symbols b/tests/baselines/reference/iteratorSpreadInArray7.symbols index d0bc9790752..c68550b7fa7 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray7.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInArray7.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInArray7.ts, 6, 28)) @@ -26,9 +26,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38)) diff --git a/tests/baselines/reference/iteratorSpreadInArray7.types b/tests/baselines/reference/iteratorSpreadInArray7.types index f207a56f3d5..6a279838060 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.types +++ b/tests/baselines/reference/iteratorSpreadInArray7.types @@ -39,6 +39,6 @@ class SymbolIterator { >iterator : symbol return this; ->this : SymbolIterator +>this : this } } diff --git a/tests/baselines/reference/iteratorSpreadInCall11.symbols b/tests/baselines/reference/iteratorSpreadInCall11.symbols index a7e5d7b8919..874a034631d 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall11.symbols @@ -19,7 +19,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall11.ts, 6, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall11.ts, 7, 28)) @@ -28,9 +28,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 2, 42)) diff --git a/tests/baselines/reference/iteratorSpreadInCall11.types b/tests/baselines/reference/iteratorSpreadInCall11.types index edce8b10355..dd440a1b4ac 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.types +++ b/tests/baselines/reference/iteratorSpreadInCall11.types @@ -42,6 +42,6 @@ class SymbolIterator { >iterator : symbol return this; ->this : SymbolIterator +>this : this } } diff --git a/tests/baselines/reference/iteratorSpreadInCall12.symbols b/tests/baselines/reference/iteratorSpreadInCall12.symbols index 67b9e9e500d..0f84a0e1cbb 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall12.symbols @@ -22,7 +22,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 8, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 9, 28)) @@ -31,9 +31,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 4, 1)) @@ -57,9 +57,9 @@ class StringIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 17, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInCall12.types b/tests/baselines/reference/iteratorSpreadInCall12.types index 4307daa78b0..5e3e7bcdbc4 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.types +++ b/tests/baselines/reference/iteratorSpreadInCall12.types @@ -49,7 +49,7 @@ class SymbolIterator { >iterator : symbol return this; ->this : SymbolIterator +>this : this } } @@ -79,6 +79,6 @@ class StringIterator { >iterator : symbol return this; ->this : StringIterator +>this : this } } diff --git a/tests/baselines/reference/iteratorSpreadInCall3.symbols b/tests/baselines/reference/iteratorSpreadInCall3.symbols index 0c3c11c84f4..6f329329431 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall3.symbols @@ -16,7 +16,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall3.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall3.ts, 6, 28)) @@ -25,9 +25,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 2, 32)) diff --git a/tests/baselines/reference/iteratorSpreadInCall3.types b/tests/baselines/reference/iteratorSpreadInCall3.types index b566c3866ff..54857755b55 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.types +++ b/tests/baselines/reference/iteratorSpreadInCall3.types @@ -37,6 +37,6 @@ class SymbolIterator { >iterator : symbol return this; ->this : SymbolIterator +>this : this } } diff --git a/tests/baselines/reference/iteratorSpreadInCall5.symbols b/tests/baselines/reference/iteratorSpreadInCall5.symbols index 03faf4b593e..01a0112b026 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall5.symbols @@ -17,7 +17,7 @@ class SymbolIterator { return { value: Symbol(), >value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 5, 16)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) done: false >done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 6, 28)) @@ -26,9 +26,9 @@ class SymbolIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 2, 43)) @@ -52,9 +52,9 @@ class StringIterator { } [Symbol.iterator]() { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) return this; >this : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 14, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInCall5.types b/tests/baselines/reference/iteratorSpreadInCall5.types index 631ad940554..043536ab4c0 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.types +++ b/tests/baselines/reference/iteratorSpreadInCall5.types @@ -40,7 +40,7 @@ class SymbolIterator { >iterator : symbol return this; ->this : SymbolIterator +>this : this } } @@ -70,6 +70,6 @@ class StringIterator { >iterator : symbol return this; ->this : StringIterator +>this : this } } diff --git a/tests/baselines/reference/jsxEmitAttributeWithPreserve.js b/tests/baselines/reference/jsxEmitAttributeWithPreserve.js new file mode 100644 index 00000000000..07cb0dee485 --- /dev/null +++ b/tests/baselines/reference/jsxEmitAttributeWithPreserve.js @@ -0,0 +1,7 @@ +//// [jsxEmitAttributeWithPreserve.tsx] + +declare var React: any; + + +//// [jsxEmitAttributeWithPreserve.jsx] +; diff --git a/tests/baselines/reference/jsxEmitAttributeWithPreserve.symbols b/tests/baselines/reference/jsxEmitAttributeWithPreserve.symbols new file mode 100644 index 00000000000..4ffadb8e888 --- /dev/null +++ b/tests/baselines/reference/jsxEmitAttributeWithPreserve.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx === + +declare var React: any; +>React : Symbol(React, Decl(jsxEmitAttributeWithPreserve.tsx, 1, 11)) + + +>data : Symbol(unknown) + diff --git a/tests/baselines/reference/jsxEmitAttributeWithPreserve.types b/tests/baselines/reference/jsxEmitAttributeWithPreserve.types new file mode 100644 index 00000000000..972ca1c3d88 --- /dev/null +++ b/tests/baselines/reference/jsxEmitAttributeWithPreserve.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx === + +declare var React: any; +>React : any + + +> : any +>foo : any +>data : any + diff --git a/tests/baselines/reference/jsxHash.types b/tests/baselines/reference/jsxHash.types index e614ebd3e0b..6d413141ca6 100644 --- a/tests/baselines/reference/jsxHash.types +++ b/tests/baselines/reference/jsxHash.types @@ -3,18 +3,21 @@ var t02 = {0}#; >t02 : any >{0}# : any >a : any +>0 : number >a : any var t03 = #{0}; >t03 : any >#{0} : any >a : any +>0 : number >a : any var t04 = #{0}#; >t04 : any >#{0}# : any >a : any +>0 : number >a : any var t05 = #; diff --git a/tests/baselines/reference/jsxImportInAttribute.symbols b/tests/baselines/reference/jsxImportInAttribute.symbols index 8481771f085..845001b22c0 100644 --- a/tests/baselines/reference/jsxImportInAttribute.symbols +++ b/tests/baselines/reference/jsxImportInAttribute.symbols @@ -9,6 +9,7 @@ let x = Test; // emit test_1.default ; // ? >attr : Symbol(unknown) +>Test : Symbol(Test, Decl(consumer.tsx, 1, 6)) === tests/cases/compiler/component.d.ts === diff --git a/tests/baselines/reference/jsxImportInAttribute.types b/tests/baselines/reference/jsxImportInAttribute.types index 8dfbe292fe0..8dc5c370fa8 100644 --- a/tests/baselines/reference/jsxImportInAttribute.types +++ b/tests/baselines/reference/jsxImportInAttribute.types @@ -11,7 +11,7 @@ let x = Test; // emit test_1.default > : any >anything : any >attr : any ->Test : any +>Test : typeof Test === tests/cases/compiler/component.d.ts === diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js index daf344b08da..d623e127be7 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js @@ -47,9 +47,9 @@ a / > ; < a; b > ; b > ; -; +; b.c > ; -; +; c > ; ; < .a > ; @@ -67,7 +67,7 @@ var x =
one
two
;; var x =
one
/* intervening comment */ /* intervening comment */
two
;; {"str"}}; id="b" />; -
>; +
>;
;
stuff
...props}>; diff --git a/tests/baselines/reference/jsxReactTestSuite.js b/tests/baselines/reference/jsxReactTestSuite.js index 300274a1614..18013d4be9b 100644 --- a/tests/baselines/reference/jsxReactTestSuite.js +++ b/tests/baselines/reference/jsxReactTestSuite.js @@ -158,14 +158,14 @@ var x =
; ; ; -; +; ; ; ; ; ; ; -; +; ; ; Text; diff --git a/tests/baselines/reference/jsxReactTestSuite.symbols b/tests/baselines/reference/jsxReactTestSuite.symbols index ba329949939..b86054ac560 100644 --- a/tests/baselines/reference/jsxReactTestSuite.symbols +++ b/tests/baselines/reference/jsxReactTestSuite.symbols @@ -46,6 +46,8 @@ declare var hasOwnProperty:any;

{foo}
{bar}
>Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>foo : Symbol(foo, Decl(jsxReactTestSuite.tsx, 7, 11)) +>bar : Symbol(bar, Decl(jsxReactTestSuite.tsx, 8, 11)) >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11))
@@ -143,6 +145,7 @@ var x = Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3)) >y : Symbol(unknown) ={2 } z />; @@ -159,30 +162,37 @@ var x = ; >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) >x : Symbol(unknown) +>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 9, 11)) ; ; >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3)) ; >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3)) >y : Symbol(unknown) ; >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) +>x : Symbol(x, Decl(jsxReactTestSuite.tsx, 10, 11), Decl(jsxReactTestSuite.tsx, 35, 3)) >y : Symbol(unknown) >z : Symbol(unknown) ; >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) >x : Symbol(unknown) +>y : Symbol(y, Decl(jsxReactTestSuite.tsx, 9, 11)) ; >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) >x : Symbol(unknown) >y : Symbol(unknown) +>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11)) +>z : Symbol(z, Decl(jsxReactTestSuite.tsx, 11, 11)) >Child : Symbol(Child, Decl(jsxReactTestSuite.tsx, 5, 11)) >Component : Symbol(Component, Decl(jsxReactTestSuite.tsx, 2, 11)) diff --git a/tests/baselines/reference/jsxReactTestSuite.types b/tests/baselines/reference/jsxReactTestSuite.types index db7ebf8d912..88c2c278e59 100644 --- a/tests/baselines/reference/jsxReactTestSuite.types +++ b/tests/baselines/reference/jsxReactTestSuite.types @@ -251,6 +251,7 @@ var x = >y : any ={2 } z />; +>2 : number >z : any Component : any >x : any >y : any +>2 : number ; > : any >Component : any >x : any >y : any +>2 : number >z : any ; > : any >Component : any >x : any +>1 : number >y : any @@ -306,6 +310,7 @@ var x = > : any >Component : any >x : any +>1 : number >y : any >z : any >z : any @@ -326,6 +331,7 @@ var x = >2 : number >z : any >z : any +>3 : number >Component : any diff --git a/tests/baselines/reference/keywordInJsxIdentifier.js b/tests/baselines/reference/keywordInJsxIdentifier.js new file mode 100644 index 00000000000..677a79138e6 --- /dev/null +++ b/tests/baselines/reference/keywordInJsxIdentifier.js @@ -0,0 +1,14 @@ +//// [keywordInJsxIdentifier.tsx] + +declare var React: any; +; +; +; +; + + +//// [keywordInJsxIdentifier.js] +React.createElement("foo", {"class-id": true}); +React.createElement("foo", {"class": true}); +React.createElement("foo", {"class-id": "1"}); +React.createElement("foo", {"class": "1"}); diff --git a/tests/baselines/reference/keywordInJsxIdentifier.symbols b/tests/baselines/reference/keywordInJsxIdentifier.symbols new file mode 100644 index 00000000000..874d7801a7f --- /dev/null +++ b/tests/baselines/reference/keywordInJsxIdentifier.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/keywordInJsxIdentifier.tsx === + +declare var React: any; +>React : Symbol(React, Decl(keywordInJsxIdentifier.tsx, 1, 11)) + +; +>class-id : Symbol(unknown) + +; +>class : Symbol(unknown) + +; +>class-id : Symbol(unknown) + +; +>class : Symbol(unknown) + diff --git a/tests/baselines/reference/keywordInJsxIdentifier.types b/tests/baselines/reference/keywordInJsxIdentifier.types new file mode 100644 index 00000000000..745fa5998b5 --- /dev/null +++ b/tests/baselines/reference/keywordInJsxIdentifier.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/keywordInJsxIdentifier.tsx === + +declare var React: any; +>React : any + +; +> : any +>foo : any +>class-id : any + +; +> : any +>foo : any +>class : any + +; +> : any +>foo : any +>class-id : any + +; +> : any +>foo : any +>class : any + diff --git a/tests/baselines/reference/listFailure.types b/tests/baselines/reference/listFailure.types index 05c3cb5dfad..03725efeca4 100644 --- a/tests/baselines/reference/listFailure.types +++ b/tests/baselines/reference/listFailure.types @@ -30,7 +30,7 @@ module Editor { >this.lines.add(line) : List >this.lines.add : (data: Line) => List >this.lines : List ->this : Buffer +>this : this >lines : List >add : (data: Line) => List >line : Line @@ -94,7 +94,7 @@ module Editor { this.next = ListMakeEntry(data); >this.next = ListMakeEntry(data) : List >this.next : List ->this : List +>this : this >next : List >ListMakeEntry(data) : List >ListMakeEntry : (data: U) => List @@ -102,7 +102,7 @@ module Editor { return this.next; >this.next : List ->this : List +>this : this >next : List } @@ -119,7 +119,7 @@ module Editor { >ListRemoveEntry(this.next) : List >ListRemoveEntry : (entry: List) => List >this.next : List ->this : List +>this : this >next : List } } diff --git a/tests/baselines/reference/localAliasExportAssignment.js b/tests/baselines/reference/localAliasExportAssignment.js index ce0f57d57cb..686ab4126a2 100644 --- a/tests/baselines/reference/localAliasExportAssignment.js +++ b/tests/baselines/reference/localAliasExportAssignment.js @@ -9,7 +9,7 @@ export = server; //// [localAliasExportAssignment_1.ts] /// -import connect = require('localAliasExportAssignment_0'); +import connect = require('./localAliasExportAssignment_0'); connect(); @@ -21,5 +21,5 @@ var server; module.exports = server; //// [localAliasExportAssignment_1.js] /// -var connect = require('localAliasExportAssignment_0'); +var connect = require('./localAliasExportAssignment_0'); connect(); diff --git a/tests/baselines/reference/localAliasExportAssignment.symbols b/tests/baselines/reference/localAliasExportAssignment.symbols index 43c99941384..0c73dfd79de 100644 --- a/tests/baselines/reference/localAliasExportAssignment.symbols +++ b/tests/baselines/reference/localAliasExportAssignment.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/localAliasExportAssignment_1.ts === /// -import connect = require('localAliasExportAssignment_0'); +import connect = require('./localAliasExportAssignment_0'); >connect : Symbol(connect, Decl(localAliasExportAssignment_1.ts, 0, 0)) connect(); diff --git a/tests/baselines/reference/localAliasExportAssignment.types b/tests/baselines/reference/localAliasExportAssignment.types index 5ea0d3085c1..f83b63fedb7 100644 --- a/tests/baselines/reference/localAliasExportAssignment.types +++ b/tests/baselines/reference/localAliasExportAssignment.types @@ -1,6 +1,6 @@ === tests/cases/compiler/localAliasExportAssignment_1.ts === /// -import connect = require('localAliasExportAssignment_0'); +import connect = require('./localAliasExportAssignment_0'); >connect : () => any connect(); diff --git a/tests/baselines/reference/localTypes5.types b/tests/baselines/reference/localTypes5.types index b12e362f754..54e28d35a32 100644 --- a/tests/baselines/reference/localTypes5.types +++ b/tests/baselines/reference/localTypes5.types @@ -36,9 +36,9 @@ function foo() { return x.m(); >x.m() : X.m..Y ->x.m : () => .Y +>x.m : () => X.m..Y >x : X ->m : () => .Y +>m : () => X.m..Y } var x = foo(); >x : foo.X.m..Y diff --git a/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.errors.txt b/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.errors.txt index bd210c55570..484c8f63b46 100644 --- a/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.errors.txt +++ b/tests/baselines/reference/logicalOrExpressionIsContextuallyTyped.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/binaryOperators/logicalOrOperator/logicalOrExpressionIsContextuallyTyped.ts(6,5): error TS2322: Type '{ a: string; b: number; } | { a: string; b: boolean; }' is not assignable to type '{ a: string; }'. +tests/cases/conformance/expressions/binaryOperators/logicalOrOperator/logicalOrExpressionIsContextuallyTyped.ts(6,33): error TS2322: Type '{ a: string; b: number; } | { a: string; b: boolean; }' is not assignable to type '{ a: string; }'. Type '{ a: string; b: number; }' is not assignable to type '{ a: string; }'. Object literal may only specify known properties, and 'b' does not exist in type '{ a: string; }'. @@ -10,7 +10,7 @@ tests/cases/conformance/expressions/binaryOperators/logicalOrOperator/logicalOrE // operand types. var r: { a: string } = { a: '', b: 123 } || { a: '', b: true }; - ~ + ~~~~~~ !!! error TS2322: Type '{ a: string; b: number; } | { a: string; b: boolean; }' is not assignable to type '{ a: string; }'. !!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; }'. !!! error TS2322: Object literal may only specify known properties, and 'b' does not exist in type '{ a: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/logicalOrOperatorWithEveryType.types b/tests/baselines/reference/logicalOrOperatorWithEveryType.types index 04bc188e308..4540e35aaf4 100644 --- a/tests/baselines/reference/logicalOrOperatorWithEveryType.types +++ b/tests/baselines/reference/logicalOrOperatorWithEveryType.types @@ -187,8 +187,8 @@ var rc5 = a5 || a3; // void || number is void | number >a3 : number var rc6 = a6 || a3; // enum || number is number ->rc6 : E | number ->a6 || a3 : E | number +>rc6 : number +>a6 || a3 : number >a6 : E >a3 : number @@ -349,8 +349,8 @@ var rg2 = a2 || a6; // boolean || enum is boolean | enum >a6 : E var rg3 = a3 || a6; // number || enum is number ->rg3 : number | E ->a3 || a6 : number | E +>rg3 : number +>a3 || a6 : number >a3 : number >a6 : E diff --git a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types index df8f6cac6db..f887ad7ae14 100644 --- a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types +++ b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types @@ -107,8 +107,8 @@ function fn3u : U var r3 = t || { a: '' }; ->r3 : T | { a: string; } ->t || { a: '' } : T | { a: string; } +>r3 : { a: string; } +>t || { a: '' } : { a: string; } >t : T >{ a: '' } : { a: string; } >a : string diff --git a/tests/baselines/reference/memberVariableDeclarations1.types b/tests/baselines/reference/memberVariableDeclarations1.types index 9aec8aa12aa..b7ec0fbaba0 100644 --- a/tests/baselines/reference/memberVariableDeclarations1.types +++ b/tests/baselines/reference/memberVariableDeclarations1.types @@ -49,21 +49,21 @@ class Employee2 { this.retired = false; >this.retired = false : boolean >this.retired : boolean ->this : Employee2 +>this : this >retired : boolean >false : boolean this.manager = null; >this.manager = null : null >this.manager : Employee ->this : Employee2 +>this : this >manager : Employee >null : null this.reports = []; >this.reports = [] : undefined[] >this.reports : Employee[] ->this : Employee2 +>this : this >reports : Employee[] >[] : undefined[] } diff --git a/tests/baselines/reference/methodInAmbientClass1.errors.txt b/tests/baselines/reference/methodInAmbientClass1.errors.txt index 05183378a85..2badd839270 100644 --- a/tests/baselines/reference/methodInAmbientClass1.errors.txt +++ b/tests/baselines/reference/methodInAmbientClass1.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/methodInAmbientClass1.ts(2,12): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. -tests/cases/compiler/methodInAmbientClass1.ts(2,20): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/compiler/methodInAmbientClass1.ts(2,20): error TS1183: An implementation cannot be declared in ambient contexts. ==== tests/cases/compiler/methodInAmbientClass1.ts (2 errors) ==== @@ -8,6 +8,6 @@ tests/cases/compiler/methodInAmbientClass1.ts(2,20): error TS1184: An implementa ~~~~~~~ !!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. } } \ No newline at end of file diff --git a/tests/baselines/reference/missingAndExcessProperties.errors.txt b/tests/baselines/reference/missingAndExcessProperties.errors.txt new file mode 100644 index 00000000000..0ee69d9af30 --- /dev/null +++ b/tests/baselines/reference/missingAndExcessProperties.errors.txt @@ -0,0 +1,97 @@ +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(3,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(4,11): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(4,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(5,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(5,14): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(6,11): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(6,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(12,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(13,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(14,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(20,17): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(20,23): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(21,25): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(22,19): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(29,14): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(29,20): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(30,22): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'. +tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts(31,16): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: number; }'. + + +==== tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts (20 errors) ==== + // Missing properties + function f1() { + var { x, y } = {}; + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + var { x = 1, y } = {}; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'. + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + var { x, y = 1 } = {}; + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'. + var { x = 1, y = 1 } = {}; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'. + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'. + } + + // Missing properties + function f2() { + var x: number, y: number; + ({ x, y } = {}); + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + ({ x: x = 1, y } = {}); + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + ({ x, y: y = 1 } = {}); + ~ +!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + ({ x: x = 1, y: y = 1 } = {}); + } + + // Excess properties + function f3() { + var { } = { x: 0, y: 0 }; + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. + var { x } = { x: 0, y: 0 }; + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. + var { y } = { x: 0, y: 0 }; + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. + var { x, y } = { x: 0, y: 0 }; + } + + // Excess properties + function f4() { + var x: number, y: number; + ({ } = { x: 0, y: 0 }); + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{}'. + ({ x } = { x: 0, y: 0 }); + ~ +!!! error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; }'. + ({ y } = { x: 0, y: 0 }); + ~ +!!! error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: number; }'. + ({ x, y } = { x: 0, y: 0 }); + } + \ No newline at end of file diff --git a/tests/baselines/reference/missingAndExcessProperties.js b/tests/baselines/reference/missingAndExcessProperties.js new file mode 100644 index 00000000000..b9fcadd9519 --- /dev/null +++ b/tests/baselines/reference/missingAndExcessProperties.js @@ -0,0 +1,69 @@ +//// [missingAndExcessProperties.ts] +// Missing properties +function f1() { + var { x, y } = {}; + var { x = 1, y } = {}; + var { x, y = 1 } = {}; + var { x = 1, y = 1 } = {}; +} + +// Missing properties +function f2() { + var x: number, y: number; + ({ x, y } = {}); + ({ x: x = 1, y } = {}); + ({ x, y: y = 1 } = {}); + ({ x: x = 1, y: y = 1 } = {}); +} + +// Excess properties +function f3() { + var { } = { x: 0, y: 0 }; + var { x } = { x: 0, y: 0 }; + var { y } = { x: 0, y: 0 }; + var { x, y } = { x: 0, y: 0 }; +} + +// Excess properties +function f4() { + var x: number, y: number; + ({ } = { x: 0, y: 0 }); + ({ x } = { x: 0, y: 0 }); + ({ y } = { x: 0, y: 0 }); + ({ x, y } = { x: 0, y: 0 }); +} + + +//// [missingAndExcessProperties.js] +// Missing properties +function f1() { + var _a = {}, x = _a.x, y = _a.y; + var _b = {}, _c = _b.x, x = _c === void 0 ? 1 : _c, y = _b.y; + var _d = {}, x = _d.x, _e = _d.y, y = _e === void 0 ? 1 : _e; + var _f = {}, _g = _f.x, x = _g === void 0 ? 1 : _g, _h = _f.y, y = _h === void 0 ? 1 : _h; +} +// Missing properties +function f2() { + var x, y; + (_a = {}, x = _a.x, y = _a.y, _a); + (_b = {}, _c = _b.x, x = _c === void 0 ? 1 : _c, y = _b.y, _b); + (_d = {}, x = _d.x, _e = _d.y, y = _e === void 0 ? 1 : _e, _d); + (_f = {}, _g = _f.x, x = _g === void 0 ? 1 : _g, _h = _f.y, y = _h === void 0 ? 1 : _h, _f); + var _a, _b, _c, _d, _e, _f, _g, _h; +} +// Excess properties +function f3() { + var _a = { x: 0, y: 0 }; + var x = { x: 0, y: 0 }.x; + var y = { x: 0, y: 0 }.y; + var _b = { x: 0, y: 0 }, x = _b.x, y = _b.y; +} +// Excess properties +function f4() { + var x, y; + ({ x: 0, y: 0 }); + (_a = { x: 0, y: 0 }, x = _a.x, _a); + (_b = { x: 0, y: 0 }, y = _b.y, _b); + (_c = { x: 0, y: 0 }, x = _c.x, y = _c.y, _c); + var _a, _b, _c; +} diff --git a/tests/baselines/reference/missingDecoratorType.js b/tests/baselines/reference/missingDecoratorType.js index ad6be3a646e..04af1be9d7b 100644 --- a/tests/baselines/reference/missingDecoratorType.js +++ b/tests/baselines/reference/missingDecoratorType.js @@ -24,20 +24,17 @@ class C { //// [a.js] //// [b.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C = (function () { function C() { } C.prototype.method = function () { }; - Object.defineProperty(C.prototype, "method", - __decorate([ - dec - ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); + __decorate([ + dec + ], C.prototype, "method", null); return C; })(); diff --git a/tests/baselines/reference/missingPropertiesOfClassExpression.errors.txt b/tests/baselines/reference/missingPropertiesOfClassExpression.errors.txt new file mode 100644 index 00000000000..b7331a68271 --- /dev/null +++ b/tests/baselines/reference/missingPropertiesOfClassExpression.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/missingPropertiesOfClassExpression.ts(1,52): error TS2339: Property 'y' does not exist on type '(Anonymous class)'. + + +==== tests/cases/compiler/missingPropertiesOfClassExpression.ts (1 errors) ==== + class George extends class { reset() { return this.y; } } { + ~ +!!! error TS2339: Property 'y' does not exist on type '(Anonymous class)'. + constructor() { + super(); + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/missingPropertiesOfClassExpression.js b/tests/baselines/reference/missingPropertiesOfClassExpression.js new file mode 100644 index 00000000000..f427da20f0c --- /dev/null +++ b/tests/baselines/reference/missingPropertiesOfClassExpression.js @@ -0,0 +1,26 @@ +//// [missingPropertiesOfClassExpression.ts] +class George extends class { reset() { return this.y; } } { + constructor() { + super(); + } +} + + +//// [missingPropertiesOfClassExpression.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var George = (function (_super) { + __extends(George, _super); + function George() { + _super.call(this); + } + return George; +})((function () { + function class_1() { + } + class_1.prototype.reset = function () { return this.y; }; + return class_1; +})()); diff --git a/tests/baselines/reference/missingSelf.types b/tests/baselines/reference/missingSelf.types index 5b46bf85db1..ea275e41a0c 100644 --- a/tests/baselines/reference/missingSelf.types +++ b/tests/baselines/reference/missingSelf.types @@ -6,7 +6,7 @@ class CalcButton >a : () => void >this.onClick() : void >this.onClick : () => void ->this : CalcButton +>this : this >onClick : () => void public onClick() { } @@ -21,7 +21,7 @@ class CalcButton2 >() => this.onClick() : () => void >this.onClick() : void >this.onClick : () => void ->this : CalcButton2 +>this : this >onClick : () => void public onClick() { } diff --git a/tests/baselines/reference/moduleInTypePosition1.errors.txt b/tests/baselines/reference/moduleInTypePosition1.errors.txt index a5b5076e172..ff5fa2da4eb 100644 --- a/tests/baselines/reference/moduleInTypePosition1.errors.txt +++ b/tests/baselines/reference/moduleInTypePosition1.errors.txt @@ -3,7 +3,7 @@ tests/cases/compiler/moduleInTypePosition1_1.ts(3,14): error TS2304: Cannot find ==== tests/cases/compiler/moduleInTypePosition1_1.ts (1 errors) ==== /// - import WinJS = require('moduleInTypePosition1_0'); + import WinJS = require('./moduleInTypePosition1_0'); var x = (w1: WinJS) => { }; ~~~~~ !!! error TS2304: Cannot find name 'WinJS'. diff --git a/tests/baselines/reference/moduleInTypePosition1.js b/tests/baselines/reference/moduleInTypePosition1.js index 972bbae63d1..bcce5f74632 100644 --- a/tests/baselines/reference/moduleInTypePosition1.js +++ b/tests/baselines/reference/moduleInTypePosition1.js @@ -7,7 +7,7 @@ export class Promise { //// [moduleInTypePosition1_1.ts] /// -import WinJS = require('moduleInTypePosition1_0'); +import WinJS = require('./moduleInTypePosition1_0'); var x = (w1: WinJS) => { }; diff --git a/tests/baselines/reference/moduleMemberWithoutTypeAnnotation1.types b/tests/baselines/reference/moduleMemberWithoutTypeAnnotation1.types index ebe70d8e6fb..c308f535a7a 100644 --- a/tests/baselines/reference/moduleMemberWithoutTypeAnnotation1.types +++ b/tests/baselines/reference/moduleMemberWithoutTypeAnnotation1.types @@ -71,7 +71,7 @@ module TypeScript { >positionedToken : any >this.findTokenInternal(null, position, 0) : any >this.findTokenInternal : (x: any, y: any, z: any) => any ->this : SyntaxNode +>this : this >findTokenInternal : (x: any, y: any, z: any) => any >null : null >position : number @@ -114,7 +114,7 @@ module TypeScript.Syntax { >new PositionedToken(parent, this, fullStart) : PositionedToken >PositionedToken : typeof PositionedToken >parent : PositionedElement ->this : VariableWidthTokenWithTrailingTrivia +>this : this >fullStart : number } } diff --git a/tests/baselines/reference/modulePrologueAMD.js b/tests/baselines/reference/modulePrologueAMD.js new file mode 100644 index 00000000000..904808b9f6b --- /dev/null +++ b/tests/baselines/reference/modulePrologueAMD.js @@ -0,0 +1,15 @@ +//// [modulePrologueAMD.ts] +"use strict"; + +export class Foo {} + +//// [modulePrologueAMD.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var Foo = (function () { + function Foo() { + } + return Foo; + })(); + exports.Foo = Foo; +}); diff --git a/tests/baselines/reference/modulePrologueAMD.symbols b/tests/baselines/reference/modulePrologueAMD.symbols new file mode 100644 index 00000000000..d6bb74d951a --- /dev/null +++ b/tests/baselines/reference/modulePrologueAMD.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/modulePrologueAMD.ts === +"use strict"; + +export class Foo {} +>Foo : Symbol(Foo, Decl(modulePrologueAMD.ts, 0, 13)) + diff --git a/tests/baselines/reference/modulePrologueAMD.types b/tests/baselines/reference/modulePrologueAMD.types new file mode 100644 index 00000000000..b57b5a8bf2f --- /dev/null +++ b/tests/baselines/reference/modulePrologueAMD.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/modulePrologueAMD.ts === +"use strict"; +>"use strict" : string + +export class Foo {} +>Foo : Foo + diff --git a/tests/baselines/reference/modulePrologueCommonjs.js b/tests/baselines/reference/modulePrologueCommonjs.js new file mode 100644 index 00000000000..67b704a3650 --- /dev/null +++ b/tests/baselines/reference/modulePrologueCommonjs.js @@ -0,0 +1,13 @@ +//// [modulePrologueCommonjs.ts] +"use strict"; + +export class Foo {} + +//// [modulePrologueCommonjs.js] +"use strict"; +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +exports.Foo = Foo; diff --git a/tests/baselines/reference/modulePrologueCommonjs.symbols b/tests/baselines/reference/modulePrologueCommonjs.symbols new file mode 100644 index 00000000000..01a2da349f2 --- /dev/null +++ b/tests/baselines/reference/modulePrologueCommonjs.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/modulePrologueCommonjs.ts === +"use strict"; + +export class Foo {} +>Foo : Symbol(Foo, Decl(modulePrologueCommonjs.ts, 0, 13)) + diff --git a/tests/baselines/reference/modulePrologueCommonjs.types b/tests/baselines/reference/modulePrologueCommonjs.types new file mode 100644 index 00000000000..5d76532b3e4 --- /dev/null +++ b/tests/baselines/reference/modulePrologueCommonjs.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/modulePrologueCommonjs.ts === +"use strict"; +>"use strict" : string + +export class Foo {} +>Foo : Foo + diff --git a/tests/baselines/reference/modulePrologueES6.js b/tests/baselines/reference/modulePrologueES6.js new file mode 100644 index 00000000000..e34f85c9d8d --- /dev/null +++ b/tests/baselines/reference/modulePrologueES6.js @@ -0,0 +1,9 @@ +//// [modulePrologueES6.ts] +"use strict"; + +export class Foo {} + +//// [modulePrologueES6.js] +"use strict"; +export class Foo { +} diff --git a/tests/baselines/reference/modulePrologueES6.symbols b/tests/baselines/reference/modulePrologueES6.symbols new file mode 100644 index 00000000000..f45180a6998 --- /dev/null +++ b/tests/baselines/reference/modulePrologueES6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/modulePrologueES6.ts === +"use strict"; + +export class Foo {} +>Foo : Symbol(Foo, Decl(modulePrologueES6.ts, 0, 13)) + diff --git a/tests/baselines/reference/modulePrologueES6.types b/tests/baselines/reference/modulePrologueES6.types new file mode 100644 index 00000000000..5f09a60ac6a --- /dev/null +++ b/tests/baselines/reference/modulePrologueES6.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/modulePrologueES6.ts === +"use strict"; +>"use strict" : string + +export class Foo {} +>Foo : Foo + diff --git a/tests/baselines/reference/modulePrologueSystem.js b/tests/baselines/reference/modulePrologueSystem.js new file mode 100644 index 00000000000..91703d1c7fb --- /dev/null +++ b/tests/baselines/reference/modulePrologueSystem.js @@ -0,0 +1,21 @@ +//// [modulePrologueSystem.ts] +"use strict"; + +export class Foo {} + +//// [modulePrologueSystem.js] +System.register([], function(exports_1) { + "use strict"; + var Foo; + return { + setters:[], + execute: function() { + Foo = (function () { + function Foo() { + } + return Foo; + })(); + exports_1("Foo", Foo); + } + } +}); diff --git a/tests/baselines/reference/modulePrologueSystem.symbols b/tests/baselines/reference/modulePrologueSystem.symbols new file mode 100644 index 00000000000..9e5ed9d452a --- /dev/null +++ b/tests/baselines/reference/modulePrologueSystem.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/modulePrologueSystem.ts === +"use strict"; + +export class Foo {} +>Foo : Symbol(Foo, Decl(modulePrologueSystem.ts, 0, 13)) + diff --git a/tests/baselines/reference/modulePrologueSystem.types b/tests/baselines/reference/modulePrologueSystem.types new file mode 100644 index 00000000000..ac0d52e4a2b --- /dev/null +++ b/tests/baselines/reference/modulePrologueSystem.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/modulePrologueSystem.ts === +"use strict"; +>"use strict" : string + +export class Foo {} +>Foo : Foo + diff --git a/tests/baselines/reference/modulePrologueUmd.js b/tests/baselines/reference/modulePrologueUmd.js new file mode 100644 index 00000000000..65803af6cad --- /dev/null +++ b/tests/baselines/reference/modulePrologueUmd.js @@ -0,0 +1,22 @@ +//// [modulePrologueUmd.ts] +"use strict"; + +export class Foo {} + +//// [modulePrologueUmd.js] +(function (factory) { + if (typeof module === 'object' && typeof module.exports === 'object') { + var v = factory(require, exports); if (v !== undefined) module.exports = v; + } + else if (typeof define === 'function' && define.amd) { + define(["require", "exports"], factory); + } +})(function (require, exports) { + "use strict"; + var Foo = (function () { + function Foo() { + } + return Foo; + })(); + exports.Foo = Foo; +}); diff --git a/tests/baselines/reference/modulePrologueUmd.symbols b/tests/baselines/reference/modulePrologueUmd.symbols new file mode 100644 index 00000000000..3b015b2ea44 --- /dev/null +++ b/tests/baselines/reference/modulePrologueUmd.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/modulePrologueUmd.ts === +"use strict"; + +export class Foo {} +>Foo : Symbol(Foo, Decl(modulePrologueUmd.ts, 0, 13)) + diff --git a/tests/baselines/reference/modulePrologueUmd.types b/tests/baselines/reference/modulePrologueUmd.types new file mode 100644 index 00000000000..2a1064da8e2 --- /dev/null +++ b/tests/baselines/reference/modulePrologueUmd.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/modulePrologueUmd.ts === +"use strict"; +>"use strict" : string + +export class Foo {} +>Foo : Foo + diff --git a/tests/baselines/reference/moduleResolutionNoResolve.js b/tests/baselines/reference/moduleResolutionNoResolve.js new file mode 100644 index 00000000000..9f0537a5ad5 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionNoResolve.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/moduleResolutionNoResolve.ts] //// + +//// [a.ts] + +import a = require('./b'); + +//// [b.ts] +export var c = ''; + + +//// [a.js] +//// [b.js] +exports.c = ''; diff --git a/tests/baselines/reference/moduleResolutionNoResolve.symbols b/tests/baselines/reference/moduleResolutionNoResolve.symbols new file mode 100644 index 00000000000..17ccfeab496 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionNoResolve.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.ts === + +import a = require('./b'); +>a : Symbol(a, Decl(a.ts, 0, 0)) + +=== tests/cases/compiler/b.ts === +export var c = ''; +>c : Symbol(c, Decl(b.ts, 0, 10)) + diff --git a/tests/baselines/reference/moduleResolutionNoResolve.types b/tests/baselines/reference/moduleResolutionNoResolve.types new file mode 100644 index 00000000000..3e96ed2b197 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionNoResolve.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/a.ts === + +import a = require('./b'); +>a : typeof a + +=== tests/cases/compiler/b.ts === +export var c = ''; +>c : string +>'' : string + diff --git a/tests/baselines/reference/multiImportExport.js b/tests/baselines/reference/multiImportExport.js index 06d81f7e984..5a03f3c848d 100644 --- a/tests/baselines/reference/multiImportExport.js +++ b/tests/baselines/reference/multiImportExport.js @@ -5,10 +5,10 @@ import Drawing = require('./Drawing'); var addr = new Drawing.Math.Adder(); //// [Drawing.ts] -export import Math = require('Math/Math') +export import Math = require('./Math/Math') //// [Math.ts] -import Adder = require('Math/Adder'); +import Adder = require('./Adder'); var Math = { Adder:Adder @@ -35,13 +35,13 @@ var Adder = (function () { })(); module.exports = Adder; //// [Math.js] -var Adder = require('Math/Adder'); +var Adder = require('./Adder'); var Math = { Adder: Adder }; module.exports = Math; //// [Drawing.js] -exports.Math = require('Math/Math'); +exports.Math = require('./Math/Math'); //// [consumer.js] var Drawing = require('./Drawing'); var addr = new Drawing.Math.Adder(); @@ -53,11 +53,11 @@ declare class Adder { } export = Adder; //// [Math.d.ts] -import Adder = require('Math/Adder'); +import Adder = require('./Adder'); declare var Math: { Adder: typeof Adder; }; export = Math; //// [Drawing.d.ts] -export import Math = require('Math/Math'); +export import Math = require('./Math/Math'); //// [consumer.d.ts] diff --git a/tests/baselines/reference/multiImportExport.symbols b/tests/baselines/reference/multiImportExport.symbols index 6601571aabc..45b59752b2a 100644 --- a/tests/baselines/reference/multiImportExport.symbols +++ b/tests/baselines/reference/multiImportExport.symbols @@ -11,11 +11,11 @@ var addr = new Drawing.Math.Adder(); >Adder : Symbol(Adder, Decl(Math.ts, 2, 12)) === tests/cases/compiler/Drawing.ts === -export import Math = require('Math/Math') +export import Math = require('./Math/Math') >Math : Symbol(Math, Decl(Drawing.ts, 0, 0)) === tests/cases/compiler/Math/Math.ts === -import Adder = require('Math/Adder'); +import Adder = require('./Adder'); >Adder : Symbol(Adder, Decl(Math.ts, 0, 0)) var Math = { diff --git a/tests/baselines/reference/multiImportExport.types b/tests/baselines/reference/multiImportExport.types index aac60aaee90..4a94eef9865 100644 --- a/tests/baselines/reference/multiImportExport.types +++ b/tests/baselines/reference/multiImportExport.types @@ -12,11 +12,11 @@ var addr = new Drawing.Math.Adder(); >Adder : typeof Adder === tests/cases/compiler/Drawing.ts === -export import Math = require('Math/Math') +export import Math = require('./Math/Math') >Math : { Adder: typeof Adder; } === tests/cases/compiler/Math/Math.ts === -import Adder = require('Math/Adder'); +import Adder = require('./Adder'); >Adder : typeof Adder var Math = { diff --git a/tests/baselines/reference/multipleDefaultExports01.errors.txt b/tests/baselines/reference/multipleDefaultExports01.errors.txt index 7b49afe1a4e..72898d474e8 100644 --- a/tests/baselines/reference/multipleDefaultExports01.errors.txt +++ b/tests/baselines/reference/multipleDefaultExports01.errors.txt @@ -24,7 +24,7 @@ tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typ !!! error TS2300: Duplicate identifier 'default'. ==== tests/cases/conformance/es6/modules/m2.ts (1 errors) ==== - import Entity from "m1" + import Entity from "./m1" Entity(); ~~~~~~~~ diff --git a/tests/baselines/reference/multipleDefaultExports01.js b/tests/baselines/reference/multipleDefaultExports01.js index e633cf69f55..b1ff3b4353c 100644 --- a/tests/baselines/reference/multipleDefaultExports01.js +++ b/tests/baselines/reference/multipleDefaultExports01.js @@ -14,7 +14,7 @@ var x = 10; export default x; //// [m2.ts] -import Entity from "m1" +import Entity from "./m1" Entity(); @@ -34,5 +34,5 @@ var x = 10; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = x; //// [m2.js] -var m1_1 = require("m1"); +var m1_1 = require("./m1"); m1_1.default(); diff --git a/tests/baselines/reference/multipleDefaultExports02.errors.txt b/tests/baselines/reference/multipleDefaultExports02.errors.txt index 51220ecfae2..235f8f7c3e3 100644 --- a/tests/baselines/reference/multipleDefaultExports02.errors.txt +++ b/tests/baselines/reference/multipleDefaultExports02.errors.txt @@ -17,6 +17,6 @@ tests/cases/conformance/es6/modules/m1.ts(6,25): error TS2393: Duplicate functio } ==== tests/cases/conformance/es6/modules/m2.ts (0 errors) ==== - import Entity from "m1" + import Entity from "./m1" Entity(); \ No newline at end of file diff --git a/tests/baselines/reference/multipleDefaultExports02.js b/tests/baselines/reference/multipleDefaultExports02.js index 3d1b84ff6a6..7b43c43ee60 100644 --- a/tests/baselines/reference/multipleDefaultExports02.js +++ b/tests/baselines/reference/multipleDefaultExports02.js @@ -11,7 +11,7 @@ export default function bar() { } //// [m2.ts] -import Entity from "m1" +import Entity from "./m1" Entity(); @@ -25,5 +25,5 @@ function bar() { Object.defineProperty(exports, "__esModule", { value: true }); exports.default = bar; //// [m2.js] -var m1_1 = require("m1"); +var m1_1 = require("./m1"); m1_1.default(); diff --git a/tests/baselines/reference/nestedSelf.types b/tests/baselines/reference/nestedSelf.types index 2c8f3f41dd6..ed7f084246a 100644 --- a/tests/baselines/reference/nestedSelf.types +++ b/tests/baselines/reference/nestedSelf.types @@ -22,7 +22,7 @@ module M { >x : number >this.n * x : number >this.n : number ->this : C +>this : this >n : number >x : number } diff --git a/tests/baselines/reference/newArrays.types b/tests/baselines/reference/newArrays.types index 4600f5efaf8..3c0928a46ea 100644 --- a/tests/baselines/reference/newArrays.types +++ b/tests/baselines/reference/newArrays.types @@ -26,17 +26,17 @@ module M { this.fa = new Array(this.x * this.y); >this.fa = new Array(this.x * this.y) : Foo[] >this.fa : Foo[] ->this : Gar +>this : this >fa : Foo[] >new Array(this.x * this.y) : Foo[] >Array : ArrayConstructor >Foo : Foo >this.x * this.y : number >this.x : number ->this : Gar +>this : this >x : number >this.y : number ->this : Gar +>this : this >y : number } } diff --git a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols index 4bddb6a1f71..9144d725efb 100644 --- a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols +++ b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols @@ -8,7 +8,7 @@ regexMatchList.forEach(match => ''.replace(match, '')); >regexMatchList : Symbol(regexMatchList, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 1, 3)) >forEach : Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95)) >match : Symbol(match, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 2, 23)) ->''.replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) ->replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) +>''.replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) +>replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) >match : Symbol(match, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 2, 23)) diff --git a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types index 81fd614cb0e..afe2ff7bd22 100644 --- a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types +++ b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types @@ -14,9 +14,9 @@ regexMatchList.forEach(match => ''.replace(match, '')); >match => ''.replace(match, '') : (match: string) => string >match : string >''.replace(match, '') : string ->''.replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>''.replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >'' : string ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >match : string >'' : string diff --git a/tests/baselines/reference/nodeResolution1.js b/tests/baselines/reference/nodeResolution1.js new file mode 100644 index 00000000000..3516342e3b2 --- /dev/null +++ b/tests/baselines/reference/nodeResolution1.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/nodeResolution1.ts] //// + +//// [a.ts] + +export var x = 1; + +//// [b.ts] +import y = require("./a"); + +//// [a.js] +exports.x = 1; +//// [b.js] diff --git a/tests/baselines/reference/nodeResolution1.symbols b/tests/baselines/reference/nodeResolution1.symbols new file mode 100644 index 00000000000..0cc98206e90 --- /dev/null +++ b/tests/baselines/reference/nodeResolution1.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/b.ts === +import y = require("./a"); +>y : Symbol(y, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/a.ts === + +export var x = 1; +>x : Symbol(x, Decl(a.ts, 1, 10)) + diff --git a/tests/baselines/reference/nodeResolution1.types b/tests/baselines/reference/nodeResolution1.types new file mode 100644 index 00000000000..4f29acfcc03 --- /dev/null +++ b/tests/baselines/reference/nodeResolution1.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/b.ts === +import y = require("./a"); +>y : typeof y + +=== tests/cases/compiler/a.ts === + +export var x = 1; +>x : number +>1 : number + diff --git a/tests/baselines/reference/nodeResolution2.js b/tests/baselines/reference/nodeResolution2.js new file mode 100644 index 00000000000..a5935461088 --- /dev/null +++ b/tests/baselines/reference/nodeResolution2.js @@ -0,0 +1,10 @@ +//// [tests/cases/compiler/nodeResolution2.ts] //// + +//// [a.d.ts] + +export var x: number; + +//// [b.ts] +import y = require("a"); + +//// [b.js] diff --git a/tests/baselines/reference/nodeResolution2.symbols b/tests/baselines/reference/nodeResolution2.symbols new file mode 100644 index 00000000000..643d285e7b8 --- /dev/null +++ b/tests/baselines/reference/nodeResolution2.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/b.ts === +import y = require("a"); +>y : Symbol(y, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/node_modules/a.d.ts === + +export var x: number; +>x : Symbol(x, Decl(a.d.ts, 1, 10)) + diff --git a/tests/baselines/reference/nodeResolution2.types b/tests/baselines/reference/nodeResolution2.types new file mode 100644 index 00000000000..896af7f8bda --- /dev/null +++ b/tests/baselines/reference/nodeResolution2.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/b.ts === +import y = require("a"); +>y : typeof y + +=== tests/cases/compiler/node_modules/a.d.ts === + +export var x: number; +>x : number + diff --git a/tests/baselines/reference/nodeResolution3.js b/tests/baselines/reference/nodeResolution3.js new file mode 100644 index 00000000000..6e0ec608323 --- /dev/null +++ b/tests/baselines/reference/nodeResolution3.js @@ -0,0 +1,10 @@ +//// [tests/cases/compiler/nodeResolution3.ts] //// + +//// [index.d.ts] + +export var x: number; + +//// [a.ts] +import y = require("b"); + +//// [a.js] diff --git a/tests/baselines/reference/nodeResolution3.symbols b/tests/baselines/reference/nodeResolution3.symbols new file mode 100644 index 00000000000..0fca588676f --- /dev/null +++ b/tests/baselines/reference/nodeResolution3.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.ts === +import y = require("b"); +>y : Symbol(y, Decl(a.ts, 0, 0)) + +=== tests/cases/compiler/node_modules/b/index.d.ts === + +export var x: number; +>x : Symbol(x, Decl(index.d.ts, 1, 10)) + diff --git a/tests/baselines/reference/nodeResolution3.types b/tests/baselines/reference/nodeResolution3.types new file mode 100644 index 00000000000..82a1ccb27d3 --- /dev/null +++ b/tests/baselines/reference/nodeResolution3.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.ts === +import y = require("b"); +>y : typeof y + +=== tests/cases/compiler/node_modules/b/index.d.ts === + +export var x: number; +>x : number + diff --git a/tests/baselines/reference/nodeResolution4.js b/tests/baselines/reference/nodeResolution4.js new file mode 100644 index 00000000000..0965c257da9 --- /dev/null +++ b/tests/baselines/reference/nodeResolution4.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/nodeResolution4.ts] //// + +//// [ref.ts] + +var x = 1; + +//// [a.ts] +/// +export var y; + +//// [b.ts] +import y = require("./a"); + +//// [ref.js] +var x = 1; +//// [a.js] +//// [b.js] diff --git a/tests/baselines/reference/nodeResolution4.symbols b/tests/baselines/reference/nodeResolution4.symbols new file mode 100644 index 00000000000..b8e0b59284a --- /dev/null +++ b/tests/baselines/reference/nodeResolution4.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/b.ts === +import y = require("./a"); +>y : Symbol(y, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/ref.ts === + +var x = 1; +>x : Symbol(x, Decl(ref.ts, 1, 3)) + +=== tests/cases/compiler/a.ts === +/// +export var y; +>y : Symbol(y, Decl(a.ts, 1, 10)) + diff --git a/tests/baselines/reference/nodeResolution4.types b/tests/baselines/reference/nodeResolution4.types new file mode 100644 index 00000000000..b273b203bde --- /dev/null +++ b/tests/baselines/reference/nodeResolution4.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/b.ts === +import y = require("./a"); +>y : typeof y + +=== tests/cases/compiler/ref.ts === + +var x = 1; +>x : number +>1 : number + +=== tests/cases/compiler/a.ts === +/// +export var y; +>y : any + diff --git a/tests/baselines/reference/nodeResolution5.errors.txt b/tests/baselines/reference/nodeResolution5.errors.txt new file mode 100644 index 00000000000..c36cce45b6d --- /dev/null +++ b/tests/baselines/reference/nodeResolution5.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/b.ts(1,20): error TS2656: Exported external package typings file 'tests/cases/compiler/node_modules/a.d.ts' is not a module. Please contact the package author to update the package definition. + + +==== tests/cases/compiler/b.ts (1 errors) ==== + import y = require("a"); + ~~~ +!!! error TS2656: Exported external package typings file 'a.d.ts' is not a module. Please contact the package author to update the package definition. + +==== tests/cases/compiler/node_modules/a.d.ts (0 errors) ==== + + declare module "a" { + var x: number; + } + \ No newline at end of file diff --git a/tests/baselines/reference/nodeResolution5.js b/tests/baselines/reference/nodeResolution5.js new file mode 100644 index 00000000000..2bc009c1522 --- /dev/null +++ b/tests/baselines/reference/nodeResolution5.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/nodeResolution5.ts] //// + +//// [a.d.ts] + +declare module "a" { + var x: number; +} + +//// [b.ts] +import y = require("a"); + + +//// [b.js] diff --git a/tests/baselines/reference/nodeResolution6.errors.txt b/tests/baselines/reference/nodeResolution6.errors.txt new file mode 100644 index 00000000000..6bab6e34389 --- /dev/null +++ b/tests/baselines/reference/nodeResolution6.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/node_modules/a.d.ts(1,1): error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition. + + +==== tests/cases/compiler/b.ts (0 errors) ==== + import y = require("a"); + +==== tests/cases/compiler/node_modules/ref.ts (0 errors) ==== + + var x = 1; + +==== tests/cases/compiler/node_modules/a.d.ts (1 errors) ==== + /// + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition. + export declare var y; + + \ No newline at end of file diff --git a/tests/baselines/reference/nodeResolution6.js b/tests/baselines/reference/nodeResolution6.js new file mode 100644 index 00000000000..140edd61f5a --- /dev/null +++ b/tests/baselines/reference/nodeResolution6.js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/nodeResolution6.ts] //// + +//// [ref.ts] + +var x = 1; + +//// [a.d.ts] +/// +export declare var y; + + +//// [b.ts] +import y = require("a"); + + +//// [ref.js] +var x = 1; +//// [b.js] diff --git a/tests/baselines/reference/nodeResolution7.errors.txt b/tests/baselines/reference/nodeResolution7.errors.txt new file mode 100644 index 00000000000..f9e8ef7ac0f --- /dev/null +++ b/tests/baselines/reference/nodeResolution7.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/b.ts(1,20): error TS2656: Exported external package typings file 'tests/cases/compiler/node_modules/a/index.d.ts' is not a module. Please contact the package author to update the package definition. + + +==== tests/cases/compiler/b.ts (1 errors) ==== + import y = require("a"); + ~~~ +!!! error TS2656: Exported external package typings file 'index.d.ts' is not a module. Please contact the package author to update the package definition. + +==== tests/cases/compiler/node_modules/a/index.d.ts (0 errors) ==== + + declare module "a" { + var x: number; + } + \ No newline at end of file diff --git a/tests/baselines/reference/nodeResolution7.js b/tests/baselines/reference/nodeResolution7.js new file mode 100644 index 00000000000..abfbbad52a6 --- /dev/null +++ b/tests/baselines/reference/nodeResolution7.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/nodeResolution7.ts] //// + +//// [index.d.ts] + +declare module "a" { + var x: number; +} + +//// [b.ts] +import y = require("a"); + + +//// [b.js] diff --git a/tests/baselines/reference/nodeResolution8.errors.txt b/tests/baselines/reference/nodeResolution8.errors.txt new file mode 100644 index 00000000000..3f14a4313c8 --- /dev/null +++ b/tests/baselines/reference/nodeResolution8.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/node_modules/a/index.d.ts(1,1): error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition. + + +==== tests/cases/compiler/b.ts (0 errors) ==== + import y = require("a"); +==== tests/cases/compiler/node_modules/a/ref.ts (0 errors) ==== + + var x = 1; + +==== tests/cases/compiler/node_modules/a/index.d.ts (1 errors) ==== + /// + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition. + export declare var y; + + \ No newline at end of file diff --git a/tests/baselines/reference/nodeResolution8.js b/tests/baselines/reference/nodeResolution8.js new file mode 100644 index 00000000000..aa67f4bf9cc --- /dev/null +++ b/tests/baselines/reference/nodeResolution8.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/nodeResolution8.ts] //// + +//// [ref.ts] + +var x = 1; + +//// [index.d.ts] +/// +export declare var y; + + +//// [b.ts] +import y = require("a"); + +//// [ref.js] +var x = 1; +//// [b.js] diff --git a/tests/baselines/reference/nonIterableRestElement1.types b/tests/baselines/reference/nonIterableRestElement1.types index 4973b67d4ae..a15fe5afd38 100644 --- a/tests/baselines/reference/nonIterableRestElement1.types +++ b/tests/baselines/reference/nonIterableRestElement1.types @@ -5,7 +5,7 @@ var c = {}; [...c] = ["", 0]; >[...c] = ["", 0] : (string | number)[] ->[...c] : {}[] +>[...c] : undefined[] >...c : any >c : {} >["", 0] : (string | number)[] diff --git a/tests/baselines/reference/nonIterableRestElement2.types b/tests/baselines/reference/nonIterableRestElement2.types index e6d84d5297e..c39a592d2e6 100644 --- a/tests/baselines/reference/nonIterableRestElement2.types +++ b/tests/baselines/reference/nonIterableRestElement2.types @@ -5,7 +5,7 @@ var c = {}; [...c] = ["", 0]; >[...c] = ["", 0] : (string | number)[] ->[...c] : {}[] +>[...c] : undefined[] >...c : any >c : {} >["", 0] : (string | number)[] diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt index 71e164d5d62..ff18160e9a5 100644 --- a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations2.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(16,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(25,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(34,5): error TS2412: Property '3.0' of type 'number' is not assignable to numeric index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: A | B | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations2.ts(39,5): error TS2322: Type '{ [x: number]: A | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. Index signatures are incompatible. - Type 'A | B | number' is not assignable to type 'A'. + Type 'A | number' is not assignable to type 'A'. Type 'number' is not assignable to type 'A'. @@ -54,9 +54,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerCo // error var b: { [x: number]: A } = { ~ -!!! error TS2322: Type '{ [x: number]: A | B | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. +!!! error TS2322: Type '{ [x: number]: A | number; 1.0: A; 2.0: B; 3.0: number; "2.5": B; "4.0": string; }' is not assignable to type '{ [x: number]: A; }'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'A | B | number' is not assignable to type 'A'. +!!! error TS2322: Type 'A | number' is not assignable to type 'A'. !!! error TS2322: Type 'number' is not assignable to type 'A'. 1.0: new A(), 2.0: new B(), diff --git a/tests/baselines/reference/objectCreationOfElementAccessExpression.errors.txt b/tests/baselines/reference/objectCreationOfElementAccessExpression.errors.txt index b2f3bd9d824..ef50db9e4e5 100644 --- a/tests/baselines/reference/objectCreationOfElementAccessExpression.errors.txt +++ b/tests/baselines/reference/objectCreationOfElementAccessExpression.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/objectCreationOfElementAccessExpression.ts(53,17): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +tests/cases/compiler/objectCreationOfElementAccessExpression.ts(53,17): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/compiler/objectCreationOfElementAccessExpression.ts(53,63): error TS2348: Value of type 'typeof Cookie' is not callable. Did you mean to include 'new'? -tests/cases/compiler/objectCreationOfElementAccessExpression.ts(54,33): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +tests/cases/compiler/objectCreationOfElementAccessExpression.ts(54,33): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/compiler/objectCreationOfElementAccessExpression.ts(54,79): error TS2348: Value of type 'typeof Cookie' is not callable. Did you mean to include 'new'? @@ -59,12 +59,12 @@ tests/cases/compiler/objectCreationOfElementAccessExpression.ts(54,79): error TS // ElementAccessExpressions can only contain one expression. There should be a parse error here. var foods = new PetFood[new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true)]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2348: Value of type 'typeof Cookie' is not callable. Did you mean to include 'new'? var foods2: MonsterFood[] = new PetFood[new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true)]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2348: Value of type 'typeof Cookie' is not callable. Did you mean to include 'new'? \ No newline at end of file diff --git a/tests/baselines/reference/objectIndexer.types b/tests/baselines/reference/objectIndexer.types index 7b42ea51b56..3dcd7bcb77e 100644 --- a/tests/baselines/reference/objectIndexer.types +++ b/tests/baselines/reference/objectIndexer.types @@ -25,7 +25,7 @@ class Emitter { this.listeners = {}; >this.listeners = {} : { [x: string]: undefined; } >this.listeners : IMap ->this : Emitter +>this : this >listeners : IMap >{} : { [x: string]: undefined; } } diff --git a/tests/baselines/reference/objectLitStructuralTypeMismatch.errors.txt b/tests/baselines/reference/objectLitStructuralTypeMismatch.errors.txt index 465c4d6d9f6..1b79e4db5ad 100644 --- a/tests/baselines/reference/objectLitStructuralTypeMismatch.errors.txt +++ b/tests/baselines/reference/objectLitStructuralTypeMismatch.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/objectLitStructuralTypeMismatch.ts(2,5): error TS2322: Type '{ b: number; }' is not assignable to type '{ a: number; }'. +tests/cases/compiler/objectLitStructuralTypeMismatch.ts(2,27): error TS2322: Type '{ b: number; }' is not assignable to type '{ a: number; }'. Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. ==== tests/cases/compiler/objectLitStructuralTypeMismatch.ts (1 errors) ==== // Shouldn't compile var x: { a: number; } = { b: 5 }; - ~ + ~~~~ !!! error TS2322: Type '{ b: number; }' is not assignable to type '{ a: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt index 149aca43a42..fb2cbdaf649 100644 --- a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt +++ b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(8,4): error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(8,6): error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I'. Object literal may only specify known properties, and 'hello' does not exist in type 'I'. -tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(10,4): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(10,17): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I'. Object literal may only specify known properties, and 'what' does not exist in type 'I'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(11,4): error TS2345: Argument of type '{ toString: (s: string) => string; }' is not assignable to parameter of type 'I'. Property 'value' is missing in type '{ toString: (s: string) => string; }'. @@ -18,12 +18,12 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping.ts(13,36): error T function f2(args: I) { } f2({ hello: 1 }) // error - ~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I'. !!! error TS2345: Object literal may only specify known properties, and 'hello' does not exist in type 'I'. f2({ value: '' }) // missing toString satisfied by Object's member f2({ value: '', what: 1 }) // missing toString satisfied by Object's member - ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~ !!! error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I'. !!! error TS2345: Object literal may only specify known properties, and 'what' does not exist in type 'I'. f2({ toString: (s) => s }) // error, missing property value from ArgsString diff --git a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt index 367a676abc6..b967b227809 100644 --- a/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt +++ b/tests/baselines/reference/objectLiteralFunctionArgContextualTyping2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(8,4): error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I2'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(8,6): error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I2'. Object literal may only specify known properties, and 'hello' does not exist in type 'I2'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(9,4): error TS2345: Argument of type '{ value: string; }' is not assignable to parameter of type 'I2'. Property 'doStuff' is missing in type '{ value: string; }'. -tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(10,4): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'. +tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(10,17): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'. Object literal may only specify known properties, and 'what' does not exist in type 'I2'. tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(11,4): error TS2345: Argument of type '{ toString: (s: any) => any; }' is not assignable to parameter of type 'I2'. Property 'value' is missing in type '{ toString: (s: any) => any; }'. @@ -21,7 +21,7 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,4): error T function f2(args: I2) { } f2({ hello: 1 }) - ~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I2'. !!! error TS2345: Object literal may only specify known properties, and 'hello' does not exist in type 'I2'. f2({ value: '' }) @@ -29,7 +29,7 @@ tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,4): error T !!! error TS2345: Argument of type '{ value: string; }' is not assignable to parameter of type 'I2'. !!! error TS2345: Property 'doStuff' is missing in type '{ value: string; }'. f2({ value: '', what: 1 }) - ~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~ !!! error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'. !!! error TS2345: Object literal may only specify known properties, and 'what' does not exist in type 'I2'. f2({ toString: (s) => s }) diff --git a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt index edb6d031b1f..c35e49f02a3 100644 --- a/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralIndexerErrors.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ [x: string]: B | A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. Index signatures are incompatible. Type 'A' is not assignable to type 'B'. @@ -18,7 +18,7 @@ tests/cases/compiler/objectLiteralIndexerErrors.ts(13,5): error TS2322: Type '{ var o1: { [s: string]: A;[n: number]: B; } = { x: b, 0: a }; // both indexers are A ~~ -!!! error TS2322: Type '{ [x: string]: B | A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. +!!! error TS2322: Type '{ [x: string]: A; [x: number]: A; 0: A; x: B; }' is not assignable to type '{ [s: string]: A; [n: number]: B; }'. !!! error TS2322: Index signatures are incompatible. !!! error TS2322: Type 'A' is not assignable to type 'B'. o1 = { x: c, 0: a }; // string indexer is any, number indexer is A \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralIndexers.types b/tests/baselines/reference/objectLiteralIndexers.types index 55cec857c70..d5add00ebaf 100644 --- a/tests/baselines/reference/objectLiteralIndexers.types +++ b/tests/baselines/reference/objectLiteralIndexers.types @@ -31,7 +31,7 @@ var o1: { [s: string]: A;[n: number]: B; } = { x: a, 0: b }; // string indexer i >A : A >n : number >B : B ->{ x: a, 0: b } : { [x: string]: A | B; [x: number]: B; 0: B; x: A; } +>{ x: a, 0: b } : { [x: string]: A; [x: number]: B; 0: B; x: A; } >x : A >a : A >b : B diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt index d00a8ddf074..50839d5e56b 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(4,5): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(4,43): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,16): error TS1131: Property or signature expected. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'. @@ -16,7 +16,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr var name: string = "my name"; var person: { b: string; id: number } = { name, id }; // error - ~~~~~~ + ~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. var person1: { name, id }; // error: can't use short-hand property assignment in type position diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt index f6f4f625c45..b4f695c835d 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(4,5): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. +tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(4,43): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(5,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'. Types of property 'name' are incompatible. @@ -16,7 +16,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr var name: string = "my name"; var person: { b: string; id: number } = { name, id }; // error - ~~~~~~ + ~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. function bar(name: string, id: number): { name: number, id: string } { return { name, id }; } // error diff --git a/tests/baselines/reference/orderMattersForSignatureGroupIdentity.errors.txt b/tests/baselines/reference/orderMattersForSignatureGroupIdentity.errors.txt index 47401a7ae8b..f108f0ea92d 100644 --- a/tests/baselines/reference/orderMattersForSignatureGroupIdentity.errors.txt +++ b/tests/baselines/reference/orderMattersForSignatureGroupIdentity.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(19,3): error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. +tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(19,5): error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. Object literal may only specify known properties, and 's' does not exist in type '{ n: number; }'. tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(22,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'w' must be of type 'A', but here has type 'C'. -tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(24,3): error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. +tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(24,5): error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. Object literal may only specify known properties, and 's' does not exist in type '{ n: number; }'. @@ -25,7 +25,7 @@ tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(24,3): error TS234 var v: B; v({ s: "", n: 0 }).toLowerCase(); - ~~~~~~~~~~~~~~~ + ~~~~~ !!! error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. !!! error TS2345: Object literal may only specify known properties, and 's' does not exist in type '{ n: number; }'. @@ -35,6 +35,6 @@ tests/cases/compiler/orderMattersForSignatureGroupIdentity.ts(24,3): error TS234 !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'w' must be of type 'A', but here has type 'C'. w({ s: "", n: 0 }).toLowerCase(); - ~~~~~~~~~~~~~~~ + ~~~~~ !!! error TS2345: Argument of type '{ s: string; n: number; }' is not assignable to parameter of type '{ n: number; }'. !!! error TS2345: Object literal may only specify known properties, and 's' does not exist in type '{ n: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/out-flag2.js b/tests/baselines/reference/out-flag2.js new file mode 100644 index 00000000000..e2a30f169e3 --- /dev/null +++ b/tests/baselines/reference/out-flag2.js @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/out-flag2.ts] //// + +//// [a.ts] + +class A { } + +//// [b.ts] +class B { } + +//// [c.js] +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +//# sourceMappingURL=c.js.map + +//// [c.d.ts] +declare class A { +} +declare class B { +} diff --git a/tests/baselines/reference/out-flag2.js.map b/tests/baselines/reference/out-flag2.js.map new file mode 100644 index 00000000000..c1523e75784 --- /dev/null +++ b/tests/baselines/reference/out-flag2.js.map @@ -0,0 +1,2 @@ +//// [c.js.map] +{"version":3,"file":"c.js","sourceRoot":"","sources":["tests/cases/compiler/a.ts","tests/cases/compiler/b.ts"],"names":["A","A.constructor","B","B.constructor"],"mappings":"AACA;IAAAA;IAAUC,CAACA;IAADD,QAACA;AAADA,CAACA,AAAX,IAAW;ACDX;IAAAE;IAAUC,CAACA;IAADD,QAACA;AAADA,CAACA,AAAX,IAAW"} \ No newline at end of file diff --git a/tests/baselines/reference/out-flag2.sourcemap.txt b/tests/baselines/reference/out-flag2.sourcemap.txt new file mode 100644 index 00000000000..6a67e61bc91 --- /dev/null +++ b/tests/baselines/reference/out-flag2.sourcemap.txt @@ -0,0 +1,104 @@ +=================================================================== +JsFile: c.js +mapUrl: c.js.map +sourceRoot: +sources: tests/cases/compiler/a.ts,tests/cases/compiler/b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:c.js +sourceFile:tests/cases/compiler/a.ts +------------------------------------------------------------------- +>>>var A = (function () { +1 > +2 >^^^^^^^^^^^^^^^^^^^-> +1 > + > +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(2, 5) Source(2, 1) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->class A { +2 > } +1->Emitted(3, 5) Source(2, 11) + SourceIndex(0) name (A.constructor) +2 >Emitted(3, 6) Source(2, 12) + SourceIndex(0) name (A.constructor) +--- +>>> return A; +1->^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(4, 5) Source(2, 11) + SourceIndex(0) name (A) +2 >Emitted(4, 13) Source(2, 12) + SourceIndex(0) name (A) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class A { } +1 >Emitted(5, 1) Source(2, 11) + SourceIndex(0) name (A) +2 >Emitted(5, 2) Source(2, 12) + SourceIndex(0) name (A) +3 >Emitted(5, 2) Source(2, 1) + SourceIndex(0) +4 >Emitted(5, 6) Source(2, 12) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:c.js +sourceFile:tests/cases/compiler/b.ts +------------------------------------------------------------------- +>>>var B = (function () { +1-> +2 >^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(6, 1) Source(1, 1) + SourceIndex(1) +--- +>>> function B() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(7, 5) Source(1, 1) + SourceIndex(1) name (B) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->class B { +2 > } +1->Emitted(8, 5) Source(1, 11) + SourceIndex(1) name (B.constructor) +2 >Emitted(8, 6) Source(1, 12) + SourceIndex(1) name (B.constructor) +--- +>>> return B; +1->^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(9, 5) Source(1, 11) + SourceIndex(1) name (B) +2 >Emitted(9, 13) Source(1, 12) + SourceIndex(1) name (B) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class B { } +1 >Emitted(10, 1) Source(1, 11) + SourceIndex(1) name (B) +2 >Emitted(10, 2) Source(1, 12) + SourceIndex(1) name (B) +3 >Emitted(10, 2) Source(1, 1) + SourceIndex(1) +4 >Emitted(10, 6) Source(1, 12) + SourceIndex(1) +--- +>>>//# sourceMappingURL=c.js.map \ No newline at end of file diff --git a/tests/baselines/reference/out-flag2.symbols b/tests/baselines/reference/out-flag2.symbols new file mode 100644 index 00000000000..1bca057c580 --- /dev/null +++ b/tests/baselines/reference/out-flag2.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.ts === + +class A { } +>A : Symbol(A, Decl(a.ts, 0, 0)) + +=== tests/cases/compiler/b.ts === +class B { } +>B : Symbol(B, Decl(b.ts, 0, 0)) + diff --git a/tests/baselines/reference/out-flag2.types b/tests/baselines/reference/out-flag2.types new file mode 100644 index 00000000000..5a13642f99f --- /dev/null +++ b/tests/baselines/reference/out-flag2.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.ts === + +class A { } +>A : A + +=== tests/cases/compiler/b.ts === +class B { } +>B : B + diff --git a/tests/baselines/reference/out-flag3.errors.txt b/tests/baselines/reference/out-flag3.errors.txt new file mode 100644 index 00000000000..6b7dda7c962 --- /dev/null +++ b/tests/baselines/reference/out-flag3.errors.txt @@ -0,0 +1,12 @@ +error TS5053: Option 'out' cannot be specified with option 'outFile'. + + +!!! error TS5053: Option 'out' cannot be specified with option 'outFile'. +==== tests/cases/compiler/a.ts (0 errors) ==== + + // --out and --outFile error + + class A { } + +==== tests/cases/compiler/b.ts (0 errors) ==== + class B { } \ No newline at end of file diff --git a/tests/baselines/reference/out-flag3.js b/tests/baselines/reference/out-flag3.js new file mode 100644 index 00000000000..8327c3429d3 --- /dev/null +++ b/tests/baselines/reference/out-flag3.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/out-flag3.ts] //// + +//// [a.ts] + +// --out and --outFile error + +class A { } + +//// [b.ts] +class B { } + +//// [c.js] +// --out and --outFile error +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +//# sourceMappingURL=c.js.map + +//// [c.d.ts] +declare class A { +} +declare class B { +} diff --git a/tests/baselines/reference/out-flag3.js.map b/tests/baselines/reference/out-flag3.js.map new file mode 100644 index 00000000000..a52d66589c7 --- /dev/null +++ b/tests/baselines/reference/out-flag3.js.map @@ -0,0 +1,2 @@ +//// [c.js.map] +{"version":3,"file":"c.js","sourceRoot":"","sources":["tests/cases/compiler/a.ts","tests/cases/compiler/b.ts"],"names":["A","A.constructor","B","B.constructor"],"mappings":"AACA,4BAA4B;AAE5B;IAAAA;IAAUC,CAACA;IAADD,QAACA;AAADA,CAACA,AAAX,IAAW;ACHX;IAAAE;IAAUC,CAACA;IAADD,QAACA;AAADA,CAACA,AAAX,IAAW"} \ No newline at end of file diff --git a/tests/baselines/reference/out-flag3.sourcemap.txt b/tests/baselines/reference/out-flag3.sourcemap.txt new file mode 100644 index 00000000000..c30c9f63020 --- /dev/null +++ b/tests/baselines/reference/out-flag3.sourcemap.txt @@ -0,0 +1,114 @@ +=================================================================== +JsFile: c.js +mapUrl: c.js.map +sourceRoot: +sources: tests/cases/compiler/a.ts,tests/cases/compiler/b.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:c.js +sourceFile:tests/cases/compiler/a.ts +------------------------------------------------------------------- +>>>// --out and --outFile error +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > + > +2 >// --out and --outFile error +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 29) Source(2, 29) + SourceIndex(0) +--- +>>>var A = (function () { +1 > +2 >^^^^^^^^^^^^^^^^^^^-> +1 > + > + > +1 >Emitted(2, 1) Source(4, 1) + SourceIndex(0) +--- +>>> function A() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(3, 5) Source(4, 1) + SourceIndex(0) name (A) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->class A { +2 > } +1->Emitted(4, 5) Source(4, 11) + SourceIndex(0) name (A.constructor) +2 >Emitted(4, 6) Source(4, 12) + SourceIndex(0) name (A.constructor) +--- +>>> return A; +1->^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(5, 5) Source(4, 11) + SourceIndex(0) name (A) +2 >Emitted(5, 13) Source(4, 12) + SourceIndex(0) name (A) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class A { } +1 >Emitted(6, 1) Source(4, 11) + SourceIndex(0) name (A) +2 >Emitted(6, 2) Source(4, 12) + SourceIndex(0) name (A) +3 >Emitted(6, 2) Source(4, 1) + SourceIndex(0) +4 >Emitted(6, 6) Source(4, 12) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:c.js +sourceFile:tests/cases/compiler/b.ts +------------------------------------------------------------------- +>>>var B = (function () { +1-> +2 >^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(7, 1) Source(1, 1) + SourceIndex(1) +--- +>>> function B() { +1->^^^^ +2 > ^^-> +1-> +1->Emitted(8, 5) Source(1, 1) + SourceIndex(1) name (B) +--- +>>> } +1->^^^^ +2 > ^ +3 > ^^^^^^^^^-> +1->class B { +2 > } +1->Emitted(9, 5) Source(1, 11) + SourceIndex(1) name (B.constructor) +2 >Emitted(9, 6) Source(1, 12) + SourceIndex(1) name (B.constructor) +--- +>>> return B; +1->^^^^ +2 > ^^^^^^^^ +1-> +2 > } +1->Emitted(10, 5) Source(1, 11) + SourceIndex(1) name (B) +2 >Emitted(10, 13) Source(1, 12) + SourceIndex(1) name (B) +--- +>>>})(); +1 > +2 >^ +3 > +4 > ^^^^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +4 > class B { } +1 >Emitted(11, 1) Source(1, 11) + SourceIndex(1) name (B) +2 >Emitted(11, 2) Source(1, 12) + SourceIndex(1) name (B) +3 >Emitted(11, 2) Source(1, 1) + SourceIndex(1) +4 >Emitted(11, 6) Source(1, 12) + SourceIndex(1) +--- +>>>//# sourceMappingURL=c.js.map \ No newline at end of file diff --git a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.symbols b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.symbols index 815f977d605..bc2bd0785b9 100644 --- a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.symbols +++ b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.symbols @@ -14,9 +14,9 @@ module Bugs { var result= message.replace(/\{(\d+)\}/g, function(match, ...rest) { >result : Symbol(result, Decl(overloadResolutionOverNonCTLambdas.ts, 6, 7)) ->message.replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) +>message.replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) >message : Symbol(message, Decl(overloadResolutionOverNonCTLambdas.ts, 5, 16)) ->replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) +>replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) >match : Symbol(match, Decl(overloadResolutionOverNonCTLambdas.ts, 6, 55)) >rest : Symbol(rest, Decl(overloadResolutionOverNonCTLambdas.ts, 6, 61)) diff --git a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types index f62bb4e8373..066015389d2 100644 --- a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types +++ b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types @@ -15,9 +15,9 @@ module Bugs { var result= message.replace(/\{(\d+)\}/g, function(match, ...rest) { >result : string >message.replace(/\{(\d+)\}/g, function(match, ...rest) { var index= rest[0]; return typeof args[index] !== 'undefined' ? args[index] : match; }) : string ->message.replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>message.replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >message : string ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/\{(\d+)\}/g : RegExp >function(match, ...rest) { var index= rest[0]; return typeof args[index] !== 'undefined' ? args[index] : match; } : (match: string, ...rest: any[]) => any >match : string diff --git a/tests/baselines/reference/parenthesizedContexualTyping1.types b/tests/baselines/reference/parenthesizedContexualTyping1.types index 1423901a28f..61ec1a24ec5 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping1.types +++ b/tests/baselines/reference/parenthesizedContexualTyping1.types @@ -149,8 +149,8 @@ var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10); >i : number >fun((Math.random() < 0.5 ? x => x : x => undefined), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? x => x : x => undefined) : ((x: number) => number) | ((x: number) => any) ->Math.random() < 0.5 ? x => x : x => undefined : ((x: number) => number) | ((x: number) => any) +>(Math.random() < 0.5 ? x => x : x => undefined) : (x: number) => any +>Math.random() < 0.5 ? x => x : x => undefined : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -169,8 +169,8 @@ var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10); >j : number >fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => x) : (x => undefined)) : ((x: number) => number) | ((x: number) => any) ->Math.random() < 0.5 ? (x => x) : (x => undefined) : ((x: number) => number) | ((x: number) => any) +>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any +>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -191,8 +191,8 @@ var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10); >k : number >fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => x) : (x => undefined)) : ((x: number) => number) | ((x: number) => any) ->Math.random() < 0.5 ? (x => x) : (x => undefined) : ((x: number) => number) | ((x: number) => any) +>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any +>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -216,9 +216,9 @@ var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x) >l : number >fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10) : number >fun : { (g: (x: T) => T, x: T): T; (g: (x: T) => T, h: (y: T) => T, x: T): T; } ->((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : ((x: number) => number) | ((x: number) => any) ->(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : ((x: number) => number) | ((x: number) => any) ->Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : ((x: number) => number) | ((x: number) => any) +>((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : (x: number) => any +>(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : (x: number) => any +>Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : (x: number) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number diff --git a/tests/baselines/reference/parenthesizedContexualTyping2.types b/tests/baselines/reference/parenthesizedContexualTyping2.types index 344933ea1fc..a055f2f1bbd 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping2.types +++ b/tests/baselines/reference/parenthesizedContexualTyping2.types @@ -186,8 +186,8 @@ var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x >i : number >fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined), 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->(Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>(Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined : (x: (p: T) => T) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -209,8 +209,8 @@ var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >j : number >fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -234,8 +234,8 @@ var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >k : number >fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number @@ -265,9 +265,9 @@ var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) >l : number >fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10) : number >fun : { (f: (x: (p: T) => T) => (p: T) => T, x: T): T; (f: (x: (p: T) => T) => (p: T) => T, g: (x: (p: T) => T) => (p: T) => T, x: T): T; } ->((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->(Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined))) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) ->Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)) : ((x: (p: T) => T) => (p: T) => T) | ((x: (p: T) => T) => any) +>((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))) : (x: (p: T) => T) => any +>(Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined))) : (x: (p: T) => T) => any +>Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)) : (x: (p: T) => T) => any >Math.random() < 0.5 : boolean >Math.random() : number >Math.random : () => number diff --git a/tests/baselines/reference/parserClassDeclaration18.errors.txt b/tests/baselines/reference/parserClassDeclaration18.errors.txt index ce4b01d5253..b5f656190bd 100644 --- a/tests/baselines/reference/parserClassDeclaration18.errors.txt +++ b/tests/baselines/reference/parserClassDeclaration18.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration18.ts(4,25): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration18.ts(4,25): error TS1183: An implementation cannot be declared in ambient contexts. ==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration18.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclarat constructor(n: number); constructor(x: any) { ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. } bar1():void; } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName30.errors.txt b/tests/baselines/reference/parserComputedPropertyName30.errors.txt index de5bc8d7dde..94ab013c8be 100644 --- a/tests/baselines/reference/parserComputedPropertyName30.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName30.errors.txt @@ -1,14 +1,20 @@ +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts(3,5): error TS1164: Computed property names are not allowed in enums. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts(3,11): error TS2304: Cannot find name 'id'. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts(4,5): error TS1005: ',' expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts(4,5): error TS1164: Computed property names are not allowed in enums. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName30.ts (4 errors) ==== enum E { // no ASI, comma expected [e] = id++ + ~~~ +!!! error TS1164: Computed property names are not allowed in enums. ~~ !!! error TS2304: Cannot find name 'id'. [e2] = 1 ~ !!! error TS1005: ',' expected. + ~~~~ +!!! error TS1164: Computed property names are not allowed in enums. } \ No newline at end of file diff --git a/tests/baselines/reference/parserConstructorDeclaration4.errors.txt b/tests/baselines/reference/parserConstructorDeclaration4.errors.txt index e851885f0ee..b5329a1cb47 100644 --- a/tests/baselines/reference/parserConstructorDeclaration4.errors.txt +++ b/tests/baselines/reference/parserConstructorDeclaration4.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts(2,3): error TS1031: 'declare' modifier cannot appear on a class element. -tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts(2,25): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts(2,25): error TS1183: An implementation cannot be declared in ambient contexts. ==== tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration4.ts (2 errors) ==== @@ -8,5 +8,5 @@ tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstru ~~~~~~~ !!! error TS1031: 'declare' modifier cannot appear on a class element. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. } \ No newline at end of file diff --git a/tests/baselines/reference/parserEnumDeclaration6.errors.txt b/tests/baselines/reference/parserEnumDeclaration6.errors.txt deleted file mode 100644 index b9d547c07f3..00000000000 --- a/tests/baselines/reference/parserEnumDeclaration6.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnumDeclaration6.ts(5,5): error TS1061: Enum member must have initializer. - - -==== tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnumDeclaration6.ts (1 errors) ==== - enum E { - A = 1, - B, - C = 1 << 1, - D, - ~ -!!! error TS1061: Enum member must have initializer. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserEnumDeclaration6.symbols b/tests/baselines/reference/parserEnumDeclaration6.symbols new file mode 100644 index 00000000000..325b236fd7e --- /dev/null +++ b/tests/baselines/reference/parserEnumDeclaration6.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnumDeclaration6.ts === +enum E { +>E : Symbol(E, Decl(parserEnumDeclaration6.ts, 0, 0)) + + A = 1, +>A : Symbol(E.A, Decl(parserEnumDeclaration6.ts, 0, 8)) + + B, +>B : Symbol(E.B, Decl(parserEnumDeclaration6.ts, 1, 10)) + + C = 1 << 1, +>C : Symbol(E.C, Decl(parserEnumDeclaration6.ts, 2, 6)) + + D, +>D : Symbol(E.D, Decl(parserEnumDeclaration6.ts, 3, 15)) +} diff --git a/tests/baselines/reference/parserEnumDeclaration6.types b/tests/baselines/reference/parserEnumDeclaration6.types new file mode 100644 index 00000000000..c13d66db41c --- /dev/null +++ b/tests/baselines/reference/parserEnumDeclaration6.types @@ -0,0 +1,20 @@ +=== tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnumDeclaration6.ts === +enum E { +>E : E + + A = 1, +>A : E +>1 : number + + B, +>B : E + + C = 1 << 1, +>C : E +>1 << 1 : number +>1 : number +>1 : number + + D, +>D : E +} diff --git a/tests/baselines/reference/parserFunctionDeclaration2.d.errors.txt b/tests/baselines/reference/parserFunctionDeclaration2.d.errors.txt index 9aee5f2b0e7..6f836544efc 100644 --- a/tests/baselines/reference/parserFunctionDeclaration2.d.errors.txt +++ b/tests/baselines/reference/parserFunctionDeclaration2.d.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.d.ts(1,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. -tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.d.ts(1,14): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.d.ts(1,14): error TS1183: An implementation cannot be declared in ambient contexts. ==== tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.d.ts (2 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDe ~~~~~~~~ !!! error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. } \ No newline at end of file diff --git a/tests/baselines/reference/parserFunctionDeclaration2.errors.txt b/tests/baselines/reference/parserFunctionDeclaration2.errors.txt index deb96553220..f69850a5210 100644 --- a/tests/baselines/reference/parserFunctionDeclaration2.errors.txt +++ b/tests/baselines/reference/parserFunctionDeclaration2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.ts(1,24): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.ts(1,24): error TS1183: An implementation cannot be declared in ambient contexts. ==== tests/cases/conformance/parser/ecmascript5/FunctionDeclarations/parserFunctionDeclaration2.ts (1 errors) ==== declare function Foo() { ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. } \ No newline at end of file diff --git a/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt b/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt index 12fb40ad232..402355919a0 100644 --- a/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt +++ b/tests/baselines/reference/parserMemberFunctionDeclaration5.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element. -tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,19): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,19): error TS1183: An implementation cannot be declared in ambient contexts. ==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts (2 errors) ==== @@ -8,5 +8,5 @@ tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemb ~~~~~~~ !!! error TS1031: 'declare' modifier cannot appear on a class element. ~ -!!! error TS1184: An implementation cannot be declared in ambient contexts. +!!! error TS1183: An implementation cannot be declared in ambient contexts. } \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolProperty1.symbols b/tests/baselines/reference/parserSymbolProperty1.symbols index 5d97b2d7a01..f21959df892 100644 --- a/tests/baselines/reference/parserSymbolProperty1.symbols +++ b/tests/baselines/reference/parserSymbolProperty1.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty1.ts, 0, 0)) [Symbol.iterator]: string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) } diff --git a/tests/baselines/reference/parserSymbolProperty2.symbols b/tests/baselines/reference/parserSymbolProperty2.symbols index 69764d70b45..9f43ba7b006 100644 --- a/tests/baselines/reference/parserSymbolProperty2.symbols +++ b/tests/baselines/reference/parserSymbolProperty2.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(parserSymbolProperty2.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty3.symbols b/tests/baselines/reference/parserSymbolProperty3.symbols index c42bb3abb83..e3a3b1d5609 100644 --- a/tests/baselines/reference/parserSymbolProperty3.symbols +++ b/tests/baselines/reference/parserSymbolProperty3.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty3.ts, 0, 0)) [Symbol.unscopables](): string; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty4.symbols b/tests/baselines/reference/parserSymbolProperty4.symbols index ba93afde837..ba0134e82a9 100644 --- a/tests/baselines/reference/parserSymbolProperty4.symbols +++ b/tests/baselines/reference/parserSymbolProperty4.symbols @@ -3,7 +3,7 @@ declare class C { >C : Symbol(C, Decl(parserSymbolProperty4.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty5.symbols b/tests/baselines/reference/parserSymbolProperty5.symbols index 4829677f516..970f8a0b753 100644 --- a/tests/baselines/reference/parserSymbolProperty5.symbols +++ b/tests/baselines/reference/parserSymbolProperty5.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty5.ts, 0, 0)) [Symbol.toPrimitive]: string; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty6.symbols b/tests/baselines/reference/parserSymbolProperty6.symbols index 793b925b382..29831fad7ef 100644 --- a/tests/baselines/reference/parserSymbolProperty6.symbols +++ b/tests/baselines/reference/parserSymbolProperty6.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty6.ts, 0, 0)) [Symbol.toStringTag]: string = ""; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty7.symbols b/tests/baselines/reference/parserSymbolProperty7.symbols index e1b85f2a3b9..8322d312839 100644 --- a/tests/baselines/reference/parserSymbolProperty7.symbols +++ b/tests/baselines/reference/parserSymbolProperty7.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(parserSymbolProperty7.ts, 0, 0)) [Symbol.toStringTag](): void { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) } diff --git a/tests/baselines/reference/parserSymbolProperty8.symbols b/tests/baselines/reference/parserSymbolProperty8.symbols index 05b002eb569..7c5dfbff7c6 100644 --- a/tests/baselines/reference/parserSymbolProperty8.symbols +++ b/tests/baselines/reference/parserSymbolProperty8.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty8.ts, 0, 3)) [Symbol.toPrimitive](): string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/parserSymbolProperty9.symbols b/tests/baselines/reference/parserSymbolProperty9.symbols index 774eb2dcc4b..7ee5e7e6998 100644 --- a/tests/baselines/reference/parserSymbolProperty9.symbols +++ b/tests/baselines/reference/parserSymbolProperty9.symbols @@ -3,7 +3,7 @@ var x: { >x : Symbol(x, Decl(parserSymbolProperty9.ts, 0, 3)) [Symbol.toPrimitive]: string ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/pinnedComments1.js b/tests/baselines/reference/pinnedComments1.js index c4b8b41fbd7..9ab2a147e6a 100644 --- a/tests/baselines/reference/pinnedComments1.js +++ b/tests/baselines/reference/pinnedComments1.js @@ -1,12 +1,19 @@ //// [pinnedComments1.ts] +/*!========= + Keep this pinned comment + ========= +*/ /* unpinned comment */ -/*! pinned comment */ +/*! pinned comment that need to be removed */ class C { } //// [pinnedComments1.js] -/*! pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ var C = (function () { function C() { } diff --git a/tests/baselines/reference/pinnedComments1.symbols b/tests/baselines/reference/pinnedComments1.symbols index 53d46ecbaf6..6ee37435dfa 100644 --- a/tests/baselines/reference/pinnedComments1.symbols +++ b/tests/baselines/reference/pinnedComments1.symbols @@ -1,7 +1,11 @@ === tests/cases/compiler/pinnedComments1.ts === +/*!========= + Keep this pinned comment + ========= +*/ /* unpinned comment */ -/*! pinned comment */ +/*! pinned comment that need to be removed */ class C { >C : Symbol(C, Decl(pinnedComments1.ts, 0, 0)) } diff --git a/tests/baselines/reference/pinnedComments1.types b/tests/baselines/reference/pinnedComments1.types index d55feb67659..df97cbdbec9 100644 --- a/tests/baselines/reference/pinnedComments1.types +++ b/tests/baselines/reference/pinnedComments1.types @@ -1,7 +1,11 @@ === tests/cases/compiler/pinnedComments1.ts === +/*!========= + Keep this pinned comment + ========= +*/ /* unpinned comment */ -/*! pinned comment */ +/*! pinned comment that need to be removed */ class C { >C : C } diff --git a/tests/baselines/reference/privacyCannotNameAccessorDeclFile.errors.txt b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.errors.txt index 578baa694fd..b5d0ea8223e 100644 --- a/tests/baselines/reference/privacyCannotNameAccessorDeclFile.errors.txt +++ b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.errors.txt @@ -9,7 +9,7 @@ tests/cases/compiler/privacyCannotNameAccessorDeclFile_consumer.ts(66,9): error ==== tests/cases/compiler/privacyCannotNameAccessorDeclFile_consumer.ts (8 errors) ==== - import exporter = require("privacyCannotNameAccessorDeclFile_exporter"); + import exporter = require("./privacyCannotNameAccessorDeclFile_exporter"); export class publicClassWithWithPrivateGetAccessorTypes { static get myPublicStaticMethod() { // Error ~~~~~~~~~~~~~~~~~~~~ @@ -144,7 +144,7 @@ tests/cases/compiler/privacyCannotNameAccessorDeclFile_consumer.ts(66,9): error ==== tests/cases/compiler/privacyCannotNameAccessorDeclFile_exporter.ts (0 errors) ==== /// - import Widgets = require("privacyCannotNameAccessorDeclFile_Widgets"); + import Widgets = require("./privacyCannotNameAccessorDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); diff --git a/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js index 0295e42e654..8c4108ea9e8 100644 --- a/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js +++ b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js @@ -35,7 +35,7 @@ export module SpecializedWidget { //// [privacyCannotNameAccessorDeclFile_exporter.ts] /// -import Widgets = require("privacyCannotNameAccessorDeclFile_Widgets"); +import Widgets = require("./privacyCannotNameAccessorDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); @@ -51,7 +51,7 @@ export function createExportedWidget4() { } //// [privacyCannotNameAccessorDeclFile_consumer.ts] -import exporter = require("privacyCannotNameAccessorDeclFile_exporter"); +import exporter = require("./privacyCannotNameAccessorDeclFile_exporter"); export class publicClassWithWithPrivateGetAccessorTypes { static get myPublicStaticMethod() { // Error return exporter.createExportedWidget1(); @@ -165,7 +165,7 @@ var SpecializedWidget; })(SpecializedWidget = exports.SpecializedWidget || (exports.SpecializedWidget = {})); //// [privacyCannotNameAccessorDeclFile_exporter.js] /// -var Widgets = require("privacyCannotNameAccessorDeclFile_Widgets"); +var Widgets = require("./privacyCannotNameAccessorDeclFile_Widgets"); var Widgets1 = require("GlobalWidgets"); function createExportedWidget1() { return Widgets.createWidget1(); @@ -184,7 +184,7 @@ function createExportedWidget4() { } exports.createExportedWidget4 = createExportedWidget4; //// [privacyCannotNameAccessorDeclFile_consumer.js] -var exporter = require("privacyCannotNameAccessorDeclFile_exporter"); +var exporter = require("./privacyCannotNameAccessorDeclFile_exporter"); var publicClassWithWithPrivateGetAccessorTypes = (function () { function publicClassWithWithPrivateGetAccessorTypes() { } @@ -403,7 +403,7 @@ export declare module SpecializedWidget { } //// [privacyCannotNameAccessorDeclFile_exporter.d.ts] /// -import Widgets = require("privacyCannotNameAccessorDeclFile_Widgets"); +import Widgets = require("./privacyCannotNameAccessorDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export declare function createExportedWidget1(): Widgets.Widget1; export declare function createExportedWidget2(): Widgets.SpecializedWidget.Widget2; diff --git a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.errors.txt b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.errors.txt index 7f155f0e454..e76474d2d33 100644 --- a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.errors.txt +++ b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.errors.txt @@ -13,7 +13,7 @@ tests/cases/compiler/privacyCannotNameVarTypeDeclFile_consumer.ts(38,12): error ==== tests/cases/compiler/privacyCannotNameVarTypeDeclFile_consumer.ts (12 errors) ==== - import exporter = require("privacyCannotNameVarTypeDeclFile_exporter"); + import exporter = require("./privacyCannotNameVarTypeDeclFile_exporter"); export class publicClassWithWithPrivatePropertyTypes { static myPublicStaticProperty = exporter.createExportedWidget1(); // Error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -120,7 +120,7 @@ tests/cases/compiler/privacyCannotNameVarTypeDeclFile_consumer.ts(38,12): error ==== tests/cases/compiler/privacyCannotNameVarTypeDeclFile_exporter.ts (0 errors) ==== /// - import Widgets = require("privacyCannotNameVarTypeDeclFile_Widgets"); + import Widgets = require("./privacyCannotNameVarTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); diff --git a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js index d1f04ee3cef..b40d1dc4980 100644 --- a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js +++ b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js @@ -36,7 +36,7 @@ export module SpecializedWidget { //// [privacyCannotNameVarTypeDeclFile_exporter.ts] /// -import Widgets = require("privacyCannotNameVarTypeDeclFile_Widgets"); +import Widgets = require("./privacyCannotNameVarTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); @@ -52,7 +52,7 @@ export function createExportedWidget4() { } //// [privacyCannotNameVarTypeDeclFile_consumer.ts] -import exporter = require("privacyCannotNameVarTypeDeclFile_exporter"); +import exporter = require("./privacyCannotNameVarTypeDeclFile_exporter"); export class publicClassWithWithPrivatePropertyTypes { static myPublicStaticProperty = exporter.createExportedWidget1(); // Error private static myPrivateStaticProperty = exporter.createExportedWidget1(); @@ -129,7 +129,7 @@ var SpecializedWidget; })(SpecializedWidget = exports.SpecializedWidget || (exports.SpecializedWidget = {})); //// [privacyCannotNameVarTypeDeclFile_exporter.js] /// -var Widgets = require("privacyCannotNameVarTypeDeclFile_Widgets"); +var Widgets = require("./privacyCannotNameVarTypeDeclFile_Widgets"); var Widgets1 = require("GlobalWidgets"); function createExportedWidget1() { return Widgets.createWidget1(); @@ -148,7 +148,7 @@ function createExportedWidget4() { } exports.createExportedWidget4 = createExportedWidget4; //// [privacyCannotNameVarTypeDeclFile_consumer.js] -var exporter = require("privacyCannotNameVarTypeDeclFile_exporter"); +var exporter = require("./privacyCannotNameVarTypeDeclFile_exporter"); var publicClassWithWithPrivatePropertyTypes = (function () { function publicClassWithWithPrivatePropertyTypes() { this.myPublicProperty = exporter.createExportedWidget1(); // Error @@ -231,7 +231,7 @@ export declare module SpecializedWidget { } //// [privacyCannotNameVarTypeDeclFile_exporter.d.ts] /// -import Widgets = require("privacyCannotNameVarTypeDeclFile_Widgets"); +import Widgets = require("./privacyCannotNameVarTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export declare function createExportedWidget1(): Widgets.Widget1; export declare function createExportedWidget2(): Widgets.SpecializedWidget.Widget2; diff --git a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.js b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.js index eeaea58e0ab..8ed0b3cfa1b 100644 --- a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.js +++ b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.js @@ -7,7 +7,7 @@ class Foo { } //// [privacyCheckExternalModuleExportAssignmentOfGenericClass_1.ts] -import Foo = require("privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); +import Foo = require("./privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); export = Bar; interface Bar { foo: Foo; @@ -31,7 +31,7 @@ declare class Foo { constructor(a: A); } //// [privacyCheckExternalModuleExportAssignmentOfGenericClass_1.d.ts] -import Foo = require("privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); +import Foo = require("./privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); export = Bar; interface Bar { foo: Foo; diff --git a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.symbols b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.symbols index fed3799f950..75ebd0bff0a 100644 --- a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.symbols +++ b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.symbols @@ -1,5 +1,5 @@ === tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_1.ts === -import Foo = require("privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); +import Foo = require("./privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); >Foo : Symbol(Foo, Decl(privacyCheckExternalModuleExportAssignmentOfGenericClass_1.ts, 0, 0)) export = Bar; diff --git a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.types b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.types index 2259b039c91..ebf2a0e3ff6 100644 --- a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.types +++ b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.types @@ -1,5 +1,5 @@ === tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_1.ts === -import Foo = require("privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); +import Foo = require("./privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); >Foo : typeof Foo export = Bar; diff --git a/tests/baselines/reference/privacyCheckOnTypeParameterReferenceInConstructorParameter.types b/tests/baselines/reference/privacyCheckOnTypeParameterReferenceInConstructorParameter.types index 2000b877abd..293585db7b0 100644 --- a/tests/baselines/reference/privacyCheckOnTypeParameterReferenceInConstructorParameter.types +++ b/tests/baselines/reference/privacyCheckOnTypeParameterReferenceInConstructorParameter.types @@ -10,10 +10,10 @@ export class A{ >T1 : T1 var child = new B(this); ->child : B> ->new B(this) : B> +>child : B +>new B(this) : B >B : typeof B ->this : A +>this : this } } diff --git a/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.errors.txt b/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.errors.txt index 1e221ccd70a..76fd8b4e80a 100644 --- a/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.errors.txt +++ b/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.errors.txt @@ -25,7 +25,7 @@ tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_consumer.ts( ==== tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_consumer.ts (24 errors) ==== - import exporter = require("privacyFunctionCannotNameParameterTypeDeclFile_exporter"); + import exporter = require("./privacyFunctionCannotNameParameterTypeDeclFile_exporter"); export class publicClassWithWithPrivateParmeterTypes { static myPublicStaticMethod(param = exporter.createExportedWidget1()) { // Error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -212,7 +212,7 @@ tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_consumer.ts( ==== tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_exporter.ts (0 errors) ==== /// - import Widgets = require("privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); + import Widgets = require("./privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); diff --git a/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.js b/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.js index 7acd56927c7..bf2d820e2ea 100644 --- a/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.js +++ b/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.js @@ -36,7 +36,7 @@ export module SpecializedWidget { //// [privacyFunctionCannotNameParameterTypeDeclFile_exporter.ts] /// -import Widgets = require("privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); +import Widgets = require("./privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); @@ -52,7 +52,7 @@ export function createExportedWidget4() { } //// [privacyFunctionCannotNameParameterTypeDeclFile_consumer.ts] -import exporter = require("privacyFunctionCannotNameParameterTypeDeclFile_exporter"); +import exporter = require("./privacyFunctionCannotNameParameterTypeDeclFile_exporter"); export class publicClassWithWithPrivateParmeterTypes { static myPublicStaticMethod(param = exporter.createExportedWidget1()) { // Error } @@ -185,7 +185,7 @@ var SpecializedWidget; })(SpecializedWidget = exports.SpecializedWidget || (exports.SpecializedWidget = {})); //// [privacyFunctionCannotNameParameterTypeDeclFile_exporter.js] /// -var Widgets = require("privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); +var Widgets = require("./privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); var Widgets1 = require("GlobalWidgets"); function createExportedWidget1() { return Widgets.createWidget1(); @@ -204,7 +204,7 @@ function createExportedWidget4() { } exports.createExportedWidget4 = createExportedWidget4; //// [privacyFunctionCannotNameParameterTypeDeclFile_consumer.js] -var exporter = require("privacyFunctionCannotNameParameterTypeDeclFile_exporter"); +var exporter = require("./privacyFunctionCannotNameParameterTypeDeclFile_exporter"); var publicClassWithWithPrivateParmeterTypes = (function () { function publicClassWithWithPrivateParmeterTypes(param, param1, param2) { if (param === void 0) { param = exporter.createExportedWidget1(); } @@ -417,7 +417,7 @@ export declare module SpecializedWidget { } //// [privacyFunctionCannotNameParameterTypeDeclFile_exporter.d.ts] /// -import Widgets = require("privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); +import Widgets = require("./privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export declare function createExportedWidget1(): Widgets.Widget1; export declare function createExportedWidget2(): Widgets.SpecializedWidget.Widget2; diff --git a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt index 4be9aec9abe..bc6229815f5 100644 --- a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt +++ b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt @@ -13,7 +13,7 @@ tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(86,17): error ==== tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts (12 errors) ==== - import exporter = require("privacyFunctionReturnTypeDeclFile_exporter"); + import exporter = require("./privacyFunctionReturnTypeDeclFile_exporter"); export class publicClassWithWithPrivateParmeterTypes { static myPublicStaticMethod() { // Error ~~~~~~~~~~~~~~~~~~~~ @@ -183,7 +183,7 @@ tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts(86,17): error ==== tests/cases/compiler/privacyFunctionReturnTypeDeclFile_exporter.ts (0 errors) ==== /// - import Widgets = require("privacyFunctionReturnTypeDeclFile_Widgets"); + import Widgets = require("./privacyFunctionReturnTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); diff --git a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.js b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.js index 5f822929a48..8de50f4ea8a 100644 --- a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.js +++ b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.js @@ -36,7 +36,7 @@ export module SpecializedWidget { //// [privacyFunctionReturnTypeDeclFile_exporter.ts] /// -import Widgets = require("privacyFunctionReturnTypeDeclFile_Widgets"); +import Widgets = require("./privacyFunctionReturnTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); @@ -52,7 +52,7 @@ export function createExportedWidget4() { } //// [privacyFunctionReturnTypeDeclFile_consumer.ts] -import exporter = require("privacyFunctionReturnTypeDeclFile_exporter"); +import exporter = require("./privacyFunctionReturnTypeDeclFile_exporter"); export class publicClassWithWithPrivateParmeterTypes { static myPublicStaticMethod() { // Error return exporter.createExportedWidget1(); @@ -192,7 +192,7 @@ var SpecializedWidget; })(SpecializedWidget = exports.SpecializedWidget || (exports.SpecializedWidget = {})); //// [privacyFunctionReturnTypeDeclFile_exporter.js] /// -var Widgets = require("privacyFunctionReturnTypeDeclFile_Widgets"); +var Widgets = require("./privacyFunctionReturnTypeDeclFile_Widgets"); var Widgets1 = require("GlobalWidgets"); function createExportedWidget1() { return Widgets.createWidget1(); @@ -211,7 +211,7 @@ function createExportedWidget4() { } exports.createExportedWidget4 = createExportedWidget4; //// [privacyFunctionReturnTypeDeclFile_consumer.js] -var exporter = require("privacyFunctionReturnTypeDeclFile_exporter"); +var exporter = require("./privacyFunctionReturnTypeDeclFile_exporter"); var publicClassWithWithPrivateParmeterTypes = (function () { function publicClassWithWithPrivateParmeterTypes() { } @@ -374,7 +374,7 @@ export declare module SpecializedWidget { } //// [privacyFunctionReturnTypeDeclFile_exporter.d.ts] /// -import Widgets = require("privacyFunctionReturnTypeDeclFile_Widgets"); +import Widgets = require("./privacyFunctionReturnTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export declare function createExportedWidget1(): Widgets.Widget1; export declare function createExportedWidget2(): Widgets.SpecializedWidget.Widget2; diff --git a/tests/baselines/reference/privacyGloImportParseErrors.errors.txt b/tests/baselines/reference/privacyGloImportParseErrors.errors.txt index d6d24ebcb30..236418a10ae 100644 --- a/tests/baselines/reference/privacyGloImportParseErrors.errors.txt +++ b/tests/baselines/reference/privacyGloImportParseErrors.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/privacyGloImportParseErrors.ts(22,27): error TS2435: Ambient modules cannot be nested in other modules. -tests/cases/compiler/privacyGloImportParseErrors.ts(30,20): error TS2435: Ambient modules cannot be nested in other modules. +tests/cases/compiler/privacyGloImportParseErrors.ts(22,27): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyGloImportParseErrors.ts(30,20): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyGloImportParseErrors.ts(49,29): error TS4000: Import declaration 'm1_im2_private' is using private name 'm1_M2_private'. tests/cases/compiler/privacyGloImportParseErrors.ts(59,37): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyGloImportParseErrors.ts(59,37): error TS2307: Cannot find module 'm1_M3_public'. @@ -11,9 +11,9 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(82,43): error TS1147: Import tests/cases/compiler/privacyGloImportParseErrors.ts(121,38): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyGloImportParseErrors.ts(125,45): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyGloImportParseErrors.ts(133,9): error TS1038: A 'declare' modifier cannot be used in an already ambient context. -tests/cases/compiler/privacyGloImportParseErrors.ts(133,24): error TS2435: Ambient modules cannot be nested in other modules. -tests/cases/compiler/privacyGloImportParseErrors.ts(138,16): error TS2435: Ambient modules cannot be nested in other modules. -tests/cases/compiler/privacyGloImportParseErrors.ts(141,12): error TS2435: Ambient modules cannot be nested in other modules. +tests/cases/compiler/privacyGloImportParseErrors.ts(133,24): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyGloImportParseErrors.ts(138,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyGloImportParseErrors.ts(141,12): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyGloImportParseErrors.ts(146,25): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyGloImportParseErrors.ts(149,29): error TS1147: Import declarations in a namespace cannot reference a module. @@ -42,7 +42,7 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(149,29): error TS1147: Impor export declare module "m1_M3_public" { ~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. export function f1(); export class c1 { } @@ -52,7 +52,7 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(149,29): error TS1147: Impor declare module "m1_M4_private" { ~~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. export function f1(); export class c1 { } @@ -179,19 +179,19 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(149,29): error TS1147: Impor ~~~~~~~ !!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. ~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. } } module m2 { module "abc2" { ~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. } } module "abc3" { ~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. } } diff --git a/tests/baselines/reference/privacyImportParseErrors.errors.txt b/tests/baselines/reference/privacyImportParseErrors.errors.txt index 06277c63b23..5bae45f405c 100644 --- a/tests/baselines/reference/privacyImportParseErrors.errors.txt +++ b/tests/baselines/reference/privacyImportParseErrors.errors.txt @@ -1,48 +1,48 @@ -tests/cases/compiler/privacyImportParseErrors.ts(22,27): error TS2435: Ambient modules cannot be nested in other modules. -tests/cases/compiler/privacyImportParseErrors.ts(30,20): error TS2435: Ambient modules cannot be nested in other modules. +tests/cases/compiler/privacyImportParseErrors.ts(22,27): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyImportParseErrors.ts(30,20): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyImportParseErrors.ts(59,37): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyImportParseErrors.ts(59,37): error TS2307: Cannot find module 'm1_M3_public'. tests/cases/compiler/privacyImportParseErrors.ts(69,37): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyImportParseErrors.ts(69,37): error TS2307: Cannot find module 'm1_M4_private'. tests/cases/compiler/privacyImportParseErrors.ts(81,43): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyImportParseErrors.ts(82,43): error TS1147: Import declarations in a namespace cannot reference a module. -tests/cases/compiler/privacyImportParseErrors.ts(106,27): error TS2435: Ambient modules cannot be nested in other modules. -tests/cases/compiler/privacyImportParseErrors.ts(114,20): error TS2435: Ambient modules cannot be nested in other modules. +tests/cases/compiler/privacyImportParseErrors.ts(106,27): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyImportParseErrors.ts(114,20): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyImportParseErrors.ts(143,37): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyImportParseErrors.ts(143,37): error TS2307: Cannot find module 'm2_M3_public'. tests/cases/compiler/privacyImportParseErrors.ts(153,37): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyImportParseErrors.ts(153,37): error TS2307: Cannot find module 'm2_M4_private'. tests/cases/compiler/privacyImportParseErrors.ts(166,43): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyImportParseErrors.ts(167,43): error TS1147: Import declarations in a namespace cannot reference a module. -tests/cases/compiler/privacyImportParseErrors.ts(180,23): error TS2435: Ambient modules cannot be nested in other modules. -tests/cases/compiler/privacyImportParseErrors.ts(198,23): error TS2435: Ambient modules cannot be nested in other modules. +tests/cases/compiler/privacyImportParseErrors.ts(180,23): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyImportParseErrors.ts(198,23): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyImportParseErrors.ts(218,34): error TS2307: Cannot find module 'glo_M2_public'. tests/cases/compiler/privacyImportParseErrors.ts(238,34): error TS2307: Cannot find module 'glo_M4_private'. tests/cases/compiler/privacyImportParseErrors.ts(251,40): error TS2307: Cannot find module 'glo_M2_public'. tests/cases/compiler/privacyImportParseErrors.ts(252,40): error TS2307: Cannot find module 'glo_M4_private'. -tests/cases/compiler/privacyImportParseErrors.ts(255,23): error TS2435: Ambient modules cannot be nested in other modules. +tests/cases/compiler/privacyImportParseErrors.ts(255,23): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyImportParseErrors.ts(258,45): error TS2304: Cannot find name 'use_glo_M1_public'. tests/cases/compiler/privacyImportParseErrors.ts(261,39): error TS2304: Cannot find name 'use_glo_M1_public'. tests/cases/compiler/privacyImportParseErrors.ts(264,40): error TS2307: Cannot find module 'glo_M2_public'. tests/cases/compiler/privacyImportParseErrors.ts(273,38): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyImportParseErrors.ts(277,45): error TS1147: Import declarations in a namespace cannot reference a module. -tests/cases/compiler/privacyImportParseErrors.ts(284,16): error TS2435: Ambient modules cannot be nested in other modules. +tests/cases/compiler/privacyImportParseErrors.ts(284,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyImportParseErrors.ts(287,46): error TS2304: Cannot find name 'use_glo_M3_private'. tests/cases/compiler/privacyImportParseErrors.ts(290,40): error TS2304: Cannot find name 'use_glo_M3_private'. tests/cases/compiler/privacyImportParseErrors.ts(293,41): error TS2307: Cannot find module 'glo_M4_private'. tests/cases/compiler/privacyImportParseErrors.ts(302,38): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyImportParseErrors.ts(306,45): error TS1147: Import declarations in a namespace cannot reference a module. -tests/cases/compiler/privacyImportParseErrors.ts(312,16): error TS2435: Ambient modules cannot be nested in other modules. +tests/cases/compiler/privacyImportParseErrors.ts(312,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyImportParseErrors.ts(314,9): error TS1038: A 'declare' modifier cannot be used in an already ambient context. -tests/cases/compiler/privacyImportParseErrors.ts(314,24): error TS2435: Ambient modules cannot be nested in other modules. -tests/cases/compiler/privacyImportParseErrors.ts(319,16): error TS2435: Ambient modules cannot be nested in other modules. -tests/cases/compiler/privacyImportParseErrors.ts(322,12): error TS2435: Ambient modules cannot be nested in other modules. +tests/cases/compiler/privacyImportParseErrors.ts(314,24): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyImportParseErrors.ts(319,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyImportParseErrors.ts(322,12): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyImportParseErrors.ts(326,9): error TS1029: 'export' modifier must precede 'declare' modifier. -tests/cases/compiler/privacyImportParseErrors.ts(326,23): error TS2435: Ambient modules cannot be nested in other modules. +tests/cases/compiler/privacyImportParseErrors.ts(326,23): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyImportParseErrors.ts(328,9): error TS1038: A 'declare' modifier cannot be used in an already ambient context. -tests/cases/compiler/privacyImportParseErrors.ts(328,24): error TS2435: Ambient modules cannot be nested in other modules. -tests/cases/compiler/privacyImportParseErrors.ts(333,16): error TS2435: Ambient modules cannot be nested in other modules. -tests/cases/compiler/privacyImportParseErrors.ts(336,12): error TS2435: Ambient modules cannot be nested in other modules. +tests/cases/compiler/privacyImportParseErrors.ts(328,24): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyImportParseErrors.ts(333,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces. +tests/cases/compiler/privacyImportParseErrors.ts(336,12): error TS2435: Ambient modules cannot be nested in other modules or namespaces. tests/cases/compiler/privacyImportParseErrors.ts(341,25): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyImportParseErrors.ts(344,29): error TS1147: Import declarations in a namespace cannot reference a module. tests/cases/compiler/privacyImportParseErrors.ts(350,25): error TS1147: Import declarations in a namespace cannot reference a module. @@ -73,7 +73,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d export declare module "m1_M3_public" { ~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. export function f1(); export class c1 { } @@ -83,7 +83,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d declare module "m1_M4_private" { ~~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. export function f1(); export class c1 { } @@ -173,7 +173,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d export declare module "m2_M3_public" { ~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. export function f1(); export class c1 { } @@ -183,7 +183,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d declare module "m2_M4_private" { ~~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. export function f1(); export class c1 { } @@ -263,7 +263,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d export declare module "glo_M2_public" { ~~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. export function f1(); export class c1 { } @@ -283,7 +283,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d export declare module "glo_M4_private" { ~~~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. export function f1(); export class c1 { } @@ -350,7 +350,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d export declare module "use_glo_M1_public" { ~~~~~~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. import use_glo_M1_public = glo_M1_public; export var use_glo_M1_public_v1_public: { new (): use_glo_M1_public.c1; }; export var use_glo_M1_public_v2_public: use_glo_M1_public; @@ -391,7 +391,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d declare module "use_glo_M3_private" { ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. import use_glo_M3_private = glo_M3_private; export var use_glo_M3_private_v1_public: { new (): use_glo_M3_private.c1; }; export var use_glo_M3_private_v2_public: use_glo_M3_private; @@ -431,25 +431,25 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d declare module "anotherParseError" { ~~~~~~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. module m2 { declare module "abc" { ~~~~~~~ !!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. ~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. } } module m2 { module "abc2" { ~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. } } module "abc3" { ~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. } } @@ -457,25 +457,25 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d ~~~~~~ !!! error TS1029: 'export' modifier must precede 'declare' modifier. ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. module m2 { declare module "abc" { ~~~~~~~ !!! error TS1038: A 'declare' modifier cannot be used in an already ambient context. ~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. } } module m2 { module "abc2" { ~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. } } module "abc3" { ~~~~~~ -!!! error TS2435: Ambient modules cannot be nested in other modules. +!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces. } } diff --git a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.js b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.js index f0ee8c1bb6c..4d184dfe714 100644 --- a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.js +++ b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.js @@ -32,8 +32,8 @@ declare module 'm2' { /// /// // Privacy errors - importing private elements -export import im_public_mi_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require"); -export import im_public_mu_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require1"); +export import im_public_mi_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require"); +export import im_public_mu_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require1"); export import im_public_mi_public = require("m"); export import im_public_mu_public = require("m2"); @@ -69,8 +69,8 @@ exports.c_public = c_public; /// /// // Privacy errors - importing private elements -exports.im_public_mi_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require"); -exports.im_public_mu_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require1"); +exports.im_public_mi_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require"); +exports.im_public_mu_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require1"); exports.im_public_mi_public = require("m"); exports.im_public_mu_public = require("m2"); // Usage of privacy error imports @@ -107,8 +107,8 @@ export declare class c_public { //// [privacyTopLevelAmbientExternalModuleImportWithExport_core.d.ts] /// /// -export import im_public_mi_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require"); -export import im_public_mu_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require1"); +export import im_public_mi_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require"); +export import im_public_mu_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require1"); export import im_public_mi_public = require("m"); export import im_public_mu_public = require("m2"); export declare var publicUse_im_public_mi_private: im_public_mi_private.c_public; diff --git a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.symbols b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.symbols index 3c0bd5ff61b..2dcddbbfa06 100644 --- a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.symbols +++ b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.symbols @@ -2,14 +2,14 @@ /// /// // Privacy errors - importing private elements -export import im_public_mi_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require"); +export import im_public_mi_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require"); >im_public_mi_private : Symbol(im_public_mi_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 0, 0)) -export import im_public_mu_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require1"); ->im_public_mu_private : Symbol(im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 3, 109)) +export import im_public_mu_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require1"); +>im_public_mu_private : Symbol(im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 3, 111)) export import im_public_mi_public = require("m"); ->im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 110)) +>im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 112)) export import im_public_mu_public = require("m2"); >im_public_mu_public : Symbol(im_public_mu_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 5, 49)) @@ -30,37 +30,37 @@ export var publicUse_im_public_mi_private = new im_public_mi_private.c_public(); var privateUse_im_public_mu_private = new im_public_mu_private.c_public(); >privateUse_im_public_mu_private : Symbol(privateUse_im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 11, 3)) >im_public_mu_private.c_public : Symbol(im_public_mu_private.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts, 0, 0)) ->im_public_mu_private : Symbol(im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 3, 109)) +>im_public_mu_private : Symbol(im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 3, 111)) >c_public : Symbol(im_public_mu_private.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts, 0, 0)) export var publicUse_im_public_mu_private = new im_public_mu_private.c_public(); >publicUse_im_public_mu_private : Symbol(publicUse_im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 12, 10)) >im_public_mu_private.c_public : Symbol(im_public_mu_private.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts, 0, 0)) ->im_public_mu_private : Symbol(im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 3, 109)) +>im_public_mu_private : Symbol(im_public_mu_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 3, 111)) >c_public : Symbol(im_public_mu_private.c_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require1.ts, 0, 0)) var privateUse_im_public_mi_public = new im_public_mi_public.c_private(); >privateUse_im_public_mi_public : Symbol(privateUse_im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 13, 3), Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 15, 3)) >im_public_mi_public.c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) ->im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 110)) +>im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 112)) >c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) export var publicUse_im_public_mi_public = new im_public_mi_public.c_private(); >publicUse_im_public_mi_public : Symbol(publicUse_im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 14, 10), Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 16, 10)) >im_public_mi_public.c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) ->im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 110)) +>im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 112)) >c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) var privateUse_im_public_mi_public = new im_public_mi_public.c_private(); >privateUse_im_public_mi_public : Symbol(privateUse_im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 13, 3), Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 15, 3)) >im_public_mi_public.c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) ->im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 110)) +>im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 112)) >c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) export var publicUse_im_public_mi_public = new im_public_mi_public.c_private(); >publicUse_im_public_mi_public : Symbol(publicUse_im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 14, 10), Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 16, 10)) >im_public_mi_public.c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) ->im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 110)) +>im_public_mi_public : Symbol(im_public_mi_public, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_core.ts, 4, 112)) >c_private : Symbol(im_public_mi_public.c_private, Decl(privacyTopLevelAmbientExternalModuleImportWithExport_require2.ts, 2, 20)) === tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport_require.ts === diff --git a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.types b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.types index b6d3d2967dc..5c082bef5de 100644 --- a/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.types +++ b/tests/baselines/reference/privacyTopLevelAmbientExternalModuleImportWithExport.types @@ -2,10 +2,10 @@ /// /// // Privacy errors - importing private elements -export import im_public_mi_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require"); +export import im_public_mi_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require"); >im_public_mi_private : typeof im_public_mi_private -export import im_public_mu_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require1"); +export import im_public_mu_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require1"); >im_public_mu_private : typeof im_public_mu_private export import im_public_mi_public = require("m"); diff --git a/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt b/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt index 7893100b5a5..adca4e30e10 100644 --- a/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt +++ b/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt @@ -1,9 +1,10 @@ +tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(5,7): error TS2415: Class 'Derived' incorrectly extends base class 'Base'. + Property 'foo' is private in type 'Base' but not in type 'Derived'. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(6,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(8,22): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,15): error TS1003: Identifier expected. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,21): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,8): error TS1110: Type expected. -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,8): error TS2341: Property 'foo' is private and only accessible within class 'Base'. +tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,12): error TS1005: ';' expected. ==== tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts (6 errors) ==== @@ -12,6 +13,9 @@ tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAcces } class Derived extends Base { + ~~~~~~~ +!!! error TS2415: Class 'Derived' incorrectly extends base class 'Base'. +!!! error TS2415: Property 'foo' is private in type 'Base' but not in type 'Derived'. x = super.foo; // error ~~~ !!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. @@ -27,8 +31,6 @@ tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAcces !!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. a: this.foo; // error - ~~~~ -!!! error TS1110: Type expected. - ~~~~~~~~ -!!! error TS2341: Property 'foo' is private and only accessible within class 'Base'. + ~ +!!! error TS1005: ';' expected. } \ No newline at end of file diff --git a/tests/baselines/reference/privateInstanceMemberAccessibility.js b/tests/baselines/reference/privateInstanceMemberAccessibility.js index ac2f44ee5d9..0ba2093a5c7 100644 --- a/tests/baselines/reference/privateInstanceMemberAccessibility.js +++ b/tests/baselines/reference/privateInstanceMemberAccessibility.js @@ -30,7 +30,6 @@ var Derived = (function (_super) { _super.apply(this, arguments); this.x = _super.prototype.foo; // error this.z = _super.prototype.foo; // error - this.a = this.foo; // error } Derived.prototype.y = function () { return _super.prototype.foo; // error diff --git a/tests/baselines/reference/privateInstanceVisibility.types b/tests/baselines/reference/privateInstanceVisibility.types index 109309ceb76..54a2c51ec14 100644 --- a/tests/baselines/reference/privateInstanceVisibility.types +++ b/tests/baselines/reference/privateInstanceVisibility.types @@ -14,8 +14,8 @@ module Test { >doSomething : () => void var that = this; ->that : Example ->this : Example +>that : this +>this : this function innerFunction() { >innerFunction : () => void @@ -23,7 +23,7 @@ module Test { var num = that.someNumber; >num : number >that.someNumber : number ->that : Example +>that : this >someNumber : number } @@ -45,7 +45,7 @@ class C { getX() { return this.x; } >getX : () => number >this.x : number ->this : C +>this : this >x : number clone(other: C) { @@ -56,7 +56,7 @@ class C { this.x = other.x; >this.x = other.x : number >this.x : number ->this : C +>this : this >x : number >other.x : number >other : C diff --git a/tests/baselines/reference/privateVisibles.types b/tests/baselines/reference/privateVisibles.types index e7c192d54db..71e26d7e264 100644 --- a/tests/baselines/reference/privateVisibles.types +++ b/tests/baselines/reference/privateVisibles.types @@ -10,7 +10,7 @@ class Foo { var n = this.pvar; >n : number >this.pvar : number ->this : Foo +>this : this >pvar : number } @@ -18,7 +18,7 @@ class Foo { >meth : () => void >q : number >this.pvar : number ->this : Foo +>this : this >pvar : number } diff --git a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt index bef02272064..44d2c93d9a5 100644 --- a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/amd/mapRootSourceRootWithNoSourceMapOption.errors.txt @@ -1,9 +1,9 @@ -error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. -error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. +error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. -!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. +!!! error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt index bef02272064..44d2c93d9a5 100644 --- a/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootSourceRootWithNoSourceMapOption/node/mapRootSourceRootWithNoSourceMapOption.errors.txt @@ -1,9 +1,9 @@ -error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. -error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. +error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. -!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. +!!! error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt index d00f552ef97..97e3ed02cf9 100644 --- a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/amd/mapRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt index d00f552ef97..97e3ed02cf9 100644 --- a/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/mapRootWithNoSourceMapOption/node/mapRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5038: Option 'mapRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'mapRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt index f4b65c12f35..56dab79dacf 100644 --- a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/amd/sourceRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt index f4b65c12f35..56dab79dacf 100644 --- a/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt +++ b/tests/baselines/reference/project/sourceRootWithNoSourceMapOption/node/sourceRootWithNoSourceMapOption.errors.txt @@ -1,7 +1,7 @@ -error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. -!!! error TS5039: Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option. +!!! error TS5052: Option 'sourceRoot' cannot be specified without specifying option 'sourceMap'. ==== m1.ts (0 errors) ==== var m1_a1 = 10; class m1_c1 { diff --git a/tests/baselines/reference/promiseChaining.types b/tests/baselines/reference/promiseChaining.types index 981a19ef0a9..23a8b276fdc 100644 --- a/tests/baselines/reference/promiseChaining.types +++ b/tests/baselines/reference/promiseChaining.types @@ -22,7 +22,7 @@ class Chain { >cb(this.value) : S >cb : (x: T) => S >this.value : T ->this : Chain +>this : this >value : T // should get a fresh type parameter which each then call @@ -34,7 +34,7 @@ class Chain { >this.then(x => result)/*S*/.then : (cb: (x: S) => S) => Chain >this.then(x => result) : Chain >this.then : (cb: (x: T) => S) => Chain ->this : Chain +>this : this >then : (cb: (x: T) => S) => Chain >x => result : (x: T) => S >x : T diff --git a/tests/baselines/reference/promiseVoidErrorCallback.symbols b/tests/baselines/reference/promiseVoidErrorCallback.symbols index 27e7df62ab1..3fc23ce5253 100644 --- a/tests/baselines/reference/promiseVoidErrorCallback.symbols +++ b/tests/baselines/reference/promiseVoidErrorCallback.symbols @@ -22,13 +22,13 @@ interface T3 { function f1(): Promise { >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) >T1 : Symbol(T1, Decl(promiseVoidErrorCallback.ts, 0, 0)) return Promise.resolve({ __t1: "foo_t1" }); ->Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4840, 39), Decl(lib.d.ts, 4847, 54)) ->Promise : Symbol(Promise, Decl(lib.d.ts, 4772, 1), Decl(lib.d.ts, 4858, 11)) ->resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 4840, 39), Decl(lib.d.ts, 4847, 54)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 5136, 39), Decl(lib.d.ts, 5143, 54)) +>Promise : Symbol(Promise, Decl(lib.d.ts, 5068, 1), Decl(lib.d.ts, 5154, 11)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.d.ts, 5136, 39), Decl(lib.d.ts, 5143, 54)) >__t1 : Symbol(__t1, Decl(promiseVoidErrorCallback.ts, 13, 28)) } @@ -47,12 +47,12 @@ function f2(x: T1): T2 { var x3 = f1() >x3 : Symbol(x3, Decl(promiseVoidErrorCallback.ts, 20, 3)) ->f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) ->f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) +>f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.d.ts, 5073, 22), Decl(lib.d.ts, 5080, 158)) +>f1() .then : Symbol(Promise.then, Decl(lib.d.ts, 5073, 22), Decl(lib.d.ts, 5080, 158)) >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) .then(f2, (e: Error) => { ->then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) +>then : Symbol(Promise.then, Decl(lib.d.ts, 5073, 22), Decl(lib.d.ts, 5080, 158)) >f2 : Symbol(f2, Decl(promiseVoidErrorCallback.ts, 14, 1)) >e : Symbol(e, Decl(promiseVoidErrorCallback.ts, 21, 15)) >Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11)) @@ -62,7 +62,7 @@ var x3 = f1() }) .then((x: T2) => { ->then : Symbol(Promise.then, Decl(lib.d.ts, 4777, 22), Decl(lib.d.ts, 4784, 158)) +>then : Symbol(Promise.then, Decl(lib.d.ts, 5073, 22), Decl(lib.d.ts, 5080, 158)) >x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 24, 11)) >T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1)) diff --git a/tests/baselines/reference/propertyAccess.errors.txt b/tests/baselines/reference/propertyAccess.errors.txt index d9cd90a48fc..7d496f87751 100644 --- a/tests/baselines/reference/propertyAccess.errors.txt +++ b/tests/baselines/reference/propertyAccess.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(45,14): error TS2339: Property 'qqq' does not exist on type '{ 10: string; x: string; y: number; z: { n: string; m: number; o: () => boolean; }; 'literal property': number; }'. -tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(80,10): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. -tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(117,10): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. -tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(80,10): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(117,10): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. ==== tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts (4 errors) ==== @@ -88,7 +88,7 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): er // Bracket notation property access using value of other type on type with numeric index signature and no string index signature var ll = numIndex[someObject]; // Error ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. // Bracket notation property access using string value on type with string index signature and no numeric index signature var mm = strIndex['N']; @@ -127,7 +127,7 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): er // Bracket notation property access using values of other types on type with no index signatures var uu = noIndex[someObject]; // Error ~~~~~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. // Bracket notation property access using numeric value on type with numeric index signature and string index signature var vv = noIndex[32]; @@ -152,7 +152,7 @@ tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts(140,12): er // Bracket notation property access using value of other type on type with numeric index signature and no string index signature and string index signature var zzzz = bothIndex[someObject]; // Error ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. var x1 = numIndex[stringOrNumber]; var x1: any; diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinClass.types b/tests/baselines/reference/protectedClassPropertyAccessibleWithinClass.types index 98e5c120c3d..1e325d1d6f5 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinClass.types +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinClass.types @@ -10,7 +10,7 @@ class C { protected get y() { return this.x; } >y : string >this.x : string ->this : C +>this : this >x : string protected set y(x) { this.y = this.x; } @@ -18,16 +18,16 @@ class C { >x : string >this.y = this.x : string >this.y : string ->this : C +>this : this >y : string >this.x : string ->this : C +>this : this >x : string protected foo() { return this.foo; } >foo : () => any >this.foo : () => any ->this : C +>this : this >foo : () => any protected static x: string; @@ -75,7 +75,7 @@ class C2 { >y : any >() => this.x : () => string >this.x : string ->this : C2 +>this : this >x : string >null : null @@ -85,17 +85,17 @@ class C2 { >() => { this.y = this.x; } : () => void >this.y = this.x : string >this.y : any ->this : C2 +>this : this >y : any >this.x : string ->this : C2 +>this : this >x : string protected foo() { () => this.foo; } >foo : () => void >() => this.foo : () => () => void >this.foo : () => void ->this : C2 +>this : this >foo : () => void protected static x: string; diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.types b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.types index bd230239d47..863f3100599 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.types +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.types @@ -18,7 +18,7 @@ class C extends B { protected get y() { return this.x; } >y : string >this.x : string ->this : C +>this : this >x : string protected set y(x) { this.y = this.x; } @@ -26,23 +26,23 @@ class C extends B { >x : string >this.y = this.x : string >this.y : string ->this : C +>this : this >y : string >this.x : string ->this : C +>this : this >x : string protected foo() { return this.x; } >foo : () => string >this.x : string ->this : C +>this : this >x : string protected bar() { return this.foo(); } >bar : () => string >this.foo() : string >this.foo : () => string ->this : C +>this : this >foo : () => string protected static get y() { return this.x; } diff --git a/tests/baselines/reference/protoInIndexer.types b/tests/baselines/reference/protoInIndexer.types index 48e8b5d56dc..bfafc56404a 100644 --- a/tests/baselines/reference/protoInIndexer.types +++ b/tests/baselines/reference/protoInIndexer.types @@ -6,7 +6,7 @@ class X { this['__proto__'] = null; // used to cause ICE >this['__proto__'] = null : null >this['__proto__'] : any ->this : X +>this : this >'__proto__' : string >null : null } diff --git a/tests/baselines/reference/quotedPropertyName3.types b/tests/baselines/reference/quotedPropertyName3.types index 53d375f7621..7c957372e0d 100644 --- a/tests/baselines/reference/quotedPropertyName3.types +++ b/tests/baselines/reference/quotedPropertyName3.types @@ -10,7 +10,7 @@ class Test { >x : () => number >() => this["prop1"] : () => number >this["prop1"] : number ->this : Test +>this : this >"prop1" : string var y: number = x(); diff --git a/tests/baselines/reference/recursiveComplicatedClasses.types b/tests/baselines/reference/recursiveComplicatedClasses.types index 247b9ee27c5..1bb48a3c0c9 100644 --- a/tests/baselines/reference/recursiveComplicatedClasses.types +++ b/tests/baselines/reference/recursiveComplicatedClasses.types @@ -24,7 +24,7 @@ class Symbol { >bound : boolean public visible() { ->visible : () => boolean +>visible : () => any var b: TypeSymbol; >b : TypeSymbol diff --git a/tests/baselines/reference/recursiveGenericUnionType1.js b/tests/baselines/reference/recursiveGenericUnionType1.js new file mode 100644 index 00000000000..54faae39b86 --- /dev/null +++ b/tests/baselines/reference/recursiveGenericUnionType1.js @@ -0,0 +1,29 @@ +//// [recursiveGenericUnionType1.ts] +declare module Test1 { + export type Container = T | { + [i: string]: Container; + }; + export type IStringContainer = Container; +} + +declare module Test2 { + export type Container = T | { + [i: string]: Container; + }; + export type IStringContainer = Container; +} + +var x: Test1.Container; + +var s1: Test1.IStringContainer; +var s2: Test2.IStringContainer; +s1 = s2; +s2 = s1; + + +//// [recursiveGenericUnionType1.js] +var x; +var s1; +var s2; +s1 = s2; +s2 = s1; diff --git a/tests/baselines/reference/recursiveGenericUnionType1.symbols b/tests/baselines/reference/recursiveGenericUnionType1.symbols new file mode 100644 index 00000000000..bd48cf90cde --- /dev/null +++ b/tests/baselines/reference/recursiveGenericUnionType1.symbols @@ -0,0 +1,62 @@ +=== tests/cases/compiler/recursiveGenericUnionType1.ts === +declare module Test1 { +>Test1 : Symbol(Test1, Decl(recursiveGenericUnionType1.ts, 0, 0)) + + export type Container = T | { +>Container : Symbol(Container, Decl(recursiveGenericUnionType1.ts, 0, 22)) +>T : Symbol(T, Decl(recursiveGenericUnionType1.ts, 1, 26)) +>T : Symbol(T, Decl(recursiveGenericUnionType1.ts, 1, 26)) + + [i: string]: Container; +>i : Symbol(i, Decl(recursiveGenericUnionType1.ts, 2, 9)) +>Container : Symbol(Container, Decl(recursiveGenericUnionType1.ts, 0, 22)) +>T : Symbol(T, Decl(recursiveGenericUnionType1.ts, 1, 26)) + + }; + export type IStringContainer = Container; +>IStringContainer : Symbol(IStringContainer, Decl(recursiveGenericUnionType1.ts, 3, 6)) +>Container : Symbol(Container, Decl(recursiveGenericUnionType1.ts, 0, 22)) +} + +declare module Test2 { +>Test2 : Symbol(Test2, Decl(recursiveGenericUnionType1.ts, 5, 1)) + + export type Container = T | { +>Container : Symbol(Container, Decl(recursiveGenericUnionType1.ts, 7, 22)) +>T : Symbol(T, Decl(recursiveGenericUnionType1.ts, 8, 26)) +>T : Symbol(T, Decl(recursiveGenericUnionType1.ts, 8, 26)) + + [i: string]: Container; +>i : Symbol(i, Decl(recursiveGenericUnionType1.ts, 9, 9)) +>Container : Symbol(Container, Decl(recursiveGenericUnionType1.ts, 7, 22)) +>T : Symbol(T, Decl(recursiveGenericUnionType1.ts, 8, 26)) + + }; + export type IStringContainer = Container; +>IStringContainer : Symbol(IStringContainer, Decl(recursiveGenericUnionType1.ts, 10, 6)) +>Container : Symbol(Container, Decl(recursiveGenericUnionType1.ts, 7, 22)) +} + +var x: Test1.Container; +>x : Symbol(x, Decl(recursiveGenericUnionType1.ts, 14, 3)) +>Test1 : Symbol(Test1, Decl(recursiveGenericUnionType1.ts, 0, 0)) +>Container : Symbol(Test1.Container, Decl(recursiveGenericUnionType1.ts, 0, 22)) + +var s1: Test1.IStringContainer; +>s1 : Symbol(s1, Decl(recursiveGenericUnionType1.ts, 16, 3)) +>Test1 : Symbol(Test1, Decl(recursiveGenericUnionType1.ts, 0, 0)) +>IStringContainer : Symbol(Test1.IStringContainer, Decl(recursiveGenericUnionType1.ts, 3, 6)) + +var s2: Test2.IStringContainer; +>s2 : Symbol(s2, Decl(recursiveGenericUnionType1.ts, 17, 3)) +>Test2 : Symbol(Test2, Decl(recursiveGenericUnionType1.ts, 5, 1)) +>IStringContainer : Symbol(Test2.IStringContainer, Decl(recursiveGenericUnionType1.ts, 10, 6)) + +s1 = s2; +>s1 : Symbol(s1, Decl(recursiveGenericUnionType1.ts, 16, 3)) +>s2 : Symbol(s2, Decl(recursiveGenericUnionType1.ts, 17, 3)) + +s2 = s1; +>s2 : Symbol(s2, Decl(recursiveGenericUnionType1.ts, 17, 3)) +>s1 : Symbol(s1, Decl(recursiveGenericUnionType1.ts, 16, 3)) + diff --git a/tests/baselines/reference/recursiveGenericUnionType1.types b/tests/baselines/reference/recursiveGenericUnionType1.types new file mode 100644 index 00000000000..c153aba0e7c --- /dev/null +++ b/tests/baselines/reference/recursiveGenericUnionType1.types @@ -0,0 +1,64 @@ +=== tests/cases/compiler/recursiveGenericUnionType1.ts === +declare module Test1 { +>Test1 : any + + export type Container = T | { +>Container : T | { [i: string]: T | any; } +>T : T +>T : T + + [i: string]: Container; +>i : string +>Container : T | { [i: string]: T | any; } +>T : T + + }; + export type IStringContainer = Container; +>IStringContainer : string | { [i: string]: string | any; } +>Container : T | { [i: string]: T | any; } +} + +declare module Test2 { +>Test2 : any + + export type Container = T | { +>Container : T | { [i: string]: T | any; } +>T : T +>T : T + + [i: string]: Container; +>i : string +>Container : T | { [i: string]: T | any; } +>T : T + + }; + export type IStringContainer = Container; +>IStringContainer : string | { [i: string]: string | any; } +>Container : T | { [i: string]: T | any; } +} + +var x: Test1.Container; +>x : number | { [i: string]: number | any; } +>Test1 : any +>Container : T | { [i: string]: T | any; } + +var s1: Test1.IStringContainer; +>s1 : string | { [i: string]: string | any; } +>Test1 : any +>IStringContainer : string | { [i: string]: string | any; } + +var s2: Test2.IStringContainer; +>s2 : string | { [i: string]: string | any; } +>Test2 : any +>IStringContainer : string | { [i: string]: string | any; } + +s1 = s2; +>s1 = s2 : string | { [i: string]: string | any; } +>s1 : string | { [i: string]: string | any; } +>s2 : string | { [i: string]: string | any; } + +s2 = s1; +>s2 = s1 : string | { [i: string]: string | any; } +>s2 : string | { [i: string]: string | any; } +>s1 : string | { [i: string]: string | any; } + diff --git a/tests/baselines/reference/recursiveGenericUnionType2.js b/tests/baselines/reference/recursiveGenericUnionType2.js new file mode 100644 index 00000000000..bb7977d02cd --- /dev/null +++ b/tests/baselines/reference/recursiveGenericUnionType2.js @@ -0,0 +1,29 @@ +//// [recursiveGenericUnionType2.ts] +declare module Test1 { + export type Container = T | { + [i: string]: Container[]; + }; + export type IStringContainer = Container; +} + +declare module Test2 { + export type Container = T | { + [i: string]: Container[]; + }; + export type IStringContainer = Container; +} + +var x: Test1.Container; + +var s1: Test1.IStringContainer; +var s2: Test2.IStringContainer; +s1 = s2; +s2 = s1; + + +//// [recursiveGenericUnionType2.js] +var x; +var s1; +var s2; +s1 = s2; +s2 = s1; diff --git a/tests/baselines/reference/recursiveGenericUnionType2.symbols b/tests/baselines/reference/recursiveGenericUnionType2.symbols new file mode 100644 index 00000000000..bd189e68f3a --- /dev/null +++ b/tests/baselines/reference/recursiveGenericUnionType2.symbols @@ -0,0 +1,62 @@ +=== tests/cases/compiler/recursiveGenericUnionType2.ts === +declare module Test1 { +>Test1 : Symbol(Test1, Decl(recursiveGenericUnionType2.ts, 0, 0)) + + export type Container = T | { +>Container : Symbol(Container, Decl(recursiveGenericUnionType2.ts, 0, 22)) +>T : Symbol(T, Decl(recursiveGenericUnionType2.ts, 1, 26)) +>T : Symbol(T, Decl(recursiveGenericUnionType2.ts, 1, 26)) + + [i: string]: Container[]; +>i : Symbol(i, Decl(recursiveGenericUnionType2.ts, 2, 9)) +>Container : Symbol(Container, Decl(recursiveGenericUnionType2.ts, 0, 22)) +>T : Symbol(T, Decl(recursiveGenericUnionType2.ts, 1, 26)) + + }; + export type IStringContainer = Container; +>IStringContainer : Symbol(IStringContainer, Decl(recursiveGenericUnionType2.ts, 3, 6)) +>Container : Symbol(Container, Decl(recursiveGenericUnionType2.ts, 0, 22)) +} + +declare module Test2 { +>Test2 : Symbol(Test2, Decl(recursiveGenericUnionType2.ts, 5, 1)) + + export type Container = T | { +>Container : Symbol(Container, Decl(recursiveGenericUnionType2.ts, 7, 22)) +>T : Symbol(T, Decl(recursiveGenericUnionType2.ts, 8, 26)) +>T : Symbol(T, Decl(recursiveGenericUnionType2.ts, 8, 26)) + + [i: string]: Container[]; +>i : Symbol(i, Decl(recursiveGenericUnionType2.ts, 9, 9)) +>Container : Symbol(Container, Decl(recursiveGenericUnionType2.ts, 7, 22)) +>T : Symbol(T, Decl(recursiveGenericUnionType2.ts, 8, 26)) + + }; + export type IStringContainer = Container; +>IStringContainer : Symbol(IStringContainer, Decl(recursiveGenericUnionType2.ts, 10, 6)) +>Container : Symbol(Container, Decl(recursiveGenericUnionType2.ts, 7, 22)) +} + +var x: Test1.Container; +>x : Symbol(x, Decl(recursiveGenericUnionType2.ts, 14, 3)) +>Test1 : Symbol(Test1, Decl(recursiveGenericUnionType2.ts, 0, 0)) +>Container : Symbol(Test1.Container, Decl(recursiveGenericUnionType2.ts, 0, 22)) + +var s1: Test1.IStringContainer; +>s1 : Symbol(s1, Decl(recursiveGenericUnionType2.ts, 16, 3)) +>Test1 : Symbol(Test1, Decl(recursiveGenericUnionType2.ts, 0, 0)) +>IStringContainer : Symbol(Test1.IStringContainer, Decl(recursiveGenericUnionType2.ts, 3, 6)) + +var s2: Test2.IStringContainer; +>s2 : Symbol(s2, Decl(recursiveGenericUnionType2.ts, 17, 3)) +>Test2 : Symbol(Test2, Decl(recursiveGenericUnionType2.ts, 5, 1)) +>IStringContainer : Symbol(Test2.IStringContainer, Decl(recursiveGenericUnionType2.ts, 10, 6)) + +s1 = s2; +>s1 : Symbol(s1, Decl(recursiveGenericUnionType2.ts, 16, 3)) +>s2 : Symbol(s2, Decl(recursiveGenericUnionType2.ts, 17, 3)) + +s2 = s1; +>s2 : Symbol(s2, Decl(recursiveGenericUnionType2.ts, 17, 3)) +>s1 : Symbol(s1, Decl(recursiveGenericUnionType2.ts, 16, 3)) + diff --git a/tests/baselines/reference/recursiveGenericUnionType2.types b/tests/baselines/reference/recursiveGenericUnionType2.types new file mode 100644 index 00000000000..f98cf144780 --- /dev/null +++ b/tests/baselines/reference/recursiveGenericUnionType2.types @@ -0,0 +1,64 @@ +=== tests/cases/compiler/recursiveGenericUnionType2.ts === +declare module Test1 { +>Test1 : any + + export type Container = T | { +>Container : T | { [i: string]: (T | any)[]; } +>T : T +>T : T + + [i: string]: Container[]; +>i : string +>Container : T | { [i: string]: (T | any)[]; } +>T : T + + }; + export type IStringContainer = Container; +>IStringContainer : string | { [i: string]: (string | any)[]; } +>Container : T | { [i: string]: (T | any)[]; } +} + +declare module Test2 { +>Test2 : any + + export type Container = T | { +>Container : T | { [i: string]: (T | any)[]; } +>T : T +>T : T + + [i: string]: Container[]; +>i : string +>Container : T | { [i: string]: (T | any)[]; } +>T : T + + }; + export type IStringContainer = Container; +>IStringContainer : string | { [i: string]: (string | any)[]; } +>Container : T | { [i: string]: (T | any)[]; } +} + +var x: Test1.Container; +>x : number | { [i: string]: (number | any)[]; } +>Test1 : any +>Container : T | { [i: string]: (T | any)[]; } + +var s1: Test1.IStringContainer; +>s1 : string | { [i: string]: (string | any)[]; } +>Test1 : any +>IStringContainer : string | { [i: string]: (string | any)[]; } + +var s2: Test2.IStringContainer; +>s2 : string | { [i: string]: (string | any)[]; } +>Test2 : any +>IStringContainer : string | { [i: string]: (string | any)[]; } + +s1 = s2; +>s1 = s2 : string | { [i: string]: (string | any)[]; } +>s1 : string | { [i: string]: (string | any)[]; } +>s2 : string | { [i: string]: (string | any)[]; } + +s2 = s1; +>s2 = s1 : string | { [i: string]: (string | any)[]; } +>s2 : string | { [i: string]: (string | any)[]; } +>s1 : string | { [i: string]: (string | any)[]; } + diff --git a/tests/baselines/reference/recursiveProperties.types b/tests/baselines/reference/recursiveProperties.types index 2c3f90c6503..1e8a4ed3c1a 100644 --- a/tests/baselines/reference/recursiveProperties.types +++ b/tests/baselines/reference/recursiveProperties.types @@ -5,7 +5,7 @@ class A { get testProp() { return this.testProp; } >testProp : any >this.testProp : any ->this : A +>this : this >testProp : any } @@ -17,7 +17,7 @@ class B { >value : string >this.testProp = value : string >this.testProp : string ->this : B +>this : this >testProp : string >value : string } diff --git a/tests/baselines/reference/recursiveTupleTypes1.js b/tests/baselines/reference/recursiveTupleTypes1.js new file mode 100644 index 00000000000..f4fa8ef4816 --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes1.js @@ -0,0 +1,20 @@ +//// [recursiveTupleTypes1.ts] +interface Tree1 { + children: [Tree1, Tree2]; +} + +interface Tree2 { + children: [Tree2, Tree1]; +} + +let tree1: Tree1; +let tree2: Tree2; +tree1 = tree2; +tree2 = tree1; + + +//// [recursiveTupleTypes1.js] +var tree1; +var tree2; +tree1 = tree2; +tree2 = tree1; diff --git a/tests/baselines/reference/recursiveTupleTypes1.symbols b/tests/baselines/reference/recursiveTupleTypes1.symbols new file mode 100644 index 00000000000..8bd0797f3f6 --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes1.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/recursiveTupleTypes1.ts === +interface Tree1 { +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0)) + + children: [Tree1, Tree2]; +>children : Symbol(children, Decl(recursiveTupleTypes1.ts, 0, 17)) +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1)) +} + +interface Tree2 { +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1)) + + children: [Tree2, Tree1]; +>children : Symbol(children, Decl(recursiveTupleTypes1.ts, 4, 17)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1)) +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0)) +} + +let tree1: Tree1; +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes1.ts, 8, 3)) +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes1.ts, 0, 0)) + +let tree2: Tree2; +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes1.ts, 9, 3)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes1.ts, 2, 1)) + +tree1 = tree2; +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes1.ts, 8, 3)) +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes1.ts, 9, 3)) + +tree2 = tree1; +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes1.ts, 9, 3)) +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes1.ts, 8, 3)) + diff --git a/tests/baselines/reference/recursiveTupleTypes1.types b/tests/baselines/reference/recursiveTupleTypes1.types new file mode 100644 index 00000000000..9dfdc768ddb --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes1.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/recursiveTupleTypes1.ts === +interface Tree1 { +>Tree1 : Tree1 + + children: [Tree1, Tree2]; +>children : [Tree1, Tree2] +>Tree1 : Tree1 +>Tree2 : Tree2 +} + +interface Tree2 { +>Tree2 : Tree2 + + children: [Tree2, Tree1]; +>children : [Tree2, Tree1] +>Tree2 : Tree2 +>Tree1 : Tree1 +} + +let tree1: Tree1; +>tree1 : Tree1 +>Tree1 : Tree1 + +let tree2: Tree2; +>tree2 : Tree2 +>Tree2 : Tree2 + +tree1 = tree2; +>tree1 = tree2 : Tree2 +>tree1 : Tree1 +>tree2 : Tree2 + +tree2 = tree1; +>tree2 = tree1 : Tree1 +>tree2 : Tree2 +>tree1 : Tree1 + diff --git a/tests/baselines/reference/recursiveTupleTypes2.js b/tests/baselines/reference/recursiveTupleTypes2.js new file mode 100644 index 00000000000..60dde8ef4d5 --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes2.js @@ -0,0 +1,20 @@ +//// [recursiveTupleTypes2.ts] +interface Tree1 { + children: [Tree1, Tree2]; +} + +interface Tree2 { + children: [Tree2, Tree2]; +} + +let tree1: Tree1; +let tree2: Tree2; +tree1 = tree2; +tree2 = tree1; + + +//// [recursiveTupleTypes2.js] +var tree1; +var tree2; +tree1 = tree2; +tree2 = tree1; diff --git a/tests/baselines/reference/recursiveTupleTypes2.symbols b/tests/baselines/reference/recursiveTupleTypes2.symbols new file mode 100644 index 00000000000..2895f1b5669 --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes2.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/recursiveTupleTypes2.ts === +interface Tree1 { +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes2.ts, 0, 0)) + + children: [Tree1, Tree2]; +>children : Symbol(children, Decl(recursiveTupleTypes2.ts, 0, 17)) +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes2.ts, 0, 0)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1)) +} + +interface Tree2 { +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1)) + + children: [Tree2, Tree2]; +>children : Symbol(children, Decl(recursiveTupleTypes2.ts, 4, 17)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1)) +} + +let tree1: Tree1; +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes2.ts, 8, 3)) +>Tree1 : Symbol(Tree1, Decl(recursiveTupleTypes2.ts, 0, 0)) + +let tree2: Tree2; +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes2.ts, 9, 3)) +>Tree2 : Symbol(Tree2, Decl(recursiveTupleTypes2.ts, 2, 1)) + +tree1 = tree2; +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes2.ts, 8, 3)) +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes2.ts, 9, 3)) + +tree2 = tree1; +>tree2 : Symbol(tree2, Decl(recursiveTupleTypes2.ts, 9, 3)) +>tree1 : Symbol(tree1, Decl(recursiveTupleTypes2.ts, 8, 3)) + diff --git a/tests/baselines/reference/recursiveTupleTypes2.types b/tests/baselines/reference/recursiveTupleTypes2.types new file mode 100644 index 00000000000..9ce8e5daf79 --- /dev/null +++ b/tests/baselines/reference/recursiveTupleTypes2.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/recursiveTupleTypes2.ts === +interface Tree1 { +>Tree1 : Tree1 + + children: [Tree1, Tree2]; +>children : [Tree1, Tree2] +>Tree1 : Tree1 +>Tree2 : Tree2 +} + +interface Tree2 { +>Tree2 : Tree2 + + children: [Tree2, Tree2]; +>children : [Tree2, Tree2] +>Tree2 : Tree2 +>Tree2 : Tree2 +} + +let tree1: Tree1; +>tree1 : Tree1 +>Tree1 : Tree1 + +let tree2: Tree2; +>tree2 : Tree2 +>Tree2 : Tree2 + +tree1 = tree2; +>tree1 = tree2 : Tree2 +>tree1 : Tree1 +>tree2 : Tree2 + +tree2 = tree1; +>tree2 = tree1 : Tree1 +>tree2 : Tree2 +>tree1 : Tree1 + diff --git a/tests/baselines/reference/regExpWithSlashInCharClass.symbols b/tests/baselines/reference/regExpWithSlashInCharClass.symbols index 2131f471466..68a257a9666 100644 --- a/tests/baselines/reference/regExpWithSlashInCharClass.symbols +++ b/tests/baselines/reference/regExpWithSlashInCharClass.symbols @@ -1,16 +1,16 @@ === tests/cases/compiler/regExpWithSlashInCharClass.ts === var foo1 = "a/".replace(/.[/]/, ""); >foo1 : Symbol(foo1, Decl(regExpWithSlashInCharClass.ts, 0, 3)) ->"a/".replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) ->replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) +>"a/".replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) +>replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) var foo2 = "a//".replace(/.[//]/g, ""); >foo2 : Symbol(foo2, Decl(regExpWithSlashInCharClass.ts, 1, 3)) ->"a//".replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) ->replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) +>"a//".replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) +>replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) var foo3 = "a/".replace(/.[/no sleep /till/]/, "bugfix"); >foo3 : Symbol(foo3, Decl(regExpWithSlashInCharClass.ts, 2, 3)) ->"a/".replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) ->replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 102), Decl(lib.d.ts, 350, 63)) +>"a/".replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) +>replace : Symbol(String.replace, Decl(lib.d.ts, 329, 44), Decl(lib.d.ts, 336, 63), Decl(lib.d.ts, 343, 98), Decl(lib.d.ts, 350, 63)) diff --git a/tests/baselines/reference/regExpWithSlashInCharClass.types b/tests/baselines/reference/regExpWithSlashInCharClass.types index 40eed3c109c..fafe6e1be69 100644 --- a/tests/baselines/reference/regExpWithSlashInCharClass.types +++ b/tests/baselines/reference/regExpWithSlashInCharClass.types @@ -2,27 +2,27 @@ var foo1 = "a/".replace(/.[/]/, ""); >foo1 : string >"a/".replace(/.[/]/, "") : string ->"a/".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>"a/".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >"a/" : string ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/.[/]/ : RegExp >"" : string var foo2 = "a//".replace(/.[//]/g, ""); >foo2 : string >"a//".replace(/.[//]/g, "") : string ->"a//".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>"a//".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >"a//" : string ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/.[//]/g : RegExp >"" : string var foo3 = "a/".replace(/.[/no sleep /till/]/, "bugfix"); >foo3 : string >"a/".replace(/.[/no sleep /till/]/, "bugfix") : string ->"a/".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>"a/".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >"a/" : string ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/.[/no sleep /till/]/ : RegExp >"bugfix" : string diff --git a/tests/baselines/reference/requireOfAnEmptyFile1.errors.txt b/tests/baselines/reference/requireOfAnEmptyFile1.errors.txt index 7094bc6699f..d02593feff9 100644 --- a/tests/baselines/reference/requireOfAnEmptyFile1.errors.txt +++ b/tests/baselines/reference/requireOfAnEmptyFile1.errors.txt @@ -4,8 +4,8 @@ tests/cases/compiler/requireOfAnEmptyFile1_a.ts(3,21): error TS2306: File 'tests ==== tests/cases/compiler/requireOfAnEmptyFile1_a.ts (1 errors) ==== //requireOfAnEmptyFile1 - import fs = require('requireOfAnEmptyFile1_b'); - ~~~~~~~~~~~~~~~~~~~~~~~~~ + import fs = require('./requireOfAnEmptyFile1_b'); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2306: File 'requireOfAnEmptyFile1_b.ts' is not a module. ==== tests/cases/compiler/requireOfAnEmptyFile1_b.ts (0 errors) ==== diff --git a/tests/baselines/reference/requireOfAnEmptyFile1.js b/tests/baselines/reference/requireOfAnEmptyFile1.js index 779bc887140..b2079afa6ef 100644 --- a/tests/baselines/reference/requireOfAnEmptyFile1.js +++ b/tests/baselines/reference/requireOfAnEmptyFile1.js @@ -3,7 +3,7 @@ //// [requireOfAnEmptyFile1_a.ts] //requireOfAnEmptyFile1 -import fs = require('requireOfAnEmptyFile1_b'); +import fs = require('./requireOfAnEmptyFile1_b'); //// [requireOfAnEmptyFile1_b.ts] diff --git a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.types b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.types index c9025b56502..3b0a3c001b4 100644 --- a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.types +++ b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.types @@ -18,8 +18,8 @@ module rionegrensis { >x : caniventer >caniventer : caniventer >() => { var y = this; } : () => void ->y : caniventer ->this : caniventer +>y : this +>this : this >x : caniventer uchidai() : lavali.xanthognathus { var x : lavali.xanthognathus; () => { var y = this; }; return x; } @@ -30,8 +30,8 @@ module rionegrensis { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : caniventer ->this : caniventer +>y : this +>this : this >x : lavali.xanthognathus raffrayana() : lavali.otion { var x : lavali.otion; () => { var y = this; }; return x; } @@ -42,8 +42,8 @@ module rionegrensis { >lavali : any >otion : lavali.otion >() => { var y = this; } : () => void ->y : caniventer ->this : caniventer +>y : this +>this : this >x : lavali.otion Uranium() : minutus.inez, trivirgatus.falconeri> { var x : minutus.inez, trivirgatus.falconeri>; () => { var y = this; }; return x; } @@ -70,8 +70,8 @@ module rionegrensis { >trivirgatus : any >falconeri : trivirgatus.falconeri >() => { var y = this; } : () => void ->y : caniventer ->this : caniventer +>y : this +>this : this >x : minutus.inez, trivirgatus.falconeri> nayaur() : gabriellae.amicus { var x : gabriellae.amicus; () => { var y = this; }; return x; } @@ -82,8 +82,8 @@ module rionegrensis { >gabriellae : any >amicus : gabriellae.amicus >() => { var y = this; } : () => void ->y : caniventer ->this : caniventer +>y : this +>this : this >x : gabriellae.amicus } export class veraecrucis extends trivirgatus.mixtus { @@ -122,8 +122,8 @@ module rionegrensis { >provocax : any >melanoleuca : provocax.melanoleuca >() => { var y = this; } : () => void ->y : veraecrucis ->this : veraecrucis +>y : this +>this : this >x : panamensis.setulosus> vancouverensis() : imperfecta.ciliolabrum { var x : imperfecta.ciliolabrum; () => { var y = this; }; return x; } @@ -142,8 +142,8 @@ module rionegrensis { >argurus : any >peninsulae : argurus.peninsulae >() => { var y = this; } : () => void ->y : veraecrucis ->this : veraecrucis +>y : this +>this : this >x : imperfecta.ciliolabrum africana() : argurus.gilbertii, sagitta.cinereus> { var x : argurus.gilbertii, sagitta.cinereus>; () => { var y = this; }; return x; } @@ -178,8 +178,8 @@ module rionegrensis { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : veraecrucis ->this : veraecrucis +>y : this +>this : this >x : argurus.gilbertii, sagitta.cinereus> palliolata() : Lanthanum.jugularis { var x : Lanthanum.jugularis; () => { var y = this; }; return x; } @@ -190,8 +190,8 @@ module rionegrensis { >Lanthanum : any >jugularis : Lanthanum.jugularis >() => { var y = this; } : () => void ->y : veraecrucis ->this : veraecrucis +>y : this +>this : this >x : Lanthanum.jugularis nivicola() : samarensis.pallidus { var x : samarensis.pallidus; () => { var y = this; }; return x; } @@ -202,8 +202,8 @@ module rionegrensis { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : veraecrucis ->this : veraecrucis +>y : this +>this : this >x : samarensis.pallidus } } @@ -224,8 +224,8 @@ module julianae { >argurus : any >germaini : argurus.germaini >() => { var y = this; } : () => void ->y : nudicaudus ->this : nudicaudus +>y : this +>this : this >x : argurus.germaini maxwellii() : ruatanica.Praseodymium { var x : ruatanica.Praseodymium; () => { var y = this; }; return x; } @@ -244,8 +244,8 @@ module julianae { >dammermani : any >melanops : dammermani.melanops >() => { var y = this; } : () => void ->y : nudicaudus ->this : nudicaudus +>y : this +>this : this >x : ruatanica.Praseodymium endoi() : panglima.abidi { var x : panglima.abidi; () => { var y = this; }; return x; } @@ -264,8 +264,8 @@ module julianae { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : nudicaudus ->this : nudicaudus +>y : this +>this : this >x : panglima.abidi venezuelae() : howi.marcanoi { var x : howi.marcanoi; () => { var y = this; }; return x; } @@ -276,8 +276,8 @@ module julianae { >howi : any >marcanoi : howi.marcanoi >() => { var y = this; } : () => void ->y : nudicaudus ->this : nudicaudus +>y : this +>this : this >x : howi.marcanoi zamicrus() : rionegrensis.caniventer { var x : rionegrensis.caniventer; () => { var y = this; }; return x; } @@ -288,8 +288,8 @@ module julianae { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : nudicaudus ->this : nudicaudus +>y : this +>this : this >x : rionegrensis.caniventer } export class galapagoensis { @@ -311,8 +311,8 @@ module julianae { >patas : any >uralensis : patas.uralensis >() => { var y = this; } : () => void ->y : galapagoensis ->this : galapagoensis +>y : this +>this : this >x : panglima.amphibius rueppellii() : ruatanica.americanus { var x : ruatanica.americanus; () => { var y = this; }; return x; } @@ -323,8 +323,8 @@ module julianae { >ruatanica : any >americanus : ruatanica.americanus >() => { var y = this; } : () => void ->y : galapagoensis ->this : galapagoensis +>y : this +>this : this >x : ruatanica.americanus peregusna() : dogramacii.kaiseri { var x : dogramacii.kaiseri; () => { var y = this; }; return x; } @@ -335,8 +335,8 @@ module julianae { >dogramacii : any >kaiseri : dogramacii.kaiseri >() => { var y = this; } : () => void ->y : galapagoensis ->this : galapagoensis +>y : this +>this : this >x : dogramacii.kaiseri gliroides() : howi.coludo { var x : howi.coludo; () => { var y = this; }; return x; } @@ -355,8 +355,8 @@ module julianae { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : galapagoensis ->this : galapagoensis +>y : this +>this : this >x : howi.coludo banakrisi() : macrorhinos.daphaenodon { var x : macrorhinos.daphaenodon; () => { var y = this; }; return x; } @@ -367,8 +367,8 @@ module julianae { >macrorhinos : any >daphaenodon : macrorhinos.daphaenodon >() => { var y = this; } : () => void ->y : galapagoensis ->this : galapagoensis +>y : this +>this : this >x : macrorhinos.daphaenodon rozendaali() : lutreolus.foina { var x : lutreolus.foina; () => { var y = this; }; return x; } @@ -379,8 +379,8 @@ module julianae { >lutreolus : any >foina : lutreolus.foina >() => { var y = this; } : () => void ->y : galapagoensis ->this : galapagoensis +>y : this +>this : this >x : lutreolus.foina stuhlmanni() : panamensis.linulus { var x : panamensis.linulus; () => { var y = this; }; return x; } @@ -399,8 +399,8 @@ module julianae { >caurinus : any >megaphyllus : caurinus.megaphyllus >() => { var y = this; } : () => void ->y : galapagoensis ->this : galapagoensis +>y : this +>this : this >x : panamensis.linulus } export class albidens { @@ -432,8 +432,8 @@ module julianae { >imperfecta : any >subspinosus : imperfecta.subspinosus >() => { var y = this; } : () => void ->y : albidens ->this : albidens +>y : this +>this : this >x : samarensis.fuscus> Astatine() : steerii { var x : steerii; () => { var y = this; }; return x; } @@ -442,8 +442,8 @@ module julianae { >x : steerii >steerii : steerii >() => { var y = this; } : () => void ->y : albidens ->this : albidens +>y : this +>this : this >x : steerii vincenti() : argurus.dauricus { var x : argurus.dauricus; () => { var y = this; }; return x; } @@ -462,8 +462,8 @@ module julianae { >patas : any >uralensis : patas.uralensis >() => { var y = this; } : () => void ->y : albidens ->this : albidens +>y : this +>this : this >x : argurus.dauricus hirta() : Lanthanum.jugularis { var x : Lanthanum.jugularis; () => { var y = this; }; return x; } @@ -474,8 +474,8 @@ module julianae { >Lanthanum : any >jugularis : Lanthanum.jugularis >() => { var y = this; } : () => void ->y : albidens ->this : albidens +>y : this +>this : this >x : Lanthanum.jugularis virginianus() : durangae { var x : durangae; () => { var y = this; }; return x; } @@ -484,8 +484,8 @@ module julianae { >x : durangae >durangae : durangae >() => { var y = this; } : () => void ->y : albidens ->this : albidens +>y : this +>this : this >x : durangae macrophyllum() : howi.marcanoi { var x : howi.marcanoi; () => { var y = this; }; return x; } @@ -496,8 +496,8 @@ module julianae { >howi : any >marcanoi : howi.marcanoi >() => { var y = this; } : () => void ->y : albidens ->this : albidens +>y : this +>this : this >x : howi.marcanoi porcellus() : ruatanica.americanus { var x : ruatanica.americanus; () => { var y = this; }; return x; } @@ -508,8 +508,8 @@ module julianae { >ruatanica : any >americanus : ruatanica.americanus >() => { var y = this; } : () => void ->y : albidens ->this : albidens +>y : this +>this : this >x : ruatanica.americanus } export class oralis extends caurinus.psilurus { @@ -528,8 +528,8 @@ module julianae { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : oralis ->this : oralis +>y : this +>this : this >x : caurinus.psilurus porteri() : lavali.thaeleri { var x : lavali.thaeleri; () => { var y = this; }; return x; } @@ -540,8 +540,8 @@ module julianae { >lavali : any >thaeleri : lavali.thaeleri >() => { var y = this; } : () => void ->y : oralis ->this : oralis +>y : this +>this : this >x : lavali.thaeleri bindi() : caurinus.mahaganus> { var x : caurinus.mahaganus>; () => { var y = this; }; return x; } @@ -568,8 +568,8 @@ module julianae { >patas : any >uralensis : patas.uralensis >() => { var y = this; } : () => void ->y : oralis ->this : oralis +>y : this +>this : this >x : caurinus.mahaganus> puda() : sagitta.stolzmanni { var x : sagitta.stolzmanni; () => { var y = this; }; return x; } @@ -580,8 +580,8 @@ module julianae { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : oralis ->this : oralis +>y : this +>this : this >x : sagitta.stolzmanni mindorensis() : trivirgatus.falconeri { var x : trivirgatus.falconeri; () => { var y = this; }; return x; } @@ -592,8 +592,8 @@ module julianae { >trivirgatus : any >falconeri : trivirgatus.falconeri >() => { var y = this; } : () => void ->y : oralis ->this : oralis +>y : this +>this : this >x : trivirgatus.falconeri ignitus() : petrophilus.rosalia, lavali.wilsoni> { var x : petrophilus.rosalia, lavali.wilsoni>; () => { var y = this; }; return x; } @@ -618,8 +618,8 @@ module julianae { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : oralis ->this : oralis +>y : this +>this : this >x : petrophilus.rosalia, lavali.wilsoni> rufus() : nudicaudus { var x : nudicaudus; () => { var y = this; }; return x; } @@ -628,8 +628,8 @@ module julianae { >x : nudicaudus >nudicaudus : nudicaudus >() => { var y = this; } : () => void ->y : oralis ->this : oralis +>y : this +>this : this >x : nudicaudus monax() : imperfecta.subspinosus { var x : imperfecta.subspinosus; () => { var y = this; }; return x; } @@ -640,8 +640,8 @@ module julianae { >imperfecta : any >subspinosus : imperfecta.subspinosus >() => { var y = this; } : () => void ->y : oralis ->this : oralis +>y : this +>this : this >x : imperfecta.subspinosus unalascensis() : minutus.inez, gabriellae.echinatus>, dogramacii.aurata> { var x : minutus.inez, gabriellae.echinatus>, dogramacii.aurata>; () => { var y = this; }; return x; } @@ -676,8 +676,8 @@ module julianae { >dogramacii : any >aurata : dogramacii.aurata >() => { var y = this; } : () => void ->y : oralis ->this : oralis +>y : this +>this : this >x : minutus.inez, gabriellae.echinatus>, dogramacii.aurata> wuchihensis() : howi.angulatus, petrophilus.minutilla> { var x : howi.angulatus, petrophilus.minutilla>; () => { var y = this; }; return x; } @@ -704,8 +704,8 @@ module julianae { >petrophilus : any >minutilla : petrophilus.minutilla >() => { var y = this; } : () => void ->y : oralis ->this : oralis +>y : this +>this : this >x : howi.angulatus, petrophilus.minutilla> leucippe() : lavali.otion { var x : lavali.otion; () => { var y = this; }; return x; } @@ -716,8 +716,8 @@ module julianae { >lavali : any >otion : lavali.otion >() => { var y = this; } : () => void ->y : oralis ->this : oralis +>y : this +>this : this >x : lavali.otion ordii() : daubentonii.arboreus { var x : daubentonii.arboreus; () => { var y = this; }; return x; } @@ -736,8 +736,8 @@ module julianae { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : oralis ->this : oralis +>y : this +>this : this >x : daubentonii.arboreus eisentrauti() : rendalli.zuluensis { var x : rendalli.zuluensis; () => { var y = this; }; return x; } @@ -748,8 +748,8 @@ module julianae { >rendalli : any >zuluensis : rendalli.zuluensis >() => { var y = this; } : () => void ->y : oralis ->this : oralis +>y : this +>this : this >x : rendalli.zuluensis } export class sumatrana extends Lanthanum.jugularis { @@ -774,8 +774,8 @@ module julianae { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : sumatrana ->this : sumatrana +>y : this +>this : this >x : Lanthanum.suillus geata() : ruatanica.hector { var x : ruatanica.hector; () => { var y = this; }; return x; } @@ -792,8 +792,8 @@ module julianae { >quasiater : any >bobrinskoi : quasiater.bobrinskoi >() => { var y = this; } : () => void ->y : sumatrana ->this : sumatrana +>y : this +>this : this >x : ruatanica.hector awashensis() : petrophilus.minutilla { var x : petrophilus.minutilla; () => { var y = this; }; return x; } @@ -804,8 +804,8 @@ module julianae { >petrophilus : any >minutilla : petrophilus.minutilla >() => { var y = this; } : () => void ->y : sumatrana ->this : sumatrana +>y : this +>this : this >x : petrophilus.minutilla sturdeei() : lutreolus.cor { var x : lutreolus.cor; () => { var y = this; }; return x; } @@ -822,8 +822,8 @@ module julianae { >jugularis : Lanthanum.jugularis >galapagoensis : galapagoensis >() => { var y = this; } : () => void ->y : sumatrana ->this : sumatrana +>y : this +>this : this >x : lutreolus.cor pachyurus() : howi.angulatus> { var x : howi.angulatus>; () => { var y = this; }; return x; } @@ -848,8 +848,8 @@ module julianae { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : sumatrana ->this : sumatrana +>y : this +>this : this >x : howi.angulatus> lyelli() : provocax.melanoleuca { var x : provocax.melanoleuca; () => { var y = this; }; return x; } @@ -860,8 +860,8 @@ module julianae { >provocax : any >melanoleuca : provocax.melanoleuca >() => { var y = this; } : () => void ->y : sumatrana ->this : sumatrana +>y : this +>this : this >x : provocax.melanoleuca neohibernicus() : dammermani.siberu { var x : dammermani.siberu; () => { var y = this; }; return x; } @@ -880,8 +880,8 @@ module julianae { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : sumatrana ->this : sumatrana +>y : this +>this : this >x : dammermani.siberu } export class gerbillus { @@ -905,8 +905,8 @@ module julianae { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : gerbillus ->this : gerbillus +>y : this +>this : this >x : sagitta.sicarius tristrami() : petrophilus.minutilla { var x : petrophilus.minutilla; () => { var y = this; }; return x; } @@ -917,8 +917,8 @@ module julianae { >petrophilus : any >minutilla : petrophilus.minutilla >() => { var y = this; } : () => void ->y : gerbillus ->this : gerbillus +>y : this +>this : this >x : petrophilus.minutilla swarthi() : lutreolus.foina { var x : lutreolus.foina; () => { var y = this; }; return x; } @@ -929,8 +929,8 @@ module julianae { >lutreolus : any >foina : lutreolus.foina >() => { var y = this; } : () => void ->y : gerbillus ->this : gerbillus +>y : this +>this : this >x : lutreolus.foina horsfieldii() : trivirgatus.falconeri { var x : trivirgatus.falconeri; () => { var y = this; }; return x; } @@ -941,8 +941,8 @@ module julianae { >trivirgatus : any >falconeri : trivirgatus.falconeri >() => { var y = this; } : () => void ->y : gerbillus ->this : gerbillus +>y : this +>this : this >x : trivirgatus.falconeri diazi() : imperfecta.lasiurus { var x : imperfecta.lasiurus; () => { var y = this; }; return x; } @@ -961,8 +961,8 @@ module julianae { >dammermani : any >melanops : dammermani.melanops >() => { var y = this; } : () => void ->y : gerbillus ->this : gerbillus +>y : this +>this : this >x : imperfecta.lasiurus rennelli() : argurus.luctuosa { var x : argurus.luctuosa; () => { var y = this; }; return x; } @@ -973,8 +973,8 @@ module julianae { >argurus : any >luctuosa : argurus.luctuosa >() => { var y = this; } : () => void ->y : gerbillus ->this : gerbillus +>y : this +>this : this >x : argurus.luctuosa maulinus() : lavali.lepturus { var x : lavali.lepturus; () => { var y = this; }; return x; } @@ -985,8 +985,8 @@ module julianae { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : gerbillus ->this : gerbillus +>y : this +>this : this >x : lavali.lepturus muscina() : daubentonii.arboreus { var x : daubentonii.arboreus; () => { var y = this; }; return x; } @@ -1005,8 +1005,8 @@ module julianae { >argurus : any >peninsulae : argurus.peninsulae >() => { var y = this; } : () => void ->y : gerbillus ->this : gerbillus +>y : this +>this : this >x : daubentonii.arboreus pelengensis() : sagitta.leptoceros { var x : sagitta.leptoceros; () => { var y = this; }; return x; } @@ -1025,8 +1025,8 @@ module julianae { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : gerbillus ->this : gerbillus +>y : this +>this : this >x : sagitta.leptoceros abramus() : lavali.thaeleri { var x : lavali.thaeleri; () => { var y = this; }; return x; } @@ -1037,8 +1037,8 @@ module julianae { >lavali : any >thaeleri : lavali.thaeleri >() => { var y = this; } : () => void ->y : gerbillus ->this : gerbillus +>y : this +>this : this >x : lavali.thaeleri reevesi() : provocax.melanoleuca { var x : provocax.melanoleuca; () => { var y = this; }; return x; } @@ -1049,8 +1049,8 @@ module julianae { >provocax : any >melanoleuca : provocax.melanoleuca >() => { var y = this; } : () => void ->y : gerbillus ->this : gerbillus +>y : this +>this : this >x : provocax.melanoleuca } export class acariensis { @@ -1064,8 +1064,8 @@ module julianae { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : acariensis ->this : acariensis +>y : this +>this : this >x : lavali.lepturus minous() : argurus.dauricus { var x : argurus.dauricus; () => { var y = this; }; return x; } @@ -1084,8 +1084,8 @@ module julianae { >lavali : any >otion : lavali.otion >() => { var y = this; } : () => void ->y : acariensis ->this : acariensis +>y : this +>this : this >x : argurus.dauricus cinereiventer() : panamensis.setulosus { var x : panamensis.setulosus; () => { var y = this; }; return x; } @@ -1104,8 +1104,8 @@ module julianae { >lavali : any >otion : lavali.otion >() => { var y = this; } : () => void ->y : acariensis ->this : acariensis +>y : this +>this : this >x : panamensis.setulosus longicaudatus() : macrorhinos.marmosurus> { var x : macrorhinos.marmosurus>; () => { var y = this; }; return x; } @@ -1130,8 +1130,8 @@ module julianae { >lavali : any >otion : lavali.otion >() => { var y = this; } : () => void ->y : acariensis ->this : acariensis +>y : this +>this : this >x : macrorhinos.marmosurus> baeodon() : argurus.netscheri, argurus.luctuosa> { var x : argurus.netscheri, argurus.luctuosa>; () => { var y = this; }; return x; } @@ -1158,8 +1158,8 @@ module julianae { >argurus : any >luctuosa : argurus.luctuosa >() => { var y = this; } : () => void ->y : acariensis ->this : acariensis +>y : this +>this : this >x : argurus.netscheri, argurus.luctuosa> soricoides() : argurus.luctuosa { var x : argurus.luctuosa; () => { var y = this; }; return x; } @@ -1170,8 +1170,8 @@ module julianae { >argurus : any >luctuosa : argurus.luctuosa >() => { var y = this; } : () => void ->y : acariensis ->this : acariensis +>y : this +>this : this >x : argurus.luctuosa datae() : daubentonii.arboreus> { var x : daubentonii.arboreus>; () => { var y = this; }; return x; } @@ -1198,8 +1198,8 @@ module julianae { >patas : any >uralensis : patas.uralensis >() => { var y = this; } : () => void ->y : acariensis ->this : acariensis +>y : this +>this : this >x : daubentonii.arboreus> spixii() : imperfecta.subspinosus { var x : imperfecta.subspinosus; () => { var y = this; }; return x; } @@ -1210,8 +1210,8 @@ module julianae { >imperfecta : any >subspinosus : imperfecta.subspinosus >() => { var y = this; } : () => void ->y : acariensis ->this : acariensis +>y : this +>this : this >x : imperfecta.subspinosus anakuma() : lavali.wilsoni { var x : lavali.wilsoni; () => { var y = this; }; return x; } @@ -1222,8 +1222,8 @@ module julianae { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : acariensis ->this : acariensis +>y : this +>this : this >x : lavali.wilsoni kihaulei() : panglima.amphibius { var x : panglima.amphibius; () => { var y = this; }; return x; } @@ -1242,8 +1242,8 @@ module julianae { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : acariensis ->this : acariensis +>y : this +>this : this >x : panglima.amphibius gymnura() : quasiater.carolinensis { var x : quasiater.carolinensis; () => { var y = this; }; return x; } @@ -1254,8 +1254,8 @@ module julianae { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : acariensis ->this : acariensis +>y : this +>this : this >x : quasiater.carolinensis olchonensis() : rendalli.crenulata { var x : rendalli.crenulata; () => { var y = this; }; return x; } @@ -1274,8 +1274,8 @@ module julianae { >provocax : any >melanoleuca : provocax.melanoleuca >() => { var y = this; } : () => void ->y : acariensis ->this : acariensis +>y : this +>this : this >x : rendalli.crenulata } export class durangae extends dogramacii.aurata { @@ -1300,8 +1300,8 @@ module julianae { >dammermani : any >melanops : dammermani.melanops >() => { var y = this; } : () => void ->y : durangae ->this : durangae +>y : this +>this : this >x : panamensis.setulosus Flerovium() : howi.angulatus { var x : howi.angulatus; () => { var y = this; }; return x; } @@ -1320,8 +1320,8 @@ module julianae { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : durangae ->this : durangae +>y : this +>this : this >x : howi.angulatus phrudus() : sagitta.stolzmanni { var x : sagitta.stolzmanni; () => { var y = this; }; return x; } @@ -1332,8 +1332,8 @@ module julianae { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : durangae ->this : durangae +>y : this +>this : this >x : sagitta.stolzmanni } } @@ -1353,8 +1353,8 @@ module ruatanica { >julianae : any >steerii : julianae.steerii >() => { var y = this; } : () => void ->y : hector ->this : hector +>y : this +>this : this >x : julianae.steerii eurycerus() : panamensis.linulus, lavali.wilsoni> { var x : panamensis.linulus, lavali.wilsoni>; () => { var y = this; }; return x; } @@ -1381,8 +1381,8 @@ module ruatanica { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : hector ->this : hector +>y : this +>this : this >x : panamensis.linulus, lavali.wilsoni> } } @@ -1402,8 +1402,8 @@ module Lanthanum { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : suillus ->this : suillus +>y : this +>this : this >x : quasiater.carolinensis tumbalensis() : caurinus.megaphyllus { var x : caurinus.megaphyllus; () => { var y = this; }; return x; } @@ -1414,8 +1414,8 @@ module Lanthanum { >caurinus : any >megaphyllus : caurinus.megaphyllus >() => { var y = this; } : () => void ->y : suillus ->this : suillus +>y : this +>this : this >x : caurinus.megaphyllus anatolicus() : julianae.steerii { var x : julianae.steerii; () => { var y = this; }; return x; } @@ -1426,8 +1426,8 @@ module Lanthanum { >julianae : any >steerii : julianae.steerii >() => { var y = this; } : () => void ->y : suillus ->this : suillus +>y : this +>this : this >x : julianae.steerii } export class nitidus extends argurus.gilbertii { @@ -1450,8 +1450,8 @@ module Lanthanum { >quasiater : any >bobrinskoi : quasiater.bobrinskoi >() => { var y = this; } : () => void ->y : nitidus ->this : nitidus +>y : this +>this : this >x : quasiater.bobrinskoi negligens() : minutus.inez { var x : minutus.inez; () => { var y = this; }; return x; } @@ -1470,8 +1470,8 @@ module Lanthanum { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : nitidus ->this : nitidus +>y : this +>this : this >x : minutus.inez lewisi() : julianae.oralis { var x : julianae.oralis; () => { var y = this; }; return x; } @@ -1490,8 +1490,8 @@ module Lanthanum { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : nitidus ->this : nitidus +>y : this +>this : this >x : julianae.oralis arge() : chrysaeolus.sarasinorum { var x : chrysaeolus.sarasinorum; () => { var y = this; }; return x; } @@ -1510,8 +1510,8 @@ module Lanthanum { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : nitidus ->this : nitidus +>y : this +>this : this >x : chrysaeolus.sarasinorum dominicensis() : dammermani.melanops { var x : dammermani.melanops; () => { var y = this; }; return x; } @@ -1522,8 +1522,8 @@ module Lanthanum { >dammermani : any >melanops : dammermani.melanops >() => { var y = this; } : () => void ->y : nitidus ->this : nitidus +>y : this +>this : this >x : dammermani.melanops taurus() : macrorhinos.konganensis { var x : macrorhinos.konganensis; () => { var y = this; }; return x; } @@ -1534,8 +1534,8 @@ module Lanthanum { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : nitidus ->this : nitidus +>y : this +>this : this >x : macrorhinos.konganensis tonganus() : argurus.netscheri { var x : argurus.netscheri; () => { var y = this; }; return x; } @@ -1554,8 +1554,8 @@ module Lanthanum { >dogramacii : any >aurata : dogramacii.aurata >() => { var y = this; } : () => void ->y : nitidus ->this : nitidus +>y : this +>this : this >x : argurus.netscheri silvatica() : rendalli.moojeni { var x : rendalli.moojeni; () => { var y = this; }; return x; } @@ -1574,8 +1574,8 @@ module Lanthanum { >lavali : any >otion : lavali.otion >() => { var y = this; } : () => void ->y : nitidus ->this : nitidus +>y : this +>this : this >x : rendalli.moojeni midas() : lavali.xanthognathus { var x : lavali.xanthognathus; () => { var y = this; }; return x; } @@ -1586,8 +1586,8 @@ module Lanthanum { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : nitidus ->this : nitidus +>y : this +>this : this >x : lavali.xanthognathus bicornis() : dogramacii.kaiseri { var x : dogramacii.kaiseri; () => { var y = this; }; return x; } @@ -1598,8 +1598,8 @@ module Lanthanum { >dogramacii : any >kaiseri : dogramacii.kaiseri >() => { var y = this; } : () => void ->y : nitidus ->this : nitidus +>y : this +>this : this >x : dogramacii.kaiseri } export class megalonyx extends caurinus.johorensis { @@ -1620,8 +1620,8 @@ module Lanthanum { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : megalonyx ->this : megalonyx +>y : this +>this : this >x : macrorhinos.konganensis melanogaster() : rionegrensis.veraecrucis { var x : rionegrensis.veraecrucis; () => { var y = this; }; return x; } @@ -1640,8 +1640,8 @@ module Lanthanum { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : megalonyx ->this : megalonyx +>y : this +>this : this >x : rionegrensis.veraecrucis elaphus() : nitidus { var x : nitidus; () => { var y = this; }; return x; } @@ -1658,8 +1658,8 @@ module Lanthanum { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : megalonyx ->this : megalonyx +>y : this +>this : this >x : nitidus elater() : lavali.lepturus { var x : lavali.lepturus; () => { var y = this; }; return x; } @@ -1670,8 +1670,8 @@ module Lanthanum { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : megalonyx ->this : megalonyx +>y : this +>this : this >x : lavali.lepturus ourebi() : provocax.melanoleuca { var x : provocax.melanoleuca; () => { var y = this; }; return x; } @@ -1682,8 +1682,8 @@ module Lanthanum { >provocax : any >melanoleuca : provocax.melanoleuca >() => { var y = this; } : () => void ->y : megalonyx ->this : megalonyx +>y : this +>this : this >x : provocax.melanoleuca caraccioli() : imperfecta.ciliolabrum> { var x : imperfecta.ciliolabrum>; () => { var y = this; }; return x; } @@ -1710,8 +1710,8 @@ module Lanthanum { >julianae : any >acariensis : julianae.acariensis >() => { var y = this; } : () => void ->y : megalonyx ->this : megalonyx +>y : this +>this : this >x : imperfecta.ciliolabrum> parva() : gabriellae.echinatus { var x : gabriellae.echinatus; () => { var y = this; }; return x; } @@ -1722,8 +1722,8 @@ module Lanthanum { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : megalonyx ->this : megalonyx +>y : this +>this : this >x : gabriellae.echinatus albipes() : quasiater.wattsi { var x : quasiater.wattsi; () => { var y = this; }; return x; } @@ -1740,8 +1740,8 @@ module Lanthanum { >melanops : dammermani.melanops >megalonyx : megalonyx >() => { var y = this; } : () => void ->y : megalonyx ->this : megalonyx +>y : this +>this : this >x : quasiater.wattsi } export class jugularis { @@ -1763,8 +1763,8 @@ module Lanthanum { >macrorhinos : any >daphaenodon : macrorhinos.daphaenodon >() => { var y = this; } : () => void ->y : jugularis ->this : jugularis +>y : this +>this : this >x : petrophilus.sodyi revoili() : lavali.wilsoni { var x : lavali.wilsoni; () => { var y = this; }; return x; } @@ -1775,8 +1775,8 @@ module Lanthanum { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : jugularis ->this : jugularis +>y : this +>this : this >x : lavali.wilsoni macrobullatus() : macrorhinos.daphaenodon { var x : macrorhinos.daphaenodon; () => { var y = this; }; return x; } @@ -1787,8 +1787,8 @@ module Lanthanum { >macrorhinos : any >daphaenodon : macrorhinos.daphaenodon >() => { var y = this; } : () => void ->y : jugularis ->this : jugularis +>y : this +>this : this >x : macrorhinos.daphaenodon compactus() : sagitta.stolzmanni { var x : sagitta.stolzmanni; () => { var y = this; }; return x; } @@ -1799,8 +1799,8 @@ module Lanthanum { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : jugularis ->this : jugularis +>y : this +>this : this >x : sagitta.stolzmanni talpinus() : nitidus { var x : nitidus; () => { var y = this; }; return x; } @@ -1817,8 +1817,8 @@ module Lanthanum { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : jugularis ->this : jugularis +>y : this +>this : this >x : nitidus stramineus() : gabriellae.amicus { var x : gabriellae.amicus; () => { var y = this; }; return x; } @@ -1829,8 +1829,8 @@ module Lanthanum { >gabriellae : any >amicus : gabriellae.amicus >() => { var y = this; } : () => void ->y : jugularis ->this : jugularis +>y : this +>this : this >x : gabriellae.amicus dartmouthi() : trivirgatus.mixtus { var x : trivirgatus.mixtus; () => { var y = this; }; return x; } @@ -1849,8 +1849,8 @@ module Lanthanum { >argurus : any >luctuosa : argurus.luctuosa >() => { var y = this; } : () => void ->y : jugularis ->this : jugularis +>y : this +>this : this >x : trivirgatus.mixtus ogilbyi() : argurus.dauricus { var x : argurus.dauricus; () => { var y = this; }; return x; } @@ -1869,8 +1869,8 @@ module Lanthanum { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : jugularis ->this : jugularis +>y : this +>this : this >x : argurus.dauricus incomtus() : daubentonii.nesiotes { var x : daubentonii.nesiotes; () => { var y = this; }; return x; } @@ -1889,8 +1889,8 @@ module Lanthanum { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : jugularis ->this : jugularis +>y : this +>this : this >x : daubentonii.nesiotes surdaster() : ruatanica.Praseodymium { var x : ruatanica.Praseodymium; () => { var y = this; }; return x; } @@ -1909,8 +1909,8 @@ module Lanthanum { >caurinus : any >megaphyllus : caurinus.megaphyllus >() => { var y = this; } : () => void ->y : jugularis ->this : jugularis +>y : this +>this : this >x : ruatanica.Praseodymium melanorhinus() : samarensis.pelurus { var x : samarensis.pelurus; () => { var y = this; }; return x; } @@ -1929,8 +1929,8 @@ module Lanthanum { >rendalli : any >zuluensis : rendalli.zuluensis >() => { var y = this; } : () => void ->y : jugularis ->this : jugularis +>y : this +>this : this >x : samarensis.pelurus picticaudata() : minutus.inez, dogramacii.kaiseri> { var x : minutus.inez, dogramacii.kaiseri>; () => { var y = this; }; return x; } @@ -1957,8 +1957,8 @@ module Lanthanum { >dogramacii : any >kaiseri : dogramacii.kaiseri >() => { var y = this; } : () => void ->y : jugularis ->this : jugularis +>y : this +>this : this >x : minutus.inez, dogramacii.kaiseri> pomona() : julianae.steerii { var x : julianae.steerii; () => { var y = this; }; return x; } @@ -1969,8 +1969,8 @@ module Lanthanum { >julianae : any >steerii : julianae.steerii >() => { var y = this; } : () => void ->y : jugularis ->this : jugularis +>y : this +>this : this >x : julianae.steerii ileile() : quasiater.carolinensis { var x : quasiater.carolinensis; () => { var y = this; }; return x; } @@ -1981,8 +1981,8 @@ module Lanthanum { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : jugularis ->this : jugularis +>y : this +>this : this >x : quasiater.carolinensis } } @@ -2011,8 +2011,8 @@ module rendalli { >provocax : any >melanoleuca : provocax.melanoleuca >() => { var y = this; } : () => void ->y : zuluensis ->this : zuluensis +>y : this +>this : this >x : argurus.wetmorei keyensis() : quasiater.wattsi { var x : quasiater.wattsi; () => { var y = this; }; return x; } @@ -2031,8 +2031,8 @@ module rendalli { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : zuluensis ->this : zuluensis +>y : this +>this : this >x : quasiater.wattsi occasius() : argurus.gilbertii { var x : argurus.gilbertii; () => { var y = this; }; return x; } @@ -2051,8 +2051,8 @@ module rendalli { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : zuluensis ->this : zuluensis +>y : this +>this : this >x : argurus.gilbertii damarensis() : julianae.galapagoensis { var x : julianae.galapagoensis; () => { var y = this; }; return x; } @@ -2063,8 +2063,8 @@ module rendalli { >julianae : any >galapagoensis : julianae.galapagoensis >() => { var y = this; } : () => void ->y : zuluensis ->this : zuluensis +>y : this +>this : this >x : julianae.galapagoensis Neptunium() : panglima.abidi { var x : panglima.abidi; () => { var y = this; }; return x; } @@ -2083,8 +2083,8 @@ module rendalli { >lutreolus : any >foina : lutreolus.foina >() => { var y = this; } : () => void ->y : zuluensis ->this : zuluensis +>y : this +>this : this >x : panglima.abidi griseoflavus() : ruatanica.americanus { var x : ruatanica.americanus; () => { var y = this; }; return x; } @@ -2095,8 +2095,8 @@ module rendalli { >ruatanica : any >americanus : ruatanica.americanus >() => { var y = this; } : () => void ->y : zuluensis ->this : zuluensis +>y : this +>this : this >x : ruatanica.americanus thar() : argurus.oreas { var x : argurus.oreas; () => { var y = this; }; return x; } @@ -2107,8 +2107,8 @@ module rendalli { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : zuluensis ->this : zuluensis +>y : this +>this : this >x : argurus.oreas alborufus() : panamensis.linulus { var x : panamensis.linulus; () => { var y = this; }; return x; } @@ -2127,8 +2127,8 @@ module rendalli { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : zuluensis ->this : zuluensis +>y : this +>this : this >x : panamensis.linulus fusicaudus() : sagitta.stolzmanni { var x : sagitta.stolzmanni; () => { var y = this; }; return x; } @@ -2139,8 +2139,8 @@ module rendalli { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : zuluensis ->this : zuluensis +>y : this +>this : this >x : sagitta.stolzmanni gordonorum() : howi.angulatus { var x : howi.angulatus; () => { var y = this; }; return x; } @@ -2159,8 +2159,8 @@ module rendalli { >argurus : any >germaini : argurus.germaini >() => { var y = this; } : () => void ->y : zuluensis ->this : zuluensis +>y : this +>this : this >x : howi.angulatus ruber() : dammermani.siberu { var x : dammermani.siberu; () => { var y = this; }; return x; } @@ -2179,8 +2179,8 @@ module rendalli { >julianae : any >acariensis : julianae.acariensis >() => { var y = this; } : () => void ->y : zuluensis ->this : zuluensis +>y : this +>this : this >x : dammermani.siberu desmarestianus() : julianae.steerii { var x : julianae.steerii; () => { var y = this; }; return x; } @@ -2191,8 +2191,8 @@ module rendalli { >julianae : any >steerii : julianae.steerii >() => { var y = this; } : () => void ->y : zuluensis ->this : zuluensis +>y : this +>this : this >x : julianae.steerii lutillus() : nigra.dolichurus { var x : nigra.dolichurus; () => { var y = this; }; return x; } @@ -2211,8 +2211,8 @@ module rendalli { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : zuluensis ->this : zuluensis +>y : this +>this : this >x : nigra.dolichurus salocco() : argurus.peninsulae { var x : argurus.peninsulae; () => { var y = this; }; return x; } @@ -2223,8 +2223,8 @@ module rendalli { >argurus : any >peninsulae : argurus.peninsulae >() => { var y = this; } : () => void ->y : zuluensis ->this : zuluensis +>y : this +>this : this >x : argurus.peninsulae } export class moojeni { @@ -2240,8 +2240,8 @@ module rendalli { >lavali : any >otion : lavali.otion >() => { var y = this; } : () => void ->y : moojeni ->this : moojeni +>y : this +>this : this >x : lavali.otion montosa() : imperfecta.ciliolabrum { var x : imperfecta.ciliolabrum; () => { var y = this; }; return x; } @@ -2260,8 +2260,8 @@ module rendalli { >petrophilus : any >minutilla : petrophilus.minutilla >() => { var y = this; } : () => void ->y : moojeni ->this : moojeni +>y : this +>this : this >x : imperfecta.ciliolabrum miletus() : julianae.sumatrana { var x : julianae.sumatrana; () => { var y = this; }; return x; } @@ -2272,8 +2272,8 @@ module rendalli { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : moojeni ->this : moojeni +>y : this +>this : this >x : julianae.sumatrana heaneyi() : zuluensis { var x : zuluensis; () => { var y = this; }; return x; } @@ -2282,8 +2282,8 @@ module rendalli { >x : zuluensis >zuluensis : zuluensis >() => { var y = this; } : () => void ->y : moojeni ->this : moojeni +>y : this +>this : this >x : zuluensis marchei() : panglima.amphibius> { var x : panglima.amphibius>; () => { var y = this; }; return x; } @@ -2310,8 +2310,8 @@ module rendalli { >dogramacii : any >aurata : dogramacii.aurata >() => { var y = this; } : () => void ->y : moojeni ->this : moojeni +>y : this +>this : this >x : panglima.amphibius> budini() : julianae.durangae { var x : julianae.durangae; () => { var y = this; }; return x; } @@ -2322,8 +2322,8 @@ module rendalli { >julianae : any >durangae : julianae.durangae >() => { var y = this; } : () => void ->y : moojeni ->this : moojeni +>y : this +>this : this >x : julianae.durangae maggietaylorae() : trivirgatus.mixtus, imperfecta.subspinosus>, sagitta.stolzmanni> { var x : trivirgatus.mixtus, imperfecta.subspinosus>, sagitta.stolzmanni>; () => { var y = this; }; return x; } @@ -2358,8 +2358,8 @@ module rendalli { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : moojeni ->this : moojeni +>y : this +>this : this >x : trivirgatus.mixtus, imperfecta.subspinosus>, sagitta.stolzmanni> poliocephalus() : julianae.gerbillus { var x : julianae.gerbillus; () => { var y = this; }; return x; } @@ -2378,8 +2378,8 @@ module rendalli { >dammermani : any >melanops : dammermani.melanops >() => { var y = this; } : () => void ->y : moojeni ->this : moojeni +>y : this +>this : this >x : julianae.gerbillus zibethicus() : minutus.inez { var x : minutus.inez; () => { var y = this; }; return x; } @@ -2398,8 +2398,8 @@ module rendalli { >dammermani : any >melanops : dammermani.melanops >() => { var y = this; } : () => void ->y : moojeni ->this : moojeni +>y : this +>this : this >x : minutus.inez biacensis() : howi.coludo { var x : howi.coludo; () => { var y = this; }; return x; } @@ -2418,8 +2418,8 @@ module rendalli { >provocax : any >melanoleuca : provocax.melanoleuca >() => { var y = this; } : () => void ->y : moojeni ->this : moojeni +>y : this +>this : this >x : howi.coludo } export class crenulata extends trivirgatus.falconeri { @@ -2446,8 +2446,8 @@ module rendalli { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : crenulata ->this : crenulata +>y : this +>this : this >x : howi.coludo maritimus() : ruatanica.americanus { var x : ruatanica.americanus; () => { var y = this; }; return x; } @@ -2458,8 +2458,8 @@ module rendalli { >ruatanica : any >americanus : ruatanica.americanus >() => { var y = this; } : () => void ->y : crenulata ->this : crenulata +>y : this +>this : this >x : ruatanica.americanus edax() : lutreolus.cor>, rionegrensis.caniventer> { var x : lutreolus.cor>, rionegrensis.caniventer>; () => { var y = this; }; return x; } @@ -2494,8 +2494,8 @@ module rendalli { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : crenulata ->this : crenulata +>y : this +>this : this >x : lutreolus.cor>, rionegrensis.caniventer> } } @@ -2515,8 +2515,8 @@ module trivirgatus { >dogramacii : any >kaiseri : dogramacii.kaiseri >() => { var y = this; } : () => void ->y : tumidifrons ->this : tumidifrons +>y : this +>this : this >x : dogramacii.kaiseri vestitus() : lavali.xanthognathus { var x : lavali.xanthognathus; () => { var y = this; }; return x; } @@ -2527,8 +2527,8 @@ module trivirgatus { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : tumidifrons ->this : tumidifrons +>y : this +>this : this >x : lavali.xanthognathus aequatorius() : rionegrensis.caniventer { var x : rionegrensis.caniventer; () => { var y = this; }; return x; } @@ -2539,8 +2539,8 @@ module trivirgatus { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : tumidifrons ->this : tumidifrons +>y : this +>this : this >x : rionegrensis.caniventer scherman() : oconnelli { var x : oconnelli; () => { var y = this; }; return x; } @@ -2549,8 +2549,8 @@ module trivirgatus { >x : oconnelli >oconnelli : oconnelli >() => { var y = this; } : () => void ->y : tumidifrons ->this : tumidifrons +>y : this +>this : this >x : oconnelli improvisum() : argurus.peninsulae { var x : argurus.peninsulae; () => { var y = this; }; return x; } @@ -2561,8 +2561,8 @@ module trivirgatus { >argurus : any >peninsulae : argurus.peninsulae >() => { var y = this; } : () => void ->y : tumidifrons ->this : tumidifrons +>y : this +>this : this >x : argurus.peninsulae cervinipes() : panglima.abidi { var x : panglima.abidi; () => { var y = this; }; return x; } @@ -2581,8 +2581,8 @@ module trivirgatus { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : tumidifrons ->this : tumidifrons +>y : this +>this : this >x : panglima.abidi audax() : dogramacii.robustulus { var x : dogramacii.robustulus; () => { var y = this; }; return x; } @@ -2593,8 +2593,8 @@ module trivirgatus { >dogramacii : any >robustulus : dogramacii.robustulus >() => { var y = this; } : () => void ->y : tumidifrons ->this : tumidifrons +>y : this +>this : this >x : dogramacii.robustulus vallinus() : sagitta.sicarius { var x : sagitta.sicarius; () => { var y = this; }; return x; } @@ -2613,8 +2613,8 @@ module trivirgatus { >lutreolus : any >punicus : lutreolus.punicus >() => { var y = this; } : () => void ->y : tumidifrons ->this : tumidifrons +>y : this +>this : this >x : sagitta.sicarius } export class mixtus extends argurus.pygmaea> { @@ -2641,8 +2641,8 @@ module trivirgatus { >dogramacii : any >aurata : dogramacii.aurata >() => { var y = this; } : () => void ->y : mixtus ->this : mixtus +>y : this +>this : this >x : dogramacii.aurata bryophilus() : macrorhinos.marmosurus>> { var x : macrorhinos.marmosurus>>; () => { var y = this; }; return x; } @@ -2677,8 +2677,8 @@ module trivirgatus { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : mixtus ->this : mixtus +>y : this +>this : this >x : macrorhinos.marmosurus>> liechtensteini() : rendalli.zuluensis { var x : rendalli.zuluensis; () => { var y = this; }; return x; } @@ -2689,8 +2689,8 @@ module trivirgatus { >rendalli : any >zuluensis : rendalli.zuluensis >() => { var y = this; } : () => void ->y : mixtus ->this : mixtus +>y : this +>this : this >x : rendalli.zuluensis crawfordi() : howi.coludo> { var x : howi.coludo>; () => { var y = this; }; return x; } @@ -2717,8 +2717,8 @@ module trivirgatus { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : mixtus ->this : mixtus +>y : this +>this : this >x : howi.coludo> hypsibia() : lavali.thaeleri { var x : lavali.thaeleri; () => { var y = this; }; return x; } @@ -2729,8 +2729,8 @@ module trivirgatus { >lavali : any >thaeleri : lavali.thaeleri >() => { var y = this; } : () => void ->y : mixtus ->this : mixtus +>y : this +>this : this >x : lavali.thaeleri matacus() : panglima.fundatus, lavali.beisa>, dammermani.melanops> { var x : panglima.fundatus, lavali.beisa>, dammermani.melanops>; () => { var y = this; }; return x; } @@ -2763,8 +2763,8 @@ module trivirgatus { >dammermani : any >melanops : dammermani.melanops >() => { var y = this; } : () => void ->y : mixtus ->this : mixtus +>y : this +>this : this >x : panglima.fundatus, lavali.beisa>, dammermani.melanops> demidoff() : caurinus.johorensis { var x : caurinus.johorensis; () => { var y = this; }; return x; } @@ -2783,8 +2783,8 @@ module trivirgatus { >rendalli : any >zuluensis : rendalli.zuluensis >() => { var y = this; } : () => void ->y : mixtus ->this : mixtus +>y : this +>this : this >x : caurinus.johorensis } export class lotor { @@ -2800,8 +2800,8 @@ module trivirgatus { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : lotor ->this : lotor +>y : this +>this : this >x : samarensis.pallidus pullata() : rionegrensis.veraecrucis { var x : rionegrensis.veraecrucis; () => { var y = this; }; return x; } @@ -2820,8 +2820,8 @@ module trivirgatus { >argurus : any >peninsulae : argurus.peninsulae >() => { var y = this; } : () => void ->y : lotor ->this : lotor +>y : this +>this : this >x : rionegrensis.veraecrucis } export class falconeri { @@ -2867,8 +2867,8 @@ module trivirgatus { >julianae : any >steerii : julianae.steerii >() => { var y = this; } : () => void ->y : falconeri ->this : falconeri +>y : this +>this : this >x : rendalli.moojeni>, daubentonii.arboreus> gouldi() : nigra.dolichurus>, patas.uralensis> { var x : nigra.dolichurus>, patas.uralensis>; () => { var y = this; }; return x; } @@ -2903,8 +2903,8 @@ module trivirgatus { >patas : any >uralensis : patas.uralensis >() => { var y = this; } : () => void ->y : falconeri ->this : falconeri +>y : this +>this : this >x : nigra.dolichurus>, patas.uralensis> fuscicollis() : samarensis.pelurus> { var x : samarensis.pelurus>; () => { var y = this; }; return x; } @@ -2931,8 +2931,8 @@ module trivirgatus { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : falconeri ->this : falconeri +>y : this +>this : this >x : samarensis.pelurus> martiensseni() : sagitta.cinereus>, dogramacii.koepckeae> { var x : sagitta.cinereus>, dogramacii.koepckeae>; () => { var y = this; }; return x; } @@ -2967,8 +2967,8 @@ module trivirgatus { >dogramacii : any >koepckeae : dogramacii.koepckeae >() => { var y = this; } : () => void ->y : falconeri ->this : falconeri +>y : this +>this : this >x : sagitta.cinereus>, dogramacii.koepckeae> gaoligongensis() : dogramacii.koepckeae { var x : dogramacii.koepckeae; () => { var y = this; }; return x; } @@ -2979,8 +2979,8 @@ module trivirgatus { >dogramacii : any >koepckeae : dogramacii.koepckeae >() => { var y = this; } : () => void ->y : falconeri ->this : falconeri +>y : this +>this : this >x : dogramacii.koepckeae shawi() : minutus.inez> { var x : minutus.inez>; () => { var y = this; }; return x; } @@ -3007,8 +3007,8 @@ module trivirgatus { >quasiater : any >bobrinskoi : quasiater.bobrinskoi >() => { var y = this; } : () => void ->y : falconeri ->this : falconeri +>y : this +>this : this >x : minutus.inez> gmelini() : rionegrensis.caniventer { var x : rionegrensis.caniventer; () => { var y = this; }; return x; } @@ -3019,8 +3019,8 @@ module trivirgatus { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : falconeri ->this : falconeri +>y : this +>this : this >x : rionegrensis.caniventer } export class oconnelli { @@ -3042,8 +3042,8 @@ module trivirgatus { >julianae : any >galapagoensis : julianae.galapagoensis >() => { var y = this; } : () => void ->y : oconnelli ->this : oconnelli +>y : this +>this : this >x : nigra.thalia terrestris() : macrorhinos.konganensis { var x : macrorhinos.konganensis; () => { var y = this; }; return x; } @@ -3054,8 +3054,8 @@ module trivirgatus { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : oconnelli ->this : oconnelli +>y : this +>this : this >x : macrorhinos.konganensis chrysopus() : sagitta.sicarius> { var x : sagitta.sicarius>; () => { var y = this; }; return x; } @@ -3082,8 +3082,8 @@ module trivirgatus { >macrorhinos : any >daphaenodon : macrorhinos.daphaenodon >() => { var y = this; } : () => void ->y : oconnelli ->this : oconnelli +>y : this +>this : this >x : sagitta.sicarius> fuscomurina() : argurus.peninsulae { var x : argurus.peninsulae; () => { var y = this; }; return x; } @@ -3094,8 +3094,8 @@ module trivirgatus { >argurus : any >peninsulae : argurus.peninsulae >() => { var y = this; } : () => void ->y : oconnelli ->this : oconnelli +>y : this +>this : this >x : argurus.peninsulae hellwaldii() : nigra.gracilis, petrophilus.sodyi> { var x : nigra.gracilis, petrophilus.sodyi>; () => { var y = this; }; return x; } @@ -3130,8 +3130,8 @@ module trivirgatus { >macrorhinos : any >daphaenodon : macrorhinos.daphaenodon >() => { var y = this; } : () => void ->y : oconnelli ->this : oconnelli +>y : this +>this : this >x : nigra.gracilis, petrophilus.sodyi> aenea() : argurus.luctuosa { var x : argurus.luctuosa; () => { var y = this; }; return x; } @@ -3142,8 +3142,8 @@ module trivirgatus { >argurus : any >luctuosa : argurus.luctuosa >() => { var y = this; } : () => void ->y : oconnelli ->this : oconnelli +>y : this +>this : this >x : argurus.luctuosa perrini() : quasiater.bobrinskoi { var x : quasiater.bobrinskoi; () => { var y = this; }; return x; } @@ -3154,8 +3154,8 @@ module trivirgatus { >quasiater : any >bobrinskoi : quasiater.bobrinskoi >() => { var y = this; } : () => void ->y : oconnelli ->this : oconnelli +>y : this +>this : this >x : quasiater.bobrinskoi entellus() : dammermani.melanops { var x : dammermani.melanops; () => { var y = this; }; return x; } @@ -3166,8 +3166,8 @@ module trivirgatus { >dammermani : any >melanops : dammermani.melanops >() => { var y = this; } : () => void ->y : oconnelli ->this : oconnelli +>y : this +>this : this >x : dammermani.melanops krebsii() : rionegrensis.veraecrucis { var x : rionegrensis.veraecrucis; () => { var y = this; }; return x; } @@ -3186,8 +3186,8 @@ module trivirgatus { >julianae : any >durangae : julianae.durangae >() => { var y = this; } : () => void ->y : oconnelli ->this : oconnelli +>y : this +>this : this >x : rionegrensis.veraecrucis cephalotes() : lutreolus.schlegeli { var x : lutreolus.schlegeli; () => { var y = this; }; return x; } @@ -3198,8 +3198,8 @@ module trivirgatus { >lutreolus : any >schlegeli : lutreolus.schlegeli >() => { var y = this; } : () => void ->y : oconnelli ->this : oconnelli +>y : this +>this : this >x : lutreolus.schlegeli molossinus() : daubentonii.nigricans> { var x : daubentonii.nigricans>; () => { var y = this; }; return x; } @@ -3226,8 +3226,8 @@ module trivirgatus { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : oconnelli ->this : oconnelli +>y : this +>this : this >x : daubentonii.nigricans> luisi() : dogramacii.robustulus { var x : dogramacii.robustulus; () => { var y = this; }; return x; } @@ -3238,8 +3238,8 @@ module trivirgatus { >dogramacii : any >robustulus : dogramacii.robustulus >() => { var y = this; } : () => void ->y : oconnelli ->this : oconnelli +>y : this +>this : this >x : dogramacii.robustulus ceylonicus() : rionegrensis.caniventer { var x : rionegrensis.caniventer; () => { var y = this; }; return x; } @@ -3250,8 +3250,8 @@ module trivirgatus { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : oconnelli ->this : oconnelli +>y : this +>this : this >x : rionegrensis.caniventer ralli() : lavali.xanthognathus { var x : lavali.xanthognathus; () => { var y = this; }; return x; } @@ -3262,8 +3262,8 @@ module trivirgatus { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : oconnelli ->this : oconnelli +>y : this +>this : this >x : lavali.xanthognathus } } @@ -3289,8 +3289,8 @@ module quasiater { >argurus : any >luctuosa : argurus.luctuosa >() => { var y = this; } : () => void ->y : bobrinskoi ->this : bobrinskoi +>y : this +>this : this >x : samarensis.cahirinus mulatta() : argurus.oreas { var x : argurus.oreas; () => { var y = this; }; return x; } @@ -3301,8 +3301,8 @@ module quasiater { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : bobrinskoi ->this : bobrinskoi +>y : this +>this : this >x : argurus.oreas ansorgei() : rendalli.moojeni, gabriellae.echinatus> { var x : rendalli.moojeni, gabriellae.echinatus>; () => { var y = this; }; return x; } @@ -3329,8 +3329,8 @@ module quasiater { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : bobrinskoi ->this : bobrinskoi +>y : this +>this : this >x : rendalli.moojeni, gabriellae.echinatus> Copper() : argurus.netscheri { var x : argurus.netscheri; () => { var y = this; }; return x; } @@ -3349,8 +3349,8 @@ module quasiater { >dogramacii : any >kaiseri : dogramacii.kaiseri >() => { var y = this; } : () => void ->y : bobrinskoi ->this : bobrinskoi +>y : this +>this : this >x : argurus.netscheri } } @@ -3375,8 +3375,8 @@ module ruatanica { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : americanus ->this : americanus +>y : this +>this : this >x : macrorhinos.konganensis mystacalis() : howi.angulatus { var x : howi.angulatus; () => { var y = this; }; return x; } @@ -3395,8 +3395,8 @@ module ruatanica { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : americanus ->this : americanus +>y : this +>this : this >x : howi.angulatus fardoulisi() : trivirgatus.oconnelli { var x : trivirgatus.oconnelli; () => { var y = this; }; return x; } @@ -3407,8 +3407,8 @@ module ruatanica { >trivirgatus : any >oconnelli : trivirgatus.oconnelli >() => { var y = this; } : () => void ->y : americanus ->this : americanus +>y : this +>this : this >x : trivirgatus.oconnelli tumidus() : gabriellae.amicus { var x : gabriellae.amicus; () => { var y = this; }; return x; } @@ -3419,8 +3419,8 @@ module ruatanica { >gabriellae : any >amicus : gabriellae.amicus >() => { var y = this; } : () => void ->y : americanus ->this : americanus +>y : this +>this : this >x : gabriellae.amicus } } @@ -3451,8 +3451,8 @@ module lavali { >uralensis : patas.uralensis >wilsoni : wilsoni >() => { var y = this; } : () => void ->y : wilsoni ->this : wilsoni +>y : this +>this : this >x : nigra.thalia lorentzii() : imperfecta.subspinosus { var x : imperfecta.subspinosus; () => { var y = this; }; return x; } @@ -3463,8 +3463,8 @@ module lavali { >imperfecta : any >subspinosus : imperfecta.subspinosus >() => { var y = this; } : () => void ->y : wilsoni ->this : wilsoni +>y : this +>this : this >x : imperfecta.subspinosus antisensis() : lutreolus.foina { var x : lutreolus.foina; () => { var y = this; }; return x; } @@ -3475,8 +3475,8 @@ module lavali { >lutreolus : any >foina : lutreolus.foina >() => { var y = this; } : () => void ->y : wilsoni ->this : wilsoni +>y : this +>this : this >x : lutreolus.foina blossevillii() : dammermani.siberu { var x : dammermani.siberu; () => { var y = this; }; return x; } @@ -3495,8 +3495,8 @@ module lavali { >dogramacii : any >kaiseri : dogramacii.kaiseri >() => { var y = this; } : () => void ->y : wilsoni ->this : wilsoni +>y : this +>this : this >x : dammermani.siberu bontanus() : rionegrensis.caniventer { var x : rionegrensis.caniventer; () => { var y = this; }; return x; } @@ -3507,8 +3507,8 @@ module lavali { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : wilsoni ->this : wilsoni +>y : this +>this : this >x : rionegrensis.caniventer caligata() : argurus.oreas { var x : argurus.oreas; () => { var y = this; }; return x; } @@ -3519,8 +3519,8 @@ module lavali { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : wilsoni ->this : wilsoni +>y : this +>this : this >x : argurus.oreas franqueti() : panglima.amphibius, imperfecta.subspinosus> { var x : panglima.amphibius, imperfecta.subspinosus>; () => { var y = this; }; return x; } @@ -3547,8 +3547,8 @@ module lavali { >imperfecta : any >subspinosus : imperfecta.subspinosus >() => { var y = this; } : () => void ->y : wilsoni ->this : wilsoni +>y : this +>this : this >x : panglima.amphibius, imperfecta.subspinosus> roberti() : julianae.acariensis { var x : julianae.acariensis; () => { var y = this; }; return x; } @@ -3559,8 +3559,8 @@ module lavali { >julianae : any >acariensis : julianae.acariensis >() => { var y = this; } : () => void ->y : wilsoni ->this : wilsoni +>y : this +>this : this >x : julianae.acariensis degelidus() : chrysaeolus.sarasinorum { var x : chrysaeolus.sarasinorum; () => { var y = this; }; return x; } @@ -3579,8 +3579,8 @@ module lavali { >imperfecta : any >subspinosus : imperfecta.subspinosus >() => { var y = this; } : () => void ->y : wilsoni ->this : wilsoni +>y : this +>this : this >x : chrysaeolus.sarasinorum amoenus() : quasiater.carolinensis { var x : quasiater.carolinensis; () => { var y = this; }; return x; } @@ -3591,8 +3591,8 @@ module lavali { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : wilsoni ->this : wilsoni +>y : this +>this : this >x : quasiater.carolinensis kob() : trivirgatus.lotor { var x : trivirgatus.lotor; () => { var y = this; }; return x; } @@ -3609,8 +3609,8 @@ module lavali { >oreas : argurus.oreas >beisa : beisa >() => { var y = this; } : () => void ->y : wilsoni ->this : wilsoni +>y : this +>this : this >x : trivirgatus.lotor csorbai() : caurinus.johorensis { var x : caurinus.johorensis; () => { var y = this; }; return x; } @@ -3629,8 +3629,8 @@ module lavali { >julianae : any >steerii : julianae.steerii >() => { var y = this; } : () => void ->y : wilsoni ->this : wilsoni +>y : this +>this : this >x : caurinus.johorensis dorsata() : gabriellae.echinatus { var x : gabriellae.echinatus; () => { var y = this; }; return x; } @@ -3641,8 +3641,8 @@ module lavali { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : wilsoni ->this : wilsoni +>y : this +>this : this >x : gabriellae.echinatus } export class beisa { @@ -3666,8 +3666,8 @@ module lavali { >provocax : any >melanoleuca : provocax.melanoleuca >() => { var y = this; } : () => void ->y : otion ->this : otion +>y : this +>this : this >x : provocax.melanoleuca dussumieri() : nigra.gracilis { var x : nigra.gracilis; () => { var y = this; }; return x; } @@ -3686,8 +3686,8 @@ module lavali { >dogramacii : any >kaiseri : dogramacii.kaiseri >() => { var y = this; } : () => void ->y : otion ->this : otion +>y : this +>this : this >x : nigra.gracilis osvaldoreigi() : julianae.albidens { var x : julianae.albidens; () => { var y = this; }; return x; } @@ -3706,8 +3706,8 @@ module lavali { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : otion ->this : otion +>y : this +>this : this >x : julianae.albidens grevyi() : samarensis.pallidus { var x : samarensis.pallidus; () => { var y = this; }; return x; } @@ -3718,8 +3718,8 @@ module lavali { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : otion ->this : otion +>y : this +>this : this >x : samarensis.pallidus hirtula() : lepturus { var x : lepturus; () => { var y = this; }; return x; } @@ -3728,8 +3728,8 @@ module lavali { >x : lepturus >lepturus : lepturus >() => { var y = this; } : () => void ->y : otion ->this : otion +>y : this +>this : this >x : lepturus cristatus() : argurus.luctuosa { var x : argurus.luctuosa; () => { var y = this; }; return x; } @@ -3740,8 +3740,8 @@ module lavali { >argurus : any >luctuosa : argurus.luctuosa >() => { var y = this; } : () => void ->y : otion ->this : otion +>y : this +>this : this >x : argurus.luctuosa darlingtoni() : sagitta.leptoceros { var x : sagitta.leptoceros; () => { var y = this; }; return x; } @@ -3758,8 +3758,8 @@ module lavali { >trivirgatus : any >oconnelli : trivirgatus.oconnelli >() => { var y = this; } : () => void ->y : otion ->this : otion +>y : this +>this : this >x : sagitta.leptoceros fontanierii() : panamensis.setulosus>, lutreolus.foina> { var x : panamensis.setulosus>, lutreolus.foina>; () => { var y = this; }; return x; } @@ -3792,8 +3792,8 @@ module lavali { >lutreolus : any >foina : lutreolus.foina >() => { var y = this; } : () => void ->y : otion ->this : otion +>y : this +>this : this >x : panamensis.setulosus>, lutreolus.foina> umbrosus() : howi.marcanoi { var x : howi.marcanoi; () => { var y = this; }; return x; } @@ -3804,8 +3804,8 @@ module lavali { >howi : any >marcanoi : howi.marcanoi >() => { var y = this; } : () => void ->y : otion ->this : otion +>y : this +>this : this >x : howi.marcanoi chiriquinus() : imperfecta.lasiurus { var x : imperfecta.lasiurus; () => { var y = this; }; return x; } @@ -3824,8 +3824,8 @@ module lavali { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : otion ->this : otion +>y : this +>this : this >x : imperfecta.lasiurus orarius() : lutreolus.schlegeli { var x : lutreolus.schlegeli; () => { var y = this; }; return x; } @@ -3836,8 +3836,8 @@ module lavali { >lutreolus : any >schlegeli : lutreolus.schlegeli >() => { var y = this; } : () => void ->y : otion ->this : otion +>y : this +>this : this >x : lutreolus.schlegeli ilaeus() : caurinus.mahaganus { var x : caurinus.mahaganus; () => { var y = this; }; return x; } @@ -3856,8 +3856,8 @@ module lavali { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : otion ->this : otion +>y : this +>this : this >x : caurinus.mahaganus musschenbroekii() : trivirgatus.falconeri { var x : trivirgatus.falconeri; () => { var y = this; }; return x; } @@ -3868,8 +3868,8 @@ module lavali { >trivirgatus : any >falconeri : trivirgatus.falconeri >() => { var y = this; } : () => void ->y : otion ->this : otion +>y : this +>this : this >x : trivirgatus.falconeri } export class xanthognathus { @@ -3891,8 +3891,8 @@ module lavali { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : xanthognathus ->this : xanthognathus +>y : this +>this : this >x : daubentonii.nigricans albigena() : chrysaeolus.sarasinorum { var x : chrysaeolus.sarasinorum; () => { var y = this; }; return x; } @@ -3911,8 +3911,8 @@ module lavali { >quasiater : any >bobrinskoi : quasiater.bobrinskoi >() => { var y = this; } : () => void ->y : xanthognathus ->this : xanthognathus +>y : this +>this : this >x : chrysaeolus.sarasinorum onca() : sagitta.stolzmanni { var x : sagitta.stolzmanni; () => { var y = this; }; return x; } @@ -3923,8 +3923,8 @@ module lavali { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : xanthognathus ->this : xanthognathus +>y : this +>this : this >x : sagitta.stolzmanni gunnii() : minutus.himalayana, nigra.thalia> { var x : minutus.himalayana, nigra.thalia>; () => { var y = this; }; return x; } @@ -3957,8 +3957,8 @@ module lavali { >dogramacii : any >robustulus : dogramacii.robustulus >() => { var y = this; } : () => void ->y : xanthognathus ->this : xanthognathus +>y : this +>this : this >x : minutus.himalayana, nigra.thalia> apeco() : lutreolus.foina { var x : lutreolus.foina; () => { var y = this; }; return x; } @@ -3969,8 +3969,8 @@ module lavali { >lutreolus : any >foina : lutreolus.foina >() => { var y = this; } : () => void ->y : xanthognathus ->this : xanthognathus +>y : this +>this : this >x : lutreolus.foina variegates() : gabriellae.klossii { var x : gabriellae.klossii; () => { var y = this; }; return x; } @@ -3987,8 +3987,8 @@ module lavali { >julianae : any >nudicaudus : julianae.nudicaudus >() => { var y = this; } : () => void ->y : xanthognathus ->this : xanthognathus +>y : this +>this : this >x : gabriellae.klossii goudotii() : trivirgatus.falconeri { var x : trivirgatus.falconeri; () => { var y = this; }; return x; } @@ -3999,8 +3999,8 @@ module lavali { >trivirgatus : any >falconeri : trivirgatus.falconeri >() => { var y = this; } : () => void ->y : xanthognathus ->this : xanthognathus +>y : this +>this : this >x : trivirgatus.falconeri pohlei() : Lanthanum.megalonyx { var x : Lanthanum.megalonyx; () => { var y = this; }; return x; } @@ -4011,8 +4011,8 @@ module lavali { >Lanthanum : any >megalonyx : Lanthanum.megalonyx >() => { var y = this; } : () => void ->y : xanthognathus ->this : xanthognathus +>y : this +>this : this >x : Lanthanum.megalonyx ineptus() : panamensis.setulosus { var x : panamensis.setulosus; () => { var y = this; }; return x; } @@ -4027,8 +4027,8 @@ module lavali { >xanthognathus : xanthognathus >beisa : beisa >() => { var y = this; } : () => void ->y : xanthognathus ->this : xanthognathus +>y : this +>this : this >x : panamensis.setulosus euryotis() : rendalli.moojeni> { var x : rendalli.moojeni>; () => { var y = this; }; return x; } @@ -4055,8 +4055,8 @@ module lavali { >ruatanica : any >americanus : ruatanica.americanus >() => { var y = this; } : () => void ->y : xanthognathus ->this : xanthognathus +>y : this +>this : this >x : rendalli.moojeni> maurisca() : Lanthanum.suillus { var x : Lanthanum.suillus; () => { var y = this; }; return x; } @@ -4075,8 +4075,8 @@ module lavali { >imperfecta : any >subspinosus : imperfecta.subspinosus >() => { var y = this; } : () => void ->y : xanthognathus ->this : xanthognathus +>y : this +>this : this >x : Lanthanum.suillus coyhaiquensis() : caurinus.mahaganus, panglima.abidi>, lutreolus.punicus> { var x : caurinus.mahaganus, panglima.abidi>, lutreolus.punicus>; () => { var y = this; }; return x; } @@ -4119,8 +4119,8 @@ module lavali { >lutreolus : any >punicus : lutreolus.punicus >() => { var y = this; } : () => void ->y : xanthognathus ->this : xanthognathus +>y : this +>this : this >x : caurinus.mahaganus, panglima.abidi>, lutreolus.punicus> } export class thaeleri extends argurus.oreas { @@ -4137,8 +4137,8 @@ module lavali { >julianae : any >galapagoensis : julianae.galapagoensis >() => { var y = this; } : () => void ->y : thaeleri ->this : thaeleri +>y : this +>this : this >x : julianae.galapagoensis parvipes() : nigra.dolichurus { var x : nigra.dolichurus; () => { var y = this; }; return x; } @@ -4157,8 +4157,8 @@ module lavali { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : thaeleri ->this : thaeleri +>y : this +>this : this >x : nigra.dolichurus sponsorius() : rionegrensis.veraecrucis, julianae.steerii> { var x : rionegrensis.veraecrucis, julianae.steerii>; () => { var y = this; }; return x; } @@ -4185,8 +4185,8 @@ module lavali { >julianae : any >steerii : julianae.steerii >() => { var y = this; } : () => void ->y : thaeleri ->this : thaeleri +>y : this +>this : this >x : rionegrensis.veraecrucis, julianae.steerii> vates() : dogramacii.robustulus { var x : dogramacii.robustulus; () => { var y = this; }; return x; } @@ -4197,8 +4197,8 @@ module lavali { >dogramacii : any >robustulus : dogramacii.robustulus >() => { var y = this; } : () => void ->y : thaeleri ->this : thaeleri +>y : this +>this : this >x : dogramacii.robustulus roosmalenorum() : dogramacii.koepckeae { var x : dogramacii.koepckeae; () => { var y = this; }; return x; } @@ -4209,8 +4209,8 @@ module lavali { >dogramacii : any >koepckeae : dogramacii.koepckeae >() => { var y = this; } : () => void ->y : thaeleri ->this : thaeleri +>y : this +>this : this >x : dogramacii.koepckeae rubicola() : rendalli.moojeni, gabriellae.echinatus>> { var x : rendalli.moojeni, gabriellae.echinatus>>; () => { var y = this; }; return x; } @@ -4245,8 +4245,8 @@ module lavali { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : thaeleri ->this : thaeleri +>y : this +>this : this >x : rendalli.moojeni, gabriellae.echinatus>> ikonnikovi() : argurus.luctuosa { var x : argurus.luctuosa; () => { var y = this; }; return x; } @@ -4257,8 +4257,8 @@ module lavali { >argurus : any >luctuosa : argurus.luctuosa >() => { var y = this; } : () => void ->y : thaeleri ->this : thaeleri +>y : this +>this : this >x : argurus.luctuosa paramicrus() : imperfecta.ciliolabrum> { var x : imperfecta.ciliolabrum>; () => { var y = this; }; return x; } @@ -4283,8 +4283,8 @@ module lavali { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : thaeleri ->this : thaeleri +>y : this +>this : this >x : imperfecta.ciliolabrum> } export class lepturus extends Lanthanum.suillus { @@ -4313,8 +4313,8 @@ module lavali { >julianae : any >nudicaudus : julianae.nudicaudus >() => { var y = this; } : () => void ->y : lepturus ->this : lepturus +>y : this +>this : this >x : argurus.netscheri aequalis() : sagitta.cinereus>, petrophilus.minutilla>, Lanthanum.jugularis> { var x : sagitta.cinereus>, petrophilus.minutilla>, Lanthanum.jugularis>; () => { var y = this; }; return x; } @@ -4355,8 +4355,8 @@ module lavali { >Lanthanum : any >jugularis : Lanthanum.jugularis >() => { var y = this; } : () => void ->y : lepturus ->this : lepturus +>y : this +>this : this >x : sagitta.cinereus>, petrophilus.minutilla>, Lanthanum.jugularis> } } @@ -4385,8 +4385,8 @@ module dogramacii { >julianae : any >nudicaudus : julianae.nudicaudus >() => { var y = this; } : () => void ->y : robustulus ->this : robustulus +>y : this +>this : this >x : minutus.inez humboldti() : sagitta.cinereus { var x : sagitta.cinereus; () => { var y = this; }; return x; } @@ -4405,8 +4405,8 @@ module dogramacii { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : robustulus ->this : robustulus +>y : this +>this : this >x : sagitta.cinereus mexicana() : macrorhinos.konganensis { var x : macrorhinos.konganensis; () => { var y = this; }; return x; } @@ -4417,8 +4417,8 @@ module dogramacii { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : robustulus ->this : robustulus +>y : this +>this : this >x : macrorhinos.konganensis martini() : julianae.oralis { var x : julianae.oralis; () => { var y = this; }; return x; } @@ -4437,8 +4437,8 @@ module dogramacii { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : robustulus ->this : robustulus +>y : this +>this : this >x : julianae.oralis beatus() : Lanthanum.jugularis { var x : Lanthanum.jugularis; () => { var y = this; }; return x; } @@ -4449,8 +4449,8 @@ module dogramacii { >Lanthanum : any >jugularis : Lanthanum.jugularis >() => { var y = this; } : () => void ->y : robustulus ->this : robustulus +>y : this +>this : this >x : Lanthanum.jugularis leporina() : trivirgatus.falconeri { var x : trivirgatus.falconeri; () => { var y = this; }; return x; } @@ -4461,8 +4461,8 @@ module dogramacii { >trivirgatus : any >falconeri : trivirgatus.falconeri >() => { var y = this; } : () => void ->y : robustulus ->this : robustulus +>y : this +>this : this >x : trivirgatus.falconeri pearsonii() : dammermani.melanops { var x : dammermani.melanops; () => { var y = this; }; return x; } @@ -4473,8 +4473,8 @@ module dogramacii { >dammermani : any >melanops : dammermani.melanops >() => { var y = this; } : () => void ->y : robustulus ->this : robustulus +>y : this +>this : this >x : dammermani.melanops keaysi() : howi.angulatus { var x : howi.angulatus; () => { var y = this; }; return x; } @@ -4493,8 +4493,8 @@ module dogramacii { >rendalli : any >zuluensis : rendalli.zuluensis >() => { var y = this; } : () => void ->y : robustulus ->this : robustulus +>y : this +>this : this >x : howi.angulatus hindei() : imperfecta.lasiurus { var x : imperfecta.lasiurus; () => { var y = this; }; return x; } @@ -4513,8 +4513,8 @@ module dogramacii { >julianae : any >steerii : julianae.steerii >() => { var y = this; } : () => void ->y : robustulus ->this : robustulus +>y : this +>this : this >x : imperfecta.lasiurus } export class koepckeae { @@ -4542,8 +4542,8 @@ module dogramacii { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : koepckeae ->this : koepckeae +>y : this +>this : this >x : samarensis.pelurus, julianae.sumatrana> } export class kaiseri { @@ -4557,8 +4557,8 @@ module dogramacii { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : kaiseri ->this : kaiseri +>y : this +>this : this >x : quasiater.carolinensis paramorum() : Lanthanum.megalonyx { var x : Lanthanum.megalonyx; () => { var y = this; }; return x; } @@ -4569,8 +4569,8 @@ module dogramacii { >Lanthanum : any >megalonyx : Lanthanum.megalonyx >() => { var y = this; } : () => void ->y : kaiseri ->this : kaiseri +>y : this +>this : this >x : Lanthanum.megalonyx rubidus() : trivirgatus.lotor { var x : trivirgatus.lotor; () => { var y = this; }; return x; } @@ -4589,8 +4589,8 @@ module dogramacii { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : kaiseri ->this : kaiseri +>y : this +>this : this >x : trivirgatus.lotor juninensis() : quasiater.bobrinskoi { var x : quasiater.bobrinskoi; () => { var y = this; }; return x; } @@ -4601,8 +4601,8 @@ module dogramacii { >quasiater : any >bobrinskoi : quasiater.bobrinskoi >() => { var y = this; } : () => void ->y : kaiseri ->this : kaiseri +>y : this +>this : this >x : quasiater.bobrinskoi marginata() : argurus.wetmorei>> { var x : argurus.wetmorei>>; () => { var y = this; }; return x; } @@ -4637,8 +4637,8 @@ module dogramacii { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : kaiseri ->this : kaiseri +>y : this +>this : this >x : argurus.wetmorei>> Meitnerium() : ruatanica.Praseodymium> { var x : ruatanica.Praseodymium>; () => { var y = this; }; return x; } @@ -4665,8 +4665,8 @@ module dogramacii { >julianae : any >galapagoensis : julianae.galapagoensis >() => { var y = this; } : () => void ->y : kaiseri ->this : kaiseri +>y : this +>this : this >x : ruatanica.Praseodymium> pinetorum() : rionegrensis.caniventer { var x : rionegrensis.caniventer; () => { var y = this; }; return x; } @@ -4677,8 +4677,8 @@ module dogramacii { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : kaiseri ->this : kaiseri +>y : this +>this : this >x : rionegrensis.caniventer hoolock() : samarensis.pelurus { var x : samarensis.pelurus; () => { var y = this; }; return x; } @@ -4697,8 +4697,8 @@ module dogramacii { >argurus : any >luctuosa : argurus.luctuosa >() => { var y = this; } : () => void ->y : kaiseri ->this : kaiseri +>y : this +>this : this >x : samarensis.pelurus poeyi() : gabriellae.echinatus { var x : gabriellae.echinatus; () => { var y = this; }; return x; } @@ -4709,8 +4709,8 @@ module dogramacii { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : kaiseri ->this : kaiseri +>y : this +>this : this >x : gabriellae.echinatus Thulium() : julianae.durangae { var x : julianae.durangae; () => { var y = this; }; return x; } @@ -4721,8 +4721,8 @@ module dogramacii { >julianae : any >durangae : julianae.durangae >() => { var y = this; } : () => void ->y : kaiseri ->this : kaiseri +>y : this +>this : this >x : julianae.durangae patrius() : Lanthanum.jugularis { var x : Lanthanum.jugularis; () => { var y = this; }; return x; } @@ -4733,8 +4733,8 @@ module dogramacii { >Lanthanum : any >jugularis : Lanthanum.jugularis >() => { var y = this; } : () => void ->y : kaiseri ->this : kaiseri +>y : this +>this : this >x : Lanthanum.jugularis quadraticauda() : julianae.nudicaudus { var x : julianae.nudicaudus; () => { var y = this; }; return x; } @@ -4745,8 +4745,8 @@ module dogramacii { >julianae : any >nudicaudus : julianae.nudicaudus >() => { var y = this; } : () => void ->y : kaiseri ->this : kaiseri +>y : this +>this : this >x : julianae.nudicaudus ater() : ruatanica.americanus { var x : ruatanica.americanus; () => { var y = this; }; return x; } @@ -4757,8 +4757,8 @@ module dogramacii { >ruatanica : any >americanus : ruatanica.americanus >() => { var y = this; } : () => void ->y : kaiseri ->this : kaiseri +>y : this +>this : this >x : ruatanica.americanus } export class aurata { @@ -4794,8 +4794,8 @@ module dogramacii { >ruatanica : any >americanus : ruatanica.americanus >() => { var y = this; } : () => void ->y : aurata ->this : aurata +>y : this +>this : this >x : nigra.gracilis, julianae.sumatrana>, ruatanica.americanus> howensis() : ruatanica.americanus { var x : ruatanica.americanus; () => { var y = this; }; return x; } @@ -4806,8 +4806,8 @@ module dogramacii { >ruatanica : any >americanus : ruatanica.americanus >() => { var y = this; } : () => void ->y : aurata ->this : aurata +>y : this +>this : this >x : ruatanica.americanus karlkoopmani() : caurinus.psilurus { var x : caurinus.psilurus; () => { var y = this; }; return x; } @@ -4818,8 +4818,8 @@ module dogramacii { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : aurata ->this : aurata +>y : this +>this : this >x : caurinus.psilurus mirapitanga() : julianae.albidens { var x : julianae.albidens; () => { var y = this; }; return x; } @@ -4838,8 +4838,8 @@ module dogramacii { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : aurata ->this : aurata +>y : this +>this : this >x : julianae.albidens ophiodon() : aurata { var x : aurata; () => { var y = this; }; return x; } @@ -4848,8 +4848,8 @@ module dogramacii { >x : aurata >aurata : aurata >() => { var y = this; } : () => void ->y : aurata ->this : aurata +>y : this +>this : this >x : aurata landeri() : samarensis.pelurus { var x : samarensis.pelurus; () => { var y = this; }; return x; } @@ -4868,8 +4868,8 @@ module dogramacii { >ruatanica : any >americanus : ruatanica.americanus >() => { var y = this; } : () => void ->y : aurata ->this : aurata +>y : this +>this : this >x : samarensis.pelurus sonomae() : trivirgatus.lotor, koepckeae> { var x : trivirgatus.lotor, koepckeae>; () => { var y = this; }; return x; } @@ -4894,8 +4894,8 @@ module dogramacii { >psilurus : caurinus.psilurus >koepckeae : koepckeae >() => { var y = this; } : () => void ->y : aurata ->this : aurata +>y : this +>this : this >x : trivirgatus.lotor, koepckeae> erythromos() : caurinus.johorensis, nigra.dolichurus> { var x : caurinus.johorensis, nigra.dolichurus>; () => { var y = this; }; return x; } @@ -4930,8 +4930,8 @@ module dogramacii { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : aurata ->this : aurata +>y : this +>this : this >x : caurinus.johorensis, nigra.dolichurus> } } @@ -4952,8 +4952,8 @@ module lutreolus { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : schlegeli ->this : schlegeli +>y : this +>this : this >x : rionegrensis.caniventer blicki() : dogramacii.robustulus { var x : dogramacii.robustulus; () => { var y = this; }; return x; } @@ -4964,8 +4964,8 @@ module lutreolus { >dogramacii : any >robustulus : dogramacii.robustulus >() => { var y = this; } : () => void ->y : schlegeli ->this : schlegeli +>y : this +>this : this >x : dogramacii.robustulus culionensis() : argurus.dauricus { var x : argurus.dauricus; () => { var y = this; }; return x; } @@ -4984,8 +4984,8 @@ module lutreolus { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : schlegeli ->this : schlegeli +>y : this +>this : this >x : argurus.dauricus scrofa() : petrophilus.sodyi { var x : petrophilus.sodyi; () => { var y = this; }; return x; } @@ -5004,8 +5004,8 @@ module lutreolus { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : schlegeli ->this : schlegeli +>y : this +>this : this >x : petrophilus.sodyi fernandoni() : quasiater.carolinensis { var x : quasiater.carolinensis; () => { var y = this; }; return x; } @@ -5016,8 +5016,8 @@ module lutreolus { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : schlegeli ->this : schlegeli +>y : this +>this : this >x : quasiater.carolinensis Tin() : sagitta.leptoceros> { var x : sagitta.leptoceros>; () => { var y = this; }; return x; } @@ -5044,8 +5044,8 @@ module lutreolus { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : schlegeli ->this : schlegeli +>y : this +>this : this >x : sagitta.leptoceros> marmorata() : panamensis.setulosus> { var x : panamensis.setulosus>; () => { var y = this; }; return x; } @@ -5072,8 +5072,8 @@ module lutreolus { >lutreolus : any >punicus : punicus >() => { var y = this; } : () => void ->y : schlegeli ->this : schlegeli +>y : this +>this : this >x : panamensis.setulosus> tavaratra() : Lanthanum.nitidus { var x : Lanthanum.nitidus; () => { var y = this; }; return x; } @@ -5092,8 +5092,8 @@ module lutreolus { >macrorhinos : any >daphaenodon : macrorhinos.daphaenodon >() => { var y = this; } : () => void ->y : schlegeli ->this : schlegeli +>y : this +>this : this >x : Lanthanum.nitidus peregrina() : daubentonii.nesiotes { var x : daubentonii.nesiotes; () => { var y = this; }; return x; } @@ -5112,8 +5112,8 @@ module lutreolus { >lutreolus : any >punicus : punicus >() => { var y = this; } : () => void ->y : schlegeli ->this : schlegeli +>y : this +>this : this >x : daubentonii.nesiotes frontalis() : macrorhinos.marmosurus>, samarensis.pallidus> { var x : macrorhinos.marmosurus>, samarensis.pallidus>; () => { var y = this; }; return x; } @@ -5148,8 +5148,8 @@ module lutreolus { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : schlegeli ->this : schlegeli +>y : this +>this : this >x : macrorhinos.marmosurus>, samarensis.pallidus> cuniculus() : patas.uralensis { var x : patas.uralensis; () => { var y = this; }; return x; } @@ -5160,8 +5160,8 @@ module lutreolus { >patas : any >uralensis : patas.uralensis >() => { var y = this; } : () => void ->y : schlegeli ->this : schlegeli +>y : this +>this : this >x : patas.uralensis magdalenae() : julianae.gerbillus> { var x : julianae.gerbillus>; () => { var y = this; }; return x; } @@ -5188,8 +5188,8 @@ module lutreolus { >dogramacii : any >robustulus : dogramacii.robustulus >() => { var y = this; } : () => void ->y : schlegeli ->this : schlegeli +>y : this +>this : this >x : julianae.gerbillus> andamanensis() : julianae.oralis { var x : julianae.oralis; () => { var y = this; }; return x; } @@ -5208,8 +5208,8 @@ module lutreolus { >rendalli : any >zuluensis : rendalli.zuluensis >() => { var y = this; } : () => void ->y : schlegeli ->this : schlegeli +>y : this +>this : this >x : julianae.oralis dispar() : panamensis.linulus { var x : panamensis.linulus; () => { var y = this; }; return x; } @@ -5228,8 +5228,8 @@ module lutreolus { >minutus : any >portoricensis : minutus.portoricensis >() => { var y = this; } : () => void ->y : schlegeli ->this : schlegeli +>y : this +>this : this >x : panamensis.linulus } } @@ -5249,8 +5249,8 @@ module argurus { >Lanthanum : any >jugularis : Lanthanum.jugularis >() => { var y = this; } : () => void ->y : dauricus ->this : dauricus +>y : this +>this : this >x : Lanthanum.jugularis duodecimcostatus() : lavali.xanthognathus { var x : lavali.xanthognathus; () => { var y = this; }; return x; } @@ -5261,8 +5261,8 @@ module argurus { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : dauricus ->this : dauricus +>y : this +>this : this >x : lavali.xanthognathus foxi() : daubentonii.nesiotes { var x : daubentonii.nesiotes; () => { var y = this; }; return x; } @@ -5281,8 +5281,8 @@ module argurus { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : dauricus ->this : dauricus +>y : this +>this : this >x : daubentonii.nesiotes macleayii() : petrophilus.sodyi>, petrophilus.minutilla> { var x : petrophilus.sodyi>, petrophilus.minutilla>; () => { var y = this; }; return x; } @@ -5317,8 +5317,8 @@ module argurus { >petrophilus : any >minutilla : petrophilus.minutilla >() => { var y = this; } : () => void ->y : dauricus ->this : dauricus +>y : this +>this : this >x : petrophilus.sodyi>, petrophilus.minutilla> darienensis() : trivirgatus.oconnelli { var x : trivirgatus.oconnelli; () => { var y = this; }; return x; } @@ -5329,8 +5329,8 @@ module argurus { >trivirgatus : any >oconnelli : trivirgatus.oconnelli >() => { var y = this; } : () => void ->y : dauricus ->this : dauricus +>y : this +>this : this >x : trivirgatus.oconnelli hardwickii() : macrorhinos.daphaenodon { var x : macrorhinos.daphaenodon; () => { var y = this; }; return x; } @@ -5341,8 +5341,8 @@ module argurus { >macrorhinos : any >daphaenodon : macrorhinos.daphaenodon >() => { var y = this; } : () => void ->y : dauricus ->this : dauricus +>y : this +>this : this >x : macrorhinos.daphaenodon albifrons() : rionegrensis.veraecrucis { var x : rionegrensis.veraecrucis; () => { var y = this; }; return x; } @@ -5361,8 +5361,8 @@ module argurus { >julianae : any >durangae : julianae.durangae >() => { var y = this; } : () => void ->y : dauricus ->this : dauricus +>y : this +>this : this >x : rionegrensis.veraecrucis jacobitus() : caurinus.johorensis>> { var x : caurinus.johorensis>>; () => { var y = this; }; return x; } @@ -5397,8 +5397,8 @@ module argurus { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : dauricus ->this : dauricus +>y : this +>this : this >x : caurinus.johorensis>> guentheri() : rendalli.moojeni { var x : rendalli.moojeni; () => { var y = this; }; return x; } @@ -5417,8 +5417,8 @@ module argurus { >argurus : any >oreas : oreas >() => { var y = this; } : () => void ->y : dauricus ->this : dauricus +>y : this +>this : this >x : rendalli.moojeni mahomet() : imperfecta.ciliolabrum { var x : imperfecta.ciliolabrum; () => { var y = this; }; return x; } @@ -5437,8 +5437,8 @@ module argurus { >lutreolus : any >foina : lutreolus.foina >() => { var y = this; } : () => void ->y : dauricus ->this : dauricus +>y : this +>this : this >x : imperfecta.ciliolabrum misionensis() : macrorhinos.marmosurus, gabriellae.echinatus> { var x : macrorhinos.marmosurus, gabriellae.echinatus>; () => { var y = this; }; return x; } @@ -5465,8 +5465,8 @@ module argurus { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : dauricus ->this : dauricus +>y : this +>this : this >x : macrorhinos.marmosurus, gabriellae.echinatus> } } @@ -5534,8 +5534,8 @@ module nigra { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : dolichurus ->this : dolichurus +>y : this +>this : this >x : panglima.abidi, argurus.netscheri, julianae.oralis>>> alfredi() : caurinus.psilurus { var x : caurinus.psilurus; () => { var y = this; }; return x; } @@ -5546,8 +5546,8 @@ module nigra { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : dolichurus ->this : dolichurus +>y : this +>this : this >x : caurinus.psilurus morrisi() : ruatanica.hector, quasiater.wattsi>>> { var x : ruatanica.hector, quasiater.wattsi>>>; () => { var y = this; }; return x; } @@ -5598,8 +5598,8 @@ module nigra { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : dolichurus ->this : dolichurus +>y : this +>this : this >x : ruatanica.hector, quasiater.wattsi>>> lekaguli() : Lanthanum.nitidus { var x : Lanthanum.nitidus; () => { var y = this; }; return x; } @@ -5618,8 +5618,8 @@ module nigra { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : dolichurus ->this : dolichurus +>y : this +>this : this >x : Lanthanum.nitidus dimissus() : imperfecta.subspinosus { var x : imperfecta.subspinosus; () => { var y = this; }; return x; } @@ -5630,8 +5630,8 @@ module nigra { >imperfecta : any >subspinosus : imperfecta.subspinosus >() => { var y = this; } : () => void ->y : dolichurus ->this : dolichurus +>y : this +>this : this >x : imperfecta.subspinosus phaeotis() : julianae.sumatrana { var x : julianae.sumatrana; () => { var y = this; }; return x; } @@ -5642,8 +5642,8 @@ module nigra { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : dolichurus ->this : dolichurus +>y : this +>this : this >x : julianae.sumatrana ustus() : julianae.acariensis { var x : julianae.acariensis; () => { var y = this; }; return x; } @@ -5654,8 +5654,8 @@ module nigra { >julianae : any >acariensis : julianae.acariensis >() => { var y = this; } : () => void ->y : dolichurus ->this : dolichurus +>y : this +>this : this >x : julianae.acariensis sagei() : howi.marcanoi { var x : howi.marcanoi; () => { var y = this; }; return x; } @@ -5666,8 +5666,8 @@ module nigra { >howi : any >marcanoi : howi.marcanoi >() => { var y = this; } : () => void ->y : dolichurus ->this : dolichurus +>y : this +>this : this >x : howi.marcanoi } } @@ -5720,8 +5720,8 @@ module panglima { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : amphibius ->this : amphibius +>y : this +>this : this >x : macrorhinos.marmosurus, gabriellae.echinatus>, sagitta.stolzmanni> jerdoni(): macrorhinos.daphaenodon { var x: macrorhinos.daphaenodon; () => { var y = this; }; return x; } @@ -5732,8 +5732,8 @@ module panglima { >macrorhinos : any >daphaenodon : macrorhinos.daphaenodon >() => { var y = this; } : () => void ->y : amphibius ->this : amphibius +>y : this +>this : this >x : macrorhinos.daphaenodon camtschatica(): samarensis.pallidus { var x: samarensis.pallidus; () => { var y = this; }; return x; } @@ -5744,8 +5744,8 @@ module panglima { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : amphibius ->this : amphibius +>y : this +>this : this >x : samarensis.pallidus spadix(): petrophilus.sodyi { var x: petrophilus.sodyi; () => { var y = this; }; return x; } @@ -5764,8 +5764,8 @@ module panglima { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : amphibius ->this : amphibius +>y : this +>this : this >x : petrophilus.sodyi luismanueli(): rendalli.moojeni { var x: rendalli.moojeni; () => { var y = this; }; return x; } @@ -5784,8 +5784,8 @@ module panglima { >trivirgatus : any >oconnelli : trivirgatus.oconnelli >() => { var y = this; } : () => void ->y : amphibius ->this : amphibius +>y : this +>this : this >x : rendalli.moojeni aceramarcae(): daubentonii.arboreus { var x: daubentonii.arboreus; () => { var y = this; }; return x; } @@ -5804,8 +5804,8 @@ module panglima { >julianae : any >steerii : julianae.steerii >() => { var y = this; } : () => void ->y : amphibius ->this : amphibius +>y : this +>this : this >x : daubentonii.arboreus } export class fundatus extends lutreolus.schlegeli { @@ -5832,8 +5832,8 @@ module panglima { >provocax : any >melanoleuca : provocax.melanoleuca >() => { var y = this; } : () => void ->y : fundatus ->this : fundatus +>y : this +>this : this >x : nigra.gracilis flamarioni(): imperfecta.lasiurus>, sagitta.leptoceros>> { var x: imperfecta.lasiurus>, sagitta.leptoceros>>; () => { var y = this; }; return x; } @@ -5882,8 +5882,8 @@ module panglima { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : fundatus ->this : fundatus +>y : this +>this : this >x : imperfecta.lasiurus>, sagitta.leptoceros>> mirabilis(): macrorhinos.marmosurus, lavali.lepturus> { var x: macrorhinos.marmosurus, lavali.lepturus>; () => { var y = this; }; return x; } @@ -5910,8 +5910,8 @@ module panglima { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : fundatus ->this : fundatus +>y : this +>this : this >x : macrorhinos.marmosurus, lavali.lepturus> } export class abidi extends argurus.dauricus { @@ -5934,8 +5934,8 @@ module panglima { >trivirgatus : any >oconnelli : trivirgatus.oconnelli >() => { var y = this; } : () => void ->y : abidi ->this : abidi +>y : this +>this : this >x : trivirgatus.oconnelli macedonicus(): petrophilus.minutilla { var x: petrophilus.minutilla; () => { var y = this; }; return x; } @@ -5946,8 +5946,8 @@ module panglima { >petrophilus : any >minutilla : petrophilus.minutilla >() => { var y = this; } : () => void ->y : abidi ->this : abidi +>y : this +>this : this >x : petrophilus.minutilla galili(): samarensis.cahirinus { var x: samarensis.cahirinus; () => { var y = this; }; return x; } @@ -5966,8 +5966,8 @@ module panglima { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : abidi ->this : abidi +>y : this +>this : this >x : samarensis.cahirinus thierryi(): dogramacii.robustulus { var x: dogramacii.robustulus; () => { var y = this; }; return x; } @@ -5978,8 +5978,8 @@ module panglima { >dogramacii : any >robustulus : dogramacii.robustulus >() => { var y = this; } : () => void ->y : abidi ->this : abidi +>y : this +>this : this >x : dogramacii.robustulus ega(): imperfecta.lasiurus> { var x: imperfecta.lasiurus>; () => { var y = this; }; return x; } @@ -6006,8 +6006,8 @@ module panglima { >howi : any >marcanoi : howi.marcanoi >() => { var y = this; } : () => void ->y : abidi ->this : abidi +>y : this +>this : this >x : imperfecta.lasiurus> } } @@ -6025,8 +6025,8 @@ module quasiater { >rendalli : any >zuluensis : rendalli.zuluensis >() => { var y = this; } : () => void ->y : carolinensis ->this : carolinensis +>y : this +>this : this >x : rendalli.zuluensis aeneus(): howi.marcanoi { var x: howi.marcanoi; () => { var y = this; }; return x; } @@ -6037,8 +6037,8 @@ module quasiater { >howi : any >marcanoi : howi.marcanoi >() => { var y = this; } : () => void ->y : carolinensis ->this : carolinensis +>y : this +>this : this >x : howi.marcanoi aloysiisabaudiae(): argurus.netscheri, lavali.lepturus> { var x: argurus.netscheri, lavali.lepturus>; () => { var y = this; }; return x; } @@ -6065,8 +6065,8 @@ module quasiater { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : carolinensis ->this : carolinensis +>y : this +>this : this >x : argurus.netscheri, lavali.lepturus> tenellus(): julianae.nudicaudus { var x: julianae.nudicaudus; () => { var y = this; }; return x; } @@ -6077,8 +6077,8 @@ module quasiater { >julianae : any >nudicaudus : julianae.nudicaudus >() => { var y = this; } : () => void ->y : carolinensis ->this : carolinensis +>y : this +>this : this >x : julianae.nudicaudus andium(): lavali.beisa { var x: lavali.beisa; () => { var y = this; }; return x; } @@ -6089,8 +6089,8 @@ module quasiater { >lavali : any >beisa : lavali.beisa >() => { var y = this; } : () => void ->y : carolinensis ->this : carolinensis +>y : this +>this : this >x : lavali.beisa persephone(): panglima.fundatus { var x: panglima.fundatus; () => { var y = this; }; return x; } @@ -6109,8 +6109,8 @@ module quasiater { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : carolinensis ->this : carolinensis +>y : this +>this : this >x : panglima.fundatus patrizii(): Lanthanum.megalonyx { var x: Lanthanum.megalonyx; () => { var y = this; }; return x; } @@ -6121,8 +6121,8 @@ module quasiater { >Lanthanum : any >megalonyx : Lanthanum.megalonyx >() => { var y = this; } : () => void ->y : carolinensis ->this : carolinensis +>y : this +>this : this >x : Lanthanum.megalonyx } } @@ -6161,8 +6161,8 @@ module minutus { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : himalayana ->this : himalayana +>y : this +>this : this >x : argurus.netscheri> lobata(): samarensis.pallidus { var x: samarensis.pallidus; () => { var y = this; }; return x; } @@ -6173,8 +6173,8 @@ module minutus { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : himalayana ->this : himalayana +>y : this +>this : this >x : samarensis.pallidus rusticus(): dogramacii.aurata { var x: dogramacii.aurata; () => { var y = this; }; return x; } @@ -6185,8 +6185,8 @@ module minutus { >dogramacii : any >aurata : dogramacii.aurata >() => { var y = this; } : () => void ->y : himalayana ->this : himalayana +>y : this +>this : this >x : dogramacii.aurata latona(): daubentonii.nesiotes { var x: daubentonii.nesiotes; () => { var y = this; }; return x; } @@ -6205,8 +6205,8 @@ module minutus { >Lanthanum : any >megalonyx : Lanthanum.megalonyx >() => { var y = this; } : () => void ->y : himalayana ->this : himalayana +>y : this +>this : this >x : daubentonii.nesiotes famulus(): patas.uralensis { var x: patas.uralensis; () => { var y = this; }; return x; } @@ -6217,8 +6217,8 @@ module minutus { >patas : any >uralensis : patas.uralensis >() => { var y = this; } : () => void ->y : himalayana ->this : himalayana +>y : this +>this : this >x : patas.uralensis flaviceps(): minutus.inez> { var x: minutus.inez>; () => { var y = this; }; return x; } @@ -6245,8 +6245,8 @@ module minutus { >lutreolus : any >foina : lutreolus.foina >() => { var y = this; } : () => void ->y : himalayana ->this : himalayana +>y : this +>this : this >x : inez> paradoxolophus(): nigra.dolichurus> { var x: nigra.dolichurus>; () => { var y = this; }; return x; } @@ -6273,8 +6273,8 @@ module minutus { >imperfecta : any >subspinosus : imperfecta.subspinosus >() => { var y = this; } : () => void ->y : himalayana ->this : himalayana +>y : this +>this : this >x : nigra.dolichurus> Osmium(): lavali.wilsoni { var x: lavali.wilsoni; () => { var y = this; }; return x; } @@ -6285,8 +6285,8 @@ module minutus { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : himalayana ->this : himalayana +>y : this +>this : this >x : lavali.wilsoni vulgaris(): Lanthanum.nitidus { var x: Lanthanum.nitidus; () => { var y = this; }; return x; } @@ -6305,8 +6305,8 @@ module minutus { >julianae : any >acariensis : julianae.acariensis >() => { var y = this; } : () => void ->y : himalayana ->this : himalayana +>y : this +>this : this >x : Lanthanum.nitidus betsileoensis(): panglima.amphibius { var x: panglima.amphibius; () => { var y = this; }; return x; } @@ -6325,8 +6325,8 @@ module minutus { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : himalayana ->this : himalayana +>y : this +>this : this >x : panglima.amphibius vespuccii(): argurus.gilbertii, provocax.melanoleuca> { var x: argurus.gilbertii, provocax.melanoleuca>; () => { var y = this; }; return x; } @@ -6353,8 +6353,8 @@ module minutus { >provocax : any >melanoleuca : provocax.melanoleuca >() => { var y = this; } : () => void ->y : himalayana ->this : himalayana +>y : this +>this : this >x : argurus.gilbertii, provocax.melanoleuca> olympus(): Lanthanum.megalonyx { var x: Lanthanum.megalonyx; () => { var y = this; }; return x; } @@ -6365,8 +6365,8 @@ module minutus { >Lanthanum : any >megalonyx : Lanthanum.megalonyx >() => { var y = this; } : () => void ->y : himalayana ->this : himalayana +>y : this +>this : this >x : Lanthanum.megalonyx } } @@ -6417,8 +6417,8 @@ module caurinus { >lavali : any >otion : lavali.otion >() => { var y = this; } : () => void ->y : mahaganus ->this : mahaganus +>y : this +>this : this >x : ruatanica.hector>> devius(): samarensis.pelurus, trivirgatus.falconeri>> { var x: samarensis.pelurus, trivirgatus.falconeri>>; () => { var y = this; }; return x; } @@ -6453,8 +6453,8 @@ module caurinus { >trivirgatus : any >falconeri : trivirgatus.falconeri >() => { var y = this; } : () => void ->y : mahaganus ->this : mahaganus +>y : this +>this : this >x : samarensis.pelurus, trivirgatus.falconeri>> masalai(): argurus.oreas { var x: argurus.oreas; () => { var y = this; }; return x; } @@ -6465,8 +6465,8 @@ module caurinus { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : mahaganus ->this : mahaganus +>y : this +>this : this >x : argurus.oreas kathleenae(): nigra.dolichurus { var x: nigra.dolichurus; () => { var y = this; }; return x; } @@ -6485,8 +6485,8 @@ module caurinus { >caurinus : any >psilurus : psilurus >() => { var y = this; } : () => void ->y : mahaganus ->this : mahaganus +>y : this +>this : this >x : nigra.dolichurus simulus(): gabriellae.echinatus { var x: gabriellae.echinatus; () => { var y = this; }; return x; } @@ -6497,8 +6497,8 @@ module caurinus { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : mahaganus ->this : mahaganus +>y : this +>this : this >x : gabriellae.echinatus nigrovittatus(): caurinus.mahaganus>> { var x: caurinus.mahaganus>>; () => { var y = this; }; return x; } @@ -6533,8 +6533,8 @@ module caurinus { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : mahaganus ->this : mahaganus +>y : this +>this : this >x : mahaganus>> senegalensis(): gabriellae.klossii, dammermani.melanops> { var x: gabriellae.klossii, dammermani.melanops>; () => { var y = this; }; return x; } @@ -6561,8 +6561,8 @@ module caurinus { >dammermani : any >melanops : dammermani.melanops >() => { var y = this; } : () => void ->y : mahaganus ->this : mahaganus +>y : this +>this : this >x : gabriellae.klossii, dammermani.melanops> acticola(): argurus.luctuosa { var x: argurus.luctuosa; () => { var y = this; }; return x; } @@ -6573,8 +6573,8 @@ module caurinus { >argurus : any >luctuosa : argurus.luctuosa >() => { var y = this; } : () => void ->y : mahaganus ->this : mahaganus +>y : this +>this : this >x : argurus.luctuosa } } @@ -6594,8 +6594,8 @@ module macrorhinos { >lutreolus : any >punicus : lutreolus.punicus >() => { var y = this; } : () => void ->y : marmosurus ->this : marmosurus +>y : this +>this : this >x : lutreolus.punicus } } @@ -6618,8 +6618,8 @@ module howi { >howi : any >marcanoi : marcanoi >() => { var y = this; } : () => void ->y : angulatus ->this : angulatus +>y : this +>this : this >x : marcanoi } } @@ -6648,8 +6648,8 @@ module nigra { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : thalia ->this : thalia +>y : this +>this : this >x : quasiater.carolinensis arnuxii(): panamensis.linulus, lavali.beisa> { var x: panamensis.linulus, lavali.beisa>; () => { var y = this; }; return x; } @@ -6676,8 +6676,8 @@ module nigra { >lavali : any >beisa : lavali.beisa >() => { var y = this; } : () => void ->y : thalia ->this : thalia +>y : this +>this : this >x : panamensis.linulus, lavali.beisa> verheyeni(): lavali.xanthognathus { var x: lavali.xanthognathus; () => { var y = this; }; return x; } @@ -6688,8 +6688,8 @@ module nigra { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : thalia ->this : thalia +>y : this +>this : this >x : lavali.xanthognathus dauuricus(): gabriellae.amicus { var x: gabriellae.amicus; () => { var y = this; }; return x; } @@ -6700,8 +6700,8 @@ module nigra { >gabriellae : any >amicus : gabriellae.amicus >() => { var y = this; } : () => void ->y : thalia ->this : thalia +>y : this +>this : this >x : gabriellae.amicus tristriatus(): rionegrensis.veraecrucis> { var x: rionegrensis.veraecrucis>; () => { var y = this; }; return x; } @@ -6728,8 +6728,8 @@ module nigra { >howi : any >marcanoi : howi.marcanoi >() => { var y = this; } : () => void ->y : thalia ->this : thalia +>y : this +>this : this >x : rionegrensis.veraecrucis> lasiura(): panglima.abidi>, Lanthanum.nitidus> { var x: panglima.abidi>, Lanthanum.nitidus>; () => { var y = this; }; return x; } @@ -6772,8 +6772,8 @@ module nigra { >julianae : any >acariensis : julianae.acariensis >() => { var y = this; } : () => void ->y : thalia ->this : thalia +>y : this +>this : this >x : panglima.abidi>, Lanthanum.nitidus> gangetica(): argurus.luctuosa { var x: argurus.luctuosa; () => { var y = this; }; return x; } @@ -6784,8 +6784,8 @@ module nigra { >argurus : any >luctuosa : argurus.luctuosa >() => { var y = this; } : () => void ->y : thalia ->this : thalia +>y : this +>this : this >x : argurus.luctuosa brucei(): chrysaeolus.sarasinorum { var x: chrysaeolus.sarasinorum; () => { var y = this; }; return x; } @@ -6804,8 +6804,8 @@ module nigra { >ruatanica : any >americanus : ruatanica.americanus >() => { var y = this; } : () => void ->y : thalia ->this : thalia +>y : this +>this : this >x : chrysaeolus.sarasinorum } } @@ -6834,8 +6834,8 @@ module sagitta { >ruatanica : any >americanus : ruatanica.americanus >() => { var y = this; } : () => void ->y : walkeri ->this : walkeri +>y : this +>this : this >x : samarensis.cahirinus } } @@ -6870,8 +6870,8 @@ module minutus { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : inez ->this : inez +>y : this +>this : this >x : samarensis.cahirinus } } @@ -6924,8 +6924,8 @@ module panamensis { >dogramacii : any >kaiseri : dogramacii.kaiseri >() => { var y = this; } : () => void ->y : linulus ->this : linulus +>y : this +>this : this >x : daubentonii.arboreus taki(): patas.uralensis { var x: patas.uralensis; () => { var y = this; }; return x; } @@ -6936,8 +6936,8 @@ module panamensis { >patas : any >uralensis : patas.uralensis >() => { var y = this; } : () => void ->y : linulus ->this : linulus +>y : this +>this : this >x : patas.uralensis fumosus(): rendalli.moojeni, lavali.beisa> { var x: rendalli.moojeni, lavali.beisa>; () => { var y = this; }; return x; } @@ -6964,8 +6964,8 @@ module panamensis { >lavali : any >beisa : lavali.beisa >() => { var y = this; } : () => void ->y : linulus ->this : linulus +>y : this +>this : this >x : rendalli.moojeni, lavali.beisa> rufinus(): macrorhinos.konganensis { var x: macrorhinos.konganensis; () => { var y = this; }; return x; } @@ -6976,8 +6976,8 @@ module panamensis { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : linulus ->this : linulus +>y : this +>this : this >x : macrorhinos.konganensis lami(): nigra.thalia { var x: nigra.thalia; () => { var y = this; }; return x; } @@ -6996,8 +6996,8 @@ module panamensis { >dogramacii : any >robustulus : dogramacii.robustulus >() => { var y = this; } : () => void ->y : linulus ->this : linulus +>y : this +>this : this >x : nigra.thalia regina(): trivirgatus.oconnelli { var x: trivirgatus.oconnelli; () => { var y = this; }; return x; } @@ -7008,8 +7008,8 @@ module panamensis { >trivirgatus : any >oconnelli : trivirgatus.oconnelli >() => { var y = this; } : () => void ->y : linulus ->this : linulus +>y : this +>this : this >x : trivirgatus.oconnelli nanilla(): dammermani.siberu { var x: dammermani.siberu; () => { var y = this; }; return x; } @@ -7028,8 +7028,8 @@ module panamensis { >trivirgatus : any >oconnelli : trivirgatus.oconnelli >() => { var y = this; } : () => void ->y : linulus ->this : linulus +>y : this +>this : this >x : dammermani.siberu enganus(): petrophilus.sodyi { var x: petrophilus.sodyi; () => { var y = this; }; return x; } @@ -7048,8 +7048,8 @@ module panamensis { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : linulus ->this : linulus +>y : this +>this : this >x : petrophilus.sodyi gomantongensis(): rionegrensis.veraecrucis> { var x: rionegrensis.veraecrucis>; () => { var y = this; }; return x; } @@ -7076,8 +7076,8 @@ module panamensis { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : linulus ->this : linulus +>y : this +>this : this >x : rionegrensis.veraecrucis> } } @@ -7105,8 +7105,8 @@ module nigra { >julianae : any >steerii : julianae.steerii >() => { var y = this; } : () => void ->y : gracilis ->this : gracilis +>y : this +>this : this >x : dolichurus echinothrix(): Lanthanum.nitidus, argurus.oreas> { var x: Lanthanum.nitidus, argurus.oreas>; () => { var y = this; }; return x; } @@ -7133,8 +7133,8 @@ module nigra { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : gracilis ->this : gracilis +>y : this +>this : this >x : Lanthanum.nitidus, argurus.oreas> garridoi(): dogramacii.koepckeae { var x: dogramacii.koepckeae; () => { var y = this; }; return x; } @@ -7145,8 +7145,8 @@ module nigra { >dogramacii : any >koepckeae : dogramacii.koepckeae >() => { var y = this; } : () => void ->y : gracilis ->this : gracilis +>y : this +>this : this >x : dogramacii.koepckeae rouxii(): nigra.gracilis, nigra.thalia> { var x: nigra.gracilis, nigra.thalia>; () => { var y = this; }; return x; } @@ -7181,8 +7181,8 @@ module nigra { >julianae : any >galapagoensis : julianae.galapagoensis >() => { var y = this; } : () => void ->y : gracilis ->this : gracilis +>y : this +>this : this >x : gracilis, thalia> aurita(): sagitta.stolzmanni { var x: sagitta.stolzmanni; () => { var y = this; }; return x; } @@ -7193,8 +7193,8 @@ module nigra { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : gracilis ->this : gracilis +>y : this +>this : this >x : sagitta.stolzmanni geoffrensis(): rionegrensis.caniventer { var x: rionegrensis.caniventer; () => { var y = this; }; return x; } @@ -7205,8 +7205,8 @@ module nigra { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : gracilis ->this : gracilis +>y : this +>this : this >x : rionegrensis.caniventer theresa(): macrorhinos.marmosurus, argurus.luctuosa>, nigra.dolichurus> { var x: macrorhinos.marmosurus, argurus.luctuosa>, nigra.dolichurus>; () => { var y = this; }; return x; } @@ -7249,8 +7249,8 @@ module nigra { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : gracilis ->this : gracilis +>y : this +>this : this >x : macrorhinos.marmosurus, argurus.luctuosa>, dolichurus> melanocarpus(): julianae.albidens, julianae.sumatrana> { var x: julianae.albidens, julianae.sumatrana>; () => { var y = this; }; return x; } @@ -7277,8 +7277,8 @@ module nigra { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : gracilis ->this : gracilis +>y : this +>this : this >x : julianae.albidens, julianae.sumatrana> dubiaquercus(): dogramacii.robustulus { var x: dogramacii.robustulus; () => { var y = this; }; return x; } @@ -7289,8 +7289,8 @@ module nigra { >dogramacii : any >robustulus : dogramacii.robustulus >() => { var y = this; } : () => void ->y : gracilis ->this : gracilis +>y : this +>this : this >x : dogramacii.robustulus pectoralis(): julianae.sumatrana { var x: julianae.sumatrana; () => { var y = this; }; return x; } @@ -7301,8 +7301,8 @@ module nigra { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : gracilis ->this : gracilis +>y : this +>this : this >x : julianae.sumatrana apoensis(): caurinus.megaphyllus { var x: caurinus.megaphyllus; () => { var y = this; }; return x; } @@ -7313,8 +7313,8 @@ module nigra { >caurinus : any >megaphyllus : caurinus.megaphyllus >() => { var y = this; } : () => void ->y : gracilis ->this : gracilis +>y : this +>this : this >x : caurinus.megaphyllus grisescens(): Lanthanum.jugularis { var x: Lanthanum.jugularis; () => { var y = this; }; return x; } @@ -7325,8 +7325,8 @@ module nigra { >Lanthanum : any >jugularis : Lanthanum.jugularis >() => { var y = this; } : () => void ->y : gracilis ->this : gracilis +>y : this +>this : this >x : Lanthanum.jugularis ramirohitra(): panglima.amphibius { var x: panglima.amphibius; () => { var y = this; }; return x; } @@ -7345,8 +7345,8 @@ module nigra { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : gracilis ->this : gracilis +>y : this +>this : this >x : panglima.amphibius } } @@ -7377,8 +7377,8 @@ module samarensis { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : pelurus ->this : pelurus +>y : this +>this : this >x : panamensis.linulus castanea(): argurus.netscheri, julianae.oralis> { var x: argurus.netscheri, julianae.oralis>; () => { var y = this; }; return x; } @@ -7413,8 +7413,8 @@ module samarensis { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : pelurus ->this : pelurus +>y : this +>this : this >x : argurus.netscheri, julianae.oralis> chamek(): argurus.pygmaea { var x: argurus.pygmaea; () => { var y = this; }; return x; } @@ -7433,8 +7433,8 @@ module samarensis { >provocax : any >melanoleuca : provocax.melanoleuca >() => { var y = this; } : () => void ->y : pelurus ->this : pelurus +>y : this +>this : this >x : argurus.pygmaea nigriceps(): lutreolus.punicus { var x: lutreolus.punicus; () => { var y = this; }; return x; } @@ -7445,8 +7445,8 @@ module samarensis { >lutreolus : any >punicus : lutreolus.punicus >() => { var y = this; } : () => void ->y : pelurus ->this : pelurus +>y : this +>this : this >x : lutreolus.punicus lunatus(): pelurus { var x: pelurus; () => { var y = this; }; return x; } @@ -7463,8 +7463,8 @@ module samarensis { >sagitta : any >walkeri : sagitta.walkeri >() => { var y = this; } : () => void ->y : pelurus ->this : pelurus +>y : this +>this : this >x : pelurus madurae(): rionegrensis.caniventer { var x: rionegrensis.caniventer; () => { var y = this; }; return x; } @@ -7475,8 +7475,8 @@ module samarensis { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : pelurus ->this : pelurus +>y : this +>this : this >x : rionegrensis.caniventer chinchilla(): macrorhinos.daphaenodon { var x: macrorhinos.daphaenodon; () => { var y = this; }; return x; } @@ -7487,8 +7487,8 @@ module samarensis { >macrorhinos : any >daphaenodon : macrorhinos.daphaenodon >() => { var y = this; } : () => void ->y : pelurus ->this : pelurus +>y : this +>this : this >x : macrorhinos.daphaenodon eliasi(): petrophilus.rosalia { var x: petrophilus.rosalia; () => { var y = this; }; return x; } @@ -7507,8 +7507,8 @@ module samarensis { >lavali : any >beisa : lavali.beisa >() => { var y = this; } : () => void ->y : pelurus ->this : pelurus +>y : this +>this : this >x : petrophilus.rosalia proditor(): panamensis.setulosus { var x: panamensis.setulosus; () => { var y = this; }; return x; } @@ -7527,8 +7527,8 @@ module samarensis { >julianae : any >steerii : julianae.steerii >() => { var y = this; } : () => void ->y : pelurus ->this : pelurus +>y : this +>this : this >x : panamensis.setulosus gambianus(): quasiater.wattsi> { var x: quasiater.wattsi>; () => { var y = this; }; return x; } @@ -7555,8 +7555,8 @@ module samarensis { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : pelurus ->this : pelurus +>y : this +>this : this >x : quasiater.wattsi> petteri(): dogramacii.kaiseri { var x: dogramacii.kaiseri; () => { var y = this; }; return x; } @@ -7567,8 +7567,8 @@ module samarensis { >dogramacii : any >kaiseri : dogramacii.kaiseri >() => { var y = this; } : () => void ->y : pelurus ->this : pelurus +>y : this +>this : this >x : dogramacii.kaiseri nusatenggara(): panglima.amphibius { var x: panglima.amphibius; () => { var y = this; }; return x; } @@ -7587,8 +7587,8 @@ module samarensis { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : pelurus ->this : pelurus +>y : this +>this : this >x : panglima.amphibius olitor(): rionegrensis.veraecrucis { var x: rionegrensis.veraecrucis; () => { var y = this; }; return x; } @@ -7607,8 +7607,8 @@ module samarensis { >quasiater : any >bobrinskoi : quasiater.bobrinskoi >() => { var y = this; } : () => void ->y : pelurus ->this : pelurus +>y : this +>this : this >x : rionegrensis.veraecrucis } export class fuscus extends macrorhinos.daphaenodon { @@ -7635,8 +7635,8 @@ module samarensis { >dogramacii : any >aurata : dogramacii.aurata >() => { var y = this; } : () => void ->y : fuscus ->this : fuscus +>y : this +>this : this >x : nigra.gracilis badia(): julianae.sumatrana { var x: julianae.sumatrana; () => { var y = this; }; return x; } @@ -7647,8 +7647,8 @@ module samarensis { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : fuscus ->this : fuscus +>y : this +>this : this >x : julianae.sumatrana prymnolopha(): sagitta.walkeri { var x: sagitta.walkeri; () => { var y = this; }; return x; } @@ -7659,8 +7659,8 @@ module samarensis { >sagitta : any >walkeri : sagitta.walkeri >() => { var y = this; } : () => void ->y : fuscus ->this : fuscus +>y : this +>this : this >x : sagitta.walkeri natalensis(): trivirgatus.falconeri { var x: trivirgatus.falconeri; () => { var y = this; }; return x; } @@ -7671,8 +7671,8 @@ module samarensis { >trivirgatus : any >falconeri : trivirgatus.falconeri >() => { var y = this; } : () => void ->y : fuscus ->this : fuscus +>y : this +>this : this >x : trivirgatus.falconeri hunteri(): julianae.durangae { var x: julianae.durangae; () => { var y = this; }; return x; } @@ -7683,8 +7683,8 @@ module samarensis { >julianae : any >durangae : julianae.durangae >() => { var y = this; } : () => void ->y : fuscus ->this : fuscus +>y : this +>this : this >x : julianae.durangae sapiens(): pallidus { var x: pallidus; () => { var y = this; }; return x; } @@ -7693,8 +7693,8 @@ module samarensis { >x : pallidus >pallidus : pallidus >() => { var y = this; } : () => void ->y : fuscus ->this : fuscus +>y : this +>this : this >x : pallidus macrocercus(): panamensis.setulosus { var x: panamensis.setulosus; () => { var y = this; }; return x; } @@ -7713,8 +7713,8 @@ module samarensis { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : fuscus ->this : fuscus +>y : this +>this : this >x : panamensis.setulosus nimbae(): lutreolus.punicus { var x: lutreolus.punicus; () => { var y = this; }; return x; } @@ -7725,8 +7725,8 @@ module samarensis { >lutreolus : any >punicus : lutreolus.punicus >() => { var y = this; } : () => void ->y : fuscus ->this : fuscus +>y : this +>this : this >x : lutreolus.punicus suricatta(): daubentonii.nigricans { var x: daubentonii.nigricans; () => { var y = this; }; return x; } @@ -7745,8 +7745,8 @@ module samarensis { >imperfecta : any >subspinosus : imperfecta.subspinosus >() => { var y = this; } : () => void ->y : fuscus ->this : fuscus +>y : this +>this : this >x : daubentonii.nigricans jagorii(): julianae.galapagoensis { var x: julianae.galapagoensis; () => { var y = this; }; return x; } @@ -7757,8 +7757,8 @@ module samarensis { >julianae : any >galapagoensis : julianae.galapagoensis >() => { var y = this; } : () => void ->y : fuscus ->this : fuscus +>y : this +>this : this >x : julianae.galapagoensis beecrofti(): sagitta.stolzmanni { var x: sagitta.stolzmanni; () => { var y = this; }; return x; } @@ -7769,8 +7769,8 @@ module samarensis { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : fuscus ->this : fuscus +>y : this +>this : this >x : sagitta.stolzmanni imaizumii(): minutus.inez, gabriellae.echinatus>, dogramacii.aurata>, lavali.otion>, macrorhinos.konganensis> { var x: minutus.inez, gabriellae.echinatus>, dogramacii.aurata>, lavali.otion>, macrorhinos.konganensis>; () => { var y = this; }; return x; } @@ -7821,8 +7821,8 @@ module samarensis { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : fuscus ->this : fuscus +>y : this +>this : this >x : minutus.inez, gabriellae.echinatus>, dogramacii.aurata>, lavali.otion>, macrorhinos.konganensis> colocolo(): quasiater.bobrinskoi { var x: quasiater.bobrinskoi; () => { var y = this; }; return x; } @@ -7833,8 +7833,8 @@ module samarensis { >quasiater : any >bobrinskoi : quasiater.bobrinskoi >() => { var y = this; } : () => void ->y : fuscus ->this : fuscus +>y : this +>this : this >x : quasiater.bobrinskoi wolfi(): petrophilus.rosalia> { var x: petrophilus.rosalia>; () => { var y = this; }; return x; } @@ -7861,8 +7861,8 @@ module samarensis { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : fuscus ->this : fuscus +>y : this +>this : this >x : petrophilus.rosalia> } export class pallidus { @@ -7876,8 +7876,8 @@ module samarensis { >trivirgatus : any >falconeri : trivirgatus.falconeri >() => { var y = this; } : () => void ->y : pallidus ->this : pallidus +>y : this +>this : this >x : trivirgatus.falconeri watersi(): lavali.wilsoni { var x: lavali.wilsoni; () => { var y = this; }; return x; } @@ -7888,8 +7888,8 @@ module samarensis { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : pallidus ->this : pallidus +>y : this +>this : this >x : lavali.wilsoni glacialis(): sagitta.cinereus, quasiater.wattsi>> { var x: sagitta.cinereus, quasiater.wattsi>>; () => { var y = this; }; return x; } @@ -7932,8 +7932,8 @@ module samarensis { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : pallidus ->this : pallidus +>y : this +>this : this >x : sagitta.cinereus, quasiater.wattsi>> viaria(): chrysaeolus.sarasinorum { var x: chrysaeolus.sarasinorum; () => { var y = this; }; return x; } @@ -7952,8 +7952,8 @@ module samarensis { >lutreolus : any >punicus : lutreolus.punicus >() => { var y = this; } : () => void ->y : pallidus ->this : pallidus +>y : this +>this : this >x : chrysaeolus.sarasinorum } export class cahirinus { @@ -7977,8 +7977,8 @@ module samarensis { >argurus : any >peninsulae : argurus.peninsulae >() => { var y = this; } : () => void ->y : cahirinus ->this : cahirinus +>y : this +>this : this >x : nigra.caucasica flaviventer(): trivirgatus.tumidifrons> { var x: trivirgatus.tumidifrons>; () => { var y = this; }; return x; } @@ -8005,8 +8005,8 @@ module samarensis { >argurus : any >peninsulae : argurus.peninsulae >() => { var y = this; } : () => void ->y : cahirinus ->this : cahirinus +>y : this +>this : this >x : trivirgatus.tumidifrons> bottai(): lutreolus.schlegeli { var x: lutreolus.schlegeli; () => { var y = this; }; return x; } @@ -8017,8 +8017,8 @@ module samarensis { >lutreolus : any >schlegeli : lutreolus.schlegeli >() => { var y = this; } : () => void ->y : cahirinus ->this : cahirinus +>y : this +>this : this >x : lutreolus.schlegeli pinetis(): argurus.oreas { var x: argurus.oreas; () => { var y = this; }; return x; } @@ -8029,8 +8029,8 @@ module samarensis { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : cahirinus ->this : cahirinus +>y : this +>this : this >x : argurus.oreas saussurei(): rendalli.crenulata, argurus.netscheri, julianae.oralis>> { var x: rendalli.crenulata, argurus.netscheri, julianae.oralis>>; () => { var y = this; }; return x; } @@ -8081,8 +8081,8 @@ module samarensis { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : cahirinus ->this : cahirinus +>y : this +>this : this >x : rendalli.crenulata, argurus.netscheri, julianae.oralis>> } } @@ -8113,8 +8113,8 @@ module sagitta { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : leptoceros ->this : leptoceros +>y : this +>this : this >x : rionegrensis.caniventer hoplomyoides(): panglima.fundatus, nigra.gracilis> { var x: panglima.fundatus, nigra.gracilis>; () => { var y = this; }; return x; } @@ -8149,8 +8149,8 @@ module sagitta { >imperfecta : any >subspinosus : imperfecta.subspinosus >() => { var y = this; } : () => void ->y : leptoceros ->this : leptoceros +>y : this +>this : this >x : panglima.fundatus, nigra.gracilis> gratiosus(): lavali.lepturus { var x: lavali.lepturus; () => { var y = this; }; return x; } @@ -8161,8 +8161,8 @@ module sagitta { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : leptoceros ->this : leptoceros +>y : this +>this : this >x : lavali.lepturus rex(): lavali.wilsoni { var x: lavali.wilsoni; () => { var y = this; }; return x; } @@ -8173,8 +8173,8 @@ module sagitta { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : leptoceros ->this : leptoceros +>y : this +>this : this >x : lavali.wilsoni bolami(): trivirgatus.tumidifrons { var x: trivirgatus.tumidifrons; () => { var y = this; }; return x; } @@ -8193,8 +8193,8 @@ module sagitta { >ruatanica : any >americanus : ruatanica.americanus >() => { var y = this; } : () => void ->y : leptoceros ->this : leptoceros +>y : this +>this : this >x : trivirgatus.tumidifrons } } @@ -8217,8 +8217,8 @@ module daubentonii { >dogramacii : any >robustulus : dogramacii.robustulus >() => { var y = this; } : () => void ->y : nigricans ->this : nigricans +>y : this +>this : this >x : dogramacii.robustulus } } @@ -8254,8 +8254,8 @@ module argurus { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : pygmaea ->this : pygmaea +>y : this +>this : this >x : gabriellae.echinatus capucinus(): rendalli.zuluensis { var x: rendalli.zuluensis; () => { var y = this; }; return x; } @@ -8266,8 +8266,8 @@ module argurus { >rendalli : any >zuluensis : rendalli.zuluensis >() => { var y = this; } : () => void ->y : pygmaea ->this : pygmaea +>y : this +>this : this >x : rendalli.zuluensis cuvieri(): rionegrensis.caniventer { var x: rionegrensis.caniventer; () => { var y = this; }; return x; } @@ -8278,8 +8278,8 @@ module argurus { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : pygmaea ->this : pygmaea +>y : this +>this : this >x : rionegrensis.caniventer } } @@ -8302,8 +8302,8 @@ module chrysaeolus { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : sarasinorum ->this : sarasinorum +>y : this +>this : this >x : samarensis.pallidus hinpoon(): nigra.caucasica { var x: nigra.caucasica; () => { var y = this; }; return x; } @@ -8322,8 +8322,8 @@ module chrysaeolus { >trivirgatus : any >oconnelli : trivirgatus.oconnelli >() => { var y = this; } : () => void ->y : sarasinorum ->this : sarasinorum +>y : this +>this : this >x : nigra.caucasica kandti(): quasiater.wattsi { var x: quasiater.wattsi; () => { var y = this; }; return x; } @@ -8342,8 +8342,8 @@ module chrysaeolus { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : sarasinorum ->this : sarasinorum +>y : this +>this : this >x : quasiater.wattsi cynosuros(): dammermani.melanops { var x: dammermani.melanops; () => { var y = this; }; return x; } @@ -8354,8 +8354,8 @@ module chrysaeolus { >dammermani : any >melanops : dammermani.melanops >() => { var y = this; } : () => void ->y : sarasinorum ->this : sarasinorum +>y : this +>this : this >x : dammermani.melanops Germanium(): lavali.beisa { var x: lavali.beisa; () => { var y = this; }; return x; } @@ -8366,8 +8366,8 @@ module chrysaeolus { >lavali : any >beisa : lavali.beisa >() => { var y = this; } : () => void ->y : sarasinorum ->this : sarasinorum +>y : this +>this : this >x : lavali.beisa Ununoctium(): nigra.gracilis { var x: nigra.gracilis; () => { var y = this; }; return x; } @@ -8386,8 +8386,8 @@ module chrysaeolus { >provocax : any >melanoleuca : provocax.melanoleuca >() => { var y = this; } : () => void ->y : sarasinorum ->this : sarasinorum +>y : this +>this : this >x : nigra.gracilis princeps(): minutus.portoricensis { var x: minutus.portoricensis; () => { var y = this; }; return x; } @@ -8398,8 +8398,8 @@ module chrysaeolus { >minutus : any >portoricensis : minutus.portoricensis >() => { var y = this; } : () => void ->y : sarasinorum ->this : sarasinorum +>y : this +>this : this >x : minutus.portoricensis } } @@ -8427,8 +8427,8 @@ module argurus { >lutreolus : any >foina : lutreolus.foina >() => { var y = this; } : () => void ->y : wetmorei ->this : wetmorei +>y : this +>this : this >x : petrophilus.rosalia ochraventer(): sagitta.walkeri { var x: sagitta.walkeri; () => { var y = this; }; return x; } @@ -8439,8 +8439,8 @@ module argurus { >sagitta : any >walkeri : sagitta.walkeri >() => { var y = this; } : () => void ->y : wetmorei ->this : wetmorei +>y : this +>this : this >x : sagitta.walkeri tephromelas(): Lanthanum.jugularis { var x: Lanthanum.jugularis; () => { var y = this; }; return x; } @@ -8451,8 +8451,8 @@ module argurus { >Lanthanum : any >jugularis : Lanthanum.jugularis >() => { var y = this; } : () => void ->y : wetmorei ->this : wetmorei +>y : this +>this : this >x : Lanthanum.jugularis cracens(): argurus.gilbertii { var x: argurus.gilbertii; () => { var y = this; }; return x; } @@ -8471,8 +8471,8 @@ module argurus { >lutreolus : any >punicus : lutreolus.punicus >() => { var y = this; } : () => void ->y : wetmorei ->this : wetmorei +>y : this +>this : this >x : gilbertii jamaicensis(): nigra.thalia> { var x: nigra.thalia>; () => { var y = this; }; return x; } @@ -8499,8 +8499,8 @@ module argurus { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : wetmorei ->this : wetmorei +>y : this +>this : this >x : nigra.thalia> gymnocaudus(): dogramacii.aurata { var x: dogramacii.aurata; () => { var y = this; }; return x; } @@ -8511,8 +8511,8 @@ module argurus { >dogramacii : any >aurata : dogramacii.aurata >() => { var y = this; } : () => void ->y : wetmorei ->this : wetmorei +>y : this +>this : this >x : dogramacii.aurata mayori(): sagitta.stolzmanni { var x: sagitta.stolzmanni; () => { var y = this; }; return x; } @@ -8523,8 +8523,8 @@ module argurus { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : wetmorei ->this : wetmorei +>y : this +>this : this >x : sagitta.stolzmanni } } @@ -8545,8 +8545,8 @@ module argurus { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : oreas ->this : oreas +>y : this +>this : this >x : lavali.xanthognathus paniscus(): ruatanica.Praseodymium { var x: ruatanica.Praseodymium; () => { var y = this; }; return x; } @@ -8565,8 +8565,8 @@ module argurus { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : oreas ->this : oreas +>y : this +>this : this >x : ruatanica.Praseodymium fagani(): trivirgatus.oconnelli { var x: trivirgatus.oconnelli; () => { var y = this; }; return x; } @@ -8577,8 +8577,8 @@ module argurus { >trivirgatus : any >oconnelli : trivirgatus.oconnelli >() => { var y = this; } : () => void ->y : oreas ->this : oreas +>y : this +>this : this >x : trivirgatus.oconnelli papuanus(): panglima.fundatus { var x: panglima.fundatus; () => { var y = this; }; return x; } @@ -8597,8 +8597,8 @@ module argurus { >macrorhinos : any >daphaenodon : macrorhinos.daphaenodon >() => { var y = this; } : () => void ->y : oreas ->this : oreas +>y : this +>this : this >x : panglima.fundatus timidus(): dammermani.melanops { var x: dammermani.melanops; () => { var y = this; }; return x; } @@ -8609,8 +8609,8 @@ module argurus { >dammermani : any >melanops : dammermani.melanops >() => { var y = this; } : () => void ->y : oreas ->this : oreas +>y : this +>this : this >x : dammermani.melanops nghetinhensis(): gabriellae.klossii { var x: gabriellae.klossii; () => { var y = this; }; return x; } @@ -8629,8 +8629,8 @@ module argurus { >julianae : any >steerii : julianae.steerii >() => { var y = this; } : () => void ->y : oreas ->this : oreas +>y : this +>this : this >x : gabriellae.klossii barbei(): samarensis.cahirinus { var x: samarensis.cahirinus; () => { var y = this; }; return x; } @@ -8649,8 +8649,8 @@ module argurus { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : oreas ->this : oreas +>y : this +>this : this >x : samarensis.cahirinus univittatus(): argurus.peninsulae { var x: argurus.peninsulae; () => { var y = this; }; return x; } @@ -8661,8 +8661,8 @@ module argurus { >argurus : any >peninsulae : peninsulae >() => { var y = this; } : () => void ->y : oreas ->this : oreas +>y : this +>this : this >x : peninsulae } } @@ -8698,8 +8698,8 @@ module daubentonii { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : arboreus ->this : arboreus +>y : this +>this : this >x : rendalli.crenulata, lavali.wilsoni> moreni(): panglima.abidi { var x: panglima.abidi; () => { var y = this; }; return x; } @@ -8718,8 +8718,8 @@ module daubentonii { >dogramacii : any >koepckeae : dogramacii.koepckeae >() => { var y = this; } : () => void ->y : arboreus ->this : arboreus +>y : this +>this : this >x : panglima.abidi hypoleucos(): nigra.gracilis { var x: nigra.gracilis; () => { var y = this; }; return x; } @@ -8738,8 +8738,8 @@ module daubentonii { >argurus : any >germaini : argurus.germaini >() => { var y = this; } : () => void ->y : arboreus ->this : arboreus +>y : this +>this : this >x : nigra.gracilis paedulcus(): minutus.portoricensis { var x: minutus.portoricensis; () => { var y = this; }; return x; } @@ -8750,8 +8750,8 @@ module daubentonii { >minutus : any >portoricensis : minutus.portoricensis >() => { var y = this; } : () => void ->y : arboreus ->this : arboreus +>y : this +>this : this >x : minutus.portoricensis pucheranii(): samarensis.fuscus { var x: samarensis.fuscus; () => { var y = this; }; return x; } @@ -8770,8 +8770,8 @@ module daubentonii { >caurinus : any >megaphyllus : caurinus.megaphyllus >() => { var y = this; } : () => void ->y : arboreus ->this : arboreus +>y : this +>this : this >x : samarensis.fuscus stella(): julianae.oralis { var x: julianae.oralis; () => { var y = this; }; return x; } @@ -8790,8 +8790,8 @@ module daubentonii { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : arboreus ->this : arboreus +>y : this +>this : this >x : julianae.oralis brasiliensis(): imperfecta.subspinosus { var x: imperfecta.subspinosus; () => { var y = this; }; return x; } @@ -8802,8 +8802,8 @@ module daubentonii { >imperfecta : any >subspinosus : imperfecta.subspinosus >() => { var y = this; } : () => void ->y : arboreus ->this : arboreus +>y : this +>this : this >x : imperfecta.subspinosus brevicaudata(): trivirgatus.oconnelli { var x: trivirgatus.oconnelli; () => { var y = this; }; return x; } @@ -8814,8 +8814,8 @@ module daubentonii { >trivirgatus : any >oconnelli : trivirgatus.oconnelli >() => { var y = this; } : () => void ->y : arboreus ->this : arboreus +>y : this +>this : this >x : trivirgatus.oconnelli vitticollis(): dogramacii.koepckeae { var x: dogramacii.koepckeae; () => { var y = this; }; return x; } @@ -8826,8 +8826,8 @@ module daubentonii { >dogramacii : any >koepckeae : dogramacii.koepckeae >() => { var y = this; } : () => void ->y : arboreus ->this : arboreus +>y : this +>this : this >x : dogramacii.koepckeae huangensis(): caurinus.psilurus { var x: caurinus.psilurus; () => { var y = this; }; return x; } @@ -8838,8 +8838,8 @@ module daubentonii { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : arboreus ->this : arboreus +>y : this +>this : this >x : caurinus.psilurus cameroni(): petrophilus.rosalia, imperfecta.ciliolabrum>, caurinus.psilurus> { var x: petrophilus.rosalia, imperfecta.ciliolabrum>, caurinus.psilurus>; () => { var y = this; }; return x; } @@ -8882,8 +8882,8 @@ module daubentonii { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : arboreus ->this : arboreus +>y : this +>this : this >x : petrophilus.rosalia, imperfecta.ciliolabrum>, caurinus.psilurus> tianshanica(): howi.marcanoi { var x: howi.marcanoi; () => { var y = this; }; return x; } @@ -8894,8 +8894,8 @@ module daubentonii { >howi : any >marcanoi : howi.marcanoi >() => { var y = this; } : () => void ->y : arboreus ->this : arboreus +>y : this +>this : this >x : howi.marcanoi } } @@ -8921,8 +8921,8 @@ module patas { >Lanthanum : any >jugularis : Lanthanum.jugularis >() => { var y = this; } : () => void ->y : uralensis ->this : uralensis +>y : this +>this : this >x : Lanthanum.nitidus pyrrhinus(): lavali.beisa { var x: lavali.beisa; () => { var y = this; }; return x; } @@ -8933,8 +8933,8 @@ module patas { >lavali : any >beisa : lavali.beisa >() => { var y = this; } : () => void ->y : uralensis ->this : uralensis +>y : this +>this : this >x : lavali.beisa insulans(): Lanthanum.jugularis { var x: Lanthanum.jugularis; () => { var y = this; }; return x; } @@ -8945,8 +8945,8 @@ module patas { >Lanthanum : any >jugularis : Lanthanum.jugularis >() => { var y = this; } : () => void ->y : uralensis ->this : uralensis +>y : this +>this : this >x : Lanthanum.jugularis nigricauda(): caurinus.johorensis, Lanthanum.jugularis> { var x: caurinus.johorensis, Lanthanum.jugularis>; () => { var y = this; }; return x; } @@ -8973,8 +8973,8 @@ module patas { >Lanthanum : any >jugularis : Lanthanum.jugularis >() => { var y = this; } : () => void ->y : uralensis ->this : uralensis +>y : this +>this : this >x : caurinus.johorensis, Lanthanum.jugularis> muricauda(): panglima.fundatus> { var x: panglima.fundatus>; () => { var y = this; }; return x; } @@ -9001,8 +9001,8 @@ module patas { >julianae : any >acariensis : julianae.acariensis >() => { var y = this; } : () => void ->y : uralensis ->this : uralensis +>y : this +>this : this >x : panglima.fundatus> albicaudus(): sagitta.stolzmanni { var x: sagitta.stolzmanni; () => { var y = this; }; return x; } @@ -9013,8 +9013,8 @@ module patas { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : uralensis ->this : uralensis +>y : this +>this : this >x : sagitta.stolzmanni fallax(): ruatanica.hector { var x: ruatanica.hector; () => { var y = this; }; return x; } @@ -9033,8 +9033,8 @@ module patas { >gabriellae : any >amicus : gabriellae.amicus >() => { var y = this; } : () => void ->y : uralensis ->this : uralensis +>y : this +>this : this >x : ruatanica.hector attenuata(): macrorhinos.marmosurus> { var x: macrorhinos.marmosurus>; () => { var y = this; }; return x; } @@ -9061,8 +9061,8 @@ module patas { >dogramacii : any >kaiseri : dogramacii.kaiseri >() => { var y = this; } : () => void ->y : uralensis ->this : uralensis +>y : this +>this : this >x : macrorhinos.marmosurus> megalura(): howi.marcanoi { var x: howi.marcanoi; () => { var y = this; }; return x; } @@ -9073,8 +9073,8 @@ module patas { >howi : any >marcanoi : howi.marcanoi >() => { var y = this; } : () => void ->y : uralensis ->this : uralensis +>y : this +>this : this >x : howi.marcanoi neblina(): samarensis.pelurus { var x: samarensis.pelurus; () => { var y = this; }; return x; } @@ -9093,8 +9093,8 @@ module patas { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : uralensis ->this : uralensis +>y : this +>this : this >x : samarensis.pelurus citellus(): daubentonii.arboreus { var x: daubentonii.arboreus; () => { var y = this; }; return x; } @@ -9113,8 +9113,8 @@ module patas { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : uralensis ->this : uralensis +>y : this +>this : this >x : daubentonii.arboreus tanezumi(): imperfecta.lasiurus { var x: imperfecta.lasiurus; () => { var y = this; }; return x; } @@ -9133,8 +9133,8 @@ module patas { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : uralensis ->this : uralensis +>y : this +>this : this >x : imperfecta.lasiurus albiventer(): rendalli.crenulata { var x: rendalli.crenulata; () => { var y = this; }; return x; } @@ -9153,8 +9153,8 @@ module patas { >dogramacii : any >robustulus : dogramacii.robustulus >() => { var y = this; } : () => void ->y : uralensis ->this : uralensis +>y : this +>this : this >x : rendalli.crenulata } } @@ -9191,8 +9191,8 @@ module provocax { >lutreolus : any >foina : lutreolus.foina >() => { var y = this; } : () => void ->y : melanoleuca ->this : melanoleuca +>y : this +>this : this >x : macrorhinos.marmosurus, lutreolus.foina> baeri(): imperfecta.lasiurus { var x: imperfecta.lasiurus; () => { var y = this; }; return x; } @@ -9211,8 +9211,8 @@ module provocax { >ruatanica : any >americanus : ruatanica.americanus >() => { var y = this; } : () => void ->y : melanoleuca ->this : melanoleuca +>y : this +>this : this >x : imperfecta.lasiurus } } @@ -9248,8 +9248,8 @@ module sagitta { >dogramacii : any >robustulus : dogramacii.robustulus >() => { var y = this; } : () => void ->y : sicarius ->this : sicarius +>y : this +>this : this >x : samarensis.cahirinus, dogramacii.robustulus> simulator(): macrorhinos.marmosurus, macrorhinos.marmosurus, gabriellae.echinatus>, sagitta.stolzmanni>> { var x: macrorhinos.marmosurus, macrorhinos.marmosurus, gabriellae.echinatus>, sagitta.stolzmanni>>; () => { var y = this; }; return x; } @@ -9300,8 +9300,8 @@ module sagitta { >sagitta : any >stolzmanni : stolzmanni >() => { var y = this; } : () => void ->y : sicarius ->this : sicarius +>y : this +>this : this >x : macrorhinos.marmosurus, macrorhinos.marmosurus, gabriellae.echinatus>, stolzmanni>> } } @@ -9322,8 +9322,8 @@ module howi { >Lanthanum : any >megalonyx : Lanthanum.megalonyx >() => { var y = this; } : () => void ->y : marcanoi ->this : marcanoi +>y : this +>this : this >x : Lanthanum.megalonyx dudui(): lutreolus.punicus { var x: lutreolus.punicus; () => { var y = this; }; return x; } @@ -9334,8 +9334,8 @@ module howi { >lutreolus : any >punicus : lutreolus.punicus >() => { var y = this; } : () => void ->y : marcanoi ->this : marcanoi +>y : this +>this : this >x : lutreolus.punicus leander(): daubentonii.nesiotes { var x: daubentonii.nesiotes; () => { var y = this; }; return x; } @@ -9354,8 +9354,8 @@ module howi { >minutus : any >portoricensis : minutus.portoricensis >() => { var y = this; } : () => void ->y : marcanoi ->this : marcanoi +>y : this +>this : this >x : daubentonii.nesiotes martinsi(): dogramacii.aurata { var x: dogramacii.aurata; () => { var y = this; }; return x; } @@ -9366,8 +9366,8 @@ module howi { >dogramacii : any >aurata : dogramacii.aurata >() => { var y = this; } : () => void ->y : marcanoi ->this : marcanoi +>y : this +>this : this >x : dogramacii.aurata beatrix(): imperfecta.ciliolabrum, gabriellae.echinatus>, dogramacii.aurata>, imperfecta.ciliolabrum>> { var x: imperfecta.ciliolabrum, gabriellae.echinatus>, dogramacii.aurata>, imperfecta.ciliolabrum>>; () => { var y = this; }; return x; } @@ -9426,8 +9426,8 @@ module howi { >lavali : any >beisa : lavali.beisa >() => { var y = this; } : () => void ->y : marcanoi ->this : marcanoi +>y : this +>this : this >x : imperfecta.ciliolabrum, gabriellae.echinatus>, dogramacii.aurata>, imperfecta.ciliolabrum>> griseoventer(): argurus.oreas { var x: argurus.oreas; () => { var y = this; }; return x; } @@ -9438,8 +9438,8 @@ module howi { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : marcanoi ->this : marcanoi +>y : this +>this : this >x : argurus.oreas zerda(): quasiater.wattsi, howi.coludo>> { var x: quasiater.wattsi, howi.coludo>>; () => { var y = this; }; return x; } @@ -9482,8 +9482,8 @@ module howi { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : marcanoi ->this : marcanoi +>y : this +>this : this >x : quasiater.wattsi, coludo>> yucatanicus(): julianae.nudicaudus { var x: julianae.nudicaudus; () => { var y = this; }; return x; } @@ -9494,8 +9494,8 @@ module howi { >julianae : any >nudicaudus : julianae.nudicaudus >() => { var y = this; } : () => void ->y : marcanoi ->this : marcanoi +>y : this +>this : this >x : julianae.nudicaudus nigrita(): argurus.peninsulae { var x: argurus.peninsulae; () => { var y = this; }; return x; } @@ -9506,8 +9506,8 @@ module howi { >argurus : any >peninsulae : argurus.peninsulae >() => { var y = this; } : () => void ->y : marcanoi ->this : marcanoi +>y : this +>this : this >x : argurus.peninsulae jouvenetae(): argurus.dauricus { var x: argurus.dauricus; () => { var y = this; }; return x; } @@ -9526,8 +9526,8 @@ module howi { >julianae : any >durangae : julianae.durangae >() => { var y = this; } : () => void ->y : marcanoi ->this : marcanoi +>y : this +>this : this >x : argurus.dauricus indefessus(): sagitta.walkeri { var x: sagitta.walkeri; () => { var y = this; }; return x; } @@ -9538,8 +9538,8 @@ module howi { >sagitta : any >walkeri : sagitta.walkeri >() => { var y = this; } : () => void ->y : marcanoi ->this : marcanoi +>y : this +>this : this >x : sagitta.walkeri vuquangensis(): macrorhinos.daphaenodon { var x: macrorhinos.daphaenodon; () => { var y = this; }; return x; } @@ -9550,8 +9550,8 @@ module howi { >macrorhinos : any >daphaenodon : macrorhinos.daphaenodon >() => { var y = this; } : () => void ->y : marcanoi ->this : marcanoi +>y : this +>this : this >x : macrorhinos.daphaenodon Zirconium(): lavali.thaeleri { var x: lavali.thaeleri; () => { var y = this; }; return x; } @@ -9562,8 +9562,8 @@ module howi { >lavali : any >thaeleri : lavali.thaeleri >() => { var y = this; } : () => void ->y : marcanoi ->this : marcanoi +>y : this +>this : this >x : lavali.thaeleri hyaena(): julianae.oralis { var x: julianae.oralis; () => { var y = this; }; return x; } @@ -9582,8 +9582,8 @@ module howi { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : marcanoi ->this : marcanoi +>y : this +>this : this >x : julianae.oralis } } @@ -9603,8 +9603,8 @@ module argurus { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : gilbertii ->this : gilbertii +>y : this +>this : this >x : lavali.lepturus poecilops(): julianae.steerii { var x: julianae.steerii; () => { var y = this; }; return x; } @@ -9615,8 +9615,8 @@ module argurus { >julianae : any >steerii : julianae.steerii >() => { var y = this; } : () => void ->y : gilbertii ->this : gilbertii +>y : this +>this : this >x : julianae.steerii sondaicus(): samarensis.fuscus { var x: samarensis.fuscus; () => { var y = this; }; return x; } @@ -9635,8 +9635,8 @@ module argurus { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : gilbertii ->this : gilbertii +>y : this +>this : this >x : samarensis.fuscus auriventer(): petrophilus.rosalia { var x: petrophilus.rosalia; () => { var y = this; }; return x; } @@ -9655,8 +9655,8 @@ module argurus { >trivirgatus : any >oconnelli : trivirgatus.oconnelli >() => { var y = this; } : () => void ->y : gilbertii ->this : gilbertii +>y : this +>this : this >x : petrophilus.rosalia cherriei(): ruatanica.Praseodymium { var x: ruatanica.Praseodymium; () => { var y = this; }; return x; } @@ -9675,8 +9675,8 @@ module argurus { >argurus : any >oreas : oreas >() => { var y = this; } : () => void ->y : gilbertii ->this : gilbertii +>y : this +>this : this >x : ruatanica.Praseodymium lindberghi(): minutus.inez { var x: minutus.inez; () => { var y = this; }; return x; } @@ -9695,8 +9695,8 @@ module argurus { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : gilbertii ->this : gilbertii +>y : this +>this : this >x : minutus.inez pipistrellus(): quasiater.carolinensis { var x: quasiater.carolinensis; () => { var y = this; }; return x; } @@ -9707,8 +9707,8 @@ module argurus { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : gilbertii ->this : gilbertii +>y : this +>this : this >x : quasiater.carolinensis paranus(): lutreolus.punicus { var x: lutreolus.punicus; () => { var y = this; }; return x; } @@ -9719,8 +9719,8 @@ module argurus { >lutreolus : any >punicus : lutreolus.punicus >() => { var y = this; } : () => void ->y : gilbertii ->this : gilbertii +>y : this +>this : this >x : lutreolus.punicus dubosti(): nigra.thalia { var x: nigra.thalia; () => { var y = this; }; return x; } @@ -9739,8 +9739,8 @@ module argurus { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : gilbertii ->this : gilbertii +>y : this +>this : this >x : nigra.thalia opossum(): nigra.dolichurus { var x: nigra.dolichurus; () => { var y = this; }; return x; } @@ -9759,8 +9759,8 @@ module argurus { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : gilbertii ->this : gilbertii +>y : this +>this : this >x : nigra.dolichurus oreopolus(): minutus.portoricensis { var x: minutus.portoricensis; () => { var y = this; }; return x; } @@ -9771,8 +9771,8 @@ module argurus { >minutus : any >portoricensis : minutus.portoricensis >() => { var y = this; } : () => void ->y : gilbertii ->this : gilbertii +>y : this +>this : this >x : minutus.portoricensis amurensis(): daubentonii.arboreus { var x: daubentonii.arboreus; () => { var y = this; }; return x; } @@ -9791,8 +9791,8 @@ module argurus { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : gilbertii ->this : gilbertii +>y : this +>this : this >x : daubentonii.arboreus } } @@ -9825,8 +9825,8 @@ module lutreolus { >Lanthanum : any >jugularis : Lanthanum.jugularis >() => { var y = this; } : () => void ->y : punicus ->this : punicus +>y : this +>this : this >x : gabriellae.klossii lar(): caurinus.mahaganus { var x: caurinus.mahaganus; () => { var y = this; }; return x; } @@ -9845,8 +9845,8 @@ module lutreolus { >lavali : any >otion : lavali.otion >() => { var y = this; } : () => void ->y : punicus ->this : punicus +>y : this +>this : this >x : caurinus.mahaganus erica(): dogramacii.koepckeae { var x: dogramacii.koepckeae; () => { var y = this; }; return x; } @@ -9857,8 +9857,8 @@ module lutreolus { >dogramacii : any >koepckeae : dogramacii.koepckeae >() => { var y = this; } : () => void ->y : punicus ->this : punicus +>y : this +>this : this >x : dogramacii.koepckeae trichura(): macrorhinos.konganensis { var x: macrorhinos.konganensis; () => { var y = this; }; return x; } @@ -9869,8 +9869,8 @@ module lutreolus { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : punicus ->this : punicus +>y : this +>this : this >x : macrorhinos.konganensis lemniscatus(): panglima.fundatus { var x: panglima.fundatus; () => { var y = this; }; return x; } @@ -9889,8 +9889,8 @@ module lutreolus { >lutreolus : any >foina : foina >() => { var y = this; } : () => void ->y : punicus ->this : punicus +>y : this +>this : this >x : panglima.fundatus aspalax(): panamensis.linulus { var x: panamensis.linulus; () => { var y = this; }; return x; } @@ -9909,8 +9909,8 @@ module lutreolus { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : punicus ->this : punicus +>y : this +>this : this >x : panamensis.linulus marshalli(): julianae.nudicaudus { var x: julianae.nudicaudus; () => { var y = this; }; return x; } @@ -9921,8 +9921,8 @@ module lutreolus { >julianae : any >nudicaudus : julianae.nudicaudus >() => { var y = this; } : () => void ->y : punicus ->this : punicus +>y : this +>this : this >x : julianae.nudicaudus Zinc(): julianae.galapagoensis { var x: julianae.galapagoensis; () => { var y = this; }; return x; } @@ -9933,8 +9933,8 @@ module lutreolus { >julianae : any >galapagoensis : julianae.galapagoensis >() => { var y = this; } : () => void ->y : punicus ->this : punicus +>y : this +>this : this >x : julianae.galapagoensis monochromos(): howi.coludo { var x: howi.coludo; () => { var y = this; }; return x; } @@ -9953,8 +9953,8 @@ module lutreolus { >lutreolus : any >punicus : punicus >() => { var y = this; } : () => void ->y : punicus ->this : punicus +>y : this +>this : this >x : howi.coludo purinus(): ruatanica.hector { var x: ruatanica.hector; () => { var y = this; }; return x; } @@ -9973,8 +9973,8 @@ module lutreolus { >provocax : any >melanoleuca : provocax.melanoleuca >() => { var y = this; } : () => void ->y : punicus ->this : punicus +>y : this +>this : this >x : ruatanica.hector ischyrus(): lavali.lepturus { var x: lavali.lepturus; () => { var y = this; }; return x; } @@ -9985,8 +9985,8 @@ module lutreolus { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : punicus ->this : punicus +>y : this +>this : this >x : lavali.lepturus tenuis(): macrorhinos.daphaenodon { var x: macrorhinos.daphaenodon; () => { var y = this; }; return x; } @@ -9997,8 +9997,8 @@ module lutreolus { >macrorhinos : any >daphaenodon : macrorhinos.daphaenodon >() => { var y = this; } : () => void ->y : punicus ->this : punicus +>y : this +>this : this >x : macrorhinos.daphaenodon Helium(): julianae.acariensis { var x: julianae.acariensis; () => { var y = this; }; return x; } @@ -10009,8 +10009,8 @@ module lutreolus { >julianae : any >acariensis : julianae.acariensis >() => { var y = this; } : () => void ->y : punicus ->this : punicus +>y : this +>this : this >x : julianae.acariensis } } @@ -10028,8 +10028,8 @@ module macrorhinos { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : daphaenodon ->this : daphaenodon +>y : this +>this : this >x : julianae.sumatrana othus(): howi.coludo { var x: howi.coludo; () => { var y = this; }; return x; } @@ -10048,8 +10048,8 @@ module macrorhinos { >howi : any >marcanoi : howi.marcanoi >() => { var y = this; } : () => void ->y : daphaenodon ->this : daphaenodon +>y : this +>this : this >x : howi.coludo hammondi(): julianae.gerbillus, gabriellae.echinatus>, dogramacii.aurata>, lavali.otion> { var x: julianae.gerbillus, gabriellae.echinatus>, dogramacii.aurata>, lavali.otion>; () => { var y = this; }; return x; } @@ -10092,8 +10092,8 @@ module macrorhinos { >lavali : any >otion : lavali.otion >() => { var y = this; } : () => void ->y : daphaenodon ->this : daphaenodon +>y : this +>this : this >x : julianae.gerbillus, gabriellae.echinatus>, dogramacii.aurata>, lavali.otion> aureocollaris(): quasiater.carolinensis { var x: quasiater.carolinensis; () => { var y = this; }; return x; } @@ -10104,8 +10104,8 @@ module macrorhinos { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : daphaenodon ->this : daphaenodon +>y : this +>this : this >x : quasiater.carolinensis flavipes(): petrophilus.minutilla { var x: petrophilus.minutilla; () => { var y = this; }; return x; } @@ -10116,8 +10116,8 @@ module macrorhinos { >petrophilus : any >minutilla : petrophilus.minutilla >() => { var y = this; } : () => void ->y : daphaenodon ->this : daphaenodon +>y : this +>this : this >x : petrophilus.minutilla callosus(): trivirgatus.lotor { var x: trivirgatus.lotor; () => { var y = this; }; return x; } @@ -10136,8 +10136,8 @@ module macrorhinos { >dogramacii : any >robustulus : dogramacii.robustulus >() => { var y = this; } : () => void ->y : daphaenodon ->this : daphaenodon +>y : this +>this : this >x : trivirgatus.lotor } } @@ -10173,8 +10173,8 @@ module sagitta { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : cinereus ->this : cinereus +>y : this +>this : this >x : rendalli.crenulata> microps(): daubentonii.nigricans> { var x: daubentonii.nigricans>; () => { var y = this; }; return x; } @@ -10201,8 +10201,8 @@ module sagitta { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : cinereus ->this : cinereus +>y : this +>this : this >x : daubentonii.nigricans> guaporensis(): daubentonii.arboreus { var x: daubentonii.arboreus; () => { var y = this; }; return x; } @@ -10221,8 +10221,8 @@ module sagitta { >argurus : any >germaini : argurus.germaini >() => { var y = this; } : () => void ->y : cinereus ->this : cinereus +>y : this +>this : this >x : daubentonii.arboreus tonkeana(): panglima.fundatus { var x: panglima.fundatus; () => { var y = this; }; return x; } @@ -10241,8 +10241,8 @@ module sagitta { >dammermani : any >melanops : dammermani.melanops >() => { var y = this; } : () => void ->y : cinereus ->this : cinereus +>y : this +>this : this >x : panglima.fundatus montensis(): dammermani.siberu { var x: dammermani.siberu; () => { var y = this; }; return x; } @@ -10261,8 +10261,8 @@ module sagitta { >trivirgatus : any >oconnelli : trivirgatus.oconnelli >() => { var y = this; } : () => void ->y : cinereus ->this : cinereus +>y : this +>this : this >x : dammermani.siberu sphinx(): minutus.portoricensis { var x: minutus.portoricensis; () => { var y = this; }; return x; } @@ -10273,8 +10273,8 @@ module sagitta { >minutus : any >portoricensis : minutus.portoricensis >() => { var y = this; } : () => void ->y : cinereus ->this : cinereus +>y : this +>this : this >x : minutus.portoricensis glis(): argurus.wetmorei { var x: argurus.wetmorei; () => { var y = this; }; return x; } @@ -10293,8 +10293,8 @@ module sagitta { >howi : any >marcanoi : howi.marcanoi >() => { var y = this; } : () => void ->y : cinereus ->this : cinereus +>y : this +>this : this >x : argurus.wetmorei dorsalis(): petrophilus.sodyi { var x: petrophilus.sodyi; () => { var y = this; }; return x; } @@ -10313,8 +10313,8 @@ module sagitta { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : cinereus ->this : cinereus +>y : this +>this : this >x : petrophilus.sodyi fimbriatus(): provocax.melanoleuca { var x: provocax.melanoleuca; () => { var y = this; }; return x; } @@ -10325,8 +10325,8 @@ module sagitta { >provocax : any >melanoleuca : provocax.melanoleuca >() => { var y = this; } : () => void ->y : cinereus ->this : cinereus +>y : this +>this : this >x : provocax.melanoleuca sara(): nigra.gracilis { var x: nigra.gracilis; () => { var y = this; }; return x; } @@ -10345,8 +10345,8 @@ module sagitta { >imperfecta : any >subspinosus : imperfecta.subspinosus >() => { var y = this; } : () => void ->y : cinereus ->this : cinereus +>y : this +>this : this >x : nigra.gracilis epimelas(): sagitta.stolzmanni { var x: sagitta.stolzmanni; () => { var y = this; }; return x; } @@ -10357,8 +10357,8 @@ module sagitta { >sagitta : any >stolzmanni : stolzmanni >() => { var y = this; } : () => void ->y : cinereus ->this : cinereus +>y : this +>this : this >x : stolzmanni pittieri(): samarensis.fuscus { var x: samarensis.fuscus; () => { var y = this; }; return x; } @@ -10377,8 +10377,8 @@ module sagitta { >sagitta : any >stolzmanni : stolzmanni >() => { var y = this; } : () => void ->y : cinereus ->this : cinereus +>y : this +>this : this >x : samarensis.fuscus } } @@ -10417,8 +10417,8 @@ module gabriellae { >argurus : any >luctuosa : argurus.luctuosa >() => { var y = this; } : () => void ->y : amicus ->this : amicus +>y : this +>this : this >x : argurus.luctuosa phaeura(): panglima.abidi { var x: panglima.abidi; () => { var y = this; }; return x; } @@ -10437,8 +10437,8 @@ module gabriellae { >argurus : any >peninsulae : argurus.peninsulae >() => { var y = this; } : () => void ->y : amicus ->this : amicus +>y : this +>this : this >x : panglima.abidi voratus(): lavali.thaeleri { var x: lavali.thaeleri; () => { var y = this; }; return x; } @@ -10449,8 +10449,8 @@ module gabriellae { >lavali : any >thaeleri : lavali.thaeleri >() => { var y = this; } : () => void ->y : amicus ->this : amicus +>y : this +>this : this >x : lavali.thaeleri satarae(): trivirgatus.lotor { var x: trivirgatus.lotor; () => { var y = this; }; return x; } @@ -10469,8 +10469,8 @@ module gabriellae { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : amicus ->this : amicus +>y : this +>this : this >x : trivirgatus.lotor hooperi(): caurinus.psilurus { var x: caurinus.psilurus; () => { var y = this; }; return x; } @@ -10481,8 +10481,8 @@ module gabriellae { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : amicus ->this : amicus +>y : this +>this : this >x : caurinus.psilurus perrensi(): rendalli.crenulata { var x: rendalli.crenulata; () => { var y = this; }; return x; } @@ -10501,8 +10501,8 @@ module gabriellae { >howi : any >marcanoi : howi.marcanoi >() => { var y = this; } : () => void ->y : amicus ->this : amicus +>y : this +>this : this >x : rendalli.crenulata ridei(): ruatanica.hector> { var x: ruatanica.hector>; () => { var y = this; }; return x; } @@ -10529,8 +10529,8 @@ module gabriellae { >sagitta : any >walkeri : sagitta.walkeri >() => { var y = this; } : () => void ->y : amicus ->this : amicus +>y : this +>this : this >x : ruatanica.hector> audeberti(): daubentonii.arboreus { var x: daubentonii.arboreus; () => { var y = this; }; return x; } @@ -10549,8 +10549,8 @@ module gabriellae { >lutreolus : any >punicus : lutreolus.punicus >() => { var y = this; } : () => void ->y : amicus ->this : amicus +>y : this +>this : this >x : daubentonii.arboreus Lutetium(): macrorhinos.marmosurus { var x: macrorhinos.marmosurus; () => { var y = this; }; return x; } @@ -10569,8 +10569,8 @@ module gabriellae { >lavali : any >thaeleri : lavali.thaeleri >() => { var y = this; } : () => void ->y : amicus ->this : amicus +>y : this +>this : this >x : macrorhinos.marmosurus atrox(): samarensis.fuscus, dogramacii.koepckeae> { var x: samarensis.fuscus, dogramacii.koepckeae>; () => { var y = this; }; return x; } @@ -10597,8 +10597,8 @@ module gabriellae { >dogramacii : any >koepckeae : dogramacii.koepckeae >() => { var y = this; } : () => void ->y : amicus ->this : amicus +>y : this +>this : this >x : samarensis.fuscus, dogramacii.koepckeae> } export class echinatus { @@ -10628,8 +10628,8 @@ module gabriellae { >patas : any >uralensis : patas.uralensis >() => { var y = this; } : () => void ->y : echinatus ->this : echinatus +>y : this +>this : this >x : howi.coludo> } } @@ -10649,8 +10649,8 @@ module imperfecta { >lavali : any >thaeleri : lavali.thaeleri >() => { var y = this; } : () => void ->y : lasiurus ->this : lasiurus +>y : this +>this : this >x : lavali.thaeleri fulvus(): argurus.germaini { var x: argurus.germaini; () => { var y = this; }; return x; } @@ -10661,8 +10661,8 @@ module imperfecta { >argurus : any >germaini : argurus.germaini >() => { var y = this; } : () => void ->y : lasiurus ->this : lasiurus +>y : this +>this : this >x : argurus.germaini paranaensis(): dogramacii.koepckeae { var x: dogramacii.koepckeae; () => { var y = this; }; return x; } @@ -10673,8 +10673,8 @@ module imperfecta { >dogramacii : any >koepckeae : dogramacii.koepckeae >() => { var y = this; } : () => void ->y : lasiurus ->this : lasiurus +>y : this +>this : this >x : dogramacii.koepckeae didactylus(): panglima.abidi> { var x: panglima.abidi>; () => { var y = this; }; return x; } @@ -10701,8 +10701,8 @@ module imperfecta { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : lasiurus ->this : lasiurus +>y : this +>this : this >x : panglima.abidi> schreibersii(): nigra.gracilis { var x: nigra.gracilis; () => { var y = this; }; return x; } @@ -10721,8 +10721,8 @@ module imperfecta { >ruatanica : any >americanus : ruatanica.americanus >() => { var y = this; } : () => void ->y : lasiurus ->this : lasiurus +>y : this +>this : this >x : nigra.gracilis orii(): dogramacii.kaiseri { var x: dogramacii.kaiseri; () => { var y = this; }; return x; } @@ -10733,8 +10733,8 @@ module imperfecta { >dogramacii : any >kaiseri : dogramacii.kaiseri >() => { var y = this; } : () => void ->y : lasiurus ->this : lasiurus +>y : this +>this : this >x : dogramacii.kaiseri } export class subspinosus { @@ -10748,8 +10748,8 @@ module imperfecta { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : subspinosus ->this : subspinosus +>y : this +>this : this >x : macrorhinos.konganensis Gadolinium(): nigra.caucasica { var x: nigra.caucasica; () => { var y = this; }; return x; } @@ -10768,8 +10768,8 @@ module imperfecta { >patas : any >uralensis : patas.uralensis >() => { var y = this; } : () => void ->y : subspinosus ->this : subspinosus +>y : this +>this : this >x : nigra.caucasica oasicus(): caurinus.johorensis> { var x: caurinus.johorensis>; () => { var y = this; }; return x; } @@ -10796,8 +10796,8 @@ module imperfecta { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : subspinosus ->this : subspinosus +>y : this +>this : this >x : caurinus.johorensis> paterculus(): lutreolus.punicus { var x: lutreolus.punicus; () => { var y = this; }; return x; } @@ -10808,8 +10808,8 @@ module imperfecta { >lutreolus : any >punicus : lutreolus.punicus >() => { var y = this; } : () => void ->y : subspinosus ->this : subspinosus +>y : this +>this : this >x : lutreolus.punicus punctata(): lavali.thaeleri { var x: lavali.thaeleri; () => { var y = this; }; return x; } @@ -10820,8 +10820,8 @@ module imperfecta { >lavali : any >thaeleri : lavali.thaeleri >() => { var y = this; } : () => void ->y : subspinosus ->this : subspinosus +>y : this +>this : this >x : lavali.thaeleri invictus(): sagitta.stolzmanni { var x: sagitta.stolzmanni; () => { var y = this; }; return x; } @@ -10832,8 +10832,8 @@ module imperfecta { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : subspinosus ->this : subspinosus +>y : this +>this : this >x : sagitta.stolzmanni stangeri(): petrophilus.minutilla { var x: petrophilus.minutilla; () => { var y = this; }; return x; } @@ -10844,8 +10844,8 @@ module imperfecta { >petrophilus : any >minutilla : petrophilus.minutilla >() => { var y = this; } : () => void ->y : subspinosus ->this : subspinosus +>y : this +>this : this >x : petrophilus.minutilla siskiyou(): minutus.inez { var x: minutus.inez; () => { var y = this; }; return x; } @@ -10864,8 +10864,8 @@ module imperfecta { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : subspinosus ->this : subspinosus +>y : this +>this : this >x : minutus.inez welwitschii(): rionegrensis.caniventer { var x: rionegrensis.caniventer; () => { var y = this; }; return x; } @@ -10876,8 +10876,8 @@ module imperfecta { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : subspinosus ->this : subspinosus +>y : this +>this : this >x : rionegrensis.caniventer Polonium(): lavali.wilsoni { var x: lavali.wilsoni; () => { var y = this; }; return x; } @@ -10888,8 +10888,8 @@ module imperfecta { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : subspinosus ->this : subspinosus +>y : this +>this : this >x : lavali.wilsoni harpia(): argurus.luctuosa { var x: argurus.luctuosa; () => { var y = this; }; return x; } @@ -10900,8 +10900,8 @@ module imperfecta { >argurus : any >luctuosa : argurus.luctuosa >() => { var y = this; } : () => void ->y : subspinosus ->this : subspinosus +>y : this +>this : this >x : argurus.luctuosa } export class ciliolabrum extends dogramacii.robustulus { @@ -10936,8 +10936,8 @@ module imperfecta { >caurinus : any >megaphyllus : caurinus.megaphyllus >() => { var y = this; } : () => void ->y : ciliolabrum ->this : ciliolabrum +>y : this +>this : this >x : argurus.dauricus> ludia(): caurinus.johorensis { var x: caurinus.johorensis; () => { var y = this; }; return x; } @@ -10956,8 +10956,8 @@ module imperfecta { >lutreolus : any >punicus : lutreolus.punicus >() => { var y = this; } : () => void ->y : ciliolabrum ->this : ciliolabrum +>y : this +>this : this >x : caurinus.johorensis sinicus(): macrorhinos.marmosurus { var x: macrorhinos.marmosurus; () => { var y = this; }; return x; } @@ -10976,8 +10976,8 @@ module imperfecta { >gabriellae : any >amicus : gabriellae.amicus >() => { var y = this; } : () => void ->y : ciliolabrum ->this : ciliolabrum +>y : this +>this : this >x : macrorhinos.marmosurus } } @@ -10997,8 +10997,8 @@ module quasiater { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : wattsi ->this : wattsi +>y : this +>this : this >x : lavali.xanthognathus hussoni(): lavali.wilsoni { var x: lavali.wilsoni; () => { var y = this; }; return x; } @@ -11009,8 +11009,8 @@ module quasiater { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : wattsi ->this : wattsi +>y : this +>this : this >x : lavali.wilsoni bilarni(): samarensis.cahirinus>, dogramacii.koepckeae> { var x: samarensis.cahirinus>, dogramacii.koepckeae>; () => { var y = this; }; return x; } @@ -11045,8 +11045,8 @@ module quasiater { >dogramacii : any >koepckeae : dogramacii.koepckeae >() => { var y = this; } : () => void ->y : wattsi ->this : wattsi +>y : this +>this : this >x : samarensis.cahirinus>, dogramacii.koepckeae> cabrerae(): lavali.lepturus { var x: lavali.lepturus; () => { var y = this; }; return x; } @@ -11057,8 +11057,8 @@ module quasiater { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : wattsi ->this : wattsi +>y : this +>this : this >x : lavali.lepturus } } @@ -11084,8 +11084,8 @@ module petrophilus { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : sodyi ->this : sodyi +>y : this +>this : this >x : samarensis.pallidus imberbis(): quasiater.carolinensis { var x: quasiater.carolinensis; () => { var y = this; }; return x; } @@ -11096,8 +11096,8 @@ module petrophilus { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : sodyi ->this : sodyi +>y : this +>this : this >x : quasiater.carolinensis cansdalei(): dammermani.melanops { var x: dammermani.melanops; () => { var y = this; }; return x; } @@ -11108,8 +11108,8 @@ module petrophilus { >dammermani : any >melanops : dammermani.melanops >() => { var y = this; } : () => void ->y : sodyi ->this : sodyi +>y : this +>this : this >x : dammermani.melanops Lawrencium(): nigra.dolichurus { var x: nigra.dolichurus; () => { var y = this; }; return x; } @@ -11128,8 +11128,8 @@ module petrophilus { >imperfecta : any >subspinosus : imperfecta.subspinosus >() => { var y = this; } : () => void ->y : sodyi ->this : sodyi +>y : this +>this : this >x : nigra.dolichurus catta(): argurus.oreas { var x: argurus.oreas; () => { var y = this; }; return x; } @@ -11140,8 +11140,8 @@ module petrophilus { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : sodyi ->this : sodyi +>y : this +>this : this >x : argurus.oreas breviceps(): argurus.dauricus { var x: argurus.dauricus; () => { var y = this; }; return x; } @@ -11160,8 +11160,8 @@ module petrophilus { >dammermani : any >melanops : dammermani.melanops >() => { var y = this; } : () => void ->y : sodyi ->this : sodyi +>y : this +>this : this >x : argurus.dauricus transitionalis(): rendalli.zuluensis { var x: rendalli.zuluensis; () => { var y = this; }; return x; } @@ -11172,8 +11172,8 @@ module petrophilus { >rendalli : any >zuluensis : rendalli.zuluensis >() => { var y = this; } : () => void ->y : sodyi ->this : sodyi +>y : this +>this : this >x : rendalli.zuluensis heptneri(): argurus.germaini { var x: argurus.germaini; () => { var y = this; }; return x; } @@ -11184,8 +11184,8 @@ module petrophilus { >argurus : any >germaini : argurus.germaini >() => { var y = this; } : () => void ->y : sodyi ->this : sodyi +>y : this +>this : this >x : argurus.germaini bairdii(): lavali.beisa { var x: lavali.beisa; () => { var y = this; }; return x; } @@ -11196,8 +11196,8 @@ module petrophilus { >lavali : any >beisa : lavali.beisa >() => { var y = this; } : () => void ->y : sodyi ->this : sodyi +>y : this +>this : this >x : lavali.beisa } } @@ -11226,8 +11226,8 @@ module caurinus { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : megaphyllus ->this : megaphyllus +>y : this +>this : this >x : argurus.oreas amatus(): lutreolus.schlegeli { var x: lutreolus.schlegeli; () => { var y = this; }; return x; } @@ -11238,8 +11238,8 @@ module caurinus { >lutreolus : any >schlegeli : lutreolus.schlegeli >() => { var y = this; } : () => void ->y : megaphyllus ->this : megaphyllus +>y : this +>this : this >x : lutreolus.schlegeli bucculentus(): gabriellae.echinatus { var x: gabriellae.echinatus; () => { var y = this; }; return x; } @@ -11250,8 +11250,8 @@ module caurinus { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : megaphyllus ->this : megaphyllus +>y : this +>this : this >x : gabriellae.echinatus lepida(): rendalli.crenulata> { var x: rendalli.crenulata>; () => { var y = this; }; return x; } @@ -11278,8 +11278,8 @@ module caurinus { >lutreolus : any >foina : lutreolus.foina >() => { var y = this; } : () => void ->y : megaphyllus ->this : megaphyllus +>y : this +>this : this >x : rendalli.crenulata> graecus(): dogramacii.kaiseri { var x: dogramacii.kaiseri; () => { var y = this; }; return x; } @@ -11290,8 +11290,8 @@ module caurinus { >dogramacii : any >kaiseri : dogramacii.kaiseri >() => { var y = this; } : () => void ->y : megaphyllus ->this : megaphyllus +>y : this +>this : this >x : dogramacii.kaiseri forsteri(): petrophilus.minutilla { var x: petrophilus.minutilla; () => { var y = this; }; return x; } @@ -11302,8 +11302,8 @@ module caurinus { >petrophilus : any >minutilla : petrophilus.minutilla >() => { var y = this; } : () => void ->y : megaphyllus ->this : megaphyllus +>y : this +>this : this >x : petrophilus.minutilla perotensis(): samarensis.cahirinus { var x: samarensis.cahirinus; () => { var y = this; }; return x; } @@ -11322,8 +11322,8 @@ module caurinus { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : megaphyllus ->this : megaphyllus +>y : this +>this : this >x : samarensis.cahirinus cirrhosus(): quasiater.carolinensis { var x: quasiater.carolinensis; () => { var y = this; }; return x; } @@ -11334,8 +11334,8 @@ module caurinus { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : megaphyllus ->this : megaphyllus +>y : this +>this : this >x : quasiater.carolinensis } } @@ -11353,8 +11353,8 @@ module minutus { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : portoricensis ->this : portoricensis +>y : this +>this : this >x : quasiater.carolinensis aequatorianus(): gabriellae.klossii { var x: gabriellae.klossii; () => { var y = this; }; return x; } @@ -11373,8 +11373,8 @@ module minutus { >dogramacii : any >aurata : dogramacii.aurata >() => { var y = this; } : () => void ->y : portoricensis ->this : portoricensis +>y : this +>this : this >x : gabriellae.klossii rhinogradoides(): samarensis.cahirinus { var x: samarensis.cahirinus; () => { var y = this; }; return x; } @@ -11393,8 +11393,8 @@ module minutus { >julianae : any >durangae : julianae.durangae >() => { var y = this; } : () => void ->y : portoricensis ->this : portoricensis +>y : this +>this : this >x : samarensis.cahirinus } } @@ -11412,8 +11412,8 @@ module lutreolus { >lutreolus : any >punicus : punicus >() => { var y = this; } : () => void ->y : foina ->this : foina +>y : this +>this : this >x : punicus Promethium(): samarensis.pelurus { var x: samarensis.pelurus; () => { var y = this; }; return x; } @@ -11432,8 +11432,8 @@ module lutreolus { >julianae : any >durangae : julianae.durangae >() => { var y = this; } : () => void ->y : foina ->this : foina +>y : this +>this : this >x : samarensis.pelurus salinae(): gabriellae.klossii { var x: gabriellae.klossii; () => { var y = this; }; return x; } @@ -11452,8 +11452,8 @@ module lutreolus { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : foina ->this : foina +>y : this +>this : this >x : gabriellae.klossii kerri(): howi.coludo { var x: howi.coludo; () => { var y = this; }; return x; } @@ -11472,8 +11472,8 @@ module lutreolus { >minutus : any >portoricensis : minutus.portoricensis >() => { var y = this; } : () => void ->y : foina ->this : foina +>y : this +>this : this >x : howi.coludo scotti(): quasiater.wattsi { var x: quasiater.wattsi; () => { var y = this; }; return x; } @@ -11492,8 +11492,8 @@ module lutreolus { >dogramacii : any >robustulus : dogramacii.robustulus >() => { var y = this; } : () => void ->y : foina ->this : foina +>y : this +>this : this >x : quasiater.wattsi camerunensis(): julianae.gerbillus { var x: julianae.gerbillus; () => { var y = this; }; return x; } @@ -11512,8 +11512,8 @@ module lutreolus { >julianae : any >durangae : julianae.durangae >() => { var y = this; } : () => void ->y : foina ->this : foina +>y : this +>this : this >x : julianae.gerbillus affinis(): argurus.germaini { var x: argurus.germaini; () => { var y = this; }; return x; } @@ -11524,8 +11524,8 @@ module lutreolus { >argurus : any >germaini : argurus.germaini >() => { var y = this; } : () => void ->y : foina ->this : foina +>y : this +>this : this >x : argurus.germaini siebersi(): trivirgatus.lotor> { var x: trivirgatus.lotor>; () => { var y = this; }; return x; } @@ -11552,8 +11552,8 @@ module lutreolus { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : foina ->this : foina +>y : this +>this : this >x : trivirgatus.lotor> maquassiensis(): trivirgatus.oconnelli { var x: trivirgatus.oconnelli; () => { var y = this; }; return x; } @@ -11564,8 +11564,8 @@ module lutreolus { >trivirgatus : any >oconnelli : trivirgatus.oconnelli >() => { var y = this; } : () => void ->y : foina ->this : foina +>y : this +>this : this >x : trivirgatus.oconnelli layardi(): julianae.albidens { var x: julianae.albidens; () => { var y = this; }; return x; } @@ -11584,8 +11584,8 @@ module lutreolus { >dogramacii : any >koepckeae : dogramacii.koepckeae >() => { var y = this; } : () => void ->y : foina ->this : foina +>y : this +>this : this >x : julianae.albidens bishopi(): dogramacii.aurata { var x: dogramacii.aurata; () => { var y = this; }; return x; } @@ -11596,8 +11596,8 @@ module lutreolus { >dogramacii : any >aurata : dogramacii.aurata >() => { var y = this; } : () => void ->y : foina ->this : foina +>y : this +>this : this >x : dogramacii.aurata apodemoides(): caurinus.psilurus { var x: caurinus.psilurus; () => { var y = this; }; return x; } @@ -11608,8 +11608,8 @@ module lutreolus { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : foina ->this : foina +>y : this +>this : this >x : caurinus.psilurus argentiventer(): trivirgatus.mixtus { var x: trivirgatus.mixtus; () => { var y = this; }; return x; } @@ -11628,8 +11628,8 @@ module lutreolus { >lutreolus : any >punicus : punicus >() => { var y = this; } : () => void ->y : foina ->this : foina +>y : this +>this : this >x : trivirgatus.mixtus } } @@ -11672,8 +11672,8 @@ module lutreolus { >argurus : any >germaini : argurus.germaini >() => { var y = this; } : () => void ->y : cor ->this : cor +>y : this +>this : this >x : petrophilus.sodyi voi(): caurinus.johorensis { var x: caurinus.johorensis; () => { var y = this; }; return x; } @@ -11692,8 +11692,8 @@ module lutreolus { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : cor ->this : cor +>y : this +>this : this >x : caurinus.johorensis mussoi(): quasiater.carolinensis { var x: quasiater.carolinensis; () => { var y = this; }; return x; } @@ -11704,8 +11704,8 @@ module lutreolus { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : cor ->this : cor +>y : this +>this : this >x : quasiater.carolinensis truncatus(): trivirgatus.lotor { var x: trivirgatus.lotor; () => { var y = this; }; return x; } @@ -11724,8 +11724,8 @@ module lutreolus { >lutreolus : any >foina : foina >() => { var y = this; } : () => void ->y : cor ->this : cor +>y : this +>this : this >x : trivirgatus.lotor achates(): provocax.melanoleuca { var x: provocax.melanoleuca; () => { var y = this; }; return x; } @@ -11736,8 +11736,8 @@ module lutreolus { >provocax : any >melanoleuca : provocax.melanoleuca >() => { var y = this; } : () => void ->y : cor ->this : cor +>y : this +>this : this >x : provocax.melanoleuca praedatrix(): howi.angulatus { var x: howi.angulatus; () => { var y = this; }; return x; } @@ -11756,8 +11756,8 @@ module lutreolus { >julianae : any >steerii : julianae.steerii >() => { var y = this; } : () => void ->y : cor ->this : cor +>y : this +>this : this >x : howi.angulatus mzabi(): quasiater.wattsi, minutus.inez> { var x: quasiater.wattsi, minutus.inez>; () => { var y = this; }; return x; } @@ -11792,8 +11792,8 @@ module lutreolus { >Lanthanum : any >jugularis : Lanthanum.jugularis >() => { var y = this; } : () => void ->y : cor ->this : cor +>y : this +>this : this >x : quasiater.wattsi, minutus.inez> xanthinus(): nigra.gracilis, howi.marcanoi> { var x: nigra.gracilis, howi.marcanoi>; () => { var y = this; }; return x; } @@ -11820,8 +11820,8 @@ module lutreolus { >howi : any >marcanoi : howi.marcanoi >() => { var y = this; } : () => void ->y : cor ->this : cor +>y : this +>this : this >x : nigra.gracilis, howi.marcanoi> tapoatafa(): caurinus.megaphyllus { var x: caurinus.megaphyllus; () => { var y = this; }; return x; } @@ -11832,8 +11832,8 @@ module lutreolus { >caurinus : any >megaphyllus : caurinus.megaphyllus >() => { var y = this; } : () => void ->y : cor ->this : cor +>y : this +>this : this >x : caurinus.megaphyllus castroviejoi(): Lanthanum.jugularis { var x: Lanthanum.jugularis; () => { var y = this; }; return x; } @@ -11844,8 +11844,8 @@ module lutreolus { >Lanthanum : any >jugularis : Lanthanum.jugularis >() => { var y = this; } : () => void ->y : cor ->this : cor +>y : this +>this : this >x : Lanthanum.jugularis } } @@ -11865,8 +11865,8 @@ module howi { >lutreolus : any >punicus : lutreolus.punicus >() => { var y = this; } : () => void ->y : coludo ->this : coludo +>y : this +>this : this >x : lutreolus.punicus isseli(): argurus.germaini { var x: argurus.germaini; () => { var y = this; }; return x; } @@ -11877,8 +11877,8 @@ module howi { >argurus : any >germaini : argurus.germaini >() => { var y = this; } : () => void ->y : coludo ->this : coludo +>y : this +>this : this >x : argurus.germaini } } @@ -11899,8 +11899,8 @@ module argurus { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : germaini ->this : germaini +>y : this +>this : this >x : lavali.wilsoni palmarum(): macrorhinos.marmosurus { var x: macrorhinos.marmosurus; () => { var y = this; }; return x; } @@ -11919,8 +11919,8 @@ module argurus { >lavali : any >thaeleri : lavali.thaeleri >() => { var y = this; } : () => void ->y : germaini ->this : germaini +>y : this +>this : this >x : macrorhinos.marmosurus } } @@ -11946,8 +11946,8 @@ module sagitta { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : stolzmanni ->this : stolzmanni +>y : this +>this : this >x : nigra.dolichurus dhofarensis(): lutreolus.foina { var x: lutreolus.foina; () => { var y = this; }; return x; } @@ -11958,8 +11958,8 @@ module sagitta { >lutreolus : any >foina : lutreolus.foina >() => { var y = this; } : () => void ->y : stolzmanni ->this : stolzmanni +>y : this +>this : this >x : lutreolus.foina tricolor(): argurus.germaini { var x: argurus.germaini; () => { var y = this; }; return x; } @@ -11970,8 +11970,8 @@ module sagitta { >argurus : any >germaini : argurus.germaini >() => { var y = this; } : () => void ->y : stolzmanni ->this : stolzmanni +>y : this +>this : this >x : argurus.germaini gardneri(): lavali.xanthognathus { var x: lavali.xanthognathus; () => { var y = this; }; return x; } @@ -11982,8 +11982,8 @@ module sagitta { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : stolzmanni ->this : stolzmanni +>y : this +>this : this >x : lavali.xanthognathus walleri(): rendalli.moojeni, gabriellae.echinatus> { var x: rendalli.moojeni, gabriellae.echinatus>; () => { var y = this; }; return x; } @@ -12010,8 +12010,8 @@ module sagitta { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : stolzmanni ->this : stolzmanni +>y : this +>this : this >x : rendalli.moojeni, gabriellae.echinatus> talpoides(): gabriellae.echinatus { var x: gabriellae.echinatus; () => { var y = this; }; return x; } @@ -12022,8 +12022,8 @@ module sagitta { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : stolzmanni ->this : stolzmanni +>y : this +>this : this >x : gabriellae.echinatus pallipes(): dammermani.melanops { var x: dammermani.melanops; () => { var y = this; }; return x; } @@ -12034,8 +12034,8 @@ module sagitta { >dammermani : any >melanops : dammermani.melanops >() => { var y = this; } : () => void ->y : stolzmanni ->this : stolzmanni +>y : this +>this : this >x : dammermani.melanops lagurus(): lavali.beisa { var x: lavali.beisa; () => { var y = this; }; return x; } @@ -12046,8 +12046,8 @@ module sagitta { >lavali : any >beisa : lavali.beisa >() => { var y = this; } : () => void ->y : stolzmanni ->this : stolzmanni +>y : this +>this : this >x : lavali.beisa hipposideros(): julianae.albidens { var x: julianae.albidens; () => { var y = this; }; return x; } @@ -12066,8 +12066,8 @@ module sagitta { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : stolzmanni ->this : stolzmanni +>y : this +>this : this >x : julianae.albidens griselda(): caurinus.psilurus { var x: caurinus.psilurus; () => { var y = this; }; return x; } @@ -12078,8 +12078,8 @@ module sagitta { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : stolzmanni ->this : stolzmanni +>y : this +>this : this >x : caurinus.psilurus florium(): rendalli.zuluensis { var x: rendalli.zuluensis; () => { var y = this; }; return x; } @@ -12090,8 +12090,8 @@ module sagitta { >rendalli : any >zuluensis : rendalli.zuluensis >() => { var y = this; } : () => void ->y : stolzmanni ->this : stolzmanni +>y : this +>this : this >x : rendalli.zuluensis } } @@ -12116,8 +12116,8 @@ module dammermani { >dammermani : any >melanops : melanops >() => { var y = this; } : () => void ->y : melanops ->this : melanops +>y : this +>this : this >x : melanops harwoodi(): rionegrensis.veraecrucis, lavali.wilsoni> { var x: rionegrensis.veraecrucis, lavali.wilsoni>; () => { var y = this; }; return x; } @@ -12144,8 +12144,8 @@ module dammermani { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : melanops ->this : melanops +>y : this +>this : this >x : rionegrensis.veraecrucis, lavali.wilsoni> ashaninka(): julianae.nudicaudus { var x: julianae.nudicaudus; () => { var y = this; }; return x; } @@ -12156,8 +12156,8 @@ module dammermani { >julianae : any >nudicaudus : julianae.nudicaudus >() => { var y = this; } : () => void ->y : melanops ->this : melanops +>y : this +>this : this >x : julianae.nudicaudus wiedii(): julianae.steerii { var x: julianae.steerii; () => { var y = this; }; return x; } @@ -12168,8 +12168,8 @@ module dammermani { >julianae : any >steerii : julianae.steerii >() => { var y = this; } : () => void ->y : melanops ->this : melanops +>y : this +>this : this >x : julianae.steerii godmani(): imperfecta.subspinosus { var x: imperfecta.subspinosus; () => { var y = this; }; return x; } @@ -12180,8 +12180,8 @@ module dammermani { >imperfecta : any >subspinosus : imperfecta.subspinosus >() => { var y = this; } : () => void ->y : melanops ->this : melanops +>y : this +>this : this >x : imperfecta.subspinosus condorensis(): imperfecta.ciliolabrum { var x: imperfecta.ciliolabrum; () => { var y = this; }; return x; } @@ -12200,8 +12200,8 @@ module dammermani { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : melanops ->this : melanops +>y : this +>this : this >x : imperfecta.ciliolabrum xerophila(): panglima.abidi { var x: panglima.abidi; () => { var y = this; }; return x; } @@ -12220,8 +12220,8 @@ module dammermani { >patas : any >uralensis : patas.uralensis >() => { var y = this; } : () => void ->y : melanops ->this : melanops +>y : this +>this : this >x : panglima.abidi laminatus(): panglima.fundatus>> { var x: panglima.fundatus>>; () => { var y = this; }; return x; } @@ -12256,8 +12256,8 @@ module dammermani { >imperfecta : any >subspinosus : imperfecta.subspinosus >() => { var y = this; } : () => void ->y : melanops ->this : melanops +>y : this +>this : this >x : panglima.fundatus>> archeri(): howi.marcanoi { var x: howi.marcanoi; () => { var y = this; }; return x; } @@ -12268,8 +12268,8 @@ module dammermani { >howi : any >marcanoi : howi.marcanoi >() => { var y = this; } : () => void ->y : melanops ->this : melanops +>y : this +>this : this >x : howi.marcanoi hidalgo(): minutus.inez { var x: minutus.inez; () => { var y = this; }; return x; } @@ -12288,8 +12288,8 @@ module dammermani { >Lanthanum : any >jugularis : Lanthanum.jugularis >() => { var y = this; } : () => void ->y : melanops ->this : melanops +>y : this +>this : this >x : minutus.inez unicolor(): lutreolus.schlegeli { var x: lutreolus.schlegeli; () => { var y = this; }; return x; } @@ -12300,8 +12300,8 @@ module dammermani { >lutreolus : any >schlegeli : lutreolus.schlegeli >() => { var y = this; } : () => void ->y : melanops ->this : melanops +>y : this +>this : this >x : lutreolus.schlegeli philippii(): nigra.gracilis { var x: nigra.gracilis; () => { var y = this; }; return x; } @@ -12320,8 +12320,8 @@ module dammermani { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : melanops ->this : melanops +>y : this +>this : this >x : nigra.gracilis bocagei(): julianae.albidens { var x: julianae.albidens; () => { var y = this; }; return x; } @@ -12340,8 +12340,8 @@ module dammermani { >lavali : any >thaeleri : lavali.thaeleri >() => { var y = this; } : () => void ->y : melanops ->this : melanops +>y : this +>this : this >x : julianae.albidens } } @@ -12386,8 +12386,8 @@ module argurus { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : peninsulae ->this : peninsulae +>y : this +>this : this >x : trivirgatus.mixtus, panglima.amphibius> novaeangliae(): lavali.xanthognathus { var x: lavali.xanthognathus; () => { var y = this; }; return x; } @@ -12398,8 +12398,8 @@ module argurus { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : peninsulae ->this : peninsulae +>y : this +>this : this >x : lavali.xanthognathus olallae(): julianae.sumatrana { var x: julianae.sumatrana; () => { var y = this; }; return x; } @@ -12410,8 +12410,8 @@ module argurus { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : peninsulae ->this : peninsulae +>y : this +>this : this >x : julianae.sumatrana anselli(): dogramacii.aurata { var x: dogramacii.aurata; () => { var y = this; }; return x; } @@ -12422,8 +12422,8 @@ module argurus { >dogramacii : any >aurata : dogramacii.aurata >() => { var y = this; } : () => void ->y : peninsulae ->this : peninsulae +>y : this +>this : this >x : dogramacii.aurata timminsi(): macrorhinos.konganensis { var x: macrorhinos.konganensis; () => { var y = this; }; return x; } @@ -12434,8 +12434,8 @@ module argurus { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : peninsulae ->this : peninsulae +>y : this +>this : this >x : macrorhinos.konganensis sordidus(): rendalli.moojeni { var x: rendalli.moojeni; () => { var y = this; }; return x; } @@ -12454,8 +12454,8 @@ module argurus { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : peninsulae ->this : peninsulae +>y : this +>this : this >x : rendalli.moojeni telfordi(): trivirgatus.oconnelli { var x: trivirgatus.oconnelli; () => { var y = this; }; return x; } @@ -12466,8 +12466,8 @@ module argurus { >trivirgatus : any >oconnelli : trivirgatus.oconnelli >() => { var y = this; } : () => void ->y : peninsulae ->this : peninsulae +>y : this +>this : this >x : trivirgatus.oconnelli cavernarum(): minutus.inez { var x: minutus.inez; () => { var y = this; }; return x; } @@ -12486,8 +12486,8 @@ module argurus { >argurus : any >luctuosa : luctuosa >() => { var y = this; } : () => void ->y : peninsulae ->this : peninsulae +>y : this +>this : this >x : minutus.inez } } @@ -12523,8 +12523,8 @@ module argurus { >dogramacii : any >kaiseri : dogramacii.kaiseri >() => { var y = this; } : () => void ->y : netscheri ->this : netscheri +>y : this +>this : this >x : nigra.caucasica, dogramacii.kaiseri> ruschii(): imperfecta.lasiurus> { var x: imperfecta.lasiurus>; () => { var y = this; }; return x; } @@ -12551,8 +12551,8 @@ module argurus { >petrophilus : any >minutilla : petrophilus.minutilla >() => { var y = this; } : () => void ->y : netscheri ->this : netscheri +>y : this +>this : this >x : imperfecta.lasiurus> tricuspidatus(): lavali.wilsoni { var x: lavali.wilsoni; () => { var y = this; }; return x; } @@ -12563,8 +12563,8 @@ module argurus { >lavali : any >wilsoni : lavali.wilsoni >() => { var y = this; } : () => void ->y : netscheri ->this : netscheri +>y : this +>this : this >x : lavali.wilsoni fernandezi(): dammermani.siberu, panglima.abidi> { var x: dammermani.siberu, panglima.abidi>; () => { var y = this; }; return x; } @@ -12599,8 +12599,8 @@ module argurus { >argurus : any >peninsulae : peninsulae >() => { var y = this; } : () => void ->y : netscheri ->this : netscheri +>y : this +>this : this >x : dammermani.siberu, panglima.abidi> colletti(): samarensis.pallidus { var x: samarensis.pallidus; () => { var y = this; }; return x; } @@ -12611,8 +12611,8 @@ module argurus { >samarensis : any >pallidus : samarensis.pallidus >() => { var y = this; } : () => void ->y : netscheri ->this : netscheri +>y : this +>this : this >x : samarensis.pallidus microbullatus(): lutreolus.schlegeli { var x: lutreolus.schlegeli; () => { var y = this; }; return x; } @@ -12623,8 +12623,8 @@ module argurus { >lutreolus : any >schlegeli : lutreolus.schlegeli >() => { var y = this; } : () => void ->y : netscheri ->this : netscheri +>y : this +>this : this >x : lutreolus.schlegeli eburneae(): chrysaeolus.sarasinorum { var x: chrysaeolus.sarasinorum; () => { var y = this; }; return x; } @@ -12643,8 +12643,8 @@ module argurus { >julianae : any >acariensis : julianae.acariensis >() => { var y = this; } : () => void ->y : netscheri ->this : netscheri +>y : this +>this : this >x : chrysaeolus.sarasinorum tatei(): argurus.pygmaea> { var x: argurus.pygmaea>; () => { var y = this; }; return x; } @@ -12671,8 +12671,8 @@ module argurus { >macrorhinos : any >daphaenodon : macrorhinos.daphaenodon >() => { var y = this; } : () => void ->y : netscheri ->this : netscheri +>y : this +>this : this >x : pygmaea> millardi(): sagitta.walkeri { var x: sagitta.walkeri; () => { var y = this; }; return x; } @@ -12683,8 +12683,8 @@ module argurus { >sagitta : any >walkeri : sagitta.walkeri >() => { var y = this; } : () => void ->y : netscheri ->this : netscheri +>y : this +>this : this >x : sagitta.walkeri pruinosus(): trivirgatus.falconeri { var x: trivirgatus.falconeri; () => { var y = this; }; return x; } @@ -12695,8 +12695,8 @@ module argurus { >trivirgatus : any >falconeri : trivirgatus.falconeri >() => { var y = this; } : () => void ->y : netscheri ->this : netscheri +>y : this +>this : this >x : trivirgatus.falconeri delator(): argurus.netscheri { var x: argurus.netscheri; () => { var y = this; }; return x; } @@ -12715,8 +12715,8 @@ module argurus { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : netscheri ->this : netscheri +>y : this +>this : this >x : netscheri nyikae(): trivirgatus.tumidifrons, petrophilus.minutilla>, julianae.acariensis> { var x: trivirgatus.tumidifrons, petrophilus.minutilla>, julianae.acariensis>; () => { var y = this; }; return x; } @@ -12751,8 +12751,8 @@ module argurus { >julianae : any >acariensis : julianae.acariensis >() => { var y = this; } : () => void ->y : netscheri ->this : netscheri +>y : this +>this : this >x : trivirgatus.tumidifrons, petrophilus.minutilla>, julianae.acariensis> ruemmleri(): panglima.amphibius, gabriellae.echinatus>, dogramacii.aurata>, imperfecta.ciliolabrum> { var x: panglima.amphibius, gabriellae.echinatus>, dogramacii.aurata>, imperfecta.ciliolabrum>; () => { var y = this; }; return x; } @@ -12803,8 +12803,8 @@ module argurus { >lavali : any >beisa : lavali.beisa >() => { var y = this; } : () => void ->y : netscheri ->this : netscheri +>y : this +>this : this >x : panglima.amphibius, gabriellae.echinatus>, dogramacii.aurata>, imperfecta.ciliolabrum> } } @@ -12855,8 +12855,8 @@ module ruatanica { >rionegrensis : any >caniventer : rionegrensis.caniventer >() => { var y = this; } : () => void ->y : Praseodymium ->this : Praseodymium +>y : this +>this : this >x : panglima.amphibius, argurus.dauricus> spectabilis(): petrophilus.sodyi { var x: petrophilus.sodyi; () => { var y = this; }; return x; } @@ -12875,8 +12875,8 @@ module ruatanica { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : Praseodymium ->this : Praseodymium +>y : this +>this : this >x : petrophilus.sodyi kamensis(): trivirgatus.lotor, lavali.lepturus> { var x: trivirgatus.lotor, lavali.lepturus>; () => { var y = this; }; return x; } @@ -12903,8 +12903,8 @@ module ruatanica { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : Praseodymium ->this : Praseodymium +>y : this +>this : this >x : trivirgatus.lotor, lavali.lepturus> ruddi(): lutreolus.foina { var x: lutreolus.foina; () => { var y = this; }; return x; } @@ -12915,8 +12915,8 @@ module ruatanica { >lutreolus : any >foina : lutreolus.foina >() => { var y = this; } : () => void ->y : Praseodymium ->this : Praseodymium +>y : this +>this : this >x : lutreolus.foina bartelsii(): julianae.sumatrana { var x: julianae.sumatrana; () => { var y = this; }; return x; } @@ -12927,8 +12927,8 @@ module ruatanica { >julianae : any >sumatrana : julianae.sumatrana >() => { var y = this; } : () => void ->y : Praseodymium ->this : Praseodymium +>y : this +>this : this >x : julianae.sumatrana yerbabuenae(): dammermani.siberu, imperfecta.ciliolabrum> { var x: dammermani.siberu, imperfecta.ciliolabrum>; () => { var y = this; }; return x; } @@ -12963,8 +12963,8 @@ module ruatanica { >petrophilus : any >minutilla : petrophilus.minutilla >() => { var y = this; } : () => void ->y : Praseodymium ->this : Praseodymium +>y : this +>this : this >x : dammermani.siberu, imperfecta.ciliolabrum> davidi(): trivirgatus.mixtus { var x: trivirgatus.mixtus; () => { var y = this; }; return x; } @@ -12983,8 +12983,8 @@ module ruatanica { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : Praseodymium ->this : Praseodymium +>y : this +>this : this >x : trivirgatus.mixtus pilirostris(): argurus.wetmorei>, sagitta.leptoceros>>, macrorhinos.konganensis> { var x: argurus.wetmorei>, sagitta.leptoceros>>, macrorhinos.konganensis>; () => { var y = this; }; return x; } @@ -13043,8 +13043,8 @@ module ruatanica { >macrorhinos : any >konganensis : macrorhinos.konganensis >() => { var y = this; } : () => void ->y : Praseodymium ->this : Praseodymium +>y : this +>this : this >x : argurus.wetmorei>, sagitta.leptoceros>>, macrorhinos.konganensis> catherinae(): imperfecta.lasiurus, petrophilus.sodyi> { var x: imperfecta.lasiurus, petrophilus.sodyi>; () => { var y = this; }; return x; } @@ -13079,8 +13079,8 @@ module ruatanica { >caurinus : any >psilurus : caurinus.psilurus >() => { var y = this; } : () => void ->y : Praseodymium ->this : Praseodymium +>y : this +>this : this >x : imperfecta.lasiurus, petrophilus.sodyi> frontata(): argurus.oreas { var x: argurus.oreas; () => { var y = this; }; return x; } @@ -13091,8 +13091,8 @@ module ruatanica { >argurus : any >oreas : argurus.oreas >() => { var y = this; } : () => void ->y : Praseodymium ->this : Praseodymium +>y : this +>this : this >x : argurus.oreas Terbium(): caurinus.mahaganus { var x: caurinus.mahaganus; () => { var y = this; }; return x; } @@ -13111,8 +13111,8 @@ module ruatanica { >argurus : any >luctuosa : argurus.luctuosa >() => { var y = this; } : () => void ->y : Praseodymium ->this : Praseodymium +>y : this +>this : this >x : caurinus.mahaganus thomensis(): minutus.inez> { var x: minutus.inez>; () => { var y = this; }; return x; } @@ -13139,8 +13139,8 @@ module ruatanica { >gabriellae : any >echinatus : gabriellae.echinatus >() => { var y = this; } : () => void ->y : Praseodymium ->this : Praseodymium +>y : this +>this : this >x : minutus.inez> soricinus(): quasiater.carolinensis { var x: quasiater.carolinensis; () => { var y = this; }; return x; } @@ -13151,8 +13151,8 @@ module ruatanica { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : Praseodymium ->this : Praseodymium +>y : this +>this : this >x : quasiater.carolinensis } } @@ -13183,8 +13183,8 @@ module caurinus { >julianae : any >acariensis : julianae.acariensis >() => { var y = this; } : () => void ->y : johorensis ->this : johorensis +>y : this +>this : this >x : ruatanica.Praseodymium } } @@ -13234,8 +13234,8 @@ module argurus { >lutreolus : any >punicus : lutreolus.punicus >() => { var y = this; } : () => void ->y : luctuosa ->this : luctuosa +>y : this +>this : this >x : rendalli.moojeni, gabriellae.echinatus>, sagitta.stolzmanni>, lutreolus.punicus> } } @@ -13271,8 +13271,8 @@ module panamensis { >dogramacii : any >aurata : dogramacii.aurata >() => { var y = this; } : () => void ->y : setulosus ->this : setulosus +>y : this +>this : this >x : caurinus.mahaganus, dogramacii.aurata> guereza(): howi.coludo { var x: howi.coludo; () => { var y = this; }; return x; } @@ -13291,8 +13291,8 @@ module panamensis { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : setulosus ->this : setulosus +>y : this +>this : this >x : howi.coludo buselaphus(): daubentonii.nesiotes, dogramacii.koepckeae>, trivirgatus.mixtus> { var x: daubentonii.nesiotes, dogramacii.koepckeae>, trivirgatus.mixtus>; () => { var y = this; }; return x; } @@ -13335,8 +13335,8 @@ module panamensis { >lutreolus : any >punicus : lutreolus.punicus >() => { var y = this; } : () => void ->y : setulosus ->this : setulosus +>y : this +>this : this >x : daubentonii.nesiotes, dogramacii.koepckeae>, trivirgatus.mixtus> nuttalli(): sagitta.cinereus, chrysaeolus.sarasinorum> { var x: sagitta.cinereus, chrysaeolus.sarasinorum>; () => { var y = this; }; return x; } @@ -13371,8 +13371,8 @@ module panamensis { >lavali : any >xanthognathus : lavali.xanthognathus >() => { var y = this; } : () => void ->y : setulosus ->this : setulosus +>y : this +>this : this >x : sagitta.cinereus, chrysaeolus.sarasinorum> pelii(): rendalli.crenulata, julianae.steerii> { var x: rendalli.crenulata, julianae.steerii>; () => { var y = this; }; return x; } @@ -13399,8 +13399,8 @@ module panamensis { >julianae : any >steerii : julianae.steerii >() => { var y = this; } : () => void ->y : setulosus ->this : setulosus +>y : this +>this : this >x : rendalli.crenulata, julianae.steerii> tunneyi(): sagitta.stolzmanni { var x: sagitta.stolzmanni; () => { var y = this; }; return x; } @@ -13411,8 +13411,8 @@ module panamensis { >sagitta : any >stolzmanni : sagitta.stolzmanni >() => { var y = this; } : () => void ->y : setulosus ->this : setulosus +>y : this +>this : this >x : sagitta.stolzmanni lamula(): patas.uralensis { var x: patas.uralensis; () => { var y = this; }; return x; } @@ -13423,8 +13423,8 @@ module panamensis { >patas : any >uralensis : patas.uralensis >() => { var y = this; } : () => void ->y : setulosus ->this : setulosus +>y : this +>this : this >x : patas.uralensis vampyrus(): julianae.oralis { var x: julianae.oralis; () => { var y = this; }; return x; } @@ -13443,8 +13443,8 @@ module panamensis { >provocax : any >melanoleuca : provocax.melanoleuca >() => { var y = this; } : () => void ->y : setulosus ->this : setulosus +>y : this +>this : this >x : julianae.oralis } } @@ -13512,8 +13512,8 @@ module petrophilus { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : rosalia ->this : rosalia +>y : this +>this : this >x : panglima.amphibius>, trivirgatus.mixtus, panglima.amphibius>> baeops(): Lanthanum.nitidus { var x: Lanthanum.nitidus; () => { var y = this; }; return x; } @@ -13532,8 +13532,8 @@ module petrophilus { >lavali : any >lepturus : lavali.lepturus >() => { var y = this; } : () => void ->y : rosalia ->this : rosalia +>y : this +>this : this >x : Lanthanum.nitidus ozensis(): imperfecta.lasiurus, lutreolus.foina> { var x: imperfecta.lasiurus, lutreolus.foina>; () => { var y = this; }; return x; } @@ -13560,8 +13560,8 @@ module petrophilus { >lutreolus : any >foina : lutreolus.foina >() => { var y = this; } : () => void ->y : rosalia ->this : rosalia +>y : this +>this : this >x : imperfecta.lasiurus, lutreolus.foina> creaghi(): argurus.luctuosa { var x: argurus.luctuosa; () => { var y = this; }; return x; } @@ -13572,8 +13572,8 @@ module petrophilus { >argurus : any >luctuosa : argurus.luctuosa >() => { var y = this; } : () => void ->y : rosalia ->this : rosalia +>y : this +>this : this >x : argurus.luctuosa montivaga(): panamensis.setulosus> { var x: panamensis.setulosus>; () => { var y = this; }; return x; } @@ -13600,8 +13600,8 @@ module petrophilus { >caurinus : any >megaphyllus : caurinus.megaphyllus >() => { var y = this; } : () => void ->y : rosalia ->this : rosalia +>y : this +>this : this >x : panamensis.setulosus> } } @@ -13630,8 +13630,8 @@ module caurinus { >caurinus : any >psilurus : psilurus >() => { var y = this; } : () => void ->y : psilurus ->this : psilurus +>y : this +>this : this >x : panglima.amphibius lundi(): petrophilus.sodyi { var x: petrophilus.sodyi; () => { var y = this; }; return x; } @@ -13650,8 +13650,8 @@ module caurinus { >quasiater : any >bobrinskoi : quasiater.bobrinskoi >() => { var y = this; } : () => void ->y : psilurus ->this : psilurus +>y : this +>this : this >x : petrophilus.sodyi araeum(): imperfecta.ciliolabrum { var x: imperfecta.ciliolabrum; () => { var y = this; }; return x; } @@ -13670,8 +13670,8 @@ module caurinus { >lavali : any >beisa : lavali.beisa >() => { var y = this; } : () => void ->y : psilurus ->this : psilurus +>y : this +>this : this >x : imperfecta.ciliolabrum calamianensis(): julianae.gerbillus { var x: julianae.gerbillus; () => { var y = this; }; return x; } @@ -13690,8 +13690,8 @@ module caurinus { >quasiater : any >carolinensis : quasiater.carolinensis >() => { var y = this; } : () => void ->y : psilurus ->this : psilurus +>y : this +>this : this >x : julianae.gerbillus petersoni(): panamensis.setulosus { var x: panamensis.setulosus; () => { var y = this; }; return x; } @@ -13710,8 +13710,8 @@ module caurinus { >dogramacii : any >robustulus : dogramacii.robustulus >() => { var y = this; } : () => void ->y : psilurus ->this : psilurus +>y : this +>this : this >x : panamensis.setulosus nitela(): panamensis.linulus { var x: panamensis.linulus; () => { var y = this; }; return x; } @@ -13730,8 +13730,8 @@ module caurinus { >howi : any >marcanoi : howi.marcanoi >() => { var y = this; } : () => void ->y : psilurus ->this : psilurus +>y : this +>this : this >x : panamensis.linulus } } diff --git a/tests/baselines/reference/reuseInnerModuleMember.js b/tests/baselines/reference/reuseInnerModuleMember.js index 8999ccea633..a15ec5e39a2 100644 --- a/tests/baselines/reference/reuseInnerModuleMember.js +++ b/tests/baselines/reference/reuseInnerModuleMember.js @@ -9,7 +9,7 @@ declare module bar { interface alpha { } } -import f = require('reuseInnerModuleMember_0'); +import f = require('./reuseInnerModuleMember_0'); module bar { var x: alpha; } diff --git a/tests/baselines/reference/reuseInnerModuleMember.symbols b/tests/baselines/reference/reuseInnerModuleMember.symbols index 27301f1256b..5dbd830293f 100644 --- a/tests/baselines/reference/reuseInnerModuleMember.symbols +++ b/tests/baselines/reference/reuseInnerModuleMember.symbols @@ -1,17 +1,17 @@ === tests/cases/compiler/reuseInnerModuleMember_1.ts === /// declare module bar { ->bar : Symbol(bar, Decl(reuseInnerModuleMember_1.ts, 0, 0), Decl(reuseInnerModuleMember_1.ts, 5, 47)) +>bar : Symbol(bar, Decl(reuseInnerModuleMember_1.ts, 0, 0), Decl(reuseInnerModuleMember_1.ts, 5, 49)) interface alpha { } >alpha : Symbol(alpha, Decl(reuseInnerModuleMember_1.ts, 1, 20)) } -import f = require('reuseInnerModuleMember_0'); +import f = require('./reuseInnerModuleMember_0'); >f : Symbol(f, Decl(reuseInnerModuleMember_1.ts, 3, 1)) module bar { ->bar : Symbol(bar, Decl(reuseInnerModuleMember_1.ts, 0, 0), Decl(reuseInnerModuleMember_1.ts, 5, 47)) +>bar : Symbol(bar, Decl(reuseInnerModuleMember_1.ts, 0, 0), Decl(reuseInnerModuleMember_1.ts, 5, 49)) var x: alpha; >x : Symbol(x, Decl(reuseInnerModuleMember_1.ts, 7, 7)) diff --git a/tests/baselines/reference/reuseInnerModuleMember.types b/tests/baselines/reference/reuseInnerModuleMember.types index d42e071e16b..433da749b49 100644 --- a/tests/baselines/reference/reuseInnerModuleMember.types +++ b/tests/baselines/reference/reuseInnerModuleMember.types @@ -7,7 +7,7 @@ declare module bar { >alpha : alpha } -import f = require('reuseInnerModuleMember_0'); +import f = require('./reuseInnerModuleMember_0'); >f : typeof f module bar { diff --git a/tests/baselines/reference/scopeResolutionIdentifiers.types b/tests/baselines/reference/scopeResolutionIdentifiers.types index 37fa897863d..7c4eae23813 100644 --- a/tests/baselines/reference/scopeResolutionIdentifiers.types +++ b/tests/baselines/reference/scopeResolutionIdentifiers.types @@ -56,7 +56,7 @@ class C { n = this.s; >n : Date >this.s : Date ->this : C +>this : this >s : Date x() { @@ -65,7 +65,7 @@ class C { var p = this.n; >p : Date >this.n : Date ->this : C +>this : this >n : Date var p: Date; diff --git a/tests/baselines/reference/selfInCallback.types b/tests/baselines/reference/selfInCallback.types index 0f9b0f3a671..6010a64d80f 100644 --- a/tests/baselines/reference/selfInCallback.types +++ b/tests/baselines/reference/selfInCallback.types @@ -18,12 +18,12 @@ class C { this.callback(()=>{this.p1+1}); >this.callback(()=>{this.p1+1}) : void >this.callback : (cb: () => void) => void ->this : C +>this : this >callback : (cb: () => void) => void >()=>{this.p1+1} : () => void >this.p1+1 : number >this.p1 : number ->this : C +>this : this >p1 : number >1 : number } diff --git a/tests/baselines/reference/selfInLambdas.types b/tests/baselines/reference/selfInLambdas.types index e8905432e75..3addf07c75a 100644 --- a/tests/baselines/reference/selfInLambdas.types +++ b/tests/baselines/reference/selfInLambdas.types @@ -79,7 +79,7 @@ class X { var x = this.value; >x : string >this.value : string ->this : X +>this : this >value : string var inner = () => { @@ -89,7 +89,7 @@ class X { var y = this.value; >y : string >this.value : string ->this : X +>this : this >value : string } diff --git a/tests/baselines/reference/sourceMap-FileWithComments.types b/tests/baselines/reference/sourceMap-FileWithComments.types index f6b87c2e4c4..6f9ca201085 100644 --- a/tests/baselines/reference/sourceMap-FileWithComments.types +++ b/tests/baselines/reference/sourceMap-FileWithComments.types @@ -32,17 +32,17 @@ module Shapes { >this.x * this.x + this.y * this.y : number >this.x * this.x : number >this.x : number ->this : Point +>this : this >x : number >this.x : number ->this : Point +>this : this >x : number >this.y * this.y : number >this.y : number ->this : Point +>this : this >y : number >this.y : number ->this : Point +>this : this >y : number // Static member diff --git a/tests/baselines/reference/sourceMapValidationClass.types b/tests/baselines/reference/sourceMapValidationClass.types index e3b30a37227..3e5234b0d6e 100644 --- a/tests/baselines/reference/sourceMapValidationClass.types +++ b/tests/baselines/reference/sourceMapValidationClass.types @@ -14,7 +14,7 @@ class Greeter { >"

" + this.greeting : string >"

" : string >this.greeting : string ->this : Greeter +>this : this >greeting : string >"

" : string } @@ -30,7 +30,7 @@ class Greeter { return this.greeting; >this.greeting : string ->this : Greeter +>this : this >greeting : string } get greetings() { @@ -38,7 +38,7 @@ class Greeter { return this.greeting; >this.greeting : string ->this : Greeter +>this : this >greeting : string } set greetings(greetings: string) { @@ -48,7 +48,7 @@ class Greeter { this.greeting = greetings; >this.greeting = greetings : string >this.greeting : string ->this : Greeter +>this : this >greeting : string >greetings : string } diff --git a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatement.types b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatement.types index 266fe496193..a20410aa842 100644 --- a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatement.types +++ b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatement.types @@ -10,6 +10,6 @@ class Greeter { >returnA : () => number >() => this.a : () => number >this.a : number ->this : Greeter +>this : this >a : number } diff --git a/tests/baselines/reference/sourceMapValidationClasses.types b/tests/baselines/reference/sourceMapValidationClasses.types index 97e168d4701..5b3512c06c1 100644 --- a/tests/baselines/reference/sourceMapValidationClasses.types +++ b/tests/baselines/reference/sourceMapValidationClasses.types @@ -21,7 +21,7 @@ module Foo.Bar { >"

" + this.greeting : string >"

" : string >this.greeting : string ->this : Greeter +>this : this >greeting : string >"

" : string } diff --git a/tests/baselines/reference/sourceMapValidationDecorators.js b/tests/baselines/reference/sourceMapValidationDecorators.js index 5196d3b0dd8..04eb1d71078 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.js +++ b/tests/baselines/reference/sourceMapValidationDecorators.js @@ -56,12 +56,10 @@ class Greeter { //// [sourceMapValidationDecorators.js] var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); - switch (arguments.length) { - case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); - case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); - case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); - } + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } @@ -91,31 +89,28 @@ var Greeter = (function () { configurable: true }); Greeter.x1 = 10; - Object.defineProperty(Greeter.prototype, "greet", - __decorate([ - PropertyDecorator1, - PropertyDecorator2(40) - ], Greeter.prototype, "greet", Object.getOwnPropertyDescriptor(Greeter.prototype, "greet"))); + __decorate([ + PropertyDecorator1, + PropertyDecorator2(40) + ], Greeter.prototype, "greet", null); __decorate([ PropertyDecorator1, PropertyDecorator2(50) - ], Greeter.prototype, "x"); - Object.defineProperty(Greeter.prototype, "fn", - __decorate([ - __param(0, ParameterDecorator1), - __param(0, ParameterDecorator2(70)) - ], Greeter.prototype, "fn", Object.getOwnPropertyDescriptor(Greeter.prototype, "fn"))); - Object.defineProperty(Greeter.prototype, "greetings", - __decorate([ - PropertyDecorator1, - PropertyDecorator2(80), - __param(0, ParameterDecorator1), - __param(0, ParameterDecorator2(90)) - ], Greeter.prototype, "greetings", Object.getOwnPropertyDescriptor(Greeter.prototype, "greetings"))); + ], Greeter.prototype, "x", void 0); + __decorate([ + __param(0, ParameterDecorator1), + __param(0, ParameterDecorator2(70)) + ], Greeter.prototype, "fn", null); + __decorate([ + PropertyDecorator1, + PropertyDecorator2(80), + __param(0, ParameterDecorator1), + __param(0, ParameterDecorator2(90)) + ], Greeter.prototype, "greetings", null); __decorate([ PropertyDecorator1, PropertyDecorator2(60) - ], Greeter, "x1"); + ], Greeter, "x1", void 0); Greeter = __decorate([ ClassDecorator1, ClassDecorator2(10), diff --git a/tests/baselines/reference/sourceMapValidationDecorators.js.map b/tests/baselines/reference/sourceMapValidationDecorators.js.map index 4cbb79f727d..4a8b3258659 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.js.map +++ b/tests/baselines/reference/sourceMapValidationDecorators.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDecorators.js.map] -{"version":3,"file":"sourceMapValidationDecorators.js","sourceRoot":"","sources":["sourceMapValidationDecorators.ts"],"names":["Greeter","Greeter.constructor","Greeter.greet","Greeter.fn","Greeter.greetings"],"mappings":";;;;;;;;;;;AAOA;IAGIA,iBAGSA,QAAgBA;QAEvBC,WAEcA;aAFdA,WAEcA,CAFdA,sBAEcA,CAFdA,IAEcA;YAFdA,0BAEcA;;QAJPA,aAAQA,GAARA,QAAQA,CAAQA;IAKzBA,CAACA;IAIDD,uBAAKA,GAFLA;QAGIE,MAAMA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,QAAQA,GAAGA,OAAOA,CAACA;IAC5CA,CAACA;IAUOF,oBAAEA,GAAVA,UAGEA,CAASA;QACPG,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;IACzBA,CAACA;IAEDH,sBAEIA,8BAASA;aAFbA;YAGII,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;QACzBA,CAACA;aAEDJ,UAGEA,SAAiBA;YACfI,IAAIA,CAACA,QAAQA,GAAGA,SAASA,CAACA;QAC9BA,CAACA;;;OAPAJ;IAbcA,UAAEA,GAAWA,EAAEA,CAACA;IAZ/BA,sBAEAA,0BAAKA;;YAFJA,kBAAkBA;YAClBA,kBAAkBA,CAACA,EAAEA,CAACA;WACvBA,0BAAKA,kCAALA,0BAAKA,IAEJA;IAEDA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACfA,sBAACA,EAASA;IAMlBA,sBAAQA,uBAAEA;;YACRA,WAACA,mBAAmBA,CAAAA;YACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;WAFlBA,uBAAEA,kCAAFA,uBAAEA,IAKTA;IAEDA,sBAEIA,8BAASA;;YAFZA,kBAAkBA;YAClBA,kBAAkBA,CAACA,EAAEA,CAACA;YAMrBA,WAACA,mBAAmBA,CAAAA;YACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;WANtBA,8BAASA,kCAATA,8BAASA,IAEZA;IAfDA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACRA,aAAEA,EAAcA;IAzBnCA;QAACA,eAAeA;QACfA,eAAeA,CAACA,EAAEA,CAACA;QAGdA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;QAGxBA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;gBAqC7BA;IAADA,cAACA;AAADA,CAACA,AA9CD,IA8CC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDecorators.js","sourceRoot":"","sources":["sourceMapValidationDecorators.ts"],"names":["Greeter","Greeter.constructor","Greeter.greet","Greeter.fn","Greeter.greetings"],"mappings":";;;;;;;;;AAOA;IAGIA,iBAGSA,QAAgBA;QAEvBC,WAEcA;aAFdA,WAEcA,CAFdA,sBAEcA,CAFdA,IAEcA;YAFdA,0BAEcA;;QAJPA,aAAQA,GAARA,QAAQA,CAAQA;IAKzBA,CAACA;IAIDD,uBAAKA,GAFLA;QAGIE,MAAMA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,QAAQA,GAAGA,OAAOA,CAACA;IAC5CA,CAACA;IAUOF,oBAAEA,GAAVA,UAGEA,CAASA;QACPG,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;IACzBA,CAACA;IAEDH,sBAEIA,8BAASA;aAFbA;YAGII,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;QACzBA,CAACA;aAEDJ,UAGEA,SAAiBA;YACfI,IAAIA,CAACA,QAAQA,GAAGA,SAASA,CAACA;QAC9BA,CAACA;;;OAPAJ;IAbcA,UAAEA,GAAWA,EAAEA,CAACA;IAZ/BA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACvBA,0BAAKA,QAEJA;IAEDA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACfA,sBAACA,UAASA;IAMlBA;QACEA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;OAFlBA,uBAAEA,QAKTA;IAEDA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;QAMrBA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;OANtBA,8BAASA,QAEZA;IAfDA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACRA,aAAEA,UAAcA;IAzBnCA;QAACA,eAAeA;QACfA,eAAeA,CAACA,EAAEA,CAACA;QAGdA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;QAGxBA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;gBAqC7BA;IAADA,cAACA;AAADA,CAACA,AA9CD,IA8CC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt index b7036723a85..d9c8d0cc976 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt @@ -9,12 +9,10 @@ emittedFile:tests/cases/compiler/sourceMapValidationDecorators.js sourceFile:sourceMapValidationDecorators.ts ------------------------------------------------------------------- >>>var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { ->>> if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); ->>> switch (arguments.length) { ->>> case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); ->>> case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); ->>> case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); ->>> } +>>> var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; +>>> if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); +>>> else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; +>>> return c > 3 && r && Object.defineProperty(target, key, r), r; >>>}; >>>var __param = (this && this.__param) || function (paramIndex, decorator) { >>> return function (target, key) { decorator(target, key, paramIndex); } @@ -30,7 +28,7 @@ sourceFile:sourceMapValidationDecorators.ts >declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void; > > -1 >Emitted(12, 1) Source(8, 1) + SourceIndex(0) +1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) --- >>> function Greeter(greeting) { 1->^^^^ @@ -45,9 +43,9 @@ sourceFile:sourceMapValidationDecorators.ts > @ParameterDecorator2(20) > public 3 > greeting: string -1->Emitted(13, 5) Source(11, 5) + SourceIndex(0) name (Greeter) -2 >Emitted(13, 22) Source(14, 14) + SourceIndex(0) name (Greeter) -3 >Emitted(13, 30) Source(14, 30) + SourceIndex(0) name (Greeter) +1->Emitted(11, 5) Source(11, 5) + SourceIndex(0) name (Greeter) +2 >Emitted(11, 22) Source(14, 14) + SourceIndex(0) name (Greeter) +3 >Emitted(11, 30) Source(14, 30) + SourceIndex(0) name (Greeter) --- >>> var b = []; 1 >^^^^^^^^ @@ -59,8 +57,8 @@ sourceFile:sourceMapValidationDecorators.ts 2 > @ParameterDecorator1 > @ParameterDecorator2(30) > ...b: string[] -1 >Emitted(14, 9) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) -2 >Emitted(14, 20) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) +1 >Emitted(12, 9) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) +2 >Emitted(12, 20) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) --- >>> for (var _i = 1; _i < arguments.length; _i++) { 1->^^^^^^^^^^^^^ @@ -81,12 +79,12 @@ sourceFile:sourceMapValidationDecorators.ts 6 > @ParameterDecorator1 > @ParameterDecorator2(30) > ...b: string[] -1->Emitted(15, 14) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) -2 >Emitted(15, 25) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) -3 >Emitted(15, 26) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) -4 >Emitted(15, 48) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) -5 >Emitted(15, 49) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) -6 >Emitted(15, 53) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) +1->Emitted(13, 14) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) +2 >Emitted(13, 25) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) +3 >Emitted(13, 26) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) +4 >Emitted(13, 48) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) +5 >Emitted(13, 49) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) +6 >Emitted(13, 53) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) --- >>> b[_i - 1] = arguments[_i]; 1 >^^^^^^^^^^^^ @@ -95,8 +93,8 @@ sourceFile:sourceMapValidationDecorators.ts 2 > @ParameterDecorator1 > @ParameterDecorator2(30) > ...b: string[] -1 >Emitted(16, 13) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) -2 >Emitted(16, 39) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) +1 >Emitted(14, 13) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) +2 >Emitted(14, 39) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) --- >>> } >>> this.greeting = greeting; @@ -110,11 +108,11 @@ sourceFile:sourceMapValidationDecorators.ts 3 > 4 > greeting 5 > : string -1 >Emitted(18, 9) Source(14, 14) + SourceIndex(0) name (Greeter.constructor) -2 >Emitted(18, 22) Source(14, 22) + SourceIndex(0) name (Greeter.constructor) -3 >Emitted(18, 25) Source(14, 14) + SourceIndex(0) name (Greeter.constructor) -4 >Emitted(18, 33) Source(14, 22) + SourceIndex(0) name (Greeter.constructor) -5 >Emitted(18, 34) Source(14, 30) + SourceIndex(0) name (Greeter.constructor) +1 >Emitted(16, 9) Source(14, 14) + SourceIndex(0) name (Greeter.constructor) +2 >Emitted(16, 22) Source(14, 22) + SourceIndex(0) name (Greeter.constructor) +3 >Emitted(16, 25) Source(14, 14) + SourceIndex(0) name (Greeter.constructor) +4 >Emitted(16, 33) Source(14, 22) + SourceIndex(0) name (Greeter.constructor) +5 >Emitted(16, 34) Source(14, 30) + SourceIndex(0) name (Greeter.constructor) --- >>> } 1 >^^^^ @@ -127,8 +125,8 @@ sourceFile:sourceMapValidationDecorators.ts > ...b: string[]) { > 2 > } -1 >Emitted(19, 5) Source(19, 5) + SourceIndex(0) name (Greeter.constructor) -2 >Emitted(19, 6) Source(19, 6) + SourceIndex(0) name (Greeter.constructor) +1 >Emitted(17, 5) Source(19, 5) + SourceIndex(0) name (Greeter.constructor) +2 >Emitted(17, 6) Source(19, 6) + SourceIndex(0) name (Greeter.constructor) --- >>> Greeter.prototype.greet = function () { 1->^^^^ @@ -142,9 +140,9 @@ sourceFile:sourceMapValidationDecorators.ts > 2 > greet 3 > -1->Emitted(20, 5) Source(23, 5) + SourceIndex(0) name (Greeter) -2 >Emitted(20, 28) Source(23, 10) + SourceIndex(0) name (Greeter) -3 >Emitted(20, 31) Source(21, 5) + SourceIndex(0) name (Greeter) +1->Emitted(18, 5) Source(23, 5) + SourceIndex(0) name (Greeter) +2 >Emitted(18, 28) Source(23, 10) + SourceIndex(0) name (Greeter) +3 >Emitted(18, 31) Source(21, 5) + SourceIndex(0) name (Greeter) --- >>> return "

" + this.greeting + "

"; 1->^^^^^^^^ @@ -172,17 +170,17 @@ sourceFile:sourceMapValidationDecorators.ts 9 > + 10> "" 11> ; -1->Emitted(21, 9) Source(24, 9) + SourceIndex(0) name (Greeter.greet) -2 >Emitted(21, 15) Source(24, 15) + SourceIndex(0) name (Greeter.greet) -3 >Emitted(21, 16) Source(24, 16) + SourceIndex(0) name (Greeter.greet) -4 >Emitted(21, 22) Source(24, 22) + SourceIndex(0) name (Greeter.greet) -5 >Emitted(21, 25) Source(24, 25) + SourceIndex(0) name (Greeter.greet) -6 >Emitted(21, 29) Source(24, 29) + SourceIndex(0) name (Greeter.greet) -7 >Emitted(21, 30) Source(24, 30) + SourceIndex(0) name (Greeter.greet) -8 >Emitted(21, 38) Source(24, 38) + SourceIndex(0) name (Greeter.greet) -9 >Emitted(21, 41) Source(24, 41) + SourceIndex(0) name (Greeter.greet) -10>Emitted(21, 48) Source(24, 48) + SourceIndex(0) name (Greeter.greet) -11>Emitted(21, 49) Source(24, 49) + SourceIndex(0) name (Greeter.greet) +1->Emitted(19, 9) Source(24, 9) + SourceIndex(0) name (Greeter.greet) +2 >Emitted(19, 15) Source(24, 15) + SourceIndex(0) name (Greeter.greet) +3 >Emitted(19, 16) Source(24, 16) + SourceIndex(0) name (Greeter.greet) +4 >Emitted(19, 22) Source(24, 22) + SourceIndex(0) name (Greeter.greet) +5 >Emitted(19, 25) Source(24, 25) + SourceIndex(0) name (Greeter.greet) +6 >Emitted(19, 29) Source(24, 29) + SourceIndex(0) name (Greeter.greet) +7 >Emitted(19, 30) Source(24, 30) + SourceIndex(0) name (Greeter.greet) +8 >Emitted(19, 38) Source(24, 38) + SourceIndex(0) name (Greeter.greet) +9 >Emitted(19, 41) Source(24, 41) + SourceIndex(0) name (Greeter.greet) +10>Emitted(19, 48) Source(24, 48) + SourceIndex(0) name (Greeter.greet) +11>Emitted(19, 49) Source(24, 49) + SourceIndex(0) name (Greeter.greet) --- >>> }; 1 >^^^^ @@ -191,8 +189,8 @@ sourceFile:sourceMapValidationDecorators.ts 1 > > 2 > } -1 >Emitted(22, 5) Source(25, 5) + SourceIndex(0) name (Greeter.greet) -2 >Emitted(22, 6) Source(25, 6) + SourceIndex(0) name (Greeter.greet) +1 >Emitted(20, 5) Source(25, 5) + SourceIndex(0) name (Greeter.greet) +2 >Emitted(20, 6) Source(25, 6) + SourceIndex(0) name (Greeter.greet) --- >>> Greeter.prototype.fn = function (x) { 1->^^^^ @@ -218,11 +216,11 @@ sourceFile:sourceMapValidationDecorators.ts > @ParameterDecorator2(70) > 5 > x: number -1->Emitted(23, 5) Source(35, 13) + SourceIndex(0) name (Greeter) -2 >Emitted(23, 25) Source(35, 15) + SourceIndex(0) name (Greeter) -3 >Emitted(23, 28) Source(35, 5) + SourceIndex(0) name (Greeter) -4 >Emitted(23, 38) Source(38, 7) + SourceIndex(0) name (Greeter) -5 >Emitted(23, 39) Source(38, 16) + SourceIndex(0) name (Greeter) +1->Emitted(21, 5) Source(35, 13) + SourceIndex(0) name (Greeter) +2 >Emitted(21, 25) Source(35, 15) + SourceIndex(0) name (Greeter) +3 >Emitted(21, 28) Source(35, 5) + SourceIndex(0) name (Greeter) +4 >Emitted(21, 38) Source(38, 7) + SourceIndex(0) name (Greeter) +5 >Emitted(21, 39) Source(38, 16) + SourceIndex(0) name (Greeter) --- >>> return this.greeting; 1 >^^^^^^^^ @@ -240,13 +238,13 @@ sourceFile:sourceMapValidationDecorators.ts 5 > . 6 > greeting 7 > ; -1 >Emitted(24, 9) Source(39, 9) + SourceIndex(0) name (Greeter.fn) -2 >Emitted(24, 15) Source(39, 15) + SourceIndex(0) name (Greeter.fn) -3 >Emitted(24, 16) Source(39, 16) + SourceIndex(0) name (Greeter.fn) -4 >Emitted(24, 20) Source(39, 20) + SourceIndex(0) name (Greeter.fn) -5 >Emitted(24, 21) Source(39, 21) + SourceIndex(0) name (Greeter.fn) -6 >Emitted(24, 29) Source(39, 29) + SourceIndex(0) name (Greeter.fn) -7 >Emitted(24, 30) Source(39, 30) + SourceIndex(0) name (Greeter.fn) +1 >Emitted(22, 9) Source(39, 9) + SourceIndex(0) name (Greeter.fn) +2 >Emitted(22, 15) Source(39, 15) + SourceIndex(0) name (Greeter.fn) +3 >Emitted(22, 16) Source(39, 16) + SourceIndex(0) name (Greeter.fn) +4 >Emitted(22, 20) Source(39, 20) + SourceIndex(0) name (Greeter.fn) +5 >Emitted(22, 21) Source(39, 21) + SourceIndex(0) name (Greeter.fn) +6 >Emitted(22, 29) Source(39, 29) + SourceIndex(0) name (Greeter.fn) +7 >Emitted(22, 30) Source(39, 30) + SourceIndex(0) name (Greeter.fn) --- >>> }; 1 >^^^^ @@ -255,8 +253,8 @@ sourceFile:sourceMapValidationDecorators.ts 1 > > 2 > } -1 >Emitted(25, 5) Source(40, 5) + SourceIndex(0) name (Greeter.fn) -2 >Emitted(25, 6) Source(40, 6) + SourceIndex(0) name (Greeter.fn) +1 >Emitted(23, 5) Source(40, 5) + SourceIndex(0) name (Greeter.fn) +2 >Emitted(23, 6) Source(40, 6) + SourceIndex(0) name (Greeter.fn) --- >>> Object.defineProperty(Greeter.prototype, "greetings", { 1->^^^^ @@ -269,15 +267,15 @@ sourceFile:sourceMapValidationDecorators.ts > @PropertyDecorator2(80) > get 3 > greetings -1->Emitted(26, 5) Source(42, 5) + SourceIndex(0) name (Greeter) -2 >Emitted(26, 27) Source(44, 9) + SourceIndex(0) name (Greeter) -3 >Emitted(26, 57) Source(44, 18) + SourceIndex(0) name (Greeter) +1->Emitted(24, 5) Source(42, 5) + SourceIndex(0) name (Greeter) +2 >Emitted(24, 27) Source(44, 9) + SourceIndex(0) name (Greeter) +3 >Emitted(24, 57) Source(44, 18) + SourceIndex(0) name (Greeter) --- >>> get: function () { 1 >^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(27, 14) Source(42, 5) + SourceIndex(0) name (Greeter) +1 >Emitted(25, 14) Source(42, 5) + SourceIndex(0) name (Greeter) --- >>> return this.greeting; 1->^^^^^^^^^^^^ @@ -297,13 +295,13 @@ sourceFile:sourceMapValidationDecorators.ts 5 > . 6 > greeting 7 > ; -1->Emitted(28, 13) Source(45, 9) + SourceIndex(0) name (Greeter.greetings) -2 >Emitted(28, 19) Source(45, 15) + SourceIndex(0) name (Greeter.greetings) -3 >Emitted(28, 20) Source(45, 16) + SourceIndex(0) name (Greeter.greetings) -4 >Emitted(28, 24) Source(45, 20) + SourceIndex(0) name (Greeter.greetings) -5 >Emitted(28, 25) Source(45, 21) + SourceIndex(0) name (Greeter.greetings) -6 >Emitted(28, 33) Source(45, 29) + SourceIndex(0) name (Greeter.greetings) -7 >Emitted(28, 34) Source(45, 30) + SourceIndex(0) name (Greeter.greetings) +1->Emitted(26, 13) Source(45, 9) + SourceIndex(0) name (Greeter.greetings) +2 >Emitted(26, 19) Source(45, 15) + SourceIndex(0) name (Greeter.greetings) +3 >Emitted(26, 20) Source(45, 16) + SourceIndex(0) name (Greeter.greetings) +4 >Emitted(26, 24) Source(45, 20) + SourceIndex(0) name (Greeter.greetings) +5 >Emitted(26, 25) Source(45, 21) + SourceIndex(0) name (Greeter.greetings) +6 >Emitted(26, 33) Source(45, 29) + SourceIndex(0) name (Greeter.greetings) +7 >Emitted(26, 34) Source(45, 30) + SourceIndex(0) name (Greeter.greetings) --- >>> }, 1 >^^^^^^^^ @@ -312,8 +310,8 @@ sourceFile:sourceMapValidationDecorators.ts 1 > > 2 > } -1 >Emitted(29, 9) Source(46, 5) + SourceIndex(0) name (Greeter.greetings) -2 >Emitted(29, 10) Source(46, 6) + SourceIndex(0) name (Greeter.greetings) +1 >Emitted(27, 9) Source(46, 5) + SourceIndex(0) name (Greeter.greetings) +2 >Emitted(27, 10) Source(46, 6) + SourceIndex(0) name (Greeter.greetings) --- >>> set: function (greetings) { 1->^^^^^^^^^^^^^ @@ -328,9 +326,9 @@ sourceFile:sourceMapValidationDecorators.ts > @ParameterDecorator2(90) > 3 > greetings: string -1->Emitted(30, 14) Source(48, 5) + SourceIndex(0) name (Greeter) -2 >Emitted(30, 24) Source(51, 7) + SourceIndex(0) name (Greeter) -3 >Emitted(30, 33) Source(51, 24) + SourceIndex(0) name (Greeter) +1->Emitted(28, 14) Source(48, 5) + SourceIndex(0) name (Greeter) +2 >Emitted(28, 24) Source(51, 7) + SourceIndex(0) name (Greeter) +3 >Emitted(28, 33) Source(51, 24) + SourceIndex(0) name (Greeter) --- >>> this.greeting = greetings; 1->^^^^^^^^^^^^ @@ -348,13 +346,13 @@ sourceFile:sourceMapValidationDecorators.ts 5 > = 6 > greetings 7 > ; -1->Emitted(31, 13) Source(52, 9) + SourceIndex(0) name (Greeter.greetings) -2 >Emitted(31, 17) Source(52, 13) + SourceIndex(0) name (Greeter.greetings) -3 >Emitted(31, 18) Source(52, 14) + SourceIndex(0) name (Greeter.greetings) -4 >Emitted(31, 26) Source(52, 22) + SourceIndex(0) name (Greeter.greetings) -5 >Emitted(31, 29) Source(52, 25) + SourceIndex(0) name (Greeter.greetings) -6 >Emitted(31, 38) Source(52, 34) + SourceIndex(0) name (Greeter.greetings) -7 >Emitted(31, 39) Source(52, 35) + SourceIndex(0) name (Greeter.greetings) +1->Emitted(29, 13) Source(52, 9) + SourceIndex(0) name (Greeter.greetings) +2 >Emitted(29, 17) Source(52, 13) + SourceIndex(0) name (Greeter.greetings) +3 >Emitted(29, 18) Source(52, 14) + SourceIndex(0) name (Greeter.greetings) +4 >Emitted(29, 26) Source(52, 22) + SourceIndex(0) name (Greeter.greetings) +5 >Emitted(29, 29) Source(52, 25) + SourceIndex(0) name (Greeter.greetings) +6 >Emitted(29, 38) Source(52, 34) + SourceIndex(0) name (Greeter.greetings) +7 >Emitted(29, 39) Source(52, 35) + SourceIndex(0) name (Greeter.greetings) --- >>> }, 1 >^^^^^^^^ @@ -363,8 +361,8 @@ sourceFile:sourceMapValidationDecorators.ts 1 > > 2 > } -1 >Emitted(32, 9) Source(53, 5) + SourceIndex(0) name (Greeter.greetings) -2 >Emitted(32, 10) Source(53, 6) + SourceIndex(0) name (Greeter.greetings) +1 >Emitted(30, 9) Source(53, 5) + SourceIndex(0) name (Greeter.greetings) +2 >Emitted(30, 10) Source(53, 6) + SourceIndex(0) name (Greeter.greetings) --- >>> enumerable: true, >>> configurable: true @@ -372,7 +370,7 @@ sourceFile:sourceMapValidationDecorators.ts 1->^^^^^^^ 2 > ^^^^^^^^^^^^^^-> 1-> -1->Emitted(35, 8) Source(46, 6) + SourceIndex(0) name (Greeter) +1->Emitted(33, 8) Source(46, 6) + SourceIndex(0) name (Greeter) --- >>> Greeter.x1 = 10; 1->^^^^ @@ -380,87 +378,22 @@ sourceFile:sourceMapValidationDecorators.ts 3 > ^^^ 4 > ^^ 5 > ^ -6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> 2 > x1 3 > : number = 4 > 10 5 > ; -1->Emitted(36, 5) Source(33, 20) + SourceIndex(0) name (Greeter) -2 >Emitted(36, 15) Source(33, 22) + SourceIndex(0) name (Greeter) -3 >Emitted(36, 18) Source(33, 33) + SourceIndex(0) name (Greeter) -4 >Emitted(36, 20) Source(33, 35) + SourceIndex(0) name (Greeter) -5 >Emitted(36, 21) Source(33, 36) + SourceIndex(0) name (Greeter) ---- ->>> Object.defineProperty(Greeter.prototype, "greet", -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ -1-> -2 > @PropertyDecorator1 - > @PropertyDecorator2(40) - > -3 > greet -1->Emitted(37, 5) Source(21, 5) + SourceIndex(0) name (Greeter) -2 >Emitted(37, 27) Source(23, 5) + SourceIndex(0) name (Greeter) -3 >Emitted(37, 53) Source(23, 10) + SourceIndex(0) name (Greeter) ---- ->>> __decorate([ ->>> PropertyDecorator1, -1 >^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^^^^^-> -1 > -2 > PropertyDecorator1 -1 >Emitted(39, 13) Source(21, 6) + SourceIndex(0) name (Greeter) -2 >Emitted(39, 31) Source(21, 24) + SourceIndex(0) name (Greeter) ---- ->>> PropertyDecorator2(40) -1->^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > @ -2 > PropertyDecorator2 -3 > ( -4 > 40 -5 > ) -1->Emitted(40, 13) Source(22, 6) + SourceIndex(0) name (Greeter) -2 >Emitted(40, 31) Source(22, 24) + SourceIndex(0) name (Greeter) -3 >Emitted(40, 32) Source(22, 25) + SourceIndex(0) name (Greeter) -4 >Emitted(40, 34) Source(22, 27) + SourceIndex(0) name (Greeter) -5 >Emitted(40, 35) Source(22, 28) + SourceIndex(0) name (Greeter) ---- ->>> ], Greeter.prototype, "greet", Object.getOwnPropertyDescriptor(Greeter.prototype, "greet"))); -1->^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ -5 > ^^^^ -1-> - > -2 > greet -3 > -4 > greet -5 > () { - > return "

" + this.greeting + "

"; - > } -1->Emitted(41, 12) Source(23, 5) + SourceIndex(0) name (Greeter) -2 >Emitted(41, 38) Source(23, 10) + SourceIndex(0) name (Greeter) -3 >Emitted(41, 72) Source(23, 5) + SourceIndex(0) name (Greeter) -4 >Emitted(41, 98) Source(23, 10) + SourceIndex(0) name (Greeter) -5 >Emitted(41, 102) Source(25, 6) + SourceIndex(0) name (Greeter) +1->Emitted(34, 5) Source(33, 20) + SourceIndex(0) name (Greeter) +2 >Emitted(34, 15) Source(33, 22) + SourceIndex(0) name (Greeter) +3 >Emitted(34, 18) Source(33, 33) + SourceIndex(0) name (Greeter) +4 >Emitted(34, 20) Source(33, 35) + SourceIndex(0) name (Greeter) +5 >Emitted(34, 21) Source(33, 36) + SourceIndex(0) name (Greeter) --- >>> __decorate([ 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > - > -1 >Emitted(42, 5) Source(27, 5) + SourceIndex(0) name (Greeter) +1 > +1 >Emitted(35, 5) Source(21, 5) + SourceIndex(0) name (Greeter) --- >>> PropertyDecorator1, 1->^^^^^^^^ @@ -468,8 +401,58 @@ sourceFile:sourceMapValidationDecorators.ts 3 > ^^^^^-> 1->@ 2 > PropertyDecorator1 -1->Emitted(43, 9) Source(27, 6) + SourceIndex(0) name (Greeter) -2 >Emitted(43, 27) Source(27, 24) + SourceIndex(0) name (Greeter) +1->Emitted(36, 9) Source(21, 6) + SourceIndex(0) name (Greeter) +2 >Emitted(36, 27) Source(21, 24) + SourceIndex(0) name (Greeter) +--- +>>> PropertyDecorator2(40) +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^^^^^-> +1-> + > @ +2 > PropertyDecorator2 +3 > ( +4 > 40 +5 > ) +1->Emitted(37, 9) Source(22, 6) + SourceIndex(0) name (Greeter) +2 >Emitted(37, 27) Source(22, 24) + SourceIndex(0) name (Greeter) +3 >Emitted(37, 28) Source(22, 25) + SourceIndex(0) name (Greeter) +4 >Emitted(37, 30) Source(22, 27) + SourceIndex(0) name (Greeter) +5 >Emitted(37, 31) Source(22, 28) + SourceIndex(0) name (Greeter) +--- +>>> ], Greeter.prototype, "greet", null); +1->^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^ +1-> + > +2 > greet +3 > () { + > return "

" + this.greeting + "

"; + > } +1->Emitted(38, 8) Source(23, 5) + SourceIndex(0) name (Greeter) +2 >Emitted(38, 34) Source(23, 10) + SourceIndex(0) name (Greeter) +3 >Emitted(38, 42) Source(25, 6) + SourceIndex(0) name (Greeter) +--- +>>> __decorate([ +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > + > +1 >Emitted(39, 5) Source(27, 5) + SourceIndex(0) name (Greeter) +--- +>>> PropertyDecorator1, +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^^^^^-> +1->@ +2 > PropertyDecorator1 +1->Emitted(40, 9) Source(27, 6) + SourceIndex(0) name (Greeter) +2 >Emitted(40, 27) Source(27, 24) + SourceIndex(0) name (Greeter) --- >>> PropertyDecorator2(50) 1->^^^^^^^^ @@ -477,163 +460,141 @@ sourceFile:sourceMapValidationDecorators.ts 3 > ^ 4 > ^^ 5 > ^ -6 > ^^-> +6 > ^^^^^^^^^^-> 1-> > @ 2 > PropertyDecorator2 3 > ( 4 > 50 5 > ) -1->Emitted(44, 9) Source(28, 6) + SourceIndex(0) name (Greeter) -2 >Emitted(44, 27) Source(28, 24) + SourceIndex(0) name (Greeter) -3 >Emitted(44, 28) Source(28, 25) + SourceIndex(0) name (Greeter) -4 >Emitted(44, 30) Source(28, 27) + SourceIndex(0) name (Greeter) -5 >Emitted(44, 31) Source(28, 28) + SourceIndex(0) name (Greeter) +1->Emitted(41, 9) Source(28, 6) + SourceIndex(0) name (Greeter) +2 >Emitted(41, 27) Source(28, 24) + SourceIndex(0) name (Greeter) +3 >Emitted(41, 28) Source(28, 25) + SourceIndex(0) name (Greeter) +4 >Emitted(41, 30) Source(28, 27) + SourceIndex(0) name (Greeter) +5 >Emitted(41, 31) Source(28, 28) + SourceIndex(0) name (Greeter) --- ->>> ], Greeter.prototype, "x"); +>>> ], Greeter.prototype, "x", void 0); 1->^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^ -4 > ^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^ 1-> > private 2 > x 3 > : string; -1->Emitted(45, 8) Source(29, 13) + SourceIndex(0) name (Greeter) -2 >Emitted(45, 30) Source(29, 14) + SourceIndex(0) name (Greeter) -3 >Emitted(45, 32) Source(29, 23) + SourceIndex(0) name (Greeter) +1->Emitted(42, 8) Source(29, 13) + SourceIndex(0) name (Greeter) +2 >Emitted(42, 30) Source(29, 14) + SourceIndex(0) name (Greeter) +3 >Emitted(42, 40) Source(29, 23) + SourceIndex(0) name (Greeter) --- ->>> Object.defineProperty(Greeter.prototype, "fn", -1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^ -1-> +>>> __decorate([ +1 >^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > > > @PropertyDecorator1 > @PropertyDecorator2(60) > private static x1: number = 10; > > -2 > private -3 > fn -1->Emitted(46, 5) Source(35, 5) + SourceIndex(0) name (Greeter) -2 >Emitted(46, 27) Source(35, 13) + SourceIndex(0) name (Greeter) -3 >Emitted(46, 50) Source(35, 15) + SourceIndex(0) name (Greeter) +1 >Emitted(43, 5) Source(35, 5) + SourceIndex(0) name (Greeter) --- ->>> __decorate([ ->>> __param(0, ParameterDecorator1), -1 >^^^^^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^-> -1 >( +>>> __param(0, ParameterDecorator1), +1->^^^^^^^^ +2 > ^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^ +4 > ^ +5 > ^^^^^-> +1->private fn( > -2 > @ -3 > ParameterDecorator1 -4 > -1 >Emitted(48, 13) Source(36, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(48, 24) Source(36, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(48, 43) Source(36, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(48, 44) Source(36, 27) + SourceIndex(0) name (Greeter) +2 > @ +3 > ParameterDecorator1 +4 > +1->Emitted(44, 9) Source(36, 7) + SourceIndex(0) name (Greeter) +2 >Emitted(44, 20) Source(36, 8) + SourceIndex(0) name (Greeter) +3 >Emitted(44, 39) Source(36, 27) + SourceIndex(0) name (Greeter) +4 >Emitted(44, 40) Source(36, 27) + SourceIndex(0) name (Greeter) --- ->>> __param(0, ParameterDecorator2(70)) -1->^^^^^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^ -6 > ^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +>>> __param(0, ParameterDecorator2(70)) +1->^^^^^^^^ +2 > ^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^ +4 > ^ +5 > ^^ +6 > ^ +7 > ^ 1-> > -2 > @ -3 > ParameterDecorator2 -4 > ( -5 > 70 -6 > ) -7 > -1->Emitted(49, 13) Source(37, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(49, 24) Source(37, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(49, 43) Source(37, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(49, 44) Source(37, 28) + SourceIndex(0) name (Greeter) -5 >Emitted(49, 46) Source(37, 30) + SourceIndex(0) name (Greeter) -6 >Emitted(49, 47) Source(37, 31) + SourceIndex(0) name (Greeter) -7 >Emitted(49, 48) Source(37, 31) + SourceIndex(0) name (Greeter) +2 > @ +3 > ParameterDecorator2 +4 > ( +5 > 70 +6 > ) +7 > +1->Emitted(45, 9) Source(37, 7) + SourceIndex(0) name (Greeter) +2 >Emitted(45, 20) Source(37, 8) + SourceIndex(0) name (Greeter) +3 >Emitted(45, 39) Source(37, 27) + SourceIndex(0) name (Greeter) +4 >Emitted(45, 40) Source(37, 28) + SourceIndex(0) name (Greeter) +5 >Emitted(45, 42) Source(37, 30) + SourceIndex(0) name (Greeter) +6 >Emitted(45, 43) Source(37, 31) + SourceIndex(0) name (Greeter) +7 >Emitted(45, 44) Source(37, 31) + SourceIndex(0) name (Greeter) --- ->>> ], Greeter.prototype, "fn", Object.getOwnPropertyDescriptor(Greeter.prototype, "fn"))); -1->^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^ -5 > ^^^^ -1-> -2 > fn -3 > -4 > fn -5 > ( - > @ParameterDecorator1 - > @ParameterDecorator2(70) - > x: number) { - > return this.greeting; - > } -1->Emitted(50, 12) Source(35, 13) + SourceIndex(0) name (Greeter) -2 >Emitted(50, 35) Source(35, 15) + SourceIndex(0) name (Greeter) -3 >Emitted(50, 69) Source(35, 13) + SourceIndex(0) name (Greeter) -4 >Emitted(50, 92) Source(35, 15) + SourceIndex(0) name (Greeter) -5 >Emitted(50, 96) Source(40, 6) + SourceIndex(0) name (Greeter) +>>> ], Greeter.prototype, "fn", null); +1 >^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^ +1 > +2 > fn +3 > ( + > @ParameterDecorator1 + > @ParameterDecorator2(70) + > x: number) { + > return this.greeting; + > } +1 >Emitted(46, 8) Source(35, 13) + SourceIndex(0) name (Greeter) +2 >Emitted(46, 31) Source(35, 15) + SourceIndex(0) name (Greeter) +3 >Emitted(46, 39) Source(40, 6) + SourceIndex(0) name (Greeter) --- ->>> Object.defineProperty(Greeter.prototype, "greetings", +>>> __decorate([ 1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > > -2 > @PropertyDecorator1 - > @PropertyDecorator2(80) - > get -3 > greetings -1 >Emitted(51, 5) Source(42, 5) + SourceIndex(0) name (Greeter) -2 >Emitted(51, 27) Source(44, 9) + SourceIndex(0) name (Greeter) -3 >Emitted(51, 57) Source(44, 18) + SourceIndex(0) name (Greeter) +1 >Emitted(47, 5) Source(42, 5) + SourceIndex(0) name (Greeter) --- ->>> __decorate([ ->>> PropertyDecorator1, -1 >^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^-> -1 > -2 > PropertyDecorator1 -1 >Emitted(53, 13) Source(42, 6) + SourceIndex(0) name (Greeter) -2 >Emitted(53, 31) Source(42, 24) + SourceIndex(0) name (Greeter) +>>> PropertyDecorator1, +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^-> +1->@ +2 > PropertyDecorator1 +1->Emitted(48, 9) Source(42, 6) + SourceIndex(0) name (Greeter) +2 >Emitted(48, 27) Source(42, 24) + SourceIndex(0) name (Greeter) --- ->>> PropertyDecorator2(80), -1->^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^-> +>>> PropertyDecorator2(80), +1->^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^^^^-> 1-> > @ -2 > PropertyDecorator2 -3 > ( -4 > 80 -5 > ) -1->Emitted(54, 13) Source(43, 6) + SourceIndex(0) name (Greeter) -2 >Emitted(54, 31) Source(43, 24) + SourceIndex(0) name (Greeter) -3 >Emitted(54, 32) Source(43, 25) + SourceIndex(0) name (Greeter) -4 >Emitted(54, 34) Source(43, 27) + SourceIndex(0) name (Greeter) -5 >Emitted(54, 35) Source(43, 28) + SourceIndex(0) name (Greeter) +2 > PropertyDecorator2 +3 > ( +4 > 80 +5 > ) +1->Emitted(49, 9) Source(43, 6) + SourceIndex(0) name (Greeter) +2 >Emitted(49, 27) Source(43, 24) + SourceIndex(0) name (Greeter) +3 >Emitted(49, 28) Source(43, 25) + SourceIndex(0) name (Greeter) +4 >Emitted(49, 30) Source(43, 27) + SourceIndex(0) name (Greeter) +5 >Emitted(49, 31) Source(43, 28) + SourceIndex(0) name (Greeter) --- ->>> __param(0, ParameterDecorator1), -1->^^^^^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^-> +>>> __param(0, ParameterDecorator1), +1->^^^^^^^^ +2 > ^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^ +4 > ^ +5 > ^^^^^-> 1-> > get greetings() { > return this.greeting; @@ -641,63 +602,57 @@ sourceFile:sourceMapValidationDecorators.ts > > set greetings( > -2 > @ -3 > ParameterDecorator1 -4 > -1->Emitted(55, 13) Source(49, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(55, 24) Source(49, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(55, 43) Source(49, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(55, 44) Source(49, 27) + SourceIndex(0) name (Greeter) +2 > @ +3 > ParameterDecorator1 +4 > +1->Emitted(50, 9) Source(49, 7) + SourceIndex(0) name (Greeter) +2 >Emitted(50, 20) Source(49, 8) + SourceIndex(0) name (Greeter) +3 >Emitted(50, 39) Source(49, 27) + SourceIndex(0) name (Greeter) +4 >Emitted(50, 40) Source(49, 27) + SourceIndex(0) name (Greeter) --- ->>> __param(0, ParameterDecorator2(90)) -1->^^^^^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^ -6 > ^ -7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +>>> __param(0, ParameterDecorator2(90)) +1->^^^^^^^^ +2 > ^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^^^^ +4 > ^ +5 > ^^ +6 > ^ +7 > ^ +8 > ^^^-> 1-> > -2 > @ -3 > ParameterDecorator2 -4 > ( -5 > 90 -6 > ) -7 > -1->Emitted(56, 13) Source(50, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(56, 24) Source(50, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(56, 43) Source(50, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(56, 44) Source(50, 28) + SourceIndex(0) name (Greeter) -5 >Emitted(56, 46) Source(50, 30) + SourceIndex(0) name (Greeter) -6 >Emitted(56, 47) Source(50, 31) + SourceIndex(0) name (Greeter) -7 >Emitted(56, 48) Source(50, 31) + SourceIndex(0) name (Greeter) +2 > @ +3 > ParameterDecorator2 +4 > ( +5 > 90 +6 > ) +7 > +1->Emitted(51, 9) Source(50, 7) + SourceIndex(0) name (Greeter) +2 >Emitted(51, 20) Source(50, 8) + SourceIndex(0) name (Greeter) +3 >Emitted(51, 39) Source(50, 27) + SourceIndex(0) name (Greeter) +4 >Emitted(51, 40) Source(50, 28) + SourceIndex(0) name (Greeter) +5 >Emitted(51, 42) Source(50, 30) + SourceIndex(0) name (Greeter) +6 >Emitted(51, 43) Source(50, 31) + SourceIndex(0) name (Greeter) +7 >Emitted(51, 44) Source(50, 31) + SourceIndex(0) name (Greeter) --- ->>> ], Greeter.prototype, "greetings", Object.getOwnPropertyDescriptor(Greeter.prototype, "greetings"))); -1->^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -5 > ^^^^ +>>> ], Greeter.prototype, "greetings", null); +1->^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^ 1-> -2 > greetings -3 > -4 > greetings -5 > () { - > return this.greeting; - > } -1->Emitted(57, 12) Source(44, 9) + SourceIndex(0) name (Greeter) -2 >Emitted(57, 42) Source(44, 18) + SourceIndex(0) name (Greeter) -3 >Emitted(57, 76) Source(44, 9) + SourceIndex(0) name (Greeter) -4 >Emitted(57, 106) Source(44, 18) + SourceIndex(0) name (Greeter) -5 >Emitted(57, 110) Source(46, 6) + SourceIndex(0) name (Greeter) +2 > greetings +3 > () { + > return this.greeting; + > } +1->Emitted(52, 8) Source(44, 9) + SourceIndex(0) name (Greeter) +2 >Emitted(52, 38) Source(44, 18) + SourceIndex(0) name (Greeter) +3 >Emitted(52, 46) Source(46, 6) + SourceIndex(0) name (Greeter) --- >>> __decorate([ 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(58, 5) Source(31, 5) + SourceIndex(0) name (Greeter) +1 >Emitted(53, 5) Source(31, 5) + SourceIndex(0) name (Greeter) --- >>> PropertyDecorator1, 1->^^^^^^^^ @@ -705,8 +660,8 @@ sourceFile:sourceMapValidationDecorators.ts 3 > ^^^^^-> 1->@ 2 > PropertyDecorator1 -1->Emitted(59, 9) Source(31, 6) + SourceIndex(0) name (Greeter) -2 >Emitted(59, 27) Source(31, 24) + SourceIndex(0) name (Greeter) +1->Emitted(54, 9) Source(31, 6) + SourceIndex(0) name (Greeter) +2 >Emitted(54, 27) Source(31, 24) + SourceIndex(0) name (Greeter) --- >>> PropertyDecorator2(60) 1->^^^^^^^^ @@ -714,36 +669,36 @@ sourceFile:sourceMapValidationDecorators.ts 3 > ^ 4 > ^^ 5 > ^ +6 > ^-> 1-> > @ 2 > PropertyDecorator2 3 > ( 4 > 60 5 > ) -1->Emitted(60, 9) Source(32, 6) + SourceIndex(0) name (Greeter) -2 >Emitted(60, 27) Source(32, 24) + SourceIndex(0) name (Greeter) -3 >Emitted(60, 28) Source(32, 25) + SourceIndex(0) name (Greeter) -4 >Emitted(60, 30) Source(32, 27) + SourceIndex(0) name (Greeter) -5 >Emitted(60, 31) Source(32, 28) + SourceIndex(0) name (Greeter) +1->Emitted(55, 9) Source(32, 6) + SourceIndex(0) name (Greeter) +2 >Emitted(55, 27) Source(32, 24) + SourceIndex(0) name (Greeter) +3 >Emitted(55, 28) Source(32, 25) + SourceIndex(0) name (Greeter) +4 >Emitted(55, 30) Source(32, 27) + SourceIndex(0) name (Greeter) +5 >Emitted(55, 31) Source(32, 28) + SourceIndex(0) name (Greeter) --- ->>> ], Greeter, "x1"); -1 >^^^^^^^ +>>> ], Greeter, "x1", void 0); +1->^^^^^^^ 2 > ^^^^^^^^^^^^^ -3 > ^^ -4 > ^^^^^-> -1 > +3 > ^^^^^^^^^^ +1-> > private static 2 > x1 3 > : number = 10; -1 >Emitted(61, 8) Source(33, 20) + SourceIndex(0) name (Greeter) -2 >Emitted(61, 21) Source(33, 22) + SourceIndex(0) name (Greeter) -3 >Emitted(61, 23) Source(33, 36) + SourceIndex(0) name (Greeter) +1->Emitted(56, 8) Source(33, 20) + SourceIndex(0) name (Greeter) +2 >Emitted(56, 21) Source(33, 22) + SourceIndex(0) name (Greeter) +3 >Emitted(56, 31) Source(33, 36) + SourceIndex(0) name (Greeter) --- >>> Greeter = __decorate([ -1->^^^^ +1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> -1-> -1->Emitted(62, 5) Source(8, 1) + SourceIndex(0) name (Greeter) +1 > +1 >Emitted(57, 5) Source(8, 1) + SourceIndex(0) name (Greeter) --- >>> ClassDecorator1, 1->^^^^^^^^ @@ -751,8 +706,8 @@ sourceFile:sourceMapValidationDecorators.ts 3 > ^^^^^^-> 1->@ 2 > ClassDecorator1 -1->Emitted(63, 9) Source(8, 2) + SourceIndex(0) name (Greeter) -2 >Emitted(63, 24) Source(8, 17) + SourceIndex(0) name (Greeter) +1->Emitted(58, 9) Source(8, 2) + SourceIndex(0) name (Greeter) +2 >Emitted(58, 24) Source(8, 17) + SourceIndex(0) name (Greeter) --- >>> ClassDecorator2(10), 1->^^^^^^^^ @@ -767,11 +722,11 @@ sourceFile:sourceMapValidationDecorators.ts 3 > ( 4 > 10 5 > ) -1->Emitted(64, 9) Source(9, 2) + SourceIndex(0) name (Greeter) -2 >Emitted(64, 24) Source(9, 17) + SourceIndex(0) name (Greeter) -3 >Emitted(64, 25) Source(9, 18) + SourceIndex(0) name (Greeter) -4 >Emitted(64, 27) Source(9, 20) + SourceIndex(0) name (Greeter) -5 >Emitted(64, 28) Source(9, 21) + SourceIndex(0) name (Greeter) +1->Emitted(59, 9) Source(9, 2) + SourceIndex(0) name (Greeter) +2 >Emitted(59, 24) Source(9, 17) + SourceIndex(0) name (Greeter) +3 >Emitted(59, 25) Source(9, 18) + SourceIndex(0) name (Greeter) +4 >Emitted(59, 27) Source(9, 20) + SourceIndex(0) name (Greeter) +5 >Emitted(59, 28) Source(9, 21) + SourceIndex(0) name (Greeter) --- >>> __param(0, ParameterDecorator1), 1->^^^^^^^^ @@ -786,10 +741,10 @@ sourceFile:sourceMapValidationDecorators.ts 2 > @ 3 > ParameterDecorator1 4 > -1->Emitted(65, 9) Source(12, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(65, 20) Source(12, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(65, 39) Source(12, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(65, 40) Source(12, 27) + SourceIndex(0) name (Greeter) +1->Emitted(60, 9) Source(12, 7) + SourceIndex(0) name (Greeter) +2 >Emitted(60, 20) Source(12, 8) + SourceIndex(0) name (Greeter) +3 >Emitted(60, 39) Source(12, 27) + SourceIndex(0) name (Greeter) +4 >Emitted(60, 40) Source(12, 27) + SourceIndex(0) name (Greeter) --- >>> __param(0, ParameterDecorator2(20)), 1->^^^^^^^^ @@ -807,13 +762,13 @@ sourceFile:sourceMapValidationDecorators.ts 5 > 20 6 > ) 7 > -1->Emitted(66, 9) Source(13, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(66, 20) Source(13, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(66, 39) Source(13, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(66, 40) Source(13, 28) + SourceIndex(0) name (Greeter) -5 >Emitted(66, 42) Source(13, 30) + SourceIndex(0) name (Greeter) -6 >Emitted(66, 43) Source(13, 31) + SourceIndex(0) name (Greeter) -7 >Emitted(66, 44) Source(13, 31) + SourceIndex(0) name (Greeter) +1->Emitted(61, 9) Source(13, 7) + SourceIndex(0) name (Greeter) +2 >Emitted(61, 20) Source(13, 8) + SourceIndex(0) name (Greeter) +3 >Emitted(61, 39) Source(13, 27) + SourceIndex(0) name (Greeter) +4 >Emitted(61, 40) Source(13, 28) + SourceIndex(0) name (Greeter) +5 >Emitted(61, 42) Source(13, 30) + SourceIndex(0) name (Greeter) +6 >Emitted(61, 43) Source(13, 31) + SourceIndex(0) name (Greeter) +7 >Emitted(61, 44) Source(13, 31) + SourceIndex(0) name (Greeter) --- >>> __param(1, ParameterDecorator1), 1 >^^^^^^^^ @@ -828,10 +783,10 @@ sourceFile:sourceMapValidationDecorators.ts 2 > @ 3 > ParameterDecorator1 4 > -1 >Emitted(67, 9) Source(16, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(67, 20) Source(16, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(67, 39) Source(16, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(67, 40) Source(16, 27) + SourceIndex(0) name (Greeter) +1 >Emitted(62, 9) Source(16, 7) + SourceIndex(0) name (Greeter) +2 >Emitted(62, 20) Source(16, 8) + SourceIndex(0) name (Greeter) +3 >Emitted(62, 39) Source(16, 27) + SourceIndex(0) name (Greeter) +4 >Emitted(62, 40) Source(16, 27) + SourceIndex(0) name (Greeter) --- >>> __param(1, ParameterDecorator2(30)) 1->^^^^^^^^ @@ -849,13 +804,13 @@ sourceFile:sourceMapValidationDecorators.ts 5 > 30 6 > ) 7 > -1->Emitted(68, 9) Source(17, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(68, 20) Source(17, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(68, 39) Source(17, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(68, 40) Source(17, 28) + SourceIndex(0) name (Greeter) -5 >Emitted(68, 42) Source(17, 30) + SourceIndex(0) name (Greeter) -6 >Emitted(68, 43) Source(17, 31) + SourceIndex(0) name (Greeter) -7 >Emitted(68, 44) Source(17, 31) + SourceIndex(0) name (Greeter) +1->Emitted(63, 9) Source(17, 7) + SourceIndex(0) name (Greeter) +2 >Emitted(63, 20) Source(17, 8) + SourceIndex(0) name (Greeter) +3 >Emitted(63, 39) Source(17, 27) + SourceIndex(0) name (Greeter) +4 >Emitted(63, 40) Source(17, 28) + SourceIndex(0) name (Greeter) +5 >Emitted(63, 42) Source(17, 30) + SourceIndex(0) name (Greeter) +6 >Emitted(63, 43) Source(17, 31) + SourceIndex(0) name (Greeter) +7 >Emitted(63, 44) Source(17, 31) + SourceIndex(0) name (Greeter) --- >>> ], Greeter); 1 >^^^^^^^^^^^^^^^^ @@ -898,15 +853,15 @@ sourceFile:sourceMapValidationDecorators.ts > this.greeting = greetings; > } >} -1 >Emitted(69, 17) Source(54, 2) + SourceIndex(0) name (Greeter) +1 >Emitted(64, 17) Source(54, 2) + SourceIndex(0) name (Greeter) --- >>> return Greeter; 1->^^^^ 2 > ^^^^^^^^^^^^^^ 1-> 2 > } -1->Emitted(70, 5) Source(54, 1) + SourceIndex(0) name (Greeter) -2 >Emitted(70, 19) Source(54, 2) + SourceIndex(0) name (Greeter) +1->Emitted(65, 5) Source(54, 1) + SourceIndex(0) name (Greeter) +2 >Emitted(65, 19) Source(54, 2) + SourceIndex(0) name (Greeter) --- >>>})(); 1 > @@ -964,9 +919,9 @@ sourceFile:sourceMapValidationDecorators.ts > this.greeting = greetings; > } > } -1 >Emitted(71, 1) Source(54, 1) + SourceIndex(0) name (Greeter) -2 >Emitted(71, 2) Source(54, 2) + SourceIndex(0) name (Greeter) -3 >Emitted(71, 2) Source(8, 1) + SourceIndex(0) -4 >Emitted(71, 6) Source(54, 2) + SourceIndex(0) +1 >Emitted(66, 1) Source(54, 1) + SourceIndex(0) name (Greeter) +2 >Emitted(66, 2) Source(54, 2) + SourceIndex(0) name (Greeter) +3 >Emitted(66, 2) Source(8, 1) + SourceIndex(0) +4 >Emitted(66, 6) Source(54, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationDecorators.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDecorators.types b/tests/baselines/reference/sourceMapValidationDecorators.types index 9e83bb03509..2fc05972307 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.types +++ b/tests/baselines/reference/sourceMapValidationDecorators.types @@ -93,7 +93,7 @@ class Greeter { >"

" + this.greeting : string >"

" : string >this.greeting : string ->this : Greeter +>this : this >greeting : string >"

" : string } @@ -137,7 +137,7 @@ class Greeter { return this.greeting; >this.greeting : string ->this : Greeter +>this : this >greeting : string } @@ -154,7 +154,7 @@ class Greeter { return this.greeting; >this.greeting : string ->this : Greeter +>this : this >greeting : string } @@ -175,7 +175,7 @@ class Greeter { this.greeting = greetings; >this.greeting = greetings : string >this.greeting : string ->this : Greeter +>this : this >greeting : string >greetings : string } diff --git a/tests/baselines/reference/staticInstanceResolution.symbols b/tests/baselines/reference/staticInstanceResolution.symbols index 69d1894679f..1b58989347d 100644 --- a/tests/baselines/reference/staticInstanceResolution.symbols +++ b/tests/baselines/reference/staticInstanceResolution.symbols @@ -14,17 +14,17 @@ class Comment { >Comment : Symbol(Comment, Decl(staticInstanceResolution.ts, 0, 0)) { comments[0].getDocCommentText(); ->comments[0].getDocCommentText : Symbol(getDocCommentText, Decl(staticInstanceResolution.ts, 0, 15)) +>comments[0].getDocCommentText : Symbol(Comment.getDocCommentText, Decl(staticInstanceResolution.ts, 0, 15)) >comments : Symbol(comments, Decl(staticInstanceResolution.ts, 7, 29)) ->getDocCommentText : Symbol(getDocCommentText, Decl(staticInstanceResolution.ts, 0, 15)) +>getDocCommentText : Symbol(Comment.getDocCommentText, Decl(staticInstanceResolution.ts, 0, 15)) var c: Comment; >c : Symbol(c, Decl(staticInstanceResolution.ts, 10, 11)) >Comment : Symbol(Comment, Decl(staticInstanceResolution.ts, 0, 0)) c.getDocCommentText(); ->c.getDocCommentText : Symbol(getDocCommentText, Decl(staticInstanceResolution.ts, 0, 15)) +>c.getDocCommentText : Symbol(Comment.getDocCommentText, Decl(staticInstanceResolution.ts, 0, 15)) >c : Symbol(c, Decl(staticInstanceResolution.ts, 10, 11)) ->getDocCommentText : Symbol(getDocCommentText, Decl(staticInstanceResolution.ts, 0, 15)) +>getDocCommentText : Symbol(Comment.getDocCommentText, Decl(staticInstanceResolution.ts, 0, 15)) } } diff --git a/tests/baselines/reference/staticInstanceResolution3.js b/tests/baselines/reference/staticInstanceResolution3.js index 92a4e6522c7..0a41cd77909 100644 --- a/tests/baselines/reference/staticInstanceResolution3.js +++ b/tests/baselines/reference/staticInstanceResolution3.js @@ -9,7 +9,7 @@ export class Promise { //// [staticInstanceResolution3_1.ts] /// -import WinJS = require('staticInstanceResolution3_0'); +import WinJS = require('./staticInstanceResolution3_0'); WinJS.Promise.timeout(10); //// [staticInstanceResolution3_0.js] @@ -24,5 +24,5 @@ var Promise = (function () { exports.Promise = Promise; //// [staticInstanceResolution3_1.js] /// -var WinJS = require('staticInstanceResolution3_0'); +var WinJS = require('./staticInstanceResolution3_0'); WinJS.Promise.timeout(10); diff --git a/tests/baselines/reference/staticInstanceResolution3.symbols b/tests/baselines/reference/staticInstanceResolution3.symbols index 8d4fecbaab2..f1afeecd34e 100644 --- a/tests/baselines/reference/staticInstanceResolution3.symbols +++ b/tests/baselines/reference/staticInstanceResolution3.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/staticInstanceResolution3_1.ts === /// -import WinJS = require('staticInstanceResolution3_0'); +import WinJS = require('./staticInstanceResolution3_0'); >WinJS : Symbol(WinJS, Decl(staticInstanceResolution3_1.ts, 0, 0)) WinJS.Promise.timeout(10); diff --git a/tests/baselines/reference/staticInstanceResolution3.types b/tests/baselines/reference/staticInstanceResolution3.types index ef5c1cc5166..fe50c659f6d 100644 --- a/tests/baselines/reference/staticInstanceResolution3.types +++ b/tests/baselines/reference/staticInstanceResolution3.types @@ -1,6 +1,6 @@ === tests/cases/compiler/staticInstanceResolution3_1.ts === /// -import WinJS = require('staticInstanceResolution3_0'); +import WinJS = require('./staticInstanceResolution3_0'); >WinJS : typeof WinJS WinJS.Promise.timeout(10); diff --git a/tests/baselines/reference/stringIncludes.symbols b/tests/baselines/reference/stringIncludes.symbols index d0fa641c857..1348b62e566 100644 --- a/tests/baselines/reference/stringIncludes.symbols +++ b/tests/baselines/reference/stringIncludes.symbols @@ -5,11 +5,11 @@ var includes: boolean; includes = "abcde".includes("cd"); >includes : Symbol(includes, Decl(stringIncludes.ts, 1, 3)) ->"abcde".includes : Symbol(String.includes, Decl(lib.d.ts, 1569, 37)) ->includes : Symbol(String.includes, Decl(lib.d.ts, 1569, 37)) +>"abcde".includes : Symbol(String.includes, Decl(lib.d.ts, 4249, 37)) +>includes : Symbol(String.includes, Decl(lib.d.ts, 4249, 37)) includes = "abcde".includes("cd", 2); >includes : Symbol(includes, Decl(stringIncludes.ts, 1, 3)) ->"abcde".includes : Symbol(String.includes, Decl(lib.d.ts, 1569, 37)) ->includes : Symbol(String.includes, Decl(lib.d.ts, 1569, 37)) +>"abcde".includes : Symbol(String.includes, Decl(lib.d.ts, 4249, 37)) +>includes : Symbol(String.includes, Decl(lib.d.ts, 4249, 37)) diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt index e6cba35be25..1f4ee3debed 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.errors.txt @@ -22,9 +22,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(71,5): error TS2411: Property 'foo' of type '() => string' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2411: Property '"4.0"' of type 'number' is not assignable to string index type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(74,5): error TS2411: Property 'f' of type 'MyString' is not assignable to string index type 'string'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString | (() => string); 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. Index signatures are incompatible. - Type 'string | number | (() => void) | MyString | (() => string)' is not assignable to type 'string'. + Type 'string | number | (() => void) | MyString' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -160,9 +160,9 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // error var b: { [x: string]: string; } = { ~ -!!! error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString | (() => string); 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. +!!! error TS2322: Type '{ [x: string]: string | number | (() => void) | MyString; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: MyString; X: string; foo(): string; }' is not assignable to type '{ [x: string]: string; }'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'string | number | (() => void) | MyString | (() => string)' is not assignable to type 'string'. +!!! error TS2322: Type 'string | number | (() => void) | MyString' is not assignable to type 'string'. !!! error TS2322: Type 'number' is not assignable to type 'string'. a: '', b: 1, diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt index 13d5adcf1f5..faef7905453 100644 --- a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations2.errors.txt @@ -4,11 +4,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(24,5): error TS2411: Property 'd' of type 'string' is not assignable to string index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(31,5): error TS2411: Property 'c' of type 'number' is not assignable to string index type 'A'. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(32,5): error TS2411: Property 'd' of type 'string' is not assignable to string index type 'A'. -tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(36,5): error TS2322: Type '{ [x: string]: typeof A | typeof B; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts(36,5): error TS2322: Type '{ [x: string]: typeof A; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. Index signatures are incompatible. - Type 'typeof A | typeof B' is not assignable to type 'A'. - Type 'typeof A' is not assignable to type 'A'. - Property 'foo' is missing in type 'typeof A'. + Type 'typeof A' is not assignable to type 'A'. + Property 'foo' is missing in type 'typeof A'. ==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerConstrainsPropertyDeclarations2.ts (7 errors) ==== @@ -61,11 +60,10 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/stringIndexerCon // error var b: { [x: string]: A } = { ~ -!!! error TS2322: Type '{ [x: string]: typeof A | typeof B; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. +!!! error TS2322: Type '{ [x: string]: typeof A; a: typeof A; b: typeof B; }' is not assignable to type '{ [x: string]: A; }'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'typeof A | typeof B' is not assignable to type 'A'. -!!! error TS2322: Type 'typeof A' is not assignable to type 'A'. -!!! error TS2322: Property 'foo' is missing in type 'typeof A'. +!!! error TS2322: Type 'typeof A' is not assignable to type 'A'. +!!! error TS2322: Property 'foo' is missing in type 'typeof A'. a: A, b: B } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.types b/tests/baselines/reference/subtypingWithCallSignatures2.types index e43382766ac..b72993e7bea 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.types +++ b/tests/baselines/reference/subtypingWithCallSignatures2.types @@ -331,14 +331,14 @@ var r1 = foo1(r1arg1); // any, return types are not subtype of first overload >r1arg1 : (x: T) => T[] var r1a = [r1arg2, r1arg1]; // generic signature, subtype in both directions ->r1a : (((x: number) => number[]) | ((x: T) => T[]))[] ->[r1arg2, r1arg1] : (((x: number) => number[]) | ((x: T) => T[]))[] +>r1a : ((x: T) => T[])[] +>[r1arg2, r1arg1] : ((x: T) => T[])[] >r1arg2 : (x: number) => number[] >r1arg1 : (x: T) => T[] var r1b = [r1arg1, r1arg2]; // generic signature, subtype in both directions ->r1b : (((x: T) => T[]) | ((x: number) => number[]))[] ->[r1arg1, r1arg2] : (((x: T) => T[]) | ((x: number) => number[]))[] +>r1b : ((x: T) => T[])[] +>[r1arg1, r1arg2] : ((x: T) => T[])[] >r1arg1 : (x: T) => T[] >r1arg2 : (x: number) => number[] @@ -365,14 +365,14 @@ var r2 = foo2(r2arg1); >r2arg1 : (x: T) => string[] var r2a = [r2arg1, r2arg2]; ->r2a : (((x: T) => string[]) | ((x: number) => string[]))[] ->[r2arg1, r2arg2] : (((x: T) => string[]) | ((x: number) => string[]))[] +>r2a : ((x: T) => string[])[] +>[r2arg1, r2arg2] : ((x: T) => string[])[] >r2arg1 : (x: T) => string[] >r2arg2 : (x: number) => string[] var r2b = [r2arg2, r2arg1]; ->r2b : (((x: number) => string[]) | ((x: T) => string[]))[] ->[r2arg2, r2arg1] : (((x: number) => string[]) | ((x: T) => string[]))[] +>r2b : ((x: number) => string[])[] +>[r2arg2, r2arg1] : ((x: number) => string[])[] >r2arg2 : (x: number) => string[] >r2arg1 : (x: T) => string[] @@ -396,14 +396,14 @@ var r3 = foo3(r3arg1); >r3arg1 : (x: T) => T var r3a = [r3arg1, r3arg2]; ->r3a : (((x: T) => T) | ((x: number) => void))[] ->[r3arg1, r3arg2] : (((x: T) => T) | ((x: number) => void))[] +>r3a : ((x: T) => T)[] +>[r3arg1, r3arg2] : ((x: T) => T)[] >r3arg1 : (x: T) => T >r3arg2 : (x: number) => void var r3b = [r3arg2, r3arg1]; ->r3b : (((x: number) => void) | ((x: T) => T))[] ->[r3arg2, r3arg1] : (((x: number) => void) | ((x: T) => T))[] +>r3b : ((x: number) => void)[] +>[r3arg2, r3arg1] : ((x: number) => void)[] >r3arg2 : (x: number) => void >r3arg1 : (x: T) => T @@ -432,14 +432,14 @@ var r4 = foo4(r4arg1); // any >r4arg1 : (x: T, y: U) => T var r4a = [r4arg1, r4arg2]; ->r4a : (((x: T, y: U) => T) | ((x: string, y: number) => string))[] ->[r4arg1, r4arg2] : (((x: T, y: U) => T) | ((x: string, y: number) => string))[] +>r4a : ((x: T, y: U) => T)[] +>[r4arg1, r4arg2] : ((x: T, y: U) => T)[] >r4arg1 : (x: T, y: U) => T >r4arg2 : (x: string, y: number) => string var r4b = [r4arg2, r4arg1]; ->r4b : (((x: string, y: number) => string) | ((x: T, y: U) => T))[] ->[r4arg2, r4arg1] : (((x: string, y: number) => string) | ((x: T, y: U) => T))[] +>r4b : ((x: T, y: U) => T)[] +>[r4arg2, r4arg1] : ((x: T, y: U) => T)[] >r4arg2 : (x: string, y: number) => string >r4arg1 : (x: T, y: U) => T @@ -470,14 +470,14 @@ var r5 = foo5(r5arg1); // any >r5arg1 : (x: (arg: T) => U) => T var r5a = [r5arg1, r5arg2]; ->r5a : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] ->[r5arg1, r5arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] +>r5a : ((x: (arg: T) => U) => T)[] +>[r5arg1, r5arg2] : ((x: (arg: T) => U) => T)[] >r5arg1 : (x: (arg: T) => U) => T >r5arg2 : (x: (arg: string) => number) => string var r5b = [r5arg2, r5arg1]; ->r5b : (((x: (arg: string) => number) => string) | ((x: (arg: T) => U) => T))[] ->[r5arg2, r5arg1] : (((x: (arg: string) => number) => string) | ((x: (arg: T) => U) => T))[] +>r5b : ((x: (arg: T) => U) => T)[] +>[r5arg2, r5arg1] : ((x: (arg: T) => U) => T)[] >r5arg2 : (x: (arg: string) => number) => string >r5arg1 : (x: (arg: T) => U) => T @@ -514,14 +514,14 @@ var r6 = foo6(r6arg1); // any >r6arg1 : (x: (arg: T) => U) => T var r6a = [r6arg1, r6arg2]; ->r6a : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] ->[r6arg1, r6arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] +>r6a : ((x: (arg: T) => U) => T)[] +>[r6arg1, r6arg2] : ((x: (arg: T) => U) => T)[] >r6arg1 : (x: (arg: T) => U) => T >r6arg2 : (x: (arg: Base) => Derived) => Base var r6b = [r6arg2, r6arg1]; ->r6b : (((x: (arg: Base) => Derived) => Base) | ((x: (arg: T) => U) => T))[] ->[r6arg2, r6arg1] : (((x: (arg: Base) => Derived) => Base) | ((x: (arg: T) => U) => T))[] +>r6b : ((x: (arg: T) => U) => T)[] +>[r6arg2, r6arg1] : ((x: (arg: T) => U) => T)[] >r6arg2 : (x: (arg: Base) => Derived) => Base >r6arg1 : (x: (arg: T) => U) => T @@ -564,14 +564,14 @@ var r7 = foo7(r7arg1); // any >r7arg1 : (x: (arg: T) => U) => (r: T) => U var r7a = [r7arg1, r7arg2]; ->r7a : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] ->[r7arg1, r7arg2] : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] +>r7a : ((x: (arg: T) => U) => (r: T) => U)[] +>[r7arg1, r7arg2] : ((x: (arg: T) => U) => (r: T) => U)[] >r7arg1 : (x: (arg: T) => U) => (r: T) => U >r7arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived var r7b = [r7arg2, r7arg1]; ->r7b : (((x: (arg: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U) => (r: T) => U))[] ->[r7arg2, r7arg1] : (((x: (arg: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U) => (r: T) => U))[] +>r7b : ((x: (arg: T) => U) => (r: T) => U)[] +>[r7arg2, r7arg1] : ((x: (arg: T) => U) => (r: T) => U)[] >r7arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived >r7arg1 : (x: (arg: T) => U) => (r: T) => U @@ -622,14 +622,14 @@ var r8 = foo8(r8arg1); // any >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U var r8a = [r8arg1, r8arg2]; ->r8a : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] ->[r8arg1, r8arg2] : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>r8a : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] +>[r8arg1, r8arg2] : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U >r8arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived var r8b = [r8arg2, r8arg1]; ->r8b : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U))[] ->[r8arg2, r8arg1] : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U))[] +>r8b : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] +>[r8arg2, r8arg1] : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] >r8arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U @@ -681,14 +681,14 @@ var r9 = foo9(r9arg1); // any >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U var r9a = [r9arg1, r9arg2]; ->r9a : (((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] ->[r9arg1, r9arg2] : (((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>r9a : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] +>[r9arg1, r9arg2] : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U >r9arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived var r9b = [r9arg2, r9arg1]; ->r9b : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U))[] ->[r9arg2, r9arg1] : (((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived) | ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U))[] +>r9b : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] +>[r9arg2, r9arg1] : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] >r9arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U @@ -719,14 +719,14 @@ var r10 = foo10(r10arg1); // any >r10arg1 : (...x: T[]) => T var r10a = [r10arg1, r10arg2]; ->r10a : (((...x: T[]) => T) | ((...x: Derived[]) => Derived))[] ->[r10arg1, r10arg2] : (((...x: T[]) => T) | ((...x: Derived[]) => Derived))[] +>r10a : ((...x: T[]) => T)[] +>[r10arg1, r10arg2] : ((...x: T[]) => T)[] >r10arg1 : (...x: T[]) => T >r10arg2 : (...x: Derived[]) => Derived var r10b = [r10arg2, r10arg1]; ->r10b : (((...x: Derived[]) => Derived) | ((...x: T[]) => T))[] ->[r10arg2, r10arg1] : (((...x: Derived[]) => Derived) | ((...x: T[]) => T))[] +>r10b : ((...x: T[]) => T)[] +>[r10arg2, r10arg1] : ((...x: T[]) => T)[] >r10arg2 : (...x: Derived[]) => Derived >r10arg1 : (...x: T[]) => T @@ -760,14 +760,14 @@ var r11 = foo11(r11arg1); // any >r11arg1 : (x: T, y: T) => T var r11a = [r11arg1, r11arg2]; ->r11a : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] ->[r11arg1, r11arg2] : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>r11a : ((x: T, y: T) => T)[] +>[r11arg1, r11arg2] : ((x: T, y: T) => T)[] >r11arg1 : (x: T, y: T) => T >r11arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base var r11b = [r11arg2, r11arg1]; ->r11b : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] ->[r11arg2, r11arg1] : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] +>r11b : ((x: T, y: T) => T)[] +>[r11arg2, r11arg1] : ((x: T, y: T) => T)[] >r11arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r11arg1 : (x: T, y: T) => T @@ -808,14 +808,14 @@ var r12 = foo12(r12arg1); // any >r12arg1 : (x: Base[], y: T) => Derived[] var r12a = [r12arg1, r12arg2]; ->r12a : (((x: Base[], y: T) => Derived[]) | ((x: Base[], y: Derived2[]) => Derived[]))[] ->[r12arg1, r12arg2] : (((x: Base[], y: T) => Derived[]) | ((x: Base[], y: Derived2[]) => Derived[]))[] +>r12a : ((x: Base[], y: T) => Derived[])[] +>[r12arg1, r12arg2] : ((x: Base[], y: T) => Derived[])[] >r12arg1 : (x: Base[], y: T) => Derived[] >r12arg2 : (x: Base[], y: Derived2[]) => Derived[] var r12b = [r12arg2, r12arg1]; ->r12b : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: T) => Derived[]))[] ->[r12arg2, r12arg1] : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: T) => Derived[]))[] +>r12b : ((x: Base[], y: Derived2[]) => Derived[])[] +>[r12arg2, r12arg1] : ((x: Base[], y: Derived2[]) => Derived[])[] >r12arg2 : (x: Base[], y: Derived2[]) => Derived[] >r12arg1 : (x: Base[], y: T) => Derived[] @@ -853,14 +853,14 @@ var r13 = foo13(r13arg1); // any >r13arg1 : (x: Base[], y: T) => T var r13a = [r13arg1, r13arg2]; ->r13a : (((x: Base[], y: T) => T) | ((x: Base[], y: Derived[]) => Derived[]))[] ->[r13arg1, r13arg2] : (((x: Base[], y: T) => T) | ((x: Base[], y: Derived[]) => Derived[]))[] +>r13a : ((x: Base[], y: T) => T)[] +>[r13arg1, r13arg2] : ((x: Base[], y: T) => T)[] >r13arg1 : (x: Base[], y: T) => T >r13arg2 : (x: Base[], y: Derived[]) => Derived[] var r13b = [r13arg2, r13arg1]; ->r13b : (((x: Base[], y: Derived[]) => Derived[]) | ((x: Base[], y: T) => T))[] ->[r13arg2, r13arg1] : (((x: Base[], y: Derived[]) => Derived[]) | ((x: Base[], y: T) => T))[] +>r13b : ((x: Base[], y: T) => T)[] +>[r13arg2, r13arg1] : ((x: Base[], y: T) => T)[] >r13arg2 : (x: Base[], y: Derived[]) => Derived[] >r13arg1 : (x: Base[], y: T) => T @@ -894,14 +894,14 @@ var r14 = foo14(r14arg1); // any >r14arg1 : (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] ->[r14arg1, r14arg2] : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] +>r14a : ((x: { a: T; b: T; }) => T)[] +>[r14arg1, r14arg2] : ((x: { a: T; b: T; }) => T)[] >r14arg1 : (x: { a: T; b: T; }) => T >r14arg2 : (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : (((x: { a: string; b: number; }) => Object) | ((x: { a: T; b: T; }) => T))[] ->[r14arg2, r14arg1] : (((x: { a: string; b: number; }) => Object) | ((x: { a: T; b: T; }) => T))[] +>r14b : ((x: { a: T; b: T; }) => T)[] +>[r14arg2, r14arg1] : ((x: { a: T; b: T; }) => T)[] >r14arg2 : (x: { a: string; b: number; }) => Object >r14arg1 : (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithCallSignatures3.types b/tests/baselines/reference/subtypingWithCallSignatures3.types index 0d3a84ac99c..2d4c6e9fda5 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures3.types +++ b/tests/baselines/reference/subtypingWithCallSignatures3.types @@ -219,8 +219,8 @@ module Errors { >null : null var r1a = [(x: number) => [''], (x: T) => null]; ->r1a : (((x: number) => string[]) | ((x: T) => U[]))[] ->[(x: number) => [''], (x: T) => null] : (((x: number) => string[]) | ((x: T) => U[]))[] +>r1a : ((x: T) => U[])[] +>[(x: number) => [''], (x: T) => null] : ((x: T) => U[])[] >(x: number) => [''] : (x: number) => string[] >x : number >[''] : string[] @@ -235,8 +235,8 @@ module Errors { >null : null var r1b = [(x: T) => null, (x: number) => ['']]; ->r1b : (((x: T) => U[]) | ((x: number) => string[]))[] ->[(x: T) => null, (x: number) => ['']] : (((x: T) => U[]) | ((x: number) => string[]))[] +>r1b : ((x: T) => U[])[] +>[(x: T) => null, (x: number) => ['']] : ((x: T) => U[])[] >(x: T) => null : (x: T) => U[] >T : T >U : U @@ -291,14 +291,14 @@ module Errors { >r2arg : (x: (arg: T) => U) => (r: T) => V var r2a = [r2arg2, r2arg]; ->r2a : (((x: (arg: Base) => Derived) => (r: Base) => Derived2) | ((x: (arg: T) => U) => (r: T) => V))[] ->[r2arg2, r2arg] : (((x: (arg: Base) => Derived) => (r: Base) => Derived2) | ((x: (arg: T) => U) => (r: T) => V))[] +>r2a : ((x: (arg: T) => U) => (r: T) => V)[] +>[r2arg2, r2arg] : ((x: (arg: T) => U) => (r: T) => V)[] >r2arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 >r2arg : (x: (arg: T) => U) => (r: T) => V var r2b = [r2arg, r2arg2]; ->r2b : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] ->[r2arg, r2arg2] : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] +>r2b : ((x: (arg: T) => U) => (r: T) => V)[] +>[r2arg, r2arg2] : ((x: (arg: T) => U) => (r: T) => V)[] >r2arg : (x: (arg: T) => U) => (r: T) => V >r2arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 @@ -387,14 +387,14 @@ module Errors { >r4arg : (...x: T[]) => T var r4a = [r4arg2, r4arg]; ->r4a : (((...x: Base[]) => Base) | ((...x: T[]) => T))[] ->[r4arg2, r4arg] : (((...x: Base[]) => Base) | ((...x: T[]) => T))[] +>r4a : ((...x: T[]) => T)[] +>[r4arg2, r4arg] : ((...x: T[]) => T)[] >r4arg2 : (...x: Base[]) => Base >r4arg : (...x: T[]) => T var r4b = [r4arg, r4arg2]; ->r4b : (((...x: T[]) => T) | ((...x: Base[]) => Base))[] ->[r4arg, r4arg2] : (((...x: T[]) => T) | ((...x: Base[]) => Base))[] +>r4b : ((...x: T[]) => T)[] +>[r4arg, r4arg2] : ((...x: T[]) => T)[] >r4arg : (...x: T[]) => T >r4arg2 : (...x: Base[]) => Base @@ -430,14 +430,14 @@ module Errors { >r5arg : (x: T, y: T) => T var r5a = [r5arg2, r5arg]; ->r5a : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] ->[r5arg2, r5arg] : (((x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | ((x: T, y: T) => T))[] +>r5a : ((x: T, y: T) => T)[] +>[r5arg2, r5arg] : ((x: T, y: T) => T)[] >r5arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r5arg : (x: T, y: T) => T var r5b = [r5arg, r5arg2]; ->r5b : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] ->[r5arg, r5arg2] : (((x: T, y: T) => T) | ((x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>r5b : ((x: T, y: T) => T)[] +>[r5arg, r5arg2] : ((x: T, y: T) => T)[] >r5arg : (x: T, y: T) => T >r5arg2 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base @@ -478,14 +478,14 @@ module Errors { >r6arg : (x: Base[], y: Derived2[]) => Derived[] var r6a = [r6arg2, r6arg]; ->r6a : (((x: Base[], y: Base[]) => T) | ((x: Base[], y: Derived2[]) => Derived[]))[] ->[r6arg2, r6arg] : (((x: Base[], y: Base[]) => T) | ((x: Base[], y: Derived2[]) => Derived[]))[] +>r6a : ((x: Base[], y: Base[]) => T)[] +>[r6arg2, r6arg] : ((x: Base[], y: Base[]) => T)[] >r6arg2 : (x: Base[], y: Base[]) => T >r6arg : (x: Base[], y: Derived2[]) => Derived[] var r6b = [r6arg, r6arg2]; ->r6b : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: Base[]) => T))[] ->[r6arg, r6arg2] : (((x: Base[], y: Derived2[]) => Derived[]) | ((x: Base[], y: Base[]) => T))[] +>r6b : ((x: Base[], y: Base[]) => T)[] +>[r6arg, r6arg2] : ((x: Base[], y: Base[]) => T)[] >r6arg : (x: Base[], y: Derived2[]) => Derived[] >r6arg2 : (x: Base[], y: Base[]) => T @@ -517,14 +517,14 @@ module Errors { >r7arg : (x: { a: T; b: T; }) => T var r7a = [r7arg2, r7arg]; ->r7a : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => T))[] ->[r7arg2, r7arg] : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => T))[] +>r7a : ((x: { a: T; b: T; }) => T)[] +>[r7arg2, r7arg] : ((x: { a: T; b: T; }) => T)[] >r7arg2 : (x: { a: string; b: number; }) => number >r7arg : (x: { a: T; b: T; }) => T var r7b = [r7arg, r7arg2]; ->r7b : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => number))[] ->[r7arg, r7arg2] : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => number))[] +>r7b : ((x: { a: T; b: T; }) => T)[] +>[r7arg, r7arg2] : ((x: { a: T; b: T; }) => T)[] >r7arg : (x: { a: T; b: T; }) => T >r7arg2 : (x: { a: string; b: number; }) => number @@ -547,14 +547,14 @@ module Errors { >r7arg3 : (x: { a: T; b: T; }) => number var r7d = [r7arg2, r7arg3]; ->r7d : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => number))[] ->[r7arg2, r7arg3] : (((x: { a: string; b: number; }) => number) | ((x: { a: T; b: T; }) => number))[] +>r7d : ((x: { a: string; b: number; }) => number)[] +>[r7arg2, r7arg3] : ((x: { a: string; b: number; }) => number)[] >r7arg2 : (x: { a: string; b: number; }) => number >r7arg3 : (x: { a: T; b: T; }) => number var r7e = [r7arg3, r7arg2]; ->r7e : (((x: { a: T; b: T; }) => number) | ((x: { a: string; b: number; }) => number))[] ->[r7arg3, r7arg2] : (((x: { a: T; b: T; }) => number) | ((x: { a: string; b: number; }) => number))[] +>r7e : ((x: { a: T; b: T; }) => number)[] +>[r7arg3, r7arg2] : ((x: { a: T; b: T; }) => number)[] >r7arg3 : (x: { a: T; b: T; }) => number >r7arg2 : (x: { a: string; b: number; }) => number diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.types b/tests/baselines/reference/subtypingWithCallSignatures4.types index 830f065f556..f490f787878 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.types +++ b/tests/baselines/reference/subtypingWithCallSignatures4.types @@ -317,14 +317,14 @@ var r3 = foo3(r3arg); >r3arg : (x: T) => T var r3a = [r3arg, r3arg2]; ->r3a : (((x: T) => T) | ((x: T) => void))[] ->[r3arg, r3arg2] : (((x: T) => T) | ((x: T) => void))[] +>r3a : ((x: T) => T)[] +>[r3arg, r3arg2] : ((x: T) => T)[] >r3arg : (x: T) => T >r3arg2 : (x: T) => void var r3b = [r3arg2, r3arg]; ->r3b : (((x: T) => void) | ((x: T) => T))[] ->[r3arg2, r3arg] : (((x: T) => void) | ((x: T) => T))[] +>r3b : ((x: T) => void)[] +>[r3arg2, r3arg] : ((x: T) => void)[] >r3arg2 : (x: T) => void >r3arg : (x: T) => T @@ -447,14 +447,14 @@ var r6 = foo6(r6arg); >r6arg : (x: (arg: T) => U) => T var r6a = [r6arg, r6arg2]; ->r6a : (((x: (arg: T) => U) => T) | ((x: (arg: T) => Derived) => T))[] ->[r6arg, r6arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: T) => Derived) => T))[] +>r6a : ((x: (arg: T) => U) => T)[] +>[r6arg, r6arg2] : ((x: (arg: T) => U) => T)[] >r6arg : (x: (arg: T) => U) => T >r6arg2 : (x: (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : (((x: (arg: T) => Derived) => T) | ((x: (arg: T) => U) => T))[] ->[r6arg2, r6arg] : (((x: (arg: T) => Derived) => T) | ((x: (arg: T) => U) => T))[] +>r6b : ((x: (arg: T) => Derived) => T)[] +>[r6arg2, r6arg] : ((x: (arg: T) => Derived) => T)[] >r6arg2 : (x: (arg: T) => Derived) => T >r6arg : (x: (arg: T) => U) => T @@ -498,14 +498,14 @@ var r11 = foo11(r11arg); >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : (((x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] ->[r11arg, r11arg2] : (((x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] +>r11a : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>[r11arg, r11arg2] : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : (((x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] ->[r11arg2, r11arg] : (((x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] +>r11b : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg2, r11arg] : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base @@ -543,14 +543,14 @@ var r15 = foo15(r15arg); >r15arg : (x: { a: U; b: V; }) => U[] var r15a = [r15arg, r15arg2]; ->r15a : (((x: { a: U; b: V; }) => U[]) | ((x: { a: T; b: T; }) => T[]))[] ->[r15arg, r15arg2] : (((x: { a: U; b: V; }) => U[]) | ((x: { a: T; b: T; }) => T[]))[] +>r15a : ((x: { a: U; b: V; }) => U[])[] +>[r15arg, r15arg2] : ((x: { a: U; b: V; }) => U[])[] >r15arg : (x: { a: U; b: V; }) => U[] >r15arg2 : (x: { a: T; b: T; }) => T[] var r15b = [r15arg2, r15arg]; ->r15b : (((x: { a: T; b: T; }) => T[]) | ((x: { a: U; b: V; }) => U[]))[] ->[r15arg2, r15arg] : (((x: { a: T; b: T; }) => T[]) | ((x: { a: U; b: V; }) => U[]))[] +>r15b : ((x: { a: T; b: T; }) => T[])[] +>[r15arg2, r15arg] : ((x: { a: T; b: T; }) => T[])[] >r15arg2 : (x: { a: T; b: T; }) => T[] >r15arg : (x: { a: U; b: V; }) => U[] diff --git a/tests/baselines/reference/subtypingWithConstructSignatures2.types b/tests/baselines/reference/subtypingWithConstructSignatures2.types index f00ad0332ca..c66d6055558 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures2.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures2.types @@ -326,14 +326,14 @@ var r1 = foo1(r1arg1); // any, return types are not subtype of first overload >r1arg1 : new (x: T) => T[] var r1a = [r1arg2, r1arg1]; // generic signature, subtype in both directions ->r1a : ((new (x: number) => number[]) | (new (x: T) => T[]))[] ->[r1arg2, r1arg1] : ((new (x: number) => number[]) | (new (x: T) => T[]))[] +>r1a : (new (x: T) => T[])[] +>[r1arg2, r1arg1] : (new (x: T) => T[])[] >r1arg2 : new (x: number) => number[] >r1arg1 : new (x: T) => T[] var r1b = [r1arg1, r1arg2]; // generic signature, subtype in both directions ->r1b : ((new (x: T) => T[]) | (new (x: number) => number[]))[] ->[r1arg1, r1arg2] : ((new (x: T) => T[]) | (new (x: number) => number[]))[] +>r1b : (new (x: T) => T[])[] +>[r1arg1, r1arg2] : (new (x: T) => T[])[] >r1arg1 : new (x: T) => T[] >r1arg2 : new (x: number) => number[] @@ -354,14 +354,14 @@ var r2 = foo2(r2arg1); >r2arg1 : new (x: T) => string[] var r2a = [r2arg1, r2arg2]; ->r2a : ((new (x: T) => string[]) | (new (x: number) => string[]))[] ->[r2arg1, r2arg2] : ((new (x: T) => string[]) | (new (x: number) => string[]))[] +>r2a : (new (x: T) => string[])[] +>[r2arg1, r2arg2] : (new (x: T) => string[])[] >r2arg1 : new (x: T) => string[] >r2arg2 : new (x: number) => string[] var r2b = [r2arg2, r2arg1]; ->r2b : ((new (x: number) => string[]) | (new (x: T) => string[]))[] ->[r2arg2, r2arg1] : ((new (x: number) => string[]) | (new (x: T) => string[]))[] +>r2b : (new (x: number) => string[])[] +>[r2arg2, r2arg1] : (new (x: number) => string[])[] >r2arg2 : new (x: number) => string[] >r2arg1 : new (x: T) => string[] @@ -383,14 +383,14 @@ var r3 = foo3(r3arg1); >r3arg1 : new (x: T) => T var r3a = [r3arg1, r3arg2]; ->r3a : ((new (x: T) => T) | (new (x: number) => void))[] ->[r3arg1, r3arg2] : ((new (x: T) => T) | (new (x: number) => void))[] +>r3a : (new (x: T) => T)[] +>[r3arg1, r3arg2] : (new (x: T) => T)[] >r3arg1 : new (x: T) => T >r3arg2 : new (x: number) => void var r3b = [r3arg2, r3arg1]; ->r3b : ((new (x: number) => void) | (new (x: T) => T))[] ->[r3arg2, r3arg1] : ((new (x: number) => void) | (new (x: T) => T))[] +>r3b : (new (x: number) => void)[] +>[r3arg2, r3arg1] : (new (x: number) => void)[] >r3arg2 : new (x: number) => void >r3arg1 : new (x: T) => T @@ -416,14 +416,14 @@ var r4 = foo4(r4arg1); // any >r4arg1 : new (x: T, y: U) => T var r4a = [r4arg1, r4arg2]; ->r4a : ((new (x: T, y: U) => T) | (new (x: string, y: number) => string))[] ->[r4arg1, r4arg2] : ((new (x: T, y: U) => T) | (new (x: string, y: number) => string))[] +>r4a : (new (x: T, y: U) => T)[] +>[r4arg1, r4arg2] : (new (x: T, y: U) => T)[] >r4arg1 : new (x: T, y: U) => T >r4arg2 : new (x: string, y: number) => string var r4b = [r4arg2, r4arg1]; ->r4b : ((new (x: string, y: number) => string) | (new (x: T, y: U) => T))[] ->[r4arg2, r4arg1] : ((new (x: string, y: number) => string) | (new (x: T, y: U) => T))[] +>r4b : (new (x: T, y: U) => T)[] +>[r4arg2, r4arg1] : (new (x: T, y: U) => T)[] >r4arg2 : new (x: string, y: number) => string >r4arg1 : new (x: T, y: U) => T @@ -449,14 +449,14 @@ var r5 = foo5(r5arg1); // any >r5arg1 : new (x: new (arg: T) => U) => T var r5a = [r5arg1, r5arg2]; ->r5a : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: string) => number) => string))[] ->[r5arg1, r5arg2] : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: string) => number) => string))[] +>r5a : (new (x: new (arg: T) => U) => T)[] +>[r5arg1, r5arg2] : (new (x: new (arg: T) => U) => T)[] >r5arg1 : new (x: new (arg: T) => U) => T >r5arg2 : new (x: new (arg: string) => number) => string var r5b = [r5arg2, r5arg1]; ->r5b : ((new (x: new (arg: string) => number) => string) | (new (x: new (arg: T) => U) => T))[] ->[r5arg2, r5arg1] : ((new (x: new (arg: string) => number) => string) | (new (x: new (arg: T) => U) => T))[] +>r5b : (new (x: new (arg: T) => U) => T)[] +>[r5arg2, r5arg1] : (new (x: new (arg: T) => U) => T)[] >r5arg2 : new (x: new (arg: string) => number) => string >r5arg1 : new (x: new (arg: T) => U) => T @@ -487,14 +487,14 @@ var r6 = foo6(r6arg1); // any >r6arg1 : new (x: new (arg: T) => U) => T var r6a = [r6arg1, r6arg2]; ->r6a : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: Base) => Derived) => Base))[] ->[r6arg1, r6arg2] : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: Base) => Derived) => Base))[] +>r6a : (new (x: new (arg: T) => U) => T)[] +>[r6arg1, r6arg2] : (new (x: new (arg: T) => U) => T)[] >r6arg1 : new (x: new (arg: T) => U) => T >r6arg2 : new (x: new (arg: Base) => Derived) => Base var r6b = [r6arg2, r6arg1]; ->r6b : ((new (x: new (arg: Base) => Derived) => Base) | (new (x: new (arg: T) => U) => T))[] ->[r6arg2, r6arg1] : ((new (x: new (arg: Base) => Derived) => Base) | (new (x: new (arg: T) => U) => T))[] +>r6b : (new (x: new (arg: T) => U) => T)[] +>[r6arg2, r6arg1] : (new (x: new (arg: T) => U) => T)[] >r6arg2 : new (x: new (arg: Base) => Derived) => Base >r6arg1 : new (x: new (arg: T) => U) => T @@ -529,14 +529,14 @@ var r7 = foo7(r7arg1); // any >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U var r7a = [r7arg1, r7arg2]; ->r7a : ((new (x: new (arg: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived))[] ->[r7arg1, r7arg2] : ((new (x: new (arg: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived))[] +>r7a : (new (x: new (arg: T) => U) => new (r: T) => U)[] +>[r7arg1, r7arg2] : (new (x: new (arg: T) => U) => new (r: T) => U)[] >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U >r7arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived var r7b = [r7arg2, r7arg1]; ->r7b : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U) => new (r: T) => U))[] ->[r7arg2, r7arg1] : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U) => new (r: T) => U))[] +>r7b : (new (x: new (arg: T) => U) => new (r: T) => U)[] +>[r7arg2, r7arg1] : (new (x: new (arg: T) => U) => new (r: T) => U)[] >r7arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived >r7arg1 : new (x: new (arg: T) => U) => new (r: T) => U @@ -579,14 +579,14 @@ var r8 = foo8(r8arg1); // any >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U var r8a = [r8arg1, r8arg2]; ->r8a : ((new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] ->[r8arg1, r8arg2] : ((new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U) | (new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived))[] +>r8a : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] +>[r8arg1, r8arg2] : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U >r8arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived var r8b = [r8arg2, r8arg1]; ->r8b : ((new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U))[] ->[r8arg2, r8arg1] : ((new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived) | (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U))[] +>r8b : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] +>[r8arg2, r8arg1] : (new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U)[] >r8arg2 : new (x: new (arg: Base) => Derived, y: new (arg2: Base) => Derived) => new (r: Base) => Derived >r8arg1 : new (x: new (arg: T) => U, y: new (arg2: T) => U) => new (r: T) => U @@ -662,14 +662,14 @@ var r10 = foo10(r10arg1); // any >r10arg1 : new (...x: T[]) => T var r10a = [r10arg1, r10arg2]; ->r10a : ((new (...x: T[]) => T) | (new (...x: Derived[]) => Derived))[] ->[r10arg1, r10arg2] : ((new (...x: T[]) => T) | (new (...x: Derived[]) => Derived))[] +>r10a : (new (...x: T[]) => T)[] +>[r10arg1, r10arg2] : (new (...x: T[]) => T)[] >r10arg1 : new (...x: T[]) => T >r10arg2 : new (...x: Derived[]) => Derived var r10b = [r10arg2, r10arg1]; ->r10b : ((new (...x: Derived[]) => Derived) | (new (...x: T[]) => T))[] ->[r10arg2, r10arg1] : ((new (...x: Derived[]) => Derived) | (new (...x: T[]) => T))[] +>r10b : (new (...x: T[]) => T)[] +>[r10arg2, r10arg1] : (new (...x: T[]) => T)[] >r10arg2 : new (...x: Derived[]) => Derived >r10arg1 : new (...x: T[]) => T @@ -699,14 +699,14 @@ var r11 = foo11(r11arg1); // any >r11arg1 : new (x: T, y: T) => T var r11a = [r11arg1, r11arg2]; ->r11a : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] ->[r11arg1, r11arg2] : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>r11a : (new (x: T, y: T) => T)[] +>[r11arg1, r11arg2] : (new (x: T, y: T) => T)[] >r11arg1 : new (x: T, y: T) => T >r11arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base var r11b = [r11arg2, r11arg1]; ->r11b : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] ->[r11arg2, r11arg1] : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] +>r11b : (new (x: T, y: T) => T)[] +>[r11arg2, r11arg1] : (new (x: T, y: T) => T)[] >r11arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r11arg1 : new (x: T, y: T) => T @@ -741,14 +741,14 @@ var r12 = foo12(r12arg1); // any >r12arg1 : new (x: Base[], y: T) => Derived[] var r12a = [r12arg1, r12arg2]; ->r12a : ((new (x: Base[], y: T) => Derived[]) | (new (x: Base[], y: Derived2[]) => Derived[]))[] ->[r12arg1, r12arg2] : ((new (x: Base[], y: T) => Derived[]) | (new (x: Base[], y: Derived2[]) => Derived[]))[] +>r12a : (new (x: Base[], y: T) => Derived[])[] +>[r12arg1, r12arg2] : (new (x: Base[], y: T) => Derived[])[] >r12arg1 : new (x: Base[], y: T) => Derived[] >r12arg2 : new (x: Base[], y: Derived2[]) => Derived[] var r12b = [r12arg2, r12arg1]; ->r12b : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: T) => Derived[]))[] ->[r12arg2, r12arg1] : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: T) => Derived[]))[] +>r12b : (new (x: Base[], y: Derived2[]) => Derived[])[] +>[r12arg2, r12arg1] : (new (x: Base[], y: Derived2[]) => Derived[])[] >r12arg2 : new (x: Base[], y: Derived2[]) => Derived[] >r12arg1 : new (x: Base[], y: T) => Derived[] @@ -782,14 +782,14 @@ var r13 = foo13(r13arg1); // any >r13arg1 : new (x: Base[], y: T) => T var r13a = [r13arg1, r13arg2]; ->r13a : ((new (x: Base[], y: T) => T) | (new (x: Base[], y: Derived[]) => Derived[]))[] ->[r13arg1, r13arg2] : ((new (x: Base[], y: T) => T) | (new (x: Base[], y: Derived[]) => Derived[]))[] +>r13a : (new (x: Base[], y: T) => T)[] +>[r13arg1, r13arg2] : (new (x: Base[], y: T) => T)[] >r13arg1 : new (x: Base[], y: T) => T >r13arg2 : new (x: Base[], y: Derived[]) => Derived[] var r13b = [r13arg2, r13arg1]; ->r13b : ((new (x: Base[], y: Derived[]) => Derived[]) | (new (x: Base[], y: T) => T))[] ->[r13arg2, r13arg1] : ((new (x: Base[], y: Derived[]) => Derived[]) | (new (x: Base[], y: T) => T))[] +>r13b : (new (x: Base[], y: T) => T)[] +>[r13arg2, r13arg1] : (new (x: Base[], y: T) => T)[] >r13arg2 : new (x: Base[], y: Derived[]) => Derived[] >r13arg1 : new (x: Base[], y: T) => T @@ -817,14 +817,14 @@ var r14 = foo14(r14arg1); // any >r14arg1 : new (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] ->[r14arg1, r14arg2] : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] +>r14a : (new (x: { a: T; b: T; }) => T)[] +>[r14arg1, r14arg2] : (new (x: { a: T; b: T; }) => T)[] >r14arg1 : new (x: { a: T; b: T; }) => T >r14arg2 : new (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : ((new (x: { a: string; b: number; }) => Object) | (new (x: { a: T; b: T; }) => T))[] ->[r14arg2, r14arg1] : ((new (x: { a: string; b: number; }) => Object) | (new (x: { a: T; b: T; }) => T))[] +>r14b : (new (x: { a: T; b: T; }) => T)[] +>[r14arg2, r14arg1] : (new (x: { a: T; b: T; }) => T)[] >r14arg2 : new (x: { a: string; b: number; }) => Object >r14arg1 : new (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithConstructSignatures3.types b/tests/baselines/reference/subtypingWithConstructSignatures3.types index b7c90d8697e..741db4f4ba6 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures3.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures3.types @@ -224,14 +224,14 @@ module Errors { >r1arg1 : new (x: T) => U[] var r1a = [r1arg2, r1arg1]; ->r1a : ((new (x: number) => string[]) | (new (x: T) => U[]))[] ->[r1arg2, r1arg1] : ((new (x: number) => string[]) | (new (x: T) => U[]))[] +>r1a : (new (x: T) => U[])[] +>[r1arg2, r1arg1] : (new (x: T) => U[])[] >r1arg2 : new (x: number) => string[] >r1arg1 : new (x: T) => U[] var r1b = [r1arg1, r1arg2]; ->r1b : ((new (x: T) => U[]) | (new (x: number) => string[]))[] ->[r1arg1, r1arg2] : ((new (x: T) => U[]) | (new (x: number) => string[]))[] +>r1b : (new (x: T) => U[])[] +>[r1arg1, r1arg2] : (new (x: T) => U[])[] >r1arg1 : new (x: T) => U[] >r1arg2 : new (x: number) => string[] @@ -268,14 +268,14 @@ module Errors { >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V var r2a = [r2arg2, r2arg1]; ->r2a : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2) | (new (x: new (arg: T) => U) => new (r: T) => V))[] ->[r2arg2, r2arg1] : ((new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2) | (new (x: new (arg: T) => U) => new (r: T) => V))[] +>r2a : (new (x: new (arg: T) => U) => new (r: T) => V)[] +>[r2arg2, r2arg1] : (new (x: new (arg: T) => U) => new (r: T) => V)[] >r2arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2 >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V var r2b = [r2arg1, r2arg2]; ->r2b : ((new (x: new (arg: T) => U) => new (r: T) => V) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2))[] ->[r2arg1, r2arg2] : ((new (x: new (arg: T) => U) => new (r: T) => V) | (new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2))[] +>r2b : (new (x: new (arg: T) => U) => new (r: T) => V)[] +>[r2arg1, r2arg2] : (new (x: new (arg: T) => U) => new (r: T) => V)[] >r2arg1 : new (x: new (arg: T) => U) => new (r: T) => V >r2arg2 : new (x: new (arg: Base) => Derived) => new (r: Base) => Derived2 @@ -350,14 +350,14 @@ module Errors { >r4arg1 : new (...x: T[]) => T var r4a = [r4arg2, r4arg1]; ->r4a : ((new (...x: Base[]) => Base) | (new (...x: T[]) => T))[] ->[r4arg2, r4arg1] : ((new (...x: Base[]) => Base) | (new (...x: T[]) => T))[] +>r4a : (new (...x: T[]) => T)[] +>[r4arg2, r4arg1] : (new (...x: T[]) => T)[] >r4arg2 : new (...x: Base[]) => Base >r4arg1 : new (...x: T[]) => T var r4b = [r4arg1, r4arg2]; ->r4b : ((new (...x: T[]) => T) | (new (...x: Base[]) => Base))[] ->[r4arg1, r4arg2] : ((new (...x: T[]) => T) | (new (...x: Base[]) => Base))[] +>r4b : (new (...x: T[]) => T)[] +>[r4arg1, r4arg2] : (new (...x: T[]) => T)[] >r4arg1 : new (...x: T[]) => T >r4arg2 : new (...x: Base[]) => Base @@ -387,14 +387,14 @@ module Errors { >r5arg1 : new (x: T, y: T) => T var r5a = [r5arg2, r5arg1]; ->r5a : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] ->[r5arg2, r5arg1] : ((new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base) | (new (x: T, y: T) => T))[] +>r5a : (new (x: T, y: T) => T)[] +>[r5arg2, r5arg1] : (new (x: T, y: T) => T)[] >r5arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base >r5arg1 : new (x: T, y: T) => T var r5b = [r5arg1, r5arg2]; ->r5b : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] ->[r5arg1, r5arg2] : ((new (x: T, y: T) => T) | (new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base))[] +>r5b : (new (x: T, y: T) => T)[] +>[r5arg1, r5arg2] : (new (x: T, y: T) => T)[] >r5arg1 : new (x: T, y: T) => T >r5arg2 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base @@ -429,14 +429,14 @@ module Errors { >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] var r6a = [r6arg2, r6arg1]; ->r6a : ((new (x: Base[], y: Base[]) => T) | (new (x: Base[], y: Derived2[]) => Derived[]))[] ->[r6arg2, r6arg1] : ((new (x: Base[], y: Base[]) => T) | (new (x: Base[], y: Derived2[]) => Derived[]))[] +>r6a : (new (x: Base[], y: Base[]) => T)[] +>[r6arg2, r6arg1] : (new (x: Base[], y: Base[]) => T)[] >r6arg2 : new (x: Base[], y: Base[]) => T >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] var r6b = [r6arg1, r6arg2]; ->r6b : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: Base[]) => T))[] ->[r6arg1, r6arg2] : ((new (x: Base[], y: Derived2[]) => Derived[]) | (new (x: Base[], y: Base[]) => T))[] +>r6b : (new (x: Base[], y: Base[]) => T)[] +>[r6arg1, r6arg2] : (new (x: Base[], y: Base[]) => T)[] >r6arg1 : new (x: Base[], y: Derived2[]) => Derived[] >r6arg2 : new (x: Base[], y: Base[]) => T @@ -463,14 +463,14 @@ module Errors { >r7arg1 : new (x: { a: T; b: T; }) => T var r7a = [r7arg2, r7arg1]; ->r7a : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => T))[] ->[r7arg2, r7arg1] : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => T))[] +>r7a : (new (x: { a: T; b: T; }) => T)[] +>[r7arg2, r7arg1] : (new (x: { a: T; b: T; }) => T)[] >r7arg2 : new (x: { a: string; b: number; }) => number >r7arg1 : new (x: { a: T; b: T; }) => T var r7b = [r7arg1, r7arg2]; ->r7b : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => number))[] ->[r7arg1, r7arg2] : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => number))[] +>r7b : (new (x: { a: T; b: T; }) => T)[] +>[r7arg1, r7arg2] : (new (x: { a: T; b: T; }) => T)[] >r7arg1 : new (x: { a: T; b: T; }) => T >r7arg2 : new (x: { a: string; b: number; }) => number @@ -491,14 +491,14 @@ module Errors { >r7arg3 : new (x: { a: T; b: T; }) => number var r7d = [r7arg2, r7arg3]; ->r7d : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => number))[] ->[r7arg2, r7arg3] : ((new (x: { a: string; b: number; }) => number) | (new (x: { a: T; b: T; }) => number))[] +>r7d : (new (x: { a: string; b: number; }) => number)[] +>[r7arg2, r7arg3] : (new (x: { a: string; b: number; }) => number)[] >r7arg2 : new (x: { a: string; b: number; }) => number >r7arg3 : new (x: { a: T; b: T; }) => number var r7e = [r7arg3, r7arg2]; ->r7e : ((new (x: { a: T; b: T; }) => number) | (new (x: { a: string; b: number; }) => number))[] ->[r7arg3, r7arg2] : ((new (x: { a: T; b: T; }) => number) | (new (x: { a: string; b: number; }) => number))[] +>r7e : (new (x: { a: T; b: T; }) => number)[] +>[r7arg3, r7arg2] : (new (x: { a: T; b: T; }) => number)[] >r7arg3 : new (x: { a: T; b: T; }) => number >r7arg2 : new (x: { a: string; b: number; }) => number diff --git a/tests/baselines/reference/subtypingWithConstructSignatures4.types b/tests/baselines/reference/subtypingWithConstructSignatures4.types index 328dadad41c..932adcb7368 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures4.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures4.types @@ -301,14 +301,14 @@ var r3 = foo3(r3arg); >r3arg : new (x: T) => T var r3a = [r3arg, r3arg2]; ->r3a : ((new (x: T) => T) | (new (x: T) => void))[] ->[r3arg, r3arg2] : ((new (x: T) => T) | (new (x: T) => void))[] +>r3a : (new (x: T) => T)[] +>[r3arg, r3arg2] : (new (x: T) => T)[] >r3arg : new (x: T) => T >r3arg2 : new (x: T) => void var r3b = [r3arg2, r3arg]; ->r3b : ((new (x: T) => void) | (new (x: T) => T))[] ->[r3arg2, r3arg] : ((new (x: T) => void) | (new (x: T) => T))[] +>r3b : (new (x: T) => void)[] +>[r3arg2, r3arg] : (new (x: T) => void)[] >r3arg2 : new (x: T) => void >r3arg : new (x: T) => T @@ -415,14 +415,14 @@ var r6 = foo6(r6arg); >r6arg : new (x: new (arg: T) => U) => T var r6a = [r6arg, r6arg2]; ->r6a : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: T) => Derived) => T))[] ->[r6arg, r6arg2] : ((new (x: new (arg: T) => U) => T) | (new (x: new (arg: T) => Derived) => T))[] +>r6a : (new (x: new (arg: T) => U) => T)[] +>[r6arg, r6arg2] : (new (x: new (arg: T) => U) => T)[] >r6arg : new (x: new (arg: T) => U) => T >r6arg2 : new (x: new (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : ((new (x: new (arg: T) => Derived) => T) | (new (x: new (arg: T) => U) => T))[] ->[r6arg2, r6arg] : ((new (x: new (arg: T) => Derived) => T) | (new (x: new (arg: T) => U) => T))[] +>r6b : (new (x: new (arg: T) => Derived) => T)[] +>[r6arg2, r6arg] : (new (x: new (arg: T) => Derived) => T)[] >r6arg2 : new (x: new (arg: T) => Derived) => T >r6arg : new (x: new (arg: T) => U) => T @@ -460,14 +460,14 @@ var r11 = foo11(r11arg); >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : ((new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] ->[r11arg, r11arg2] : ((new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base) | (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base))[] +>r11a : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>[r11arg, r11arg2] : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : ((new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] ->[r11arg2, r11arg] : ((new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base) | (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base))[] +>r11b : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg2, r11arg] : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base @@ -499,14 +499,14 @@ var r15 = foo15(r15arg); >r15arg : new (x: { a: U; b: V; }) => U[] var r15a = [r15arg, r15arg2]; ->r15a : ((new (x: { a: U; b: V; }) => U[]) | (new (x: { a: T; b: T; }) => T[]))[] ->[r15arg, r15arg2] : ((new (x: { a: U; b: V; }) => U[]) | (new (x: { a: T; b: T; }) => T[]))[] +>r15a : (new (x: { a: U; b: V; }) => U[])[] +>[r15arg, r15arg2] : (new (x: { a: U; b: V; }) => U[])[] >r15arg : new (x: { a: U; b: V; }) => U[] >r15arg2 : new (x: { a: T; b: T; }) => T[] var r15b = [r15arg2, r15arg]; ->r15b : ((new (x: { a: T; b: T; }) => T[]) | (new (x: { a: U; b: V; }) => U[]))[] ->[r15arg2, r15arg] : ((new (x: { a: T; b: T; }) => T[]) | (new (x: { a: U; b: V; }) => U[]))[] +>r15b : (new (x: { a: T; b: T; }) => T[])[] +>[r15arg2, r15arg] : (new (x: { a: T; b: T; }) => T[])[] >r15arg2 : new (x: { a: T; b: T; }) => T[] >r15arg : new (x: { a: U; b: V; }) => U[] diff --git a/tests/baselines/reference/subtypingWithObjectMembersOptionality.types b/tests/baselines/reference/subtypingWithObjectMembersOptionality.types index 0d55d78e266..815f2d60740 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersOptionality.types +++ b/tests/baselines/reference/subtypingWithObjectMembersOptionality.types @@ -85,8 +85,8 @@ var b = { Foo: null }; >null : null var r = true ? a : b; ->r : { Foo?: Base; } | { Foo: Derived; } ->true ? a : b : { Foo?: Base; } | { Foo: Derived; } +>r : { Foo?: Base; } +>true ? a : b : { Foo?: Base; } >true : boolean >a : { Foo?: Base; } >b : { Foo: Derived; } @@ -156,8 +156,8 @@ module TwoLevels { >null : null var r = true ? a : b; ->r : { Foo?: Base; } | { Foo: Derived2; } ->true ? a : b : { Foo?: Base; } | { Foo: Derived2; } +>r : { Foo?: Base; } +>true ? a : b : { Foo?: Base; } >true : boolean >a : { Foo?: Base; } >b : { Foo: Derived2; } diff --git a/tests/baselines/reference/superAccessInFatArrow1.types b/tests/baselines/reference/superAccessInFatArrow1.types index 0c50015c051..95f0d769655 100644 --- a/tests/baselines/reference/superAccessInFatArrow1.types +++ b/tests/baselines/reference/superAccessInFatArrow1.types @@ -23,7 +23,7 @@ module test { this.bar(() => { >this.bar(() => { super.foo(); }) : void >this.bar : (callback: () => void) => void ->this : B +>this : this >bar : (callback: () => void) => void >() => { super.foo(); } : () => void diff --git a/tests/baselines/reference/superSymbolIndexedAccess1.symbols b/tests/baselines/reference/superSymbolIndexedAccess1.symbols index 818d0ac52af..416ac465e24 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess1.symbols +++ b/tests/baselines/reference/superSymbolIndexedAccess1.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess1.ts === var symbol = Symbol.for('myThing'); >symbol : Symbol(symbol, Decl(superSymbolIndexedAccess1.ts, 0, 3)) ->Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) +>Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 3862, 42)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 3862, 42)) class Foo { >Foo : Symbol(Foo, Decl(superSymbolIndexedAccess1.ts, 0, 35)) diff --git a/tests/baselines/reference/superSymbolIndexedAccess2.symbols b/tests/baselines/reference/superSymbolIndexedAccess2.symbols index 3865b920647..726abb3fdc5 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess2.symbols +++ b/tests/baselines/reference/superSymbolIndexedAccess2.symbols @@ -4,9 +4,9 @@ class Foo { >Foo : Symbol(Foo, Decl(superSymbolIndexedAccess2.ts, 0, 0)) [Symbol.isConcatSpreadable]() { ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) return 0; } @@ -17,14 +17,14 @@ class Bar extends Foo { >Foo : Symbol(Foo, Decl(superSymbolIndexedAccess2.ts, 0, 0)) [Symbol.isConcatSpreadable]() { ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) return super[Symbol.isConcatSpreadable](); >super : Symbol(Foo, Decl(superSymbolIndexedAccess2.ts, 0, 0)) ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } } diff --git a/tests/baselines/reference/superSymbolIndexedAccess3.errors.txt b/tests/baselines/reference/superSymbolIndexedAccess3.errors.txt index 7f25510e00b..1cac31dec40 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess3.errors.txt +++ b/tests/baselines/reference/superSymbolIndexedAccess3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts(11,16): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts(11,16): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. ==== tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess3.ts (1 errors) ==== @@ -14,6 +14,6 @@ tests/cases/conformance/expressions/superPropertyAccess/superSymbolIndexedAccess [symbol]() { return super[Bar](); ~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. } } \ No newline at end of file diff --git a/tests/baselines/reference/switchStatements.errors.txt b/tests/baselines/reference/switchStatements.errors.txt index aa5b796e252..c99b0eba909 100644 --- a/tests/baselines/reference/switchStatements.errors.txt +++ b/tests/baselines/reference/switchStatements.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/statements/switchStatements/switchStatements.ts(35,10): error TS2322: Type '{ id: number; name: string; }' is not assignable to type 'C'. +tests/cases/conformance/statements/switchStatements/switchStatements.ts(35,20): error TS2322: Type '{ id: number; name: string; }' is not assignable to type 'C'. Object literal may only specify known properties, and 'name' does not exist in type 'C'. @@ -38,7 +38,7 @@ tests/cases/conformance/statements/switchStatements/switchStatements.ts(35,10): switch (new C()) { case new D(): case { id: 12, name: '' }: - ~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type 'C'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type 'C'. case new C(): diff --git a/tests/baselines/reference/symbolDeclarationEmit1.symbols b/tests/baselines/reference/symbolDeclarationEmit1.symbols index 9fae9d57c4f..9a7d93c7246 100644 --- a/tests/baselines/reference/symbolDeclarationEmit1.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit1.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit1.ts, 0, 0)) [Symbol.toPrimitive]: number; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit10.symbols b/tests/baselines/reference/symbolDeclarationEmit10.symbols index 5dba2268d26..63602f4fd2c 100644 --- a/tests/baselines/reference/symbolDeclarationEmit10.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit10.symbols @@ -3,13 +3,13 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit10.ts, 0, 3)) get [Symbol.isConcatSpreadable]() { return '' }, ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) set [Symbol.isConcatSpreadable](x) { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit10.ts, 2, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit11.symbols b/tests/baselines/reference/symbolDeclarationEmit11.symbols index a6019a364e4..850bde66c49 100644 --- a/tests/baselines/reference/symbolDeclarationEmit11.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit11.symbols @@ -3,23 +3,23 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit11.ts, 0, 0)) static [Symbol.iterator] = 0; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) static [Symbol.isConcatSpreadable]() { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) static get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) static set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit11.ts, 4, 36)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit13.symbols b/tests/baselines/reference/symbolDeclarationEmit13.symbols index e16ec738489..accb92a8c52 100644 --- a/tests/baselines/reference/symbolDeclarationEmit13.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit13.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit13.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) set [Symbol.toStringTag](x) { } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) >x : Symbol(x, Decl(symbolDeclarationEmit13.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit14.symbols b/tests/baselines/reference/symbolDeclarationEmit14.symbols index b2f520351f2..91a5cfdd760 100644 --- a/tests/baselines/reference/symbolDeclarationEmit14.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit14.symbols @@ -3,12 +3,12 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit14.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) get [Symbol.toStringTag]() { return ""; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit2.symbols b/tests/baselines/reference/symbolDeclarationEmit2.symbols index 7e9d06cd332..1993e369aea 100644 --- a/tests/baselines/reference/symbolDeclarationEmit2.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit2.symbols @@ -3,7 +3,7 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit2.ts, 0, 0)) [Symbol.toPrimitive] = ""; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit3.symbols b/tests/baselines/reference/symbolDeclarationEmit3.symbols index 177180b5bca..84f39f363f1 100644 --- a/tests/baselines/reference/symbolDeclarationEmit3.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit3.symbols @@ -3,20 +3,20 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit3.ts, 0, 0)) [Symbol.toPrimitive](x: number); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 1, 25)) [Symbol.toPrimitive](x: string); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 2, 25)) [Symbol.toPrimitive](x: any) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit3.ts, 3, 25)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit4.symbols b/tests/baselines/reference/symbolDeclarationEmit4.symbols index 98cb277ad47..655a91fc88b 100644 --- a/tests/baselines/reference/symbolDeclarationEmit4.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit4.symbols @@ -3,13 +3,13 @@ class C { >C : Symbol(C, Decl(symbolDeclarationEmit4.ts, 0, 0)) get [Symbol.toPrimitive]() { return ""; } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) set [Symbol.toPrimitive](x) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >x : Symbol(x, Decl(symbolDeclarationEmit4.ts, 2, 29)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit5.symbols b/tests/baselines/reference/symbolDeclarationEmit5.symbols index 17bda345253..1436f9b9f69 100644 --- a/tests/baselines/reference/symbolDeclarationEmit5.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit5.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(symbolDeclarationEmit5.ts, 0, 0)) [Symbol.isConcatSpreadable](): string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit6.symbols b/tests/baselines/reference/symbolDeclarationEmit6.symbols index c4b046cc146..f07ebd532fa 100644 --- a/tests/baselines/reference/symbolDeclarationEmit6.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit6.symbols @@ -3,7 +3,7 @@ interface I { >I : Symbol(I, Decl(symbolDeclarationEmit6.ts, 0, 0)) [Symbol.isConcatSpreadable]: string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit7.symbols b/tests/baselines/reference/symbolDeclarationEmit7.symbols index 58a661412da..0435dc15df2 100644 --- a/tests/baselines/reference/symbolDeclarationEmit7.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit7.symbols @@ -3,7 +3,7 @@ var obj: { >obj : Symbol(obj, Decl(symbolDeclarationEmit7.ts, 0, 3)) [Symbol.isConcatSpreadable]: string; ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit8.symbols b/tests/baselines/reference/symbolDeclarationEmit8.symbols index 7879d28b02f..7e95754b1eb 100644 --- a/tests/baselines/reference/symbolDeclarationEmit8.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit8.symbols @@ -3,7 +3,7 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit8.ts, 0, 3)) [Symbol.isConcatSpreadable]: 0 ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } diff --git a/tests/baselines/reference/symbolDeclarationEmit9.symbols b/tests/baselines/reference/symbolDeclarationEmit9.symbols index 17901fb713a..d4f08115a21 100644 --- a/tests/baselines/reference/symbolDeclarationEmit9.symbols +++ b/tests/baselines/reference/symbolDeclarationEmit9.symbols @@ -3,7 +3,7 @@ var obj = { >obj : Symbol(obj, Decl(symbolDeclarationEmit9.ts, 0, 3)) [Symbol.isConcatSpreadable]() { } ->Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 1243, 24)) +>Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.d.ts, 3884, 24)) } diff --git a/tests/baselines/reference/symbolProperty11.symbols b/tests/baselines/reference/symbolProperty11.symbols index 4028da455a6..3db0f7012cb 100644 --- a/tests/baselines/reference/symbolProperty11.symbols +++ b/tests/baselines/reference/symbolProperty11.symbols @@ -6,9 +6,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty11.ts, 0, 11)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty11.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty13.symbols b/tests/baselines/reference/symbolProperty13.symbols index 07e9b6bae26..62ce887a731 100644 --- a/tests/baselines/reference/symbolProperty13.symbols +++ b/tests/baselines/reference/symbolProperty13.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(symbolProperty13.ts, 0, 0)) [Symbol.iterator]: { x; y }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty13.ts, 1, 27)) } @@ -13,9 +13,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty13.ts, 2, 1)) [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty13.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty14.symbols b/tests/baselines/reference/symbolProperty14.symbols index d4e79a064a9..c48bd271c87 100644 --- a/tests/baselines/reference/symbolProperty14.symbols +++ b/tests/baselines/reference/symbolProperty14.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(symbolProperty14.ts, 0, 0)) [Symbol.iterator]: { x; y }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 1, 24)) >y : Symbol(y, Decl(symbolProperty14.ts, 1, 27)) } @@ -13,9 +13,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty14.ts, 2, 1)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty14.ts, 4, 25)) } diff --git a/tests/baselines/reference/symbolProperty15.symbols b/tests/baselines/reference/symbolProperty15.symbols index 2a83145da03..56f722c523b 100644 --- a/tests/baselines/reference/symbolProperty15.symbols +++ b/tests/baselines/reference/symbolProperty15.symbols @@ -6,9 +6,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty15.ts, 0, 11)) [Symbol.iterator]?: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty15.ts, 2, 25)) } diff --git a/tests/baselines/reference/symbolProperty16.symbols b/tests/baselines/reference/symbolProperty16.symbols index 1b4b23e9511..092d766034e 100644 --- a/tests/baselines/reference/symbolProperty16.symbols +++ b/tests/baselines/reference/symbolProperty16.symbols @@ -3,18 +3,18 @@ class C { >C : Symbol(C, Decl(symbolProperty16.ts, 0, 0)) private [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 1, 32)) } interface I { >I : Symbol(I, Decl(symbolProperty16.ts, 2, 1)) [Symbol.iterator]: { x }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty16.ts, 4, 24)) } diff --git a/tests/baselines/reference/symbolProperty18.symbols b/tests/baselines/reference/symbolProperty18.symbols index 89df72d6543..b5d930b4005 100644 --- a/tests/baselines/reference/symbolProperty18.symbols +++ b/tests/baselines/reference/symbolProperty18.symbols @@ -3,39 +3,39 @@ var i = { >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) [Symbol.iterator]: 0, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) [Symbol.toStringTag]() { return "" }, ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) set [Symbol.toPrimitive](p: boolean) { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) >p : Symbol(p, Decl(symbolProperty18.ts, 3, 29)) } var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty18.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty18.ts, 7, 3)) >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) i[Symbol.toPrimitive] = false; >i : Symbol(i, Decl(symbolProperty18.ts, 0, 3)) ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) diff --git a/tests/baselines/reference/symbolProperty19.symbols b/tests/baselines/reference/symbolProperty19.symbols index 3ee9ed595c2..eae891f2e22 100644 --- a/tests/baselines/reference/symbolProperty19.symbols +++ b/tests/baselines/reference/symbolProperty19.symbols @@ -3,15 +3,15 @@ var i = { >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) [Symbol.iterator]: { p: null }, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >p : Symbol(p, Decl(symbolProperty19.ts, 1, 24)) [Symbol.toStringTag]() { return { p: undefined }; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) >p : Symbol(p, Decl(symbolProperty19.ts, 2, 37)) >undefined : Symbol(undefined) } @@ -19,14 +19,14 @@ var i = { var it = i[Symbol.iterator]; >it : Symbol(it, Decl(symbolProperty19.ts, 5, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) var str = i[Symbol.toStringTag](); >str : Symbol(str, Decl(symbolProperty19.ts, 6, 3)) >i : Symbol(i, Decl(symbolProperty19.ts, 0, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) diff --git a/tests/baselines/reference/symbolProperty2.symbols b/tests/baselines/reference/symbolProperty2.symbols index b52c4087d71..d03ca9a4c51 100644 --- a/tests/baselines/reference/symbolProperty2.symbols +++ b/tests/baselines/reference/symbolProperty2.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/Symbols/symbolProperty2.ts === var s = Symbol(); >s : Symbol(s, Decl(symbolProperty2.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) var x = { >x : Symbol(x, Decl(symbolProperty2.ts, 1, 3)) diff --git a/tests/baselines/reference/symbolProperty20.symbols b/tests/baselines/reference/symbolProperty20.symbols index ad4f0c79523..110067abda5 100644 --- a/tests/baselines/reference/symbolProperty20.symbols +++ b/tests/baselines/reference/symbolProperty20.symbols @@ -3,15 +3,15 @@ interface I { >I : Symbol(I, Decl(symbolProperty20.ts, 0, 0)) [Symbol.iterator]: (s: string) => string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 1, 24)) [Symbol.toStringTag](s: number): number; ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) >s : Symbol(s, Decl(symbolProperty20.ts, 2, 25)) } @@ -20,16 +20,16 @@ var i: I = { >I : Symbol(I, Decl(symbolProperty20.ts, 0, 0)) [Symbol.iterator]: s => s, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) >s : Symbol(s, Decl(symbolProperty20.ts, 6, 22)) [Symbol.toStringTag](n) { return n; } ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) >n : Symbol(n, Decl(symbolProperty20.ts, 7, 25)) } diff --git a/tests/baselines/reference/symbolProperty21.errors.txt b/tests/baselines/reference/symbolProperty21.errors.txt index b9162acc84f..fa9cabc9b61 100644 --- a/tests/baselines/reference/symbolProperty21.errors.txt +++ b/tests/baselines/reference/symbolProperty21.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/Symbols/symbolProperty21.ts(8,5): error TS2345: Argument of type '{ [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: boolean; }' is not assignable to parameter of type 'I'. +tests/cases/conformance/es6/Symbols/symbolProperty21.ts(10,5): error TS2345: Argument of type '{ [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: boolean; }' is not assignable to parameter of type 'I'. Object literal may only specify known properties, and '[Symbol.toPrimitive]' does not exist in type 'I'. @@ -11,14 +11,10 @@ tests/cases/conformance/es6/Symbols/symbolProperty21.ts(8,5): error TS2345: Argu declare function foo(p: I): { t: T; u: U }; foo({ - ~ [Symbol.isConcatSpreadable]: "", - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [Symbol.toPrimitive]: 0, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - [Symbol.unscopables]: true - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - }); - ~ + ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: boolean; }' is not assignable to parameter of type 'I'. -!!! error TS2345: Object literal may only specify known properties, and '[Symbol.toPrimitive]' does not exist in type 'I'. \ No newline at end of file +!!! error TS2345: Object literal may only specify known properties, and '[Symbol.toPrimitive]' does not exist in type 'I'. + [Symbol.unscopables]: true + }); \ No newline at end of file diff --git a/tests/baselines/reference/symbolProperty22.symbols b/tests/baselines/reference/symbolProperty22.symbols index b62037e32a5..2288537456c 100644 --- a/tests/baselines/reference/symbolProperty22.symbols +++ b/tests/baselines/reference/symbolProperty22.symbols @@ -5,9 +5,9 @@ interface I { >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) [Symbol.unscopables](x: T): U; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) >x : Symbol(x, Decl(symbolProperty22.ts, 1, 25)) >T : Symbol(T, Decl(symbolProperty22.ts, 0, 12)) >U : Symbol(U, Decl(symbolProperty22.ts, 0, 14)) @@ -27,9 +27,9 @@ declare function foo(p1: T, p2: I): U; foo("", { [Symbol.unscopables]: s => s.length }); >foo : Symbol(foo, Decl(symbolProperty22.ts, 2, 1)) ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) >s.length : Symbol(String.length, Decl(lib.d.ts, 414, 19)) >s : Symbol(s, Decl(symbolProperty22.ts, 6, 31)) diff --git a/tests/baselines/reference/symbolProperty23.symbols b/tests/baselines/reference/symbolProperty23.symbols index da9d07ffeed..152048a95a8 100644 --- a/tests/baselines/reference/symbolProperty23.symbols +++ b/tests/baselines/reference/symbolProperty23.symbols @@ -3,9 +3,9 @@ interface I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]: () => boolean; ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } class C implements I { @@ -13,9 +13,9 @@ class C implements I { >I : Symbol(I, Decl(symbolProperty23.ts, 0, 0)) [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) return true; } diff --git a/tests/baselines/reference/symbolProperty26.symbols b/tests/baselines/reference/symbolProperty26.symbols index 46babb69a87..7a2e443368f 100644 --- a/tests/baselines/reference/symbolProperty26.symbols +++ b/tests/baselines/reference/symbolProperty26.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return ""; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty26.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty27.symbols b/tests/baselines/reference/symbolProperty27.symbols index 69fe473e17c..306802cdff2 100644 --- a/tests/baselines/reference/symbolProperty27.symbols +++ b/tests/baselines/reference/symbolProperty27.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return {}; } @@ -16,9 +16,9 @@ class C2 extends C1 { >C1 : Symbol(C1, Decl(symbolProperty27.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return ""; } diff --git a/tests/baselines/reference/symbolProperty28.symbols b/tests/baselines/reference/symbolProperty28.symbols index cf6ab1f5edb..77b476c6ea3 100644 --- a/tests/baselines/reference/symbolProperty28.symbols +++ b/tests/baselines/reference/symbolProperty28.symbols @@ -3,9 +3,9 @@ class C1 { >C1 : Symbol(C1, Decl(symbolProperty28.ts, 0, 0)) [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return { x: "" }; >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) @@ -24,8 +24,8 @@ var obj = c[Symbol.toStringTag]().x; >obj : Symbol(obj, Decl(symbolProperty28.ts, 9, 3)) >c[Symbol.toStringTag]().x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) >c : Symbol(c, Decl(symbolProperty28.ts, 8, 3)) ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) >x : Symbol(x, Decl(symbolProperty28.ts, 2, 16)) diff --git a/tests/baselines/reference/symbolProperty4.symbols b/tests/baselines/reference/symbolProperty4.symbols index 4e17e561bce..c159cc756d8 100644 --- a/tests/baselines/reference/symbolProperty4.symbols +++ b/tests/baselines/reference/symbolProperty4.symbols @@ -3,13 +3,13 @@ var x = { >x : Symbol(x, Decl(symbolProperty4.ts, 0, 3)) [Symbol()]: 0, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) [Symbol()]() { }, ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) get [Symbol()]() { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) return 0; } diff --git a/tests/baselines/reference/symbolProperty40.symbols b/tests/baselines/reference/symbolProperty40.symbols index e3e469764a8..29b66c96f1f 100644 --- a/tests/baselines/reference/symbolProperty40.symbols +++ b/tests/baselines/reference/symbolProperty40.symbols @@ -3,21 +3,21 @@ class C { >C : Symbol(C, Decl(symbolProperty40.ts, 0, 0)) [Symbol.iterator](x: string): string; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 1, 22)) [Symbol.iterator](x: number): number; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 2, 22)) [Symbol.iterator](x: any) { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty40.ts, 3, 22)) return undefined; @@ -31,13 +31,13 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) c[Symbol.iterator](0); >c : Symbol(c, Decl(symbolProperty40.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) diff --git a/tests/baselines/reference/symbolProperty41.symbols b/tests/baselines/reference/symbolProperty41.symbols index 622d1b693e8..129c856b804 100644 --- a/tests/baselines/reference/symbolProperty41.symbols +++ b/tests/baselines/reference/symbolProperty41.symbols @@ -3,24 +3,24 @@ class C { >C : Symbol(C, Decl(symbolProperty41.ts, 0, 0)) [Symbol.iterator](x: string): { x: string }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 1, 35)) [Symbol.iterator](x: "hello"): { x: string; hello: string }; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 22)) >x : Symbol(x, Decl(symbolProperty41.ts, 2, 36)) >hello : Symbol(hello, Decl(symbolProperty41.ts, 2, 47)) [Symbol.iterator](x: any) { ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >x : Symbol(x, Decl(symbolProperty41.ts, 3, 22)) return undefined; @@ -34,13 +34,13 @@ var c = new C; c[Symbol.iterator](""); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) c[Symbol.iterator]("hello"); >c : Symbol(c, Decl(symbolProperty41.ts, 8, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) diff --git a/tests/baselines/reference/symbolProperty45.symbols b/tests/baselines/reference/symbolProperty45.symbols index 5aba3b8c104..34bb5ad967f 100644 --- a/tests/baselines/reference/symbolProperty45.symbols +++ b/tests/baselines/reference/symbolProperty45.symbols @@ -3,16 +3,16 @@ class C { >C : Symbol(C, Decl(symbolProperty45.ts, 0, 0)) get [Symbol.hasInstance]() { ->Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1235, 32)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 1235, 32)) +>Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 3876, 32)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.d.ts, 3876, 32)) return ""; } get [Symbol.toPrimitive]() { ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) return ""; } diff --git a/tests/baselines/reference/symbolProperty5.symbols b/tests/baselines/reference/symbolProperty5.symbols index 7b57003e607..063ae8d3d34 100644 --- a/tests/baselines/reference/symbolProperty5.symbols +++ b/tests/baselines/reference/symbolProperty5.symbols @@ -3,19 +3,19 @@ var x = { >x : Symbol(x, Decl(symbolProperty5.ts, 0, 3)) [Symbol.iterator]: 0, ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) [Symbol.toPrimitive]() { }, ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty50.symbols b/tests/baselines/reference/symbolProperty50.symbols index 4beb1f6d9e2..64472f3c71a 100644 --- a/tests/baselines/reference/symbolProperty50.symbols +++ b/tests/baselines/reference/symbolProperty50.symbols @@ -9,8 +9,8 @@ module M { >C : Symbol(C, Decl(symbolProperty50.ts, 1, 24)) [Symbol.iterator]() { } ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) } } diff --git a/tests/baselines/reference/symbolProperty51.symbols b/tests/baselines/reference/symbolProperty51.symbols index 32240efd986..45a56260828 100644 --- a/tests/baselines/reference/symbolProperty51.symbols +++ b/tests/baselines/reference/symbolProperty51.symbols @@ -9,8 +9,8 @@ module M { >C : Symbol(C, Decl(symbolProperty51.ts, 1, 21)) [Symbol.iterator]() { } ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) } } diff --git a/tests/baselines/reference/symbolProperty53.errors.txt b/tests/baselines/reference/symbolProperty53.errors.txt index 7658744eb55..03002cd92b2 100644 --- a/tests/baselines/reference/symbolProperty53.errors.txt +++ b/tests/baselines/reference/symbolProperty53.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/Symbols/symbolProperty53.ts(2,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. -tests/cases/conformance/es6/Symbols/symbolProperty53.ts(5,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. +tests/cases/conformance/es6/Symbols/symbolProperty53.ts(5,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. ==== tests/cases/conformance/es6/Symbols/symbolProperty53.ts (2 errors) ==== @@ -11,4 +11,4 @@ tests/cases/conformance/es6/Symbols/symbolProperty53.ts(5,1): error TS2342: An i obj[Symbol.for]; ~~~~~~~~~~~~~~~ -!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'. \ No newline at end of file +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. \ No newline at end of file diff --git a/tests/baselines/reference/symbolProperty55.symbols b/tests/baselines/reference/symbolProperty55.symbols index 05eeace3b86..98f4a7769b2 100644 --- a/tests/baselines/reference/symbolProperty55.symbols +++ b/tests/baselines/reference/symbolProperty55.symbols @@ -3,9 +3,9 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty55.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) }; @@ -14,13 +14,13 @@ module M { var Symbol: SymbolConstructor; >Symbol : Symbol(Symbol, Decl(symbolProperty55.ts, 5, 7)) ->SymbolConstructor : Symbol(SymbolConstructor, Decl(lib.d.ts, 1209, 1)) +>SymbolConstructor : Symbol(SymbolConstructor, Decl(lib.d.ts, 3850, 1)) // The following should be of type 'any'. This is because even though obj has a property keyed by Symbol.iterator, // the key passed in here is the *wrong* Symbol.iterator. It is not the iterator property of the global Symbol. obj[Symbol.iterator]; >obj : Symbol(obj, Decl(symbolProperty55.ts, 0, 3)) ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) >Symbol : Symbol(Symbol, Decl(symbolProperty55.ts, 5, 7)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) } diff --git a/tests/baselines/reference/symbolProperty56.symbols b/tests/baselines/reference/symbolProperty56.symbols index a4e335cc7d7..fe73fb9f330 100644 --- a/tests/baselines/reference/symbolProperty56.symbols +++ b/tests/baselines/reference/symbolProperty56.symbols @@ -3,9 +3,9 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty56.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) }; diff --git a/tests/baselines/reference/symbolProperty57.symbols b/tests/baselines/reference/symbolProperty57.symbols index 249545872b1..eaf5be2a07c 100644 --- a/tests/baselines/reference/symbolProperty57.symbols +++ b/tests/baselines/reference/symbolProperty57.symbols @@ -3,14 +3,14 @@ var obj = { >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) [Symbol.iterator]: 0 ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) }; // Should give type 'any'. obj[Symbol["nonsense"]]; >obj : Symbol(obj, Decl(symbolProperty57.ts, 0, 3)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) diff --git a/tests/baselines/reference/symbolProperty6.symbols b/tests/baselines/reference/symbolProperty6.symbols index 78be14d0862..04b89f43652 100644 --- a/tests/baselines/reference/symbolProperty6.symbols +++ b/tests/baselines/reference/symbolProperty6.symbols @@ -3,24 +3,24 @@ class C { >C : Symbol(C, Decl(symbolProperty6.ts, 0, 0)) [Symbol.iterator] = 0; ->Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1249, 31)) +>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 3890, 31)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) [Symbol.toPrimitive]() { } ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) get [Symbol.toStringTag]() { ->Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 1291, 24)) +>Symbol.toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toStringTag : Symbol(SymbolConstructor.toStringTag, Decl(lib.d.ts, 3932, 24)) return 0; } diff --git a/tests/baselines/reference/symbolProperty8.symbols b/tests/baselines/reference/symbolProperty8.symbols index 64452f49c9c..541833d686a 100644 --- a/tests/baselines/reference/symbolProperty8.symbols +++ b/tests/baselines/reference/symbolProperty8.symbols @@ -3,12 +3,12 @@ interface I { >I : Symbol(I, Decl(symbolProperty8.ts, 0, 0)) [Symbol.unscopables]: number; ->Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 1297, 24)) +>Symbol.unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>unscopables : Symbol(SymbolConstructor.unscopables, Decl(lib.d.ts, 3938, 24)) [Symbol.toPrimitive](); ->Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 1285, 18)) +>Symbol.toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>toPrimitive : Symbol(SymbolConstructor.toPrimitive, Decl(lib.d.ts, 3926, 18)) } diff --git a/tests/baselines/reference/symbolType11.symbols b/tests/baselines/reference/symbolType11.symbols index d40e0e72724..bbccd2a0f8b 100644 --- a/tests/baselines/reference/symbolType11.symbols +++ b/tests/baselines/reference/symbolType11.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/Symbols/symbolType11.ts === var s = Symbol.for("logical"); >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) ->Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11)) ->for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 1221, 42)) +>Symbol.for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 3862, 42)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11)) +>for : Symbol(SymbolConstructor.for, Decl(lib.d.ts, 3862, 42)) s && s; >s : Symbol(s, Decl(symbolType11.ts, 0, 3)) diff --git a/tests/baselines/reference/symbolType11.types b/tests/baselines/reference/symbolType11.types index a7de59a11b7..b251db43301 100644 --- a/tests/baselines/reference/symbolType11.types +++ b/tests/baselines/reference/symbolType11.types @@ -33,7 +33,7 @@ s || 1; >1 : number ({}) || s; ->({}) || s : {} | symbol +>({}) || s : {} >({}) : {} >{} : {} >s : symbol diff --git a/tests/baselines/reference/symbolType16.symbols b/tests/baselines/reference/symbolType16.symbols index 4b61749b898..9a25d9ad152 100644 --- a/tests/baselines/reference/symbolType16.symbols +++ b/tests/baselines/reference/symbolType16.symbols @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/Symbols/symbolType16.ts === interface Symbol { ->Symbol : Symbol(Symbol, Decl(lib.d.ts, 1199, 52), Decl(lib.d.ts, 1305, 11), Decl(symbolType16.ts, 0, 0)) +>Symbol : Symbol(Symbol, Decl(lib.d.ts, 3840, 52), Decl(lib.d.ts, 3946, 11), Decl(symbolType16.ts, 0, 0)) newSymbolProp: number; >newSymbolProp : Symbol(newSymbolProp, Decl(symbolType16.ts, 0, 18)) diff --git a/tests/baselines/reference/systemModule1.errors.txt b/tests/baselines/reference/systemModule1.errors.txt deleted file mode 100644 index 18b64607455..00000000000 --- a/tests/baselines/reference/systemModule1.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. - - -!!! error TS1204: Cannot compile modules into 'commonjs', 'amd', 'system' or 'umd' when targeting 'ES6' or higher. -==== tests/cases/compiler/systemModule1.ts (0 errors) ==== - - export var x = 1; \ No newline at end of file diff --git a/tests/baselines/reference/systemModule1.js b/tests/baselines/reference/systemModule1.js index 9731106471c..573a7ae04c8 100644 --- a/tests/baselines/reference/systemModule1.js +++ b/tests/baselines/reference/systemModule1.js @@ -3,4 +3,12 @@ export var x = 1; //// [systemModule1.js] -export var x = 1; +System.register([], function(exports_1) { + var x; + return { + setters:[], + execute: function() { + x = 1; + } + } +}); diff --git a/tests/baselines/reference/systemModule1.symbols b/tests/baselines/reference/systemModule1.symbols new file mode 100644 index 00000000000..d6293c21fd9 --- /dev/null +++ b/tests/baselines/reference/systemModule1.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/systemModule1.ts === + +export var x = 1; +>x : Symbol(x, Decl(systemModule1.ts, 1, 10)) + diff --git a/tests/baselines/reference/systemModule1.types b/tests/baselines/reference/systemModule1.types new file mode 100644 index 00000000000..2adf73d116f --- /dev/null +++ b/tests/baselines/reference/systemModule1.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/systemModule1.ts === + +export var x = 1; +>x : number +>1 : number + diff --git a/tests/baselines/reference/systemModule17.js b/tests/baselines/reference/systemModule17.js new file mode 100644 index 00000000000..90efdc8872a --- /dev/null +++ b/tests/baselines/reference/systemModule17.js @@ -0,0 +1,84 @@ +//// [tests/cases/compiler/systemModule17.ts] //// + +//// [f1.ts] + + +export class A {} +export interface I {} + +//// [f2.ts] + +var x = 1; +interface I { } + +namespace N { + export var x = 1; + export interface I { } +} + +import IX = N.x; +import II = N.I; +import { A, A as EA, I as EI } from "f1"; + +export {x}; +export {x as x1}; + +export {I}; +export {I as I1}; + +export {A}; +export {A as A1}; + +export {EA}; +export {EA as EA1}; + +export {EI }; +export {EI as EI1}; + +export {IX}; +export {IX as IX1}; + +export {II}; +export {II as II1}; + +//// [f1.js] +System.register([], function(exports_1) { + var A; + return { + setters:[], + execute: function() { + A = (function () { + function A() { + } + return A; + })(); + exports_1("A", A); + } + } +}); +//// [f2.js] +System.register(["f1"], function(exports_1) { + var f1_1; + var x, N, IX; + return { + setters:[ + function (f1_1_1) { + f1_1 = f1_1_1; + }], + execute: function() { + x = 1; + (function (N) { + N.x = 1; + })(N || (N = {})); + IX = N.x; + exports_1("x", x); + exports_1("x1", x); + exports_1("A", f1_1.A); + exports_1("A1", f1_1.A); + exports_1("EA", f1_1.A); + exports_1("EA1", f1_1.A); + exports_1("IX", IX); + exports_1("IX1", IX); + } + } +}); diff --git a/tests/baselines/reference/systemModule17.symbols b/tests/baselines/reference/systemModule17.symbols new file mode 100644 index 00000000000..3bf19dad950 --- /dev/null +++ b/tests/baselines/reference/systemModule17.symbols @@ -0,0 +1,93 @@ +=== tests/cases/compiler/f1.ts === + + +export class A {} +>A : Symbol(A, Decl(f1.ts, 0, 0)) + +export interface I {} +>I : Symbol(I, Decl(f1.ts, 2, 17)) + +=== tests/cases/compiler/f2.ts === + +var x = 1; +>x : Symbol(x, Decl(f2.ts, 1, 3)) + +interface I { } +>I : Symbol(I, Decl(f2.ts, 1, 10)) + +namespace N { +>N : Symbol(N, Decl(f2.ts, 2, 15)) + + export var x = 1; +>x : Symbol(x, Decl(f2.ts, 5, 11)) + + export interface I { } +>I : Symbol(I, Decl(f2.ts, 5, 18)) +} + +import IX = N.x; +>IX : Symbol(IX, Decl(f2.ts, 7, 1)) +>N : Symbol(N, Decl(f2.ts, 2, 15)) +>x : Symbol(IX, Decl(f2.ts, 5, 11)) + +import II = N.I; +>II : Symbol(II, Decl(f2.ts, 9, 16)) +>N : Symbol(N, Decl(f2.ts, 2, 15)) +>I : Symbol(II, Decl(f2.ts, 5, 18)) + +import { A, A as EA, I as EI } from "f1"; +>A : Symbol(A, Decl(f2.ts, 11, 8)) +>A : Symbol(EA, Decl(f2.ts, 11, 11)) +>EA : Symbol(EA, Decl(f2.ts, 11, 11)) +>I : Symbol(EI, Decl(f2.ts, 11, 20)) +>EI : Symbol(EI, Decl(f2.ts, 11, 20)) + +export {x}; +>x : Symbol(x, Decl(f2.ts, 13, 8)) + +export {x as x1}; +>x : Symbol(x1, Decl(f2.ts, 14, 8)) +>x1 : Symbol(x1, Decl(f2.ts, 14, 8)) + +export {I}; +>I : Symbol(I, Decl(f2.ts, 16, 8)) + +export {I as I1}; +>I : Symbol(I1, Decl(f2.ts, 17, 8)) +>I1 : Symbol(I1, Decl(f2.ts, 17, 8)) + +export {A}; +>A : Symbol(A, Decl(f2.ts, 19, 8)) + +export {A as A1}; +>A : Symbol(A1, Decl(f2.ts, 20, 8)) +>A1 : Symbol(A1, Decl(f2.ts, 20, 8)) + +export {EA}; +>EA : Symbol(EA, Decl(f2.ts, 22, 8)) + +export {EA as EA1}; +>EA : Symbol(EA1, Decl(f2.ts, 23, 8)) +>EA1 : Symbol(EA1, Decl(f2.ts, 23, 8)) + +export {EI }; +>EI : Symbol(EI, Decl(f2.ts, 25, 8)) + +export {EI as EI1}; +>EI : Symbol(EI1, Decl(f2.ts, 26, 8)) +>EI1 : Symbol(EI1, Decl(f2.ts, 26, 8)) + +export {IX}; +>IX : Symbol(IX, Decl(f2.ts, 28, 8)) + +export {IX as IX1}; +>IX : Symbol(IX1, Decl(f2.ts, 29, 8)) +>IX1 : Symbol(IX1, Decl(f2.ts, 29, 8)) + +export {II}; +>II : Symbol(II, Decl(f2.ts, 31, 8)) + +export {II as II1}; +>II : Symbol(II1, Decl(f2.ts, 32, 8)) +>II1 : Symbol(II1, Decl(f2.ts, 32, 8)) + diff --git a/tests/baselines/reference/systemModule17.types b/tests/baselines/reference/systemModule17.types new file mode 100644 index 00000000000..1f0b1b51842 --- /dev/null +++ b/tests/baselines/reference/systemModule17.types @@ -0,0 +1,95 @@ +=== tests/cases/compiler/f1.ts === + + +export class A {} +>A : A + +export interface I {} +>I : I + +=== tests/cases/compiler/f2.ts === + +var x = 1; +>x : number +>1 : number + +interface I { } +>I : I + +namespace N { +>N : typeof N + + export var x = 1; +>x : number +>1 : number + + export interface I { } +>I : I +} + +import IX = N.x; +>IX : number +>N : typeof N +>x : number + +import II = N.I; +>II : any +>N : typeof N +>I : II + +import { A, A as EA, I as EI } from "f1"; +>A : typeof A +>A : typeof A +>EA : typeof A +>I : any +>EI : any + +export {x}; +>x : number + +export {x as x1}; +>x : number +>x1 : number + +export {I}; +>I : any + +export {I as I1}; +>I : any +>I1 : any + +export {A}; +>A : typeof A + +export {A as A1}; +>A : typeof A +>A1 : typeof A + +export {EA}; +>EA : typeof A + +export {EA as EA1}; +>EA : typeof A +>EA1 : typeof A + +export {EI }; +>EI : any + +export {EI as EI1}; +>EI : any +>EI1 : any + +export {IX}; +>IX : number + +export {IX as IX1}; +>IX : number +>IX1 : number + +export {II}; +>II : any + +export {II as II1}; +>II : any +>II1 : any + diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt index 6464366d33d..be5c21f1a0b 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(64,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,79): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. @@ -86,7 +86,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference } var a9e = someGenerics9 `${ undefined }${ { x: 6, z: new Date() } }${ { x: 6, y: '' } }`; - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. !!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt index be8c517d39c..63d04a42b3b 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(63,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. -tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(76,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(76,79): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. @@ -85,7 +85,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference } var a9e = someGenerics9 `${ undefined }${ { x: 6, z: new Date() } }${ { x: 6, y: '' } }`; - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. !!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols index baa4613d26b..9d8b6024e0c 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperatorES6.ts === var x = `abc${ new String("Hi") }def`; >x : Symbol(x, Decl(templateStringWithEmbeddedNewOperatorES6.ts, 0, 3)) ->String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1556, 1)) +>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4236, 1)) diff --git a/tests/baselines/reference/thisBinding2.types b/tests/baselines/reference/thisBinding2.types index 5b6b5213524..99668ca4901 100644 --- a/tests/baselines/reference/thisBinding2.types +++ b/tests/baselines/reference/thisBinding2.types @@ -9,7 +9,7 @@ class C { this.x = (() => { >this.x = (() => { var x = 1; return this.x; })() : number >this.x : number ->this : C +>this : this >x : number >(() => { var x = 1; return this.x; })() : number >(() => { var x = 1; return this.x; }) : () => number @@ -21,14 +21,14 @@ class C { return this.x; >this.x : number ->this : C +>this : this >x : number })(); this.x = function() { >this.x = function() { var x = 1; return this.x; }() : any >this.x : number ->this : C +>this : this >x : number >function() { var x = 1; return this.x; }() : any >function() { var x = 1; return this.x; } : () => any diff --git a/tests/baselines/reference/thisCapture1.types b/tests/baselines/reference/thisCapture1.types index 05eabf5c914..eb4501203ca 100644 --- a/tests/baselines/reference/thisCapture1.types +++ b/tests/baselines/reference/thisCapture1.types @@ -25,7 +25,7 @@ class X { this.y = 0; >this.y = 0 : number >this.y : number ->this : X +>this : this >y : number >0 : number diff --git a/tests/baselines/reference/thisExpressionOfGenericObject.types b/tests/baselines/reference/thisExpressionOfGenericObject.types index 0a8e147f073..f7031d6cf80 100644 --- a/tests/baselines/reference/thisExpressionOfGenericObject.types +++ b/tests/baselines/reference/thisExpressionOfGenericObject.types @@ -9,8 +9,8 @@ class MyClass1 { constructor() { () => this; ->() => this : () => MyClass1 ->this : MyClass1 +>() => this : () => this +>this : this } } diff --git a/tests/baselines/reference/thisInInstanceMemberInitializer.types b/tests/baselines/reference/thisInInstanceMemberInitializer.types index 9c64929ca89..c7fcc69d006 100644 --- a/tests/baselines/reference/thisInInstanceMemberInitializer.types +++ b/tests/baselines/reference/thisInInstanceMemberInitializer.types @@ -3,8 +3,8 @@ class C { >C : C x = this; ->x : C ->this : C +>x : this +>this : this } class D { @@ -12,8 +12,8 @@ class D { >T : T x = this; ->x : D ->this : D +>x : this +>this : this y: T; >y : T diff --git a/tests/baselines/reference/thisInInvalidContexts.errors.txt b/tests/baselines/reference/thisInInvalidContexts.errors.txt index d6f24cbcfdc..76b90ed7c20 100644 --- a/tests/baselines/reference/thisInInvalidContexts.errors.txt +++ b/tests/baselines/reference/thisInInvalidContexts.errors.txt @@ -1,12 +1,13 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(3,16): error TS2334: 'this' cannot be referenced in a static property initializer. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(22,15): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(28,13): error TS2331: 'this' cannot be referenced in a module or namespace body. +tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(36,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(38,25): error TS2507: Type 'any' is not a constructor function type. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(44,9): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(45,9): error TS2332: 'this' cannot be referenced in current location. -==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts (6 errors) ==== +==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts (7 errors) ==== //'this' in static member initializer class ErrClass1 { static t = this; // Error @@ -49,6 +50,8 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContexts.ts(45,9): //'this' as a type argument function genericFunc(x: T) { } genericFunc(undefined); // Should be an error + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. class ErrClass3 extends this { ~~~~ diff --git a/tests/baselines/reference/thisInInvalidContexts.js b/tests/baselines/reference/thisInInvalidContexts.js index 84b96404683..d5ba69ff536 100644 --- a/tests/baselines/reference/thisInInvalidContexts.js +++ b/tests/baselines/reference/thisInInvalidContexts.js @@ -92,7 +92,7 @@ var M; // function fn() { } // Error //'this' as a type argument function genericFunc(x) { } -genericFunc < this > (undefined); // Should be an error +genericFunc(undefined); // Should be an error var ErrClass3 = (function (_super) { __extends(ErrClass3, _super); function ErrClass3() { diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt index df47901d771..2aa474d4cdc 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt @@ -1,13 +1,14 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(3,16): error TS2334: 'this' cannot be referenced in a static property initializer. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(22,15): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(28,13): error TS2331: 'this' cannot be referenced in a module or namespace body. +tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(36,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(38,25): error TS2507: Type 'any' is not a constructor function type. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(44,9): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(45,9): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(48,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. -==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts (7 errors) ==== +==== tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts (8 errors) ==== //'this' in static member initializer class ErrClass1 { static t = this; // Error @@ -50,6 +51,8 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalMod //'this' as a type argument function genericFunc(x: T) { } genericFunc(undefined); // Should be an error + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. class ErrClass3 extends this { ~~~~ diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.js b/tests/baselines/reference/thisInInvalidContextsExternalModule.js index 7de94be9420..7c195964947 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.js +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.js @@ -92,7 +92,7 @@ var M; // function fn() { } // Error //'this' as a type argument function genericFunc(x) { } -genericFunc < this > (undefined); // Should be an error +genericFunc(undefined); // Should be an error var ErrClass3 = (function (_super) { __extends(ErrClass3, _super); function ErrClass3() { diff --git a/tests/baselines/reference/thisInLambda.types b/tests/baselines/reference/thisInLambda.types index ef4d7557abd..aea7fb08bd6 100644 --- a/tests/baselines/reference/thisInLambda.types +++ b/tests/baselines/reference/thisInLambda.types @@ -11,14 +11,14 @@ class Foo { this.x; // 'this' is type 'Foo' >this.x : string ->this : Foo +>this : this >x : string var f = () => this.x; // 'this' should be type 'Foo' as well >f : () => string >() => this.x : () => string >this.x : string ->this : Foo +>this : this >x : string } } @@ -42,8 +42,8 @@ class myCls { >() => { var x = this; } : () => void var x = this; ->x : myCls ->this : myCls +>x : this +>this : this }); }); diff --git a/tests/baselines/reference/thisInObjectLiterals.errors.txt b/tests/baselines/reference/thisInObjectLiterals.errors.txt new file mode 100644 index 00000000000..73300d86d74 --- /dev/null +++ b/tests/baselines/reference/thisInObjectLiterals.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts(7,13): error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type '{ x: this; y: number; }', but here has type '{ x: MyClass; y: number; }'. + + +==== tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts (1 errors) ==== + class MyClass { + t: number; + + fn() { + //type of 'this' in an object literal is the containing scope's this + var t = { x: this, y: this.t }; + var t: { x: MyClass; y: number }; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type '{ x: this; y: number; }', but here has type '{ x: MyClass; y: number; }'. + } + } + + //type of 'this' in an object literal property of a function type is Any + var obj = { + f() { + return this.spaaace; + } + }; + var obj: { f: () => any; }; + \ No newline at end of file diff --git a/tests/baselines/reference/thisInObjectLiterals.symbols b/tests/baselines/reference/thisInObjectLiterals.symbols deleted file mode 100644 index cb351ccd457..00000000000 --- a/tests/baselines/reference/thisInObjectLiterals.symbols +++ /dev/null @@ -1,42 +0,0 @@ -=== tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts === -class MyClass { ->MyClass : Symbol(MyClass, Decl(thisInObjectLiterals.ts, 0, 0)) - - t: number; ->t : Symbol(t, Decl(thisInObjectLiterals.ts, 0, 15)) - - fn() { ->fn : Symbol(fn, Decl(thisInObjectLiterals.ts, 1, 14)) - - //type of 'this' in an object literal is the containing scope's this - var t = { x: this, y: this.t }; ->t : Symbol(t, Decl(thisInObjectLiterals.ts, 5, 11), Decl(thisInObjectLiterals.ts, 6, 11)) ->x : Symbol(x, Decl(thisInObjectLiterals.ts, 5, 17)) ->this : Symbol(MyClass, Decl(thisInObjectLiterals.ts, 0, 0)) ->y : Symbol(y, Decl(thisInObjectLiterals.ts, 5, 26)) ->this.t : Symbol(t, Decl(thisInObjectLiterals.ts, 0, 15)) ->this : Symbol(MyClass, Decl(thisInObjectLiterals.ts, 0, 0)) ->t : Symbol(t, Decl(thisInObjectLiterals.ts, 0, 15)) - - var t: { x: MyClass; y: number }; ->t : Symbol(t, Decl(thisInObjectLiterals.ts, 5, 11), Decl(thisInObjectLiterals.ts, 6, 11)) ->x : Symbol(x, Decl(thisInObjectLiterals.ts, 6, 16)) ->MyClass : Symbol(MyClass, Decl(thisInObjectLiterals.ts, 0, 0)) ->y : Symbol(y, Decl(thisInObjectLiterals.ts, 6, 28)) - } -} - -//type of 'this' in an object literal property of a function type is Any -var obj = { ->obj : Symbol(obj, Decl(thisInObjectLiterals.ts, 11, 3), Decl(thisInObjectLiterals.ts, 16, 3)) - - f() { ->f : Symbol(f, Decl(thisInObjectLiterals.ts, 11, 11)) - - return this.spaaace; - } -}; -var obj: { f: () => any; }; ->obj : Symbol(obj, Decl(thisInObjectLiterals.ts, 11, 3), Decl(thisInObjectLiterals.ts, 16, 3)) ->f : Symbol(f, Decl(thisInObjectLiterals.ts, 16, 10)) - diff --git a/tests/baselines/reference/thisInObjectLiterals.types b/tests/baselines/reference/thisInObjectLiterals.types deleted file mode 100644 index d3853389a9e..00000000000 --- a/tests/baselines/reference/thisInObjectLiterals.types +++ /dev/null @@ -1,47 +0,0 @@ -=== tests/cases/conformance/expressions/thisKeyword/thisInObjectLiterals.ts === -class MyClass { ->MyClass : MyClass - - t: number; ->t : number - - fn() { ->fn : () => void - - //type of 'this' in an object literal is the containing scope's this - var t = { x: this, y: this.t }; ->t : { x: MyClass; y: number; } ->{ x: this, y: this.t } : { x: MyClass; y: number; } ->x : MyClass ->this : MyClass ->y : number ->this.t : number ->this : MyClass ->t : number - - var t: { x: MyClass; y: number }; ->t : { x: MyClass; y: number; } ->x : MyClass ->MyClass : MyClass ->y : number - } -} - -//type of 'this' in an object literal property of a function type is Any -var obj = { ->obj : { f(): any; } ->{ f() { return this.spaaace; }} : { f(): any; } - - f() { ->f : () => any - - return this.spaaace; ->this.spaaace : any ->this : any ->spaaace : any - } -}; -var obj: { f: () => any; }; ->obj : { f(): any; } ->f : () => any - diff --git a/tests/baselines/reference/thisInPropertyBoundDeclarations.symbols b/tests/baselines/reference/thisInPropertyBoundDeclarations.symbols index 6a5f1417cd0..b10113ff43b 100644 --- a/tests/baselines/reference/thisInPropertyBoundDeclarations.symbols +++ b/tests/baselines/reference/thisInPropertyBoundDeclarations.symbols @@ -15,9 +15,9 @@ class Bug { >name : Symbol(name, Decl(thisInPropertyBoundDeclarations.ts, 4, 16)) that.foo(name); ->that.foo : Symbol(foo, Decl(thisInPropertyBoundDeclarations.ts, 7, 6)) +>that.foo : Symbol(Bug.foo, Decl(thisInPropertyBoundDeclarations.ts, 7, 6)) >that : Symbol(that, Decl(thisInPropertyBoundDeclarations.ts, 4, 6)) ->foo : Symbol(foo, Decl(thisInPropertyBoundDeclarations.ts, 7, 6)) +>foo : Symbol(Bug.foo, Decl(thisInPropertyBoundDeclarations.ts, 7, 6)) >name : Symbol(name, Decl(thisInPropertyBoundDeclarations.ts, 4, 16)) } ]; diff --git a/tests/baselines/reference/thisInPropertyBoundDeclarations.types b/tests/baselines/reference/thisInPropertyBoundDeclarations.types index 596632f1691..f871e78d219 100644 --- a/tests/baselines/reference/thisInPropertyBoundDeclarations.types +++ b/tests/baselines/reference/thisInPropertyBoundDeclarations.types @@ -32,7 +32,7 @@ class Bug { this.name = name; >this.name = name : string >this.name : string ->this : Bug +>this : this >name : string >name : string } @@ -110,21 +110,21 @@ class B { >B : B prop1 = this; ->prop1 : B ->this : B +>prop1 : this +>this : this prop2 = () => this; ->prop2 : () => B ->() => this : () => B ->this : B +>prop2 : () => this +>() => this : () => this +>this : this prop3 = () => () => () => () => this; ->prop3 : () => () => () => () => B ->() => () => () => () => this : () => () => () => () => B ->() => () => () => this : () => () => () => B ->() => () => this : () => () => B ->() => this : () => B ->this : B +>prop3 : () => () => () => () => this +>() => () => () => () => this : () => () => () => () => this +>() => () => () => this : () => () => () => this +>() => () => this : () => () => this +>() => this : () => this +>this : this prop4 = ' ' + >prop4 : string @@ -141,34 +141,34 @@ class B { >' ' : string (() => () => () => this); ->(() => () => () => this) : () => () => () => B ->() => () => () => this : () => () => () => B ->() => () => this : () => () => B ->() => this : () => B ->this : B +>(() => () => () => this) : () => () => () => this +>() => () => () => this : () => () => () => this +>() => () => this : () => () => this +>() => this : () => this +>this : this prop5 = { ->prop5 : { a: () => B; } ->{ a: () => { return this; } } : { a: () => B; } +>prop5 : { a: () => this; } +>{ a: () => { return this; } } : { a: () => this; } a: () => { return this; } ->a : () => B ->() => { return this; } : () => B ->this : B +>a : () => this +>() => { return this; } : () => this +>this : this }; prop6 = () => { ->prop6 : () => { a: () => B; } ->() => { return { a: () => { return this; } }; } : () => { a: () => B; } +>prop6 : () => { a: () => this; } +>() => { return { a: () => { return this; } }; } : () => { a: () => this; } return { ->{ a: () => { return this; } } : { a: () => B; } +>{ a: () => { return this; } } : { a: () => this; } a: () => { return this; } ->a : () => B ->() => { return this; } : () => B ->this : B +>a : () => this +>() => { return this; } : () => this +>this : this }; }; diff --git a/tests/baselines/reference/thisTypeErrors.errors.txt b/tests/baselines/reference/thisTypeErrors.errors.txt new file mode 100644 index 00000000000..17b7e0d39b9 --- /dev/null +++ b/tests/baselines/reference/thisTypeErrors.errors.txt @@ -0,0 +1,149 @@ +tests/cases/conformance/types/thisType/thisTypeErrors.ts(1,9): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(2,14): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(3,9): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(5,16): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(5,23): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(6,12): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(11,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(12,14): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(13,18): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(14,23): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(15,15): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(15,22): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(19,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(20,14): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(21,18): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(22,23): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(23,15): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(23,22): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(27,15): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(28,17): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(29,19): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(29,26): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(35,19): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(36,20): error TS2331: 'this' cannot be referenced in a module or namespace body. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(41,14): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(41,21): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(46,23): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(46,30): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(50,18): error TS2526: A 'this' type is available only in a non-static member of a class or interface. +tests/cases/conformance/types/thisType/thisTypeErrors.ts(50,25): error TS2526: A 'this' type is available only in a non-static member of a class or interface. + + +==== tests/cases/conformance/types/thisType/thisTypeErrors.ts (30 errors) ==== + var x1: this; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + var x2: { a: this }; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + var x3: this[]; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + + function f1(x: this): this { + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + var y: this; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + return this; + } + + interface I1 { + a: { x: this }; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + b: { (): this }; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + c: { new (): this }; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + d: { [x: string]: this }; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + e: { f(x: this): this }; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + } + + class C1 { + a: { x: this }; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + b: { (): this }; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + c: { new (): this }; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + d: { [x: string]: this }; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + e: { f(x: this): this }; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + } + + class C2 { + static x: this; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + static y = undefined; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + static foo(x: this): this { + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + return undefined; + } + } + + namespace N1 { + export var x: this; + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + export var y = this; + ~~~~ +!!! error TS2331: 'this' cannot be referenced in a module or namespace body. + } + + class C3 { + x1 = { + g(x: this): this { + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + return undefined; + } + } + f() { + function g(x: this): this { + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + return undefined; + } + let x2 = { + h(x: this): this { + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + ~~~~ +!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. + return undefined; + } + } + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/thisTypeErrors.js b/tests/baselines/reference/thisTypeErrors.js new file mode 100644 index 00000000000..677feb374e1 --- /dev/null +++ b/tests/baselines/reference/thisTypeErrors.js @@ -0,0 +1,104 @@ +//// [thisTypeErrors.ts] +var x1: this; +var x2: { a: this }; +var x3: this[]; + +function f1(x: this): this { + var y: this; + return this; +} + +interface I1 { + a: { x: this }; + b: { (): this }; + c: { new (): this }; + d: { [x: string]: this }; + e: { f(x: this): this }; +} + +class C1 { + a: { x: this }; + b: { (): this }; + c: { new (): this }; + d: { [x: string]: this }; + e: { f(x: this): this }; +} + +class C2 { + static x: this; + static y = undefined; + static foo(x: this): this { + return undefined; + } +} + +namespace N1 { + export var x: this; + export var y = this; +} + +class C3 { + x1 = { + g(x: this): this { + return undefined; + } + } + f() { + function g(x: this): this { + return undefined; + } + let x2 = { + h(x: this): this { + return undefined; + } + } + } +} + + +//// [thisTypeErrors.js] +var x1; +var x2; +var x3; +function f1(x) { + var y; + return this; +} +var C1 = (function () { + function C1() { + } + return C1; +})(); +var C2 = (function () { + function C2() { + } + C2.foo = function (x) { + return undefined; + }; + C2.y = undefined; + return C2; +})(); +var N1; +(function (N1) { + N1.y = this; +})(N1 || (N1 = {})); +var C3 = (function () { + function C3() { + this.x1 = { + g: function (x) { + return undefined; + } + }; + } + C3.prototype.f = function () { + function g(x) { + return undefined; + } + var x2 = { + h: function (x) { + return undefined; + } + }; + }; + return C3; +})(); diff --git a/tests/baselines/reference/thisTypeInClasses.js b/tests/baselines/reference/thisTypeInClasses.js new file mode 100644 index 00000000000..93344fa62cb --- /dev/null +++ b/tests/baselines/reference/thisTypeInClasses.js @@ -0,0 +1,91 @@ +//// [thisTypeInClasses.ts] +class C1 { + x: this; + f(x: this): this { return undefined; } + constructor(x: this) { } +} + +class C2 { + [x: string]: this; +} + +interface Foo { + x: T; + y: this; +} + +class C3 { + a: this[]; + b: [this, this]; + c: this | Date; + d: this & Date; + e: (((this))); + f: (x: this) => this; + g: new (x: this) => this; + h: Foo; + i: Foo this)>; + j: (x: any) => x is this; +} + +declare class C4 { + x: this; + f(x: this): this; +} + +class C5 { + foo() { + let f1 = (x: this): this => this; + let f2 = (x: this) => this; + let f3 = (x: this) => (y: this) => this; + let f4 = (x: this) => { + let g = (y: this) => { + return () => this; + } + return g(this); + } + } + bar() { + let x1 = undefined; + let x2 = undefined as this; + } +} + + +//// [thisTypeInClasses.js] +var C1 = (function () { + function C1(x) { + } + C1.prototype.f = function (x) { return undefined; }; + return C1; +})(); +var C2 = (function () { + function C2() { + } + return C2; +})(); +var C3 = (function () { + function C3() { + } + return C3; +})(); +var C5 = (function () { + function C5() { + } + C5.prototype.foo = function () { + var _this = this; + var f1 = function (x) { return _this; }; + var f2 = function (x) { return _this; }; + var f3 = function (x) { return function (y) { return _this; }; }; + var f4 = function (x) { + var g = function (y) { + return function () { return _this; }; + }; + return g(_this); + }; + }; + C5.prototype.bar = function () { + var x1 = undefined; + var x2 = undefined; + }; + return C5; +})(); diff --git a/tests/baselines/reference/thisTypeInClasses.symbols b/tests/baselines/reference/thisTypeInClasses.symbols new file mode 100644 index 00000000000..6383bb01b8d --- /dev/null +++ b/tests/baselines/reference/thisTypeInClasses.symbols @@ -0,0 +1,140 @@ +=== tests/cases/conformance/types/thisType/thisTypeInClasses.ts === +class C1 { +>C1 : Symbol(C1, Decl(thisTypeInClasses.ts, 0, 0)) + + x: this; +>x : Symbol(x, Decl(thisTypeInClasses.ts, 0, 10)) + + f(x: this): this { return undefined; } +>f : Symbol(f, Decl(thisTypeInClasses.ts, 1, 12)) +>x : Symbol(x, Decl(thisTypeInClasses.ts, 2, 6)) +>undefined : Symbol(undefined) + + constructor(x: this) { } +>x : Symbol(x, Decl(thisTypeInClasses.ts, 3, 16)) +} + +class C2 { +>C2 : Symbol(C2, Decl(thisTypeInClasses.ts, 4, 1)) + + [x: string]: this; +>x : Symbol(x, Decl(thisTypeInClasses.ts, 7, 5)) +} + +interface Foo { +>Foo : Symbol(Foo, Decl(thisTypeInClasses.ts, 8, 1)) +>T : Symbol(T, Decl(thisTypeInClasses.ts, 10, 14)) + + x: T; +>x : Symbol(x, Decl(thisTypeInClasses.ts, 10, 18)) +>T : Symbol(T, Decl(thisTypeInClasses.ts, 10, 14)) + + y: this; +>y : Symbol(y, Decl(thisTypeInClasses.ts, 11, 9)) +} + +class C3 { +>C3 : Symbol(C3, Decl(thisTypeInClasses.ts, 13, 1)) + + a: this[]; +>a : Symbol(a, Decl(thisTypeInClasses.ts, 15, 10)) + + b: [this, this]; +>b : Symbol(b, Decl(thisTypeInClasses.ts, 16, 14)) + + c: this | Date; +>c : Symbol(c, Decl(thisTypeInClasses.ts, 17, 20)) +>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) + + d: this & Date; +>d : Symbol(d, Decl(thisTypeInClasses.ts, 18, 19)) +>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) + + e: (((this))); +>e : Symbol(e, Decl(thisTypeInClasses.ts, 19, 19)) + + f: (x: this) => this; +>f : Symbol(f, Decl(thisTypeInClasses.ts, 20, 18)) +>x : Symbol(x, Decl(thisTypeInClasses.ts, 21, 8)) + + g: new (x: this) => this; +>g : Symbol(g, Decl(thisTypeInClasses.ts, 21, 25)) +>x : Symbol(x, Decl(thisTypeInClasses.ts, 22, 12)) + + h: Foo; +>h : Symbol(h, Decl(thisTypeInClasses.ts, 22, 29)) +>Foo : Symbol(Foo, Decl(thisTypeInClasses.ts, 8, 1)) + + i: Foo this)>; +>i : Symbol(i, Decl(thisTypeInClasses.ts, 23, 17)) +>Foo : Symbol(Foo, Decl(thisTypeInClasses.ts, 8, 1)) + + j: (x: any) => x is this; +>j : Symbol(j, Decl(thisTypeInClasses.ts, 24, 32)) +>x : Symbol(x, Decl(thisTypeInClasses.ts, 25, 8)) +>x : Symbol(x, Decl(thisTypeInClasses.ts, 25, 8)) +} + +declare class C4 { +>C4 : Symbol(C4, Decl(thisTypeInClasses.ts, 26, 1)) + + x: this; +>x : Symbol(x, Decl(thisTypeInClasses.ts, 28, 18)) + + f(x: this): this; +>f : Symbol(f, Decl(thisTypeInClasses.ts, 29, 12)) +>x : Symbol(x, Decl(thisTypeInClasses.ts, 30, 6)) +} + +class C5 { +>C5 : Symbol(C5, Decl(thisTypeInClasses.ts, 31, 1)) + + foo() { +>foo : Symbol(foo, Decl(thisTypeInClasses.ts, 33, 10)) + + let f1 = (x: this): this => this; +>f1 : Symbol(f1, Decl(thisTypeInClasses.ts, 35, 11)) +>x : Symbol(x, Decl(thisTypeInClasses.ts, 35, 18)) +>this : Symbol(C5, Decl(thisTypeInClasses.ts, 31, 1)) +>this : Symbol(C5, Decl(thisTypeInClasses.ts, 31, 1)) + + let f2 = (x: this) => this; +>f2 : Symbol(f2, Decl(thisTypeInClasses.ts, 36, 11)) +>x : Symbol(x, Decl(thisTypeInClasses.ts, 36, 18)) +>this : Symbol(C5, Decl(thisTypeInClasses.ts, 31, 1)) + + let f3 = (x: this) => (y: this) => this; +>f3 : Symbol(f3, Decl(thisTypeInClasses.ts, 37, 11)) +>x : Symbol(x, Decl(thisTypeInClasses.ts, 37, 18)) +>y : Symbol(y, Decl(thisTypeInClasses.ts, 37, 31)) +>this : Symbol(C5, Decl(thisTypeInClasses.ts, 31, 1)) + + let f4 = (x: this) => { +>f4 : Symbol(f4, Decl(thisTypeInClasses.ts, 38, 11)) +>x : Symbol(x, Decl(thisTypeInClasses.ts, 38, 18)) + + let g = (y: this) => { +>g : Symbol(g, Decl(thisTypeInClasses.ts, 39, 15)) +>y : Symbol(y, Decl(thisTypeInClasses.ts, 39, 21)) + + return () => this; +>this : Symbol(C5, Decl(thisTypeInClasses.ts, 31, 1)) + } + return g(this); +>g : Symbol(g, Decl(thisTypeInClasses.ts, 39, 15)) +>this : Symbol(C5, Decl(thisTypeInClasses.ts, 31, 1)) + } + } + bar() { +>bar : Symbol(bar, Decl(thisTypeInClasses.ts, 44, 5)) + + let x1 = undefined; +>x1 : Symbol(x1, Decl(thisTypeInClasses.ts, 46, 11)) +>undefined : Symbol(undefined) + + let x2 = undefined as this; +>x2 : Symbol(x2, Decl(thisTypeInClasses.ts, 47, 11)) +>undefined : Symbol(undefined) + } +} + diff --git a/tests/baselines/reference/thisTypeInClasses.types b/tests/baselines/reference/thisTypeInClasses.types new file mode 100644 index 00000000000..ddfdfb277a9 --- /dev/null +++ b/tests/baselines/reference/thisTypeInClasses.types @@ -0,0 +1,150 @@ +=== tests/cases/conformance/types/thisType/thisTypeInClasses.ts === +class C1 { +>C1 : C1 + + x: this; +>x : this + + f(x: this): this { return undefined; } +>f : (x: this) => this +>x : this +>undefined : undefined + + constructor(x: this) { } +>x : this +} + +class C2 { +>C2 : C2 + + [x: string]: this; +>x : string +} + +interface Foo { +>Foo : Foo +>T : T + + x: T; +>x : T +>T : T + + y: this; +>y : this +} + +class C3 { +>C3 : C3 + + a: this[]; +>a : this[] + + b: [this, this]; +>b : [this, this] + + c: this | Date; +>c : this | Date +>Date : Date + + d: this & Date; +>d : this & Date +>Date : Date + + e: (((this))); +>e : this + + f: (x: this) => this; +>f : (x: this) => this +>x : this + + g: new (x: this) => this; +>g : new (x: this) => this +>x : this + + h: Foo; +>h : Foo +>Foo : Foo + + i: Foo this)>; +>i : Foo this)> +>Foo : Foo + + j: (x: any) => x is this; +>j : (x: any) => x is this +>x : any +>x : any +} + +declare class C4 { +>C4 : C4 + + x: this; +>x : this + + f(x: this): this; +>f : (x: this) => this +>x : this +} + +class C5 { +>C5 : C5 + + foo() { +>foo : () => void + + let f1 = (x: this): this => this; +>f1 : (x: this) => this +>(x: this): this => this : (x: this) => this +>x : this +>this : this +>this : this + + let f2 = (x: this) => this; +>f2 : (x: this) => this +>(x: this) => this : (x: this) => this +>x : this +>this : this + + let f3 = (x: this) => (y: this) => this; +>f3 : (x: this) => (y: this) => this +>(x: this) => (y: this) => this : (x: this) => (y: this) => this +>x : this +>(y: this) => this : (y: this) => this +>y : this +>this : this + + let f4 = (x: this) => { +>f4 : (x: this) => () => this +>(x: this) => { let g = (y: this) => { return () => this; } return g(this); } : (x: this) => () => this +>x : this + + let g = (y: this) => { +>g : (y: this) => () => this +>(y: this) => { return () => this; } : (y: this) => () => this +>y : this + + return () => this; +>() => this : () => this +>this : this + } + return g(this); +>g(this) : () => this +>g : (y: this) => () => this +>this : this + } + } + bar() { +>bar : () => void + + let x1 = undefined; +>x1 : this +>undefined : this +>undefined : undefined + + let x2 = undefined as this; +>x2 : this +>undefined as this : this +>undefined : undefined + } +} + diff --git a/tests/baselines/reference/thisTypeInInterfaces.js b/tests/baselines/reference/thisTypeInInterfaces.js new file mode 100644 index 00000000000..eb521918d33 --- /dev/null +++ b/tests/baselines/reference/thisTypeInInterfaces.js @@ -0,0 +1,32 @@ +//// [thisTypeInInterfaces.ts] +interface I1 { + x: this; + f(x: this): this; +} + +interface I2 { + (x: this): this; + new (x: this): this; + [x: string]: this; +} + +interface Foo { + x: T; + y: this; +} + +interface I3 { + a: this[]; + b: [this, this]; + c: this | Date; + d: this & Date; + e: (((this))); + f: (x: this) => this; + g: new (x: this) => this; + h: Foo; + i: Foo this)>; + j: (x: any) => x is this; +} + + +//// [thisTypeInInterfaces.js] diff --git a/tests/baselines/reference/thisTypeInInterfaces.symbols b/tests/baselines/reference/thisTypeInInterfaces.symbols new file mode 100644 index 00000000000..498fbcc8796 --- /dev/null +++ b/tests/baselines/reference/thisTypeInInterfaces.symbols @@ -0,0 +1,79 @@ +=== tests/cases/conformance/types/thisType/thisTypeInInterfaces.ts === +interface I1 { +>I1 : Symbol(I1, Decl(thisTypeInInterfaces.ts, 0, 0)) + + x: this; +>x : Symbol(x, Decl(thisTypeInInterfaces.ts, 0, 14)) + + f(x: this): this; +>f : Symbol(f, Decl(thisTypeInInterfaces.ts, 1, 12)) +>x : Symbol(x, Decl(thisTypeInInterfaces.ts, 2, 6)) +} + +interface I2 { +>I2 : Symbol(I2, Decl(thisTypeInInterfaces.ts, 3, 1)) + + (x: this): this; +>x : Symbol(x, Decl(thisTypeInInterfaces.ts, 6, 5)) + + new (x: this): this; +>x : Symbol(x, Decl(thisTypeInInterfaces.ts, 7, 9)) + + [x: string]: this; +>x : Symbol(x, Decl(thisTypeInInterfaces.ts, 8, 5)) +} + +interface Foo { +>Foo : Symbol(Foo, Decl(thisTypeInInterfaces.ts, 9, 1)) +>T : Symbol(T, Decl(thisTypeInInterfaces.ts, 11, 14)) + + x: T; +>x : Symbol(x, Decl(thisTypeInInterfaces.ts, 11, 18)) +>T : Symbol(T, Decl(thisTypeInInterfaces.ts, 11, 14)) + + y: this; +>y : Symbol(y, Decl(thisTypeInInterfaces.ts, 12, 9)) +} + +interface I3 { +>I3 : Symbol(I3, Decl(thisTypeInInterfaces.ts, 14, 1)) + + a: this[]; +>a : Symbol(a, Decl(thisTypeInInterfaces.ts, 16, 14)) + + b: [this, this]; +>b : Symbol(b, Decl(thisTypeInInterfaces.ts, 17, 14)) + + c: this | Date; +>c : Symbol(c, Decl(thisTypeInInterfaces.ts, 18, 20)) +>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) + + d: this & Date; +>d : Symbol(d, Decl(thisTypeInInterfaces.ts, 19, 19)) +>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11)) + + e: (((this))); +>e : Symbol(e, Decl(thisTypeInInterfaces.ts, 20, 19)) + + f: (x: this) => this; +>f : Symbol(f, Decl(thisTypeInInterfaces.ts, 21, 18)) +>x : Symbol(x, Decl(thisTypeInInterfaces.ts, 22, 8)) + + g: new (x: this) => this; +>g : Symbol(g, Decl(thisTypeInInterfaces.ts, 22, 25)) +>x : Symbol(x, Decl(thisTypeInInterfaces.ts, 23, 12)) + + h: Foo; +>h : Symbol(h, Decl(thisTypeInInterfaces.ts, 23, 29)) +>Foo : Symbol(Foo, Decl(thisTypeInInterfaces.ts, 9, 1)) + + i: Foo this)>; +>i : Symbol(i, Decl(thisTypeInInterfaces.ts, 24, 17)) +>Foo : Symbol(Foo, Decl(thisTypeInInterfaces.ts, 9, 1)) + + j: (x: any) => x is this; +>j : Symbol(j, Decl(thisTypeInInterfaces.ts, 25, 32)) +>x : Symbol(x, Decl(thisTypeInInterfaces.ts, 26, 8)) +>x : Symbol(x, Decl(thisTypeInInterfaces.ts, 26, 8)) +} + diff --git a/tests/baselines/reference/thisTypeInInterfaces.types b/tests/baselines/reference/thisTypeInInterfaces.types new file mode 100644 index 00000000000..5eadd7c13be --- /dev/null +++ b/tests/baselines/reference/thisTypeInInterfaces.types @@ -0,0 +1,79 @@ +=== tests/cases/conformance/types/thisType/thisTypeInInterfaces.ts === +interface I1 { +>I1 : I1 + + x: this; +>x : this + + f(x: this): this; +>f : (x: this) => this +>x : this +} + +interface I2 { +>I2 : I2 + + (x: this): this; +>x : this + + new (x: this): this; +>x : this + + [x: string]: this; +>x : string +} + +interface Foo { +>Foo : Foo +>T : T + + x: T; +>x : T +>T : T + + y: this; +>y : this +} + +interface I3 { +>I3 : I3 + + a: this[]; +>a : this[] + + b: [this, this]; +>b : [this, this] + + c: this | Date; +>c : this | Date +>Date : Date + + d: this & Date; +>d : this & Date +>Date : Date + + e: (((this))); +>e : this + + f: (x: this) => this; +>f : (x: this) => this +>x : this + + g: new (x: this) => this; +>g : new (x: this) => this +>x : this + + h: Foo; +>h : Foo +>Foo : Foo + + i: Foo this)>; +>i : Foo this)> +>Foo : Foo + + j: (x: any) => x is this; +>j : (x: any) => x is this +>x : any +>x : any +} + diff --git a/tests/baselines/reference/thisTypeInTuples.js b/tests/baselines/reference/thisTypeInTuples.js new file mode 100644 index 00000000000..b80cfded513 --- /dev/null +++ b/tests/baselines/reference/thisTypeInTuples.js @@ -0,0 +1,16 @@ +//// [thisTypeInTuples.ts] +interface Array { + slice(): this; +} + +let t: [number, string] = [42, "hello"]; +let a = t.slice(); +let b = t.slice(1); +let c = t.slice(0, 1); + + +//// [thisTypeInTuples.js] +var t = [42, "hello"]; +var a = t.slice(); +var b = t.slice(1); +var c = t.slice(0, 1); diff --git a/tests/baselines/reference/thisTypeInTuples.symbols b/tests/baselines/reference/thisTypeInTuples.symbols new file mode 100644 index 00000000000..5b9965510a7 --- /dev/null +++ b/tests/baselines/reference/thisTypeInTuples.symbols @@ -0,0 +1,30 @@ +=== tests/cases/conformance/types/thisType/thisTypeInTuples.ts === +interface Array { +>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(thisTypeInTuples.ts, 0, 0)) +>T : Symbol(T, Decl(lib.d.ts, 1007, 16), Decl(thisTypeInTuples.ts, 0, 16)) + + slice(): this; +>slice : Symbol(slice, Decl(lib.d.ts, 1048, 15), Decl(thisTypeInTuples.ts, 0, 20)) +} + +let t: [number, string] = [42, "hello"]; +>t : Symbol(t, Decl(thisTypeInTuples.ts, 4, 3)) + +let a = t.slice(); +>a : Symbol(a, Decl(thisTypeInTuples.ts, 5, 3)) +>t.slice : Symbol(Array.slice, Decl(lib.d.ts, 1048, 15), Decl(thisTypeInTuples.ts, 0, 20)) +>t : Symbol(t, Decl(thisTypeInTuples.ts, 4, 3)) +>slice : Symbol(Array.slice, Decl(lib.d.ts, 1048, 15), Decl(thisTypeInTuples.ts, 0, 20)) + +let b = t.slice(1); +>b : Symbol(b, Decl(thisTypeInTuples.ts, 6, 3)) +>t.slice : Symbol(Array.slice, Decl(lib.d.ts, 1048, 15), Decl(thisTypeInTuples.ts, 0, 20)) +>t : Symbol(t, Decl(thisTypeInTuples.ts, 4, 3)) +>slice : Symbol(Array.slice, Decl(lib.d.ts, 1048, 15), Decl(thisTypeInTuples.ts, 0, 20)) + +let c = t.slice(0, 1); +>c : Symbol(c, Decl(thisTypeInTuples.ts, 7, 3)) +>t.slice : Symbol(Array.slice, Decl(lib.d.ts, 1048, 15), Decl(thisTypeInTuples.ts, 0, 20)) +>t : Symbol(t, Decl(thisTypeInTuples.ts, 4, 3)) +>slice : Symbol(Array.slice, Decl(lib.d.ts, 1048, 15), Decl(thisTypeInTuples.ts, 0, 20)) + diff --git a/tests/baselines/reference/thisTypeInTuples.types b/tests/baselines/reference/thisTypeInTuples.types new file mode 100644 index 00000000000..e0268840317 --- /dev/null +++ b/tests/baselines/reference/thisTypeInTuples.types @@ -0,0 +1,39 @@ +=== tests/cases/conformance/types/thisType/thisTypeInTuples.ts === +interface Array { +>Array : T[] +>T : T + + slice(): this; +>slice : { (start?: number, end?: number): T[]; (): this; } +} + +let t: [number, string] = [42, "hello"]; +>t : [number, string] +>[42, "hello"] : [number, string] +>42 : number +>"hello" : string + +let a = t.slice(); +>a : [number, string] +>t.slice() : [number, string] +>t.slice : { (start?: number, end?: number): (number | string)[]; (): [number, string]; } +>t : [number, string] +>slice : { (start?: number, end?: number): (number | string)[]; (): [number, string]; } + +let b = t.slice(1); +>b : (number | string)[] +>t.slice(1) : (number | string)[] +>t.slice : { (start?: number, end?: number): (number | string)[]; (): [number, string]; } +>t : [number, string] +>slice : { (start?: number, end?: number): (number | string)[]; (): [number, string]; } +>1 : number + +let c = t.slice(0, 1); +>c : (number | string)[] +>t.slice(0, 1) : (number | string)[] +>t.slice : { (start?: number, end?: number): (number | string)[]; (): [number, string]; } +>t : [number, string] +>slice : { (start?: number, end?: number): (number | string)[]; (): [number, string]; } +>0 : number +>1 : number + diff --git a/tests/baselines/reference/throwInEnclosingStatements.types b/tests/baselines/reference/throwInEnclosingStatements.types index f3ae0bacd60..bcff8653d52 100644 --- a/tests/baselines/reference/throwInEnclosingStatements.types +++ b/tests/baselines/reference/throwInEnclosingStatements.types @@ -81,13 +81,13 @@ class C { throw this.value; >this.value : T ->this : C +>this : this >value : T } constructor() { throw this; ->this : C +>this : this } } diff --git a/tests/baselines/reference/topLevel.types b/tests/baselines/reference/topLevel.types index d7ed4a27001..ac1dd1182b9 100644 --- a/tests/baselines/reference/topLevel.types +++ b/tests/baselines/reference/topLevel.types @@ -18,26 +18,26 @@ class Point implements IPoint { >y : any public move(xo:number,yo:number) { ->move : (xo: number, yo: number) => Point +>move : (xo: number, yo: number) => this >xo : number >yo : number this.x+=xo; >this.x+=xo : any >this.x : any ->this : Point +>this : this >x : any >xo : number this.y+=yo; >this.y+=yo : any >this.y : any ->this : Point +>this : this >y : any >yo : number return this; ->this : Point +>this : this } public toString() { >toString : () => string @@ -50,11 +50,11 @@ class Point implements IPoint { >"("+this.x : string >"(" : string >this.x : any ->this : Point +>this : this >x : any >"," : string >this.y : any ->this : Point +>this : this >y : any >")" : string } diff --git a/tests/baselines/reference/topLevelFileModule.js b/tests/baselines/reference/topLevelFileModule.js index 5d655f78397..a6e7a151eb9 100644 --- a/tests/baselines/reference/topLevelFileModule.js +++ b/tests/baselines/reference/topLevelFileModule.js @@ -7,13 +7,13 @@ export var x: number; export declare var y: number; //// [foo_1.ts] -import foo = require("vs/foo_0"); -import fum = require("vs/fum"); +import foo = require("./vs/foo_0"); +import fum = require("./vs/fum"); var z = foo.x + fum.y; //// [foo_0.js] //// [foo_1.js] -var foo = require("vs/foo_0"); -var fum = require("vs/fum"); +var foo = require("./vs/foo_0"); +var fum = require("./vs/fum"); var z = foo.x + fum.y; diff --git a/tests/baselines/reference/topLevelFileModule.symbols b/tests/baselines/reference/topLevelFileModule.symbols index a677274ec07..d3961c0fa72 100644 --- a/tests/baselines/reference/topLevelFileModule.symbols +++ b/tests/baselines/reference/topLevelFileModule.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/externalModules/foo_1.ts === -import foo = require("vs/foo_0"); +import foo = require("./vs/foo_0"); >foo : Symbol(foo, Decl(foo_1.ts, 0, 0)) -import fum = require("vs/fum"); ->fum : Symbol(fum, Decl(foo_1.ts, 0, 33)) +import fum = require("./vs/fum"); +>fum : Symbol(fum, Decl(foo_1.ts, 0, 35)) var z = foo.x + fum.y; >z : Symbol(z, Decl(foo_1.ts, 2, 3)) @@ -11,7 +11,7 @@ var z = foo.x + fum.y; >foo : Symbol(foo, Decl(foo_1.ts, 0, 0)) >x : Symbol(foo.x, Decl(foo_0.ts, 0, 10)) >fum.y : Symbol(fum.y, Decl(fum.d.ts, 0, 18)) ->fum : Symbol(fum, Decl(foo_1.ts, 0, 33)) +>fum : Symbol(fum, Decl(foo_1.ts, 0, 35)) >y : Symbol(fum.y, Decl(fum.d.ts, 0, 18)) === tests/cases/conformance/externalModules/vs/foo_0.ts === diff --git a/tests/baselines/reference/topLevelFileModule.types b/tests/baselines/reference/topLevelFileModule.types index 033dbf197d3..2706fd75670 100644 --- a/tests/baselines/reference/topLevelFileModule.types +++ b/tests/baselines/reference/topLevelFileModule.types @@ -1,8 +1,8 @@ === tests/cases/conformance/externalModules/foo_1.ts === -import foo = require("vs/foo_0"); +import foo = require("./vs/foo_0"); >foo : typeof foo -import fum = require("vs/fum"); +import fum = require("./vs/fum"); >fum : typeof fum var z = foo.x + fum.y; diff --git a/tests/baselines/reference/topLevelModuleDeclarationAndFile.errors.txt b/tests/baselines/reference/topLevelModuleDeclarationAndFile.errors.txt index de343803529..cb555b7a603 100644 --- a/tests/baselines/reference/topLevelModuleDeclarationAndFile.errors.txt +++ b/tests/baselines/reference/topLevelModuleDeclarationAndFile.errors.txt @@ -9,7 +9,7 @@ tests/cases/conformance/externalModules/foo_2.ts(3,14): error TS2339: Property ' !!! error TS2339: Property 'x' does not exist on type 'typeof "vs/foo_0"'. var z2 = foo.y() + 10; // Should resolve -==== tests/cases/conformance/externalModules/vs/foo_0.ts (0 errors) ==== +==== tests/cases/conformance/externalModules/vs/foo_0/index.ts (0 errors) ==== export var x: number = 42; ==== tests/cases/conformance/externalModules/foo_1.ts (0 errors) ==== diff --git a/tests/baselines/reference/topLevelModuleDeclarationAndFile.js b/tests/baselines/reference/topLevelModuleDeclarationAndFile.js index c47de516108..e223a293d7c 100644 --- a/tests/baselines/reference/topLevelModuleDeclarationAndFile.js +++ b/tests/baselines/reference/topLevelModuleDeclarationAndFile.js @@ -1,6 +1,6 @@ //// [tests/cases/conformance/externalModules/topLevelModuleDeclarationAndFile.ts] //// -//// [foo_0.ts] +//// [index.ts] export var x: number = 42; //// [foo_1.ts] @@ -17,8 +17,6 @@ var z2 = foo.y() + 10; // Should resolve //// [foo_1.js] -//// [foo_0.js] -exports.x = 42; //// [foo_2.js] /// var foo = require("vs/foo_0"); diff --git a/tests/baselines/reference/tsxAttributeResolution6.js b/tests/baselines/reference/tsxAttributeResolution6.js index f4af0ba875a..5d6ad1e20c6 100644 --- a/tests/baselines/reference/tsxAttributeResolution6.js +++ b/tests/baselines/reference/tsxAttributeResolution6.js @@ -20,10 +20,10 @@ declare module JSX { //// [tsxAttributeResolution6.jsx] // Error -; +; ; ; // OK -; +; ; -; +; diff --git a/tests/baselines/reference/tsxAttributeResolution8.symbols b/tests/baselines/reference/tsxAttributeResolution8.symbols index 9bb09c6cd85..85db1985cc2 100644 --- a/tests/baselines/reference/tsxAttributeResolution8.symbols +++ b/tests/baselines/reference/tsxAttributeResolution8.symbols @@ -20,4 +20,5 @@ var x: any; // Should be OK >test1 : Symbol(JSX.IntrinsicElements.test1, Decl(tsxAttributeResolution8.tsx, 2, 30)) +>x : Symbol(x, Decl(tsxAttributeResolution8.tsx, 7, 3)) diff --git a/tests/baselines/reference/tsxElementResolution13.types b/tests/baselines/reference/tsxElementResolution13.types index cd6265de091..613835f3211 100644 --- a/tests/baselines/reference/tsxElementResolution13.types +++ b/tests/baselines/reference/tsxElementResolution13.types @@ -25,4 +25,5 @@ var obj1: Obj1; > : JSX.Element >obj1 : Obj1 >x : any +>10 : number diff --git a/tests/baselines/reference/tsxElementResolution14.types b/tests/baselines/reference/tsxElementResolution14.types index ef03187d28e..80f9555030f 100644 --- a/tests/baselines/reference/tsxElementResolution14.types +++ b/tests/baselines/reference/tsxElementResolution14.types @@ -20,4 +20,5 @@ var obj1: Obj1; > : JSX.Element >obj1 : Obj1 >x : any +>10 : number diff --git a/tests/baselines/reference/tsxElementResolution9.types b/tests/baselines/reference/tsxElementResolution9.types index 525e4600b2e..6725bd216bd 100644 --- a/tests/baselines/reference/tsxElementResolution9.types +++ b/tests/baselines/reference/tsxElementResolution9.types @@ -67,4 +67,5 @@ var Obj3: Obj3; > : JSX.Element >Obj3 : Obj3 >x : any +>42 : number diff --git a/tests/baselines/reference/tsxEmit1.symbols b/tests/baselines/reference/tsxEmit1.symbols index b7c8cde024a..aaca98ae9db 100644 --- a/tests/baselines/reference/tsxEmit1.symbols +++ b/tests/baselines/reference/tsxEmit1.symbols @@ -52,6 +52,7 @@ var selfClosed7 =
; >selfClosed7 : Symbol(selfClosed7, Decl(tsxEmit1.tsx, 14, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) >x : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) >y : Symbol(unknown) var openClosed1 =
; @@ -69,6 +70,7 @@ var openClosed3 =
{p}
; >openClosed3 : Symbol(openClosed3, Decl(tsxEmit1.tsx, 18, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) >n : Symbol(unknown) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) var openClosed4 =
{p < p}
; @@ -146,6 +148,7 @@ var whitespace1 =
; var whitespace2 =
{p}
; >whitespace2 : Symbol(whitespace2, Decl(tsxEmit1.tsx, 35, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) var whitespace3 =
@@ -153,6 +156,8 @@ var whitespace3 =
>div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) {p} +>p : Symbol(p, Decl(tsxEmit1.tsx, 7, 3)) +
; >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit1.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxEmit1.types b/tests/baselines/reference/tsxEmit1.types index 667ec113337..c34896b08ad 100644 --- a/tests/baselines/reference/tsxEmit1.types +++ b/tests/baselines/reference/tsxEmit1.types @@ -45,6 +45,7 @@ var selfClosed5 =
; >
: JSX.Element >div : any >x : any +>0 : number >y : any var selfClosed6 =
; @@ -52,6 +53,7 @@ var selfClosed6 =
; >
: JSX.Element >div : any >x : any +>"1" : string >y : any var selfClosed7 =
; @@ -113,8 +115,8 @@ class SomeClass { >rewrites1 : JSX.Element >
{() => this}
: JSX.Element >div : any ->() => this : () => SomeClass ->this : SomeClass +>() => this : () => this +>this : this >div : any var rewrites2 =
{[p, ...p, p]}
; @@ -141,8 +143,8 @@ class SomeClass { >
this}>
: JSX.Element >div : any >a : any ->() => this : () => SomeClass ->this : SomeClass +>() => this : () => this +>this : this >div : any var rewrites5 =
; diff --git a/tests/baselines/reference/tsxEmit2.symbols b/tests/baselines/reference/tsxEmit2.symbols index fd568953493..5da1b16ae44 100644 --- a/tests/baselines/reference/tsxEmit2.symbols +++ b/tests/baselines/reference/tsxEmit2.symbols @@ -21,29 +21,43 @@ var p1, p2, p3; var spreads1 =
{p2}
; >spreads1 : Symbol(spreads1, Decl(tsxEmit2.tsx, 8, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) +>p1 : Symbol(p1, Decl(tsxEmit2.tsx, 7, 3)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) var spreads2 =
{p2}
; >spreads2 : Symbol(spreads2, Decl(tsxEmit2.tsx, 9, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) +>p1 : Symbol(p1, Decl(tsxEmit2.tsx, 7, 3)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) var spreads3 =
{p2}
; >spreads3 : Symbol(spreads3, Decl(tsxEmit2.tsx, 10, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) >x : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxEmit2.tsx, 7, 11)) +>p1 : Symbol(p1, Decl(tsxEmit2.tsx, 7, 3)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) var spreads4 =
{p2}
; >spreads4 : Symbol(spreads4, Decl(tsxEmit2.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) +>p1 : Symbol(p1, Decl(tsxEmit2.tsx, 7, 3)) >x : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxEmit2.tsx, 7, 11)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) var spreads5 =
{p2}
; >spreads5 : Symbol(spreads5, Decl(tsxEmit2.tsx, 12, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) >x : Symbol(unknown) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) +>p1 : Symbol(p1, Decl(tsxEmit2.tsx, 7, 3)) >y : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxEmit2.tsx, 7, 11)) +>p2 : Symbol(p2, Decl(tsxEmit2.tsx, 7, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxEmit2.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxExternalModuleEmit2.symbols b/tests/baselines/reference/tsxExternalModuleEmit2.symbols index 137e9befa56..ff5fdc49171 100644 --- a/tests/baselines/reference/tsxExternalModuleEmit2.symbols +++ b/tests/baselines/reference/tsxExternalModuleEmit2.symbols @@ -20,11 +20,13 @@ declare var Foo, React; ; >Foo : Symbol(Foo, Decl(app.tsx, 1, 11)) >handler : Symbol(unknown) +>Main : Symbol(Main, Decl(app.tsx, 0, 6)) >Foo : Symbol(Foo, Decl(app.tsx, 1, 11)) // Should see mod_1['default'] in emit here ; >Foo : Symbol(Foo, Decl(app.tsx, 1, 11)) +>Main : Symbol(Main, Decl(app.tsx, 0, 6)) >Foo : Symbol(Foo, Decl(app.tsx, 1, 11)) diff --git a/tests/baselines/reference/tsxGenericArrowFunctionParsing.js b/tests/baselines/reference/tsxGenericArrowFunctionParsing.js index f493347ca9c..ece48831f8e 100644 --- a/tests/baselines/reference/tsxGenericArrowFunctionParsing.js +++ b/tests/baselines/reference/tsxGenericArrowFunctionParsing.js @@ -42,5 +42,5 @@ x3(); var x4 = () => ; x4.isElement; // This is an element -var x5 = () => ; +var x5 = () => ; x5.isElement; diff --git a/tests/baselines/reference/tsxParseTests2.js b/tests/baselines/reference/tsxParseTests2.js new file mode 100644 index 00000000000..c179d75776a --- /dev/null +++ b/tests/baselines/reference/tsxParseTests2.js @@ -0,0 +1,11 @@ +//// [tsxParseTests2.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { div; span; } +} + +var x =
; + + +//// [tsxParseTests2.jsx] +var x =
; diff --git a/tests/baselines/reference/tsxParseTests2.symbols b/tests/baselines/reference/tsxParseTests2.symbols new file mode 100644 index 00000000000..17b612df786 --- /dev/null +++ b/tests/baselines/reference/tsxParseTests2.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/jsx/tsxParseTests2.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxParseTests2.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxParseTests2.tsx, 0, 20)) + + interface IntrinsicElements { div; span; } +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxParseTests2.tsx, 1, 22)) +>div : Symbol(div, Decl(tsxParseTests2.tsx, 2, 30)) +>span : Symbol(span, Decl(tsxParseTests2.tsx, 2, 35)) +} + +var x =
; +>x : Symbol(x, Decl(tsxParseTests2.tsx, 5, 3)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxParseTests2.tsx, 2, 30)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(tsxParseTests2.tsx, 2, 30)) + diff --git a/tests/baselines/reference/tsxParseTests2.types b/tests/baselines/reference/tsxParseTests2.types new file mode 100644 index 00000000000..5714a4d3483 --- /dev/null +++ b/tests/baselines/reference/tsxParseTests2.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/jsx/tsxParseTests2.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { div; span; } +>IntrinsicElements : IntrinsicElements +>div : any +>span : any +} + +var x =
; +>x : JSX.Element +>
: JSX.Element +>div : any +>div : any + diff --git a/tests/baselines/reference/tsxPreserveEmit1.js b/tests/baselines/reference/tsxPreserveEmit1.js new file mode 100644 index 00000000000..80aeef6b297 --- /dev/null +++ b/tests/baselines/reference/tsxPreserveEmit1.js @@ -0,0 +1,32 @@ +//// [tests/cases/conformance/jsx/tsxPreserveEmit1.tsx] //// + +//// [react.d.ts] + +declare module 'react' { + var x: any; + export = x; +} + +declare module ReactRouter { + var Route: any; + interface Thing { } +} +declare module 'react-router' { + export = ReactRouter; +} + +//// [test.tsx] +// Should emit 'react-router' in the AMD dependency list +import React = require('react'); +import ReactRouter = require('react-router'); + +import Route = ReactRouter.Route; + +var routes = ; + + +//// [test.jsx] +define(["require", "exports", 'react-router'], function (require, exports, ReactRouter) { + var Route = ReactRouter.Route; + var routes = ; +}); diff --git a/tests/baselines/reference/tsxPreserveEmit1.symbols b/tests/baselines/reference/tsxPreserveEmit1.symbols new file mode 100644 index 00000000000..6dcf4d9ac49 --- /dev/null +++ b/tests/baselines/reference/tsxPreserveEmit1.symbols @@ -0,0 +1,41 @@ +=== tests/cases/conformance/jsx/test.tsx === +// Should emit 'react-router' in the AMD dependency list +import React = require('react'); +>React : Symbol(React, Decl(test.tsx, 0, 0)) + +import ReactRouter = require('react-router'); +>ReactRouter : Symbol(ReactRouter, Decl(test.tsx, 1, 32)) + +import Route = ReactRouter.Route; +>Route : Symbol(Route, Decl(test.tsx, 2, 45)) +>ReactRouter : Symbol(ReactRouter, Decl(react.d.ts, 4, 1)) +>Route : Symbol(ReactRouter.Route, Decl(react.d.ts, 7, 4)) + +var routes = ; +>routes : Symbol(routes, Decl(test.tsx, 6, 3)) +>Route : Symbol(Route, Decl(test.tsx, 2, 45)) + +=== tests/cases/conformance/jsx/react.d.ts === + +declare module 'react' { + var x: any; +>x : Symbol(x, Decl(react.d.ts, 2, 4)) + + export = x; +>x : Symbol(x, Decl(react.d.ts, 2, 4)) +} + +declare module ReactRouter { +>ReactRouter : Symbol(ReactRouter, Decl(react.d.ts, 4, 1)) + + var Route: any; +>Route : Symbol(Route, Decl(react.d.ts, 7, 4)) + + interface Thing { } +>Thing : Symbol(Thing, Decl(react.d.ts, 7, 16)) +} +declare module 'react-router' { + export = ReactRouter; +>ReactRouter : Symbol(ReactRouter, Decl(react.d.ts, 4, 1)) +} + diff --git a/tests/baselines/reference/tsxPreserveEmit1.types b/tests/baselines/reference/tsxPreserveEmit1.types new file mode 100644 index 00000000000..ea64e2d2e94 --- /dev/null +++ b/tests/baselines/reference/tsxPreserveEmit1.types @@ -0,0 +1,42 @@ +=== tests/cases/conformance/jsx/test.tsx === +// Should emit 'react-router' in the AMD dependency list +import React = require('react'); +>React : any + +import ReactRouter = require('react-router'); +>ReactRouter : typeof ReactRouter + +import Route = ReactRouter.Route; +>Route : any +>ReactRouter : typeof ReactRouter +>Route : any + +var routes = ; +>routes : any +> : any +>Route : any + +=== tests/cases/conformance/jsx/react.d.ts === + +declare module 'react' { + var x: any; +>x : any + + export = x; +>x : any +} + +declare module ReactRouter { +>ReactRouter : typeof ReactRouter + + var Route: any; +>Route : any + + interface Thing { } +>Thing : Thing +} +declare module 'react-router' { + export = ReactRouter; +>ReactRouter : typeof ReactRouter +} + diff --git a/tests/baselines/reference/tsxReactEmit1.js b/tests/baselines/reference/tsxReactEmit1.js index f1799e5bb77..260bd9cd228 100644 --- a/tests/baselines/reference/tsxReactEmit1.js +++ b/tests/baselines/reference/tsxReactEmit1.js @@ -69,6 +69,6 @@ var SomeClass = (function () { }; return SomeClass; })(); -var whitespace1 = React.createElement("div", null); -var whitespace2 = React.createElement("div", null, p); +var whitespace1 = React.createElement("div", null, " "); +var whitespace2 = React.createElement("div", null, " ", p, " "); var whitespace3 = React.createElement("div", null, p); diff --git a/tests/baselines/reference/tsxReactEmit1.symbols b/tests/baselines/reference/tsxReactEmit1.symbols index 665c6a0271f..4149142dd82 100644 --- a/tests/baselines/reference/tsxReactEmit1.symbols +++ b/tests/baselines/reference/tsxReactEmit1.symbols @@ -54,6 +54,7 @@ var selfClosed7 =
; >selfClosed7 : Symbol(selfClosed7, Decl(tsxReactEmit1.tsx, 15, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >x : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) >y : Symbol(unknown) >b : Symbol(unknown) @@ -72,6 +73,7 @@ var openClosed3 =
{p}
; >openClosed3 : Symbol(openClosed3, Decl(tsxReactEmit1.tsx, 19, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) >n : Symbol(unknown) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var openClosed4 =
{p < p}
; @@ -150,6 +152,7 @@ var whitespace1 =
; var whitespace2 =
{p}
; >whitespace2 : Symbol(whitespace2, Decl(tsxReactEmit1.tsx, 36, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) var whitespace3 =
@@ -157,6 +160,8 @@ var whitespace3 =
>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) {p} +>p : Symbol(p, Decl(tsxReactEmit1.tsx, 8, 3)) +
; >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit1.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxReactEmit1.types b/tests/baselines/reference/tsxReactEmit1.types index 0b6e03c5742..4afe4be01dc 100644 --- a/tests/baselines/reference/tsxReactEmit1.types +++ b/tests/baselines/reference/tsxReactEmit1.types @@ -47,6 +47,7 @@ var selfClosed5 =
; >
: JSX.Element >div : any >x : any +>0 : number >y : any var selfClosed6 =
; @@ -54,6 +55,7 @@ var selfClosed6 =
; >
: JSX.Element >div : any >x : any +>"1" : string >y : any var selfClosed7 =
; @@ -117,8 +119,8 @@ class SomeClass { >rewrites1 : JSX.Element >
{() => this}
: JSX.Element >div : any ->() => this : () => SomeClass ->this : SomeClass +>() => this : () => this +>this : this >div : any var rewrites2 =
{[p, ...p, p]}
; @@ -145,8 +147,8 @@ class SomeClass { >
this}>
: JSX.Element >div : any >a : any ->() => this : () => SomeClass ->this : SomeClass +>() => this : () => this +>this : this >div : any var rewrites5 =
; diff --git a/tests/baselines/reference/tsxReactEmit2.symbols b/tests/baselines/reference/tsxReactEmit2.symbols index 7805a16363e..051f7588f25 100644 --- a/tests/baselines/reference/tsxReactEmit2.symbols +++ b/tests/baselines/reference/tsxReactEmit2.symbols @@ -23,29 +23,43 @@ var p1, p2, p3; var spreads1 =
{p2}
; >spreads1 : Symbol(spreads1, Decl(tsxReactEmit2.tsx, 9, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) +>p1 : Symbol(p1, Decl(tsxReactEmit2.tsx, 8, 3)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads2 =
{p2}
; >spreads2 : Symbol(spreads2, Decl(tsxReactEmit2.tsx, 10, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) +>p1 : Symbol(p1, Decl(tsxReactEmit2.tsx, 8, 3)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads3 =
{p2}
; >spreads3 : Symbol(spreads3, Decl(tsxReactEmit2.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 8, 11)) +>p1 : Symbol(p1, Decl(tsxReactEmit2.tsx, 8, 3)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads4 =
{p2}
; >spreads4 : Symbol(spreads4, Decl(tsxReactEmit2.tsx, 12, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) +>p1 : Symbol(p1, Decl(tsxReactEmit2.tsx, 8, 3)) >x : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 8, 11)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) var spreads5 =
{p2}
; >spreads5 : Symbol(spreads5, Decl(tsxReactEmit2.tsx, 13, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) >x : Symbol(unknown) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) +>p1 : Symbol(p1, Decl(tsxReactEmit2.tsx, 8, 3)) >y : Symbol(unknown) +>p3 : Symbol(p3, Decl(tsxReactEmit2.tsx, 8, 11)) +>p2 : Symbol(p2, Decl(tsxReactEmit2.tsx, 8, 7)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmit2.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxReactEmit3.js b/tests/baselines/reference/tsxReactEmit3.js index 1a6ba037230..23910548534 100644 --- a/tests/baselines/reference/tsxReactEmit3.js +++ b/tests/baselines/reference/tsxReactEmit3.js @@ -8,4 +8,4 @@ declare var Foo, Bar, baz; q s ; //// [tsxReactEmit3.js] -React.createElement(Foo, null, React.createElement(Bar, null, "q "), React.createElement(Bar, null), "s ", React.createElement(Bar, null), React.createElement(Bar, null)); +React.createElement(Foo, null, " ", React.createElement(Bar, null, " q "), " ", React.createElement(Bar, null), " s ", React.createElement(Bar, null), React.createElement(Bar, null)); diff --git a/tests/baselines/reference/tsxReactEmit5.js b/tests/baselines/reference/tsxReactEmit5.js new file mode 100644 index 00000000000..f6a7eeb72a1 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit5.js @@ -0,0 +1,29 @@ +//// [tests/cases/conformance/jsx/tsxReactEmit5.tsx] //// + +//// [file.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +//// [test.d.ts] +export var React; + +//// [react-consumer.tsx] +import {React} from "./test"; +// Should emit test_1.React.createElement +// and React.__spread +var foo; +var spread1 =
; + + +//// [file.js] +//// [react-consumer.js] +var test_1 = require("./test"); +// Should emit test_1.React.createElement +// and React.__spread +var foo; +var spread1 = test_1.React.createElement("div", test_1.React.__spread({x: ''}, foo, {y: ''})); diff --git a/tests/baselines/reference/tsxReactEmit5.symbols b/tests/baselines/reference/tsxReactEmit5.symbols new file mode 100644 index 00000000000..3e0e1790676 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit5.symbols @@ -0,0 +1,36 @@ +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : Symbol(JSX, Decl(file.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(file.tsx, 1, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(file.tsx, 2, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(file.tsx, 4, 3)) + } +} + +=== tests/cases/conformance/jsx/test.d.ts === +export var React; +>React : Symbol(React, Decl(test.d.ts, 0, 10)) + +=== tests/cases/conformance/jsx/react-consumer.tsx === +import {React} from "./test"; +>React : Symbol(React, Decl(react-consumer.tsx, 0, 8)) + +// Should emit test_1.React.createElement +// and React.__spread +var foo; +>foo : Symbol(foo, Decl(react-consumer.tsx, 3, 3)) + +var spread1 =
; +>spread1 : Symbol(spread1, Decl(react-consumer.tsx, 4, 3)) +>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 2, 22)) +>x : Symbol(unknown) +>foo : Symbol(foo, Decl(react-consumer.tsx, 3, 3)) +>y : Symbol(unknown) + diff --git a/tests/baselines/reference/tsxReactEmit5.types b/tests/baselines/reference/tsxReactEmit5.types new file mode 100644 index 00000000000..fb1c6594f30 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit5.types @@ -0,0 +1,37 @@ +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +=== tests/cases/conformance/jsx/test.d.ts === +export var React; +>React : any + +=== tests/cases/conformance/jsx/react-consumer.tsx === +import {React} from "./test"; +>React : any + +// Should emit test_1.React.createElement +// and React.__spread +var foo; +>foo : any + +var spread1 =
; +>spread1 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>foo : any +>y : any + diff --git a/tests/baselines/reference/tsxReactEmit6.js b/tests/baselines/reference/tsxReactEmit6.js new file mode 100644 index 00000000000..d20ef7051e0 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit6.js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/jsx/tsxReactEmit6.tsx] //// + +//// [file.tsx] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +//// [react-consumer.tsx] +namespace M { + export var React: any; +} + +namespace M { + // Should emit M.React.createElement + // and M.React.__spread + var foo; + var spread1 =
; +} + + +//// [file.js] +//// [react-consumer.js] +var M; +(function (M) { +})(M || (M = {})); +var M; +(function (M) { + // Should emit M.React.createElement + // and M.React.__spread + var foo; + var spread1 = M.React.createElement("div", M.React.__spread({x: ''}, foo, {y: ''})); +})(M || (M = {})); diff --git a/tests/baselines/reference/tsxReactEmit6.symbols b/tests/baselines/reference/tsxReactEmit6.symbols new file mode 100644 index 00000000000..fd717ee4a5b --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit6.symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : Symbol(JSX, Decl(file.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(file.tsx, 1, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(file.tsx, 2, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(file.tsx, 4, 3)) + } +} + +=== tests/cases/conformance/jsx/react-consumer.tsx === +namespace M { +>M : Symbol(M, Decl(react-consumer.tsx, 0, 0), Decl(react-consumer.tsx, 2, 1)) + + export var React: any; +>React : Symbol(React, Decl(react-consumer.tsx, 1, 11)) +} + +namespace M { +>M : Symbol(M, Decl(react-consumer.tsx, 0, 0), Decl(react-consumer.tsx, 2, 1)) + + // Should emit M.React.createElement + // and M.React.__spread + var foo; +>foo : Symbol(foo, Decl(react-consumer.tsx, 7, 4)) + + var spread1 =
; +>spread1 : Symbol(spread1, Decl(react-consumer.tsx, 8, 4)) +>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 2, 22)) +>x : Symbol(unknown) +>foo : Symbol(foo, Decl(react-consumer.tsx, 7, 4)) +>y : Symbol(unknown) +} + diff --git a/tests/baselines/reference/tsxReactEmit6.types b/tests/baselines/reference/tsxReactEmit6.types new file mode 100644 index 00000000000..1b16b84fcc7 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmit6.types @@ -0,0 +1,41 @@ +=== tests/cases/conformance/jsx/file.tsx === + +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} + +=== tests/cases/conformance/jsx/react-consumer.tsx === +namespace M { +>M : typeof M + + export var React: any; +>React : any +} + +namespace M { +>M : typeof M + + // Should emit M.React.createElement + // and M.React.__spread + var foo; +>foo : any + + var spread1 =
; +>spread1 : JSX.Element +>
: JSX.Element +>div : any +>x : any +>foo : any +>y : any +} + diff --git a/tests/baselines/reference/tsxReactEmitEntities.js b/tests/baselines/reference/tsxReactEmitEntities.js new file mode 100644 index 00000000000..7517c85fc73 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitEntities.js @@ -0,0 +1,14 @@ +//// [tsxReactEmitEntities.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +
Dot goes here: · ¬AnEntity;
; + + +//// [tsxReactEmitEntities.js] +React.createElement("div", null, "Dot goes here: · ¬AnEntity; "); diff --git a/tests/baselines/reference/tsxReactEmitEntities.symbols b/tests/baselines/reference/tsxReactEmitEntities.symbols new file mode 100644 index 00000000000..7de35241a3a --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitEntities.symbols @@ -0,0 +1,21 @@ +=== tests/cases/conformance/jsx/tsxReactEmitEntities.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxReactEmitEntities.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxReactEmitEntities.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxReactEmitEntities.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxReactEmitEntities.tsx, 3, 3)) + } +} +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmitEntities.tsx, 6, 11)) + +
Dot goes here: · ¬AnEntity;
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitEntities.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitEntities.tsx, 1, 22)) + diff --git a/tests/baselines/reference/tsxReactEmitEntities.types b/tests/baselines/reference/tsxReactEmitEntities.types new file mode 100644 index 00000000000..e1c9cb6e6bf --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitEntities.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/jsx/tsxReactEmitEntities.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} +declare var React: any; +>React : any + +
Dot goes here: · ¬AnEntity;
; +>
Dot goes here: · ¬AnEntity;
: JSX.Element +>div : any +>div : any + diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.js b/tests/baselines/reference/tsxReactEmitWhitespace.js index a124ce73312..a1b5894106f 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.js +++ b/tests/baselines/reference/tsxReactEmitWhitespace.js @@ -57,17 +57,17 @@ var p = 0; // WHITESPACE, DO NOT RUN 'FORMAT DOCUMENT' ON IT var p = 0; // Emit " " -React.createElement("div", null); +React.createElement("div", null, " "); // Emit " ", p, " " -React.createElement("div", null, p); +React.createElement("div", null, " ", p, " "); // Emit only p React.createElement("div", null, p); // Emit only p React.createElement("div", null, p); // Emit " 3" -React.createElement("div", null, "3"); +React.createElement("div", null, " 3"); // Emit " 3 " -React.createElement("div", null, "3 "); +React.createElement("div", null, " 3 "); // Emit "3" React.createElement("div", null, "3"); // Emit no args diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.symbols b/tests/baselines/reference/tsxReactEmitWhitespace.symbols index 96b902372b7..3aa3f0d0f8a 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.symbols +++ b/tests/baselines/reference/tsxReactEmitWhitespace.symbols @@ -29,6 +29,7 @@ var p = 0; // Emit " ", p, " "
{p}
; >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) +>p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 11, 3)) >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) // Emit only p @@ -36,6 +37,8 @@ var p = 0; >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) {p} +>p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 11, 3)) +
; >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) @@ -44,6 +47,8 @@ var p = 0; >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) {p} +>p : Symbol(p, Decl(tsxReactEmitWhitespace.tsx, 11, 3)) +
; >div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace.tsx, 1, 22)) diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.types b/tests/baselines/reference/tsxReactEmitWhitespace.types index 603dc4ca6c1..4622aef1991 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.types +++ b/tests/baselines/reference/tsxReactEmitWhitespace.types @@ -32,7 +32,7 @@ var p = 0;
{p}
; >
{p}
: JSX.Element >div : any ->p : any +>p : number >div : any // Emit only p @@ -41,7 +41,7 @@ var p = 0; >div : any {p} ->p : any +>p : number
; >div : any @@ -52,7 +52,7 @@ var p = 0; >div : any {p} ->p : any +>p : number
; >div : any diff --git a/tests/baselines/reference/tsxReactEmitWhitespace2.js b/tests/baselines/reference/tsxReactEmitWhitespace2.js new file mode 100644 index 00000000000..091a193cdc5 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace2.js @@ -0,0 +1,25 @@ +//// [tsxReactEmitWhitespace2.tsx] +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +// Emit ' word' in the last string +
word code word
; +// Same here +
code word
; +// And here +
word
; + + + +//// [tsxReactEmitWhitespace2.js] +// Emit ' word' in the last string +React.createElement("div", null, "word ", React.createElement("code", null, "code"), " word"); +// Same here +React.createElement("div", null, React.createElement("code", null, "code"), " word"); +// And here +React.createElement("div", null, React.createElement("code", null), " word"); diff --git a/tests/baselines/reference/tsxReactEmitWhitespace2.symbols b/tests/baselines/reference/tsxReactEmitWhitespace2.symbols new file mode 100644 index 00000000000..44ff4cba292 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace2.symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/jsx/tsxReactEmitWhitespace2.tsx === +declare module JSX { +>JSX : Symbol(JSX, Decl(tsxReactEmitWhitespace2.tsx, 0, 0)) + + interface Element { } +>Element : Symbol(Element, Decl(tsxReactEmitWhitespace2.tsx, 0, 20)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) + + [s: string]: any; +>s : Symbol(s, Decl(tsxReactEmitWhitespace2.tsx, 3, 3)) + } +} +declare var React: any; +>React : Symbol(React, Decl(tsxReactEmitWhitespace2.tsx, 6, 11)) + +// Emit ' word' in the last string +
word code word
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>code : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>code : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) + +// Same here +
code word
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>code : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>code : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) + +// And here +
word
; +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>code : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) +>div : Symbol(JSX.IntrinsicElements, Decl(tsxReactEmitWhitespace2.tsx, 1, 22)) + + diff --git a/tests/baselines/reference/tsxReactEmitWhitespace2.types b/tests/baselines/reference/tsxReactEmitWhitespace2.types new file mode 100644 index 00000000000..7287e59b9b1 --- /dev/null +++ b/tests/baselines/reference/tsxReactEmitWhitespace2.types @@ -0,0 +1,44 @@ +=== tests/cases/conformance/jsx/tsxReactEmitWhitespace2.tsx === +declare module JSX { +>JSX : any + + interface Element { } +>Element : Element + + interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + [s: string]: any; +>s : string + } +} +declare var React: any; +>React : any + +// Emit ' word' in the last string +
word code word
; +>
word code word
: JSX.Element +>div : any +>code : JSX.Element +>code : any +>code : any +>div : any + +// Same here +
code word
; +>
code word
: JSX.Element +>div : any +>code : JSX.Element +>code : any +>code : any +>div : any + +// And here +
word
; +>
word
: JSX.Element +>div : any +> : JSX.Element +>code : any +>div : any + + diff --git a/tests/baselines/reference/tsxTypeErrors.symbols b/tests/baselines/reference/tsxTypeErrors.symbols index bfe0c568640..94399b95d1f 100644 --- a/tests/baselines/reference/tsxTypeErrors.symbols +++ b/tests/baselines/reference/tsxTypeErrors.symbols @@ -18,6 +18,7 @@ var thing = { oops: 100 }; var a3 =
>a3 : Symbol(a3, Decl(tsxTypeErrors.tsx, 9, 3)) >id : Symbol(unknown) +>thing : Symbol(thing, Decl(tsxTypeErrors.tsx, 8, 3)) // Mistyped html name (error) var e1 = diff --git a/tests/baselines/reference/tsxTypeErrors.types b/tests/baselines/reference/tsxTypeErrors.types index 92c7148b314..303c7695dbf 100644 --- a/tests/baselines/reference/tsxTypeErrors.types +++ b/tests/baselines/reference/tsxTypeErrors.types @@ -26,7 +26,7 @@ var a3 =
>
: any >div : any >id : any ->thing : any +>thing : { oops: number; } // Mistyped html name (error) var e1 = diff --git a/tests/baselines/reference/typeArgInference2.errors.txt b/tests/baselines/reference/typeArgInference2.errors.txt index 71d2a13f4a1..b7201fd1033 100644 --- a/tests/baselines/reference/typeArgInference2.errors.txt +++ b/tests/baselines/reference/typeArgInference2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/typeArgInference2.ts(12,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/compiler/typeArgInference2.ts(12,52): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ name: string; a: number; }' is not a valid type argument because it is not a supertype of candidate '{ name: string; b: number; }'. Object literal may only specify known properties, and 'b' does not exist in type '{ name: string; a: number; }'. @@ -16,7 +16,7 @@ tests/cases/compiler/typeArgInference2.ts(12,10): error TS2453: The type argumen var z4 = foo({ name: "abc" }); // { name: string } var z5 = foo({ name: "abc", a: 5 }); // { name: string; a: number } var z6 = foo({ name: "abc", a: 5 }, { name: "def", b: 5 }); // error - ~~~ + ~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ name: string; a: number; }' is not a valid type argument because it is not a supertype of candidate '{ name: string; b: number; }'. !!! error TS2453: Object literal may only specify known properties, and 'b' does not exist in type '{ name: string; a: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInference.errors.txt b/tests/baselines/reference/typeArgumentInference.errors.txt index 669ebadd28a..51cf4ccf7d2 100644 --- a/tests/baselines/reference/typeArgumentInference.errors.txt +++ b/tests/baselines/reference/typeArgumentInference.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(68,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(82,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(82,69): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(84,66): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(84,74): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. Object literal may only specify known properties, and 'y' does not exist in type 'A92'. @@ -93,13 +93,13 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(84,66 z?: Date; } var a9e = someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }); - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. !!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. var a9e: {}; var a9f = someGenerics9(undefined, { x: 6, z: new Date() }, { x: 6, y: '' }); - ~~~~~~~~~~~~~~~ + ~~~~~ !!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. !!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type 'A92'. var a9f: A92; diff --git a/tests/baselines/reference/typeArgumentInferenceApparentType1.symbols b/tests/baselines/reference/typeArgumentInferenceApparentType1.symbols index abcb8fdfc68..557175473da 100644 --- a/tests/baselines/reference/typeArgumentInferenceApparentType1.symbols +++ b/tests/baselines/reference/typeArgumentInferenceApparentType1.symbols @@ -3,7 +3,7 @@ function method(iterable: Iterable): T { >method : Symbol(method, Decl(typeArgumentInferenceApparentType1.ts, 0, 0)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType1.ts, 0, 16)) >iterable : Symbol(iterable, Decl(typeArgumentInferenceApparentType1.ts, 0, 19)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4396, 1)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType1.ts, 0, 16)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType1.ts, 0, 16)) diff --git a/tests/baselines/reference/typeArgumentInferenceApparentType2.symbols b/tests/baselines/reference/typeArgumentInferenceApparentType2.symbols index 86cf8e7cdcd..f25ca2bba6b 100644 --- a/tests/baselines/reference/typeArgumentInferenceApparentType2.symbols +++ b/tests/baselines/reference/typeArgumentInferenceApparentType2.symbols @@ -3,14 +3,14 @@ function method(iterable: Iterable): T { >method : Symbol(method, Decl(typeArgumentInferenceApparentType2.ts, 0, 0)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) >iterable : Symbol(iterable, Decl(typeArgumentInferenceApparentType2.ts, 0, 19)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4396, 1)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) function inner>() { >inner : Symbol(inner, Decl(typeArgumentInferenceApparentType2.ts, 0, 46)) >U : Symbol(U, Decl(typeArgumentInferenceApparentType2.ts, 1, 19)) ->Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 4396, 1)) >T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) var u: U; diff --git a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt index 305eee1c941..d058426b9c9 100644 --- a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt @@ -12,12 +12,12 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(106,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(118,9): error TS2304: Cannot find name 'Window'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,51): error TS2304: Cannot find name 'window'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,69): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,51): error TS2304: Cannot find name 'window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(122,56): error TS2304: Cannot find name 'window'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(122,66): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(122,74): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. Object literal may only specify known properties, and 'y' does not exist in type 'A92'. @@ -163,17 +163,17 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct !!! error TS2304: Cannot find name 'Window'. } var a9e = new someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); - ~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS2304: Cannot find name 'window'. + ~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. !!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'. - ~~~~~~ -!!! error TS2304: Cannot find name 'window'. var a9e: {}; var a9f = new someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); ~~~~~~ !!! error TS2304: Cannot find name 'window'. - ~~~~~~~~~~~~~~~ + ~~~~~ !!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. !!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type 'A92'. var a9f: A92; diff --git a/tests/baselines/reference/typeArgumentInferenceWithClassExpression2.errors.txt b/tests/baselines/reference/typeArgumentInferenceWithClassExpression2.errors.txt index c630944306b..eb74ff0ade0 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithClassExpression2.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceWithClassExpression2.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpression2.ts(6,5): error TS2345: Argument of type 'typeof (Anonymous class)' is not assignable to parameter of type 'typeof (Anonymous class)'. - Type '(Anonymous class)' is not assignable to type 'foo<{}>.'. + Type '(Anonymous class)' is not assignable to type 'foo<{}>.(Anonymous class)'. Property 'prop' is missing in type '(Anonymous class)'. @@ -12,5 +12,5 @@ tests/cases/conformance/es6/classExpressions/typeArgumentInferenceWithClassExpre foo(class { static prop = "hello" }).length; ~~~~~ !!! error TS2345: Argument of type 'typeof (Anonymous class)' is not assignable to parameter of type 'typeof (Anonymous class)'. -!!! error TS2345: Type '(Anonymous class)' is not assignable to type 'foo<{}>.'. +!!! error TS2345: Type '(Anonymous class)' is not assignable to type 'foo<{}>.(Anonymous class)'. !!! error TS2345: Property 'prop' is missing in type '(Anonymous class)'. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt b/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt index 6b81cd6f232..0c1e8cc4e97 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt @@ -17,12 +17,12 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(73,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(85,9): error TS2304: Cannot find name 'Window'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,47): error TS2304: Cannot find name 'window'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,65): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,47): error TS2304: Cannot find name 'window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(89,52): error TS2304: Cannot find name 'window'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(89,62): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(89,70): error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. Object literal may only specify known properties, and 'y' does not exist in type 'A92'. @@ -145,17 +145,17 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst !!! error TS2304: Cannot find name 'Window'. } var a9e = someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); - ~~~~~~~~~~~~~ + ~~~~~~ +!!! error TS2304: Cannot find name 'window'. + ~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. !!! error TS2453: Type argument candidate '{ x: number; z: any; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. !!! error TS2453: Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: any; }'. - ~~~~~~ -!!! error TS2304: Cannot find name 'window'. var a9e: {}; var a9f = someGenerics9(undefined, { x: 6, z: window }, { x: 6, y: '' }); ~~~~~~ !!! error TS2304: Cannot find name 'window'. - ~~~~~~~~~~~~~~~ + ~~~~~ !!! error TS2345: Argument of type '{ x: number; y: string; }' is not assignable to parameter of type 'A92'. !!! error TS2345: Object literal may only specify known properties, and 'y' does not exist in type 'A92'. var a9f: A92; diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.js b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.js new file mode 100644 index 00000000000..e23af7afab6 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.js @@ -0,0 +1,13 @@ +//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts] +type TreeNode = { + name: string; + parent: TreeNode; +} + +var nodes: TreeNode[]; +nodes.map(n => n.name); + + +//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.js] +var nodes; +nodes.map(function (n) { return n.name; }); diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols new file mode 100644 index 00000000000..08b61492a54 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts === +type TreeNode = { +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0)) + + name: string; +>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17)) + + parent: TreeNode; +>parent : Symbol(parent, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 1, 17)) +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0)) +} + +var nodes: TreeNode[]; +>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 5, 3)) +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0)) + +nodes.map(n => n.name); +>nodes.map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92)) +>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 5, 3)) +>map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92)) +>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 6, 10)) +>n.name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17)) +>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 6, 10)) +>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17)) + diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types new file mode 100644 index 00000000000..ea821607211 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts === +type TreeNode = { +>TreeNode : { name: string; parent: TreeNode; } + + name: string; +>name : string + + parent: TreeNode; +>parent : { name: string; parent: TreeNode; } +>TreeNode : { name: string; parent: TreeNode; } +} + +var nodes: TreeNode[]; +>nodes : { name: string; parent: TreeNode; }[] +>TreeNode : { name: string; parent: TreeNode; } + +nodes.map(n => n.name); +>nodes.map(n => n.name) : string[] +>nodes.map : (callbackfn: (value: { name: string; parent: TreeNode; }, index: number, array: { name: string; parent: TreeNode; }[]) => U, thisArg?: any) => U[] +>nodes : { name: string; parent: TreeNode; }[] +>map : (callbackfn: (value: { name: string; parent: TreeNode; }, index: number, array: { name: string; parent: TreeNode; }[]) => U, thisArg?: any) => U[] +>n => n.name : (n: { name: string; parent: TreeNode; }) => string +>n : { name: string; parent: TreeNode; } +>n.name : string +>n : { name: string; parent: TreeNode; } +>name : string + diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.js b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.js new file mode 100644 index 00000000000..d8e32e12b55 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.js @@ -0,0 +1,18 @@ +//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts] +type TreeNode = { + name: string; + parent: TreeNode; +} + +type TreeNodeMiddleman = { + name: string; + parent: TreeNode; +} + +var nodes: TreeNodeMiddleman[]; +nodes.map(n => n.name); + + +//// [typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.js] +var nodes; +nodes.map(function (n) { return n.name; }); diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols new file mode 100644 index 00000000000..cb2e8e94656 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts === +type TreeNode = { +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 0)) + + name: string; +>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 17)) + + parent: TreeNode; +>parent : Symbol(parent, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 1, 17)) +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 0)) +} + +type TreeNodeMiddleman = { +>TreeNodeMiddleman : Symbol(TreeNodeMiddleman, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 3, 1)) + + name: string; +>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26)) + + parent: TreeNode; +>parent : Symbol(parent, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 6, 17)) +>TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 0, 0)) +} + +var nodes: TreeNodeMiddleman[]; +>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 10, 3)) +>TreeNodeMiddleman : Symbol(TreeNodeMiddleman, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 3, 1)) + +nodes.map(n => n.name); +>nodes.map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92)) +>nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 10, 3)) +>map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92)) +>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 11, 10)) +>n.name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26)) +>n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 11, 10)) +>name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26)) + diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types new file mode 100644 index 00000000000..d18cf3a2b1d --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types @@ -0,0 +1,38 @@ +=== tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts === +type TreeNode = { +>TreeNode : { name: string; parent: TreeNode; } + + name: string; +>name : string + + parent: TreeNode; +>parent : { name: string; parent: TreeNode; } +>TreeNode : { name: string; parent: TreeNode; } +} + +type TreeNodeMiddleman = { +>TreeNodeMiddleman : { name: string; parent: { name: string; parent: TreeNode; }; } + + name: string; +>name : string + + parent: TreeNode; +>parent : { name: string; parent: TreeNode; } +>TreeNode : { name: string; parent: TreeNode; } +} + +var nodes: TreeNodeMiddleman[]; +>nodes : { name: string; parent: { name: string; parent: TreeNode; }; }[] +>TreeNodeMiddleman : { name: string; parent: { name: string; parent: TreeNode; }; } + +nodes.map(n => n.name); +>nodes.map(n => n.name) : string[] +>nodes.map : (callbackfn: (value: { name: string; parent: { name: string; parent: TreeNode; }; }, index: number, array: { name: string; parent: { name: string; parent: TreeNode; }; }[]) => U, thisArg?: any) => U[] +>nodes : { name: string; parent: { name: string; parent: TreeNode; }; }[] +>map : (callbackfn: (value: { name: string; parent: { name: string; parent: TreeNode; }; }, index: number, array: { name: string; parent: { name: string; parent: TreeNode; }; }[]) => U, thisArg?: any) => U[] +>n => n.name : (n: { name: string; parent: { name: string; parent: TreeNode; }; }) => string +>n : { name: string; parent: { name: string; parent: TreeNode; }; } +>n.name : string +>n : { name: string; parent: { name: string; parent: TreeNode; }; } +>name : string + diff --git a/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.js b/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.js index b25ad480a9d..e75fa63c4b7 100644 --- a/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.js +++ b/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.js @@ -7,7 +7,7 @@ var classes = undefined; } //// [file2.ts] -import f = require('file1'); +import f = require('./file1'); f.foo(); @@ -18,7 +18,7 @@ function foo() { } exports.foo = foo; //// [file2.js] -var f = require('file1'); +var f = require('./file1'); f.foo(); diff --git a/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.symbols b/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.symbols index 2326ee5a8cd..4a4e4ef57da 100644 --- a/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.symbols +++ b/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.symbols @@ -1,5 +1,5 @@ === tests/cases/compiler/file2.ts === -import f = require('file1'); +import f = require('./file1'); >f : Symbol(f, Decl(file2.ts, 0, 0)) f.foo(); diff --git a/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.types b/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.types index 23d2c3167d6..044de70c5cd 100644 --- a/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.types +++ b/tests/baselines/reference/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.types @@ -1,5 +1,5 @@ === tests/cases/compiler/file2.ts === -import f = require('file1'); +import f = require('./file1'); >f : typeof f f.foo(); diff --git a/tests/baselines/reference/typeConstraintsWithConstructSignatures.types b/tests/baselines/reference/typeConstraintsWithConstructSignatures.types index 3814c014ece..9141aec0496 100644 --- a/tests/baselines/reference/typeConstraintsWithConstructSignatures.types +++ b/tests/baselines/reference/typeConstraintsWithConstructSignatures.types @@ -23,14 +23,14 @@ class C { >x : any >new this.data() : any >this.data : T ->this : C +>this : this >data : T var x2 = new this.data2(); // should not error >x2 : any >new this.data2() : any >this.data2 : Constructable ->this : C +>this : this >data2 : Constructable } } diff --git a/tests/baselines/reference/typeGuardsInConditionalExpression.types b/tests/baselines/reference/typeGuardsInConditionalExpression.types index ef048fb8562..493a8c0a31a 100644 --- a/tests/baselines/reference/typeGuardsInConditionalExpression.types +++ b/tests/baselines/reference/typeGuardsInConditionalExpression.types @@ -363,9 +363,9 @@ function foo12(x: number | string | boolean) { >10 : number >x.toString().length : number >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string >length : number : ((b = x) // x is number | boolean | string - changed in true branch diff --git a/tests/baselines/reference/typeGuardsInIfStatement.js b/tests/baselines/reference/typeGuardsInIfStatement.js index 820d205bc65..de05a7bf82a 100644 --- a/tests/baselines/reference/typeGuardsInIfStatement.js +++ b/tests/baselines/reference/typeGuardsInIfStatement.js @@ -1,9 +1,9 @@ //// [typeGuardsInIfStatement.ts] -// In the true branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when true, +// In the true branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true, // provided the true branch statement contains no assignments to the variable or parameter. -// In the false branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when false, +// In the false branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when false, // provided the false branch statement contains no assignments to the variable or parameter function foo(x: number | string) { if (typeof x === "string") { @@ -149,11 +149,11 @@ function foo12(x: number | string | boolean) { } //// [typeGuardsInIfStatement.js] -// In the true branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when true, +// In the true branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true, // provided the true branch statement contains no assignments to the variable or parameter. -// In the false branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when false, +// In the false branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when false, // provided the false branch statement contains no assignments to the variable or parameter function foo(x) { if (typeof x === "string") { diff --git a/tests/baselines/reference/typeGuardsInIfStatement.symbols b/tests/baselines/reference/typeGuardsInIfStatement.symbols index d940e10e066..798fe18cf5a 100644 --- a/tests/baselines/reference/typeGuardsInIfStatement.symbols +++ b/tests/baselines/reference/typeGuardsInIfStatement.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts === -// In the true branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when true, +// In the true branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true, // provided the true branch statement contains no assignments to the variable or parameter. -// In the false branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when false, +// In the false branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when false, // provided the false branch statement contains no assignments to the variable or parameter function foo(x: number | string) { >foo : Symbol(foo, Decl(typeGuardsInIfStatement.ts, 0, 0)) diff --git a/tests/baselines/reference/typeGuardsInIfStatement.types b/tests/baselines/reference/typeGuardsInIfStatement.types index e049d318a02..0095a7cc768 100644 --- a/tests/baselines/reference/typeGuardsInIfStatement.types +++ b/tests/baselines/reference/typeGuardsInIfStatement.types @@ -1,9 +1,9 @@ === tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts === -// In the true branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when true, +// In the true branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true, // provided the true branch statement contains no assignments to the variable or parameter. -// In the false branch statement of an �if� statement, -// the type of a variable or parameter is narrowed by any type guard in the �if� condition when false, +// In the false branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when false, // provided the false branch statement contains no assignments to the variable or parameter function foo(x: number | string) { >foo : (x: number | string) => number @@ -333,9 +333,9 @@ function foo11(x: number | string | boolean) { >10 && x.toString() : string >10 : number >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string ) : ( @@ -348,9 +348,9 @@ function foo11(x: number | string | boolean) { >x && x.toString() : string >x : number | string | boolean >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string ); } @@ -369,9 +369,9 @@ function foo12(x: number | string | boolean) { return x.toString(); // string | number | boolean - x changed in else branch >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string } else { x = 10; diff --git a/tests/baselines/reference/typeGuardsInProperties.types b/tests/baselines/reference/typeGuardsInProperties.types index 2167eb88642..ca4d8b94527 100644 --- a/tests/baselines/reference/typeGuardsInProperties.types +++ b/tests/baselines/reference/typeGuardsInProperties.types @@ -35,11 +35,11 @@ class C1 { >typeof this.pp1 === "string" : boolean >typeof this.pp1 : string >this.pp1 : string | number ->this : C1 +>this : this >pp1 : string | number >"string" : string >this.pp1 : string | number ->this : C1 +>this : this >pp1 : string | number strOrNum = typeof this.pp2 === "string" && this.pp2; // string | number @@ -49,11 +49,11 @@ class C1 { >typeof this.pp2 === "string" : boolean >typeof this.pp2 : string >this.pp2 : string | number ->this : C1 +>this : this >pp2 : string | number >"string" : string >this.pp2 : string | number ->this : C1 +>this : this >pp2 : string | number strOrNum = typeof this.pp3 === "string" && this.pp3; // string | number @@ -63,11 +63,11 @@ class C1 { >typeof this.pp3 === "string" : boolean >typeof this.pp3 : string >this.pp3 : string | number ->this : C1 +>this : this >pp3 : string | number >"string" : string >this.pp3 : string | number ->this : C1 +>this : this >pp3 : string | number } } diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types index b69c80ff55a..22d390618c1 100644 --- a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types +++ b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types @@ -180,9 +180,9 @@ function foo7(x: number | string | boolean) { >10 && x.toString() : string >10 : number >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string // do not change value : (y = x && x.toString()))); // number | boolean | string @@ -192,9 +192,9 @@ function foo7(x: number | string | boolean) { >x && x.toString() : string >x : number | string | boolean >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string } function foo8(x: number | string) { >foo8 : (x: number | string) => number diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types index b2f5401e843..38d9a723d3a 100644 --- a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types +++ b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types @@ -180,9 +180,9 @@ function foo7(x: number | string | boolean) { >10 && x.toString() : string >10 : number >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string // do not change value : (y = x && x.toString()))); // number | boolean | string @@ -192,9 +192,9 @@ function foo7(x: number | string | boolean) { >x && x.toString() : string >x : number | string | boolean >x.toString() : string ->x.toString : ((radix?: number) => string) | (() => string) +>x.toString : (radix?: number) => string >x : number | string | boolean ->toString : ((radix?: number) => string) | (() => string) +>toString : (radix?: number) => string } function foo8(x: number | string) { >foo8 : (x: number | string) => boolean | number diff --git a/tests/baselines/reference/typeInfer1.errors.txt b/tests/baselines/reference/typeInfer1.errors.txt index 2550bb1fe8d..6f26b2e6054 100644 --- a/tests/baselines/reference/typeInfer1.errors.txt +++ b/tests/baselines/reference/typeInfer1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/typeInfer1.ts(11,5): error TS2322: Type '{ Moo: () => string; }' is not assignable to type 'ITextWriter2'. +tests/cases/compiler/typeInfer1.ts(12,5): error TS2322: Type '{ Moo: () => string; }' is not assignable to type 'ITextWriter2'. Object literal may only specify known properties, and 'Moo' does not exist in type 'ITextWriter2'. @@ -14,8 +14,8 @@ tests/cases/compiler/typeInfer1.ts(11,5): error TS2322: Type '{ Moo: () => strin } var yyyyyyyy: ITextWriter2 = { - ~~~~~~~~ + Moo: function() { return "cow"; } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ Moo: () => string; }' is not assignable to type 'ITextWriter2'. !!! error TS2322: Object literal may only specify known properties, and 'Moo' does not exist in type 'ITextWriter2'. - Moo: function() { return "cow"; } } \ No newline at end of file diff --git a/tests/baselines/reference/typeInferenceReturnTypeCallback.types b/tests/baselines/reference/typeInferenceReturnTypeCallback.types index fb26424d892..408e60f90ec 100644 --- a/tests/baselines/reference/typeInferenceReturnTypeCallback.types +++ b/tests/baselines/reference/typeInferenceReturnTypeCallback.types @@ -54,7 +54,7 @@ class Cons implements IList{ return this.foldRight(new Nil(), (t, acc) => { >this.foldRight(new Nil(), (t, acc) => { return new Cons(); }) : Nil >this.foldRight : (z: E, f: (t: T, acc: E) => E) => E ->this : Cons +>this : this >foldRight : (z: E, f: (t: T, acc: E) => E) => E >new Nil() : Nil >Nil : typeof Nil diff --git a/tests/baselines/reference/typeMatch2.errors.txt b/tests/baselines/reference/typeMatch2.errors.txt index a497551c953..e82439c0ad5 100644 --- a/tests/baselines/reference/typeMatch2.errors.txt +++ b/tests/baselines/reference/typeMatch2.errors.txt @@ -2,9 +2,9 @@ tests/cases/compiler/typeMatch2.ts(3,2): error TS2322: Type '{}' is not assignab Property 'x' is missing in type '{}'. tests/cases/compiler/typeMatch2.ts(4,5): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: number; y: number; }'. Property 'y' is missing in type '{ x: number; }'. -tests/cases/compiler/typeMatch2.ts(5,2): error TS2322: Type '{ x: number; y: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. +tests/cases/compiler/typeMatch2.ts(5,20): error TS2322: Type '{ x: number; y: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. -tests/cases/compiler/typeMatch2.ts(6,5): error TS2322: Type '{ x: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. +tests/cases/compiler/typeMatch2.ts(6,17): error TS2322: Type '{ x: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. tests/cases/compiler/typeMatch2.ts(18,5): error TS2322: Type 'Animal[]' is not assignable to type 'Giraffe[]'. Type 'Animal' is not assignable to type 'Giraffe'. @@ -13,7 +13,7 @@ tests/cases/compiler/typeMatch2.ts(22,5): error TS2322: Type '{ f1: number; f2: Types of property 'f2' are incompatible. Type 'Animal[]' is not assignable to type 'Giraffe[]'. Type 'Animal' is not assignable to type 'Giraffe'. -tests/cases/compiler/typeMatch2.ts(34,5): error TS2322: Type '{ x: number; y: any; z: number; }' is not assignable to type '{ x: number; y: number; }'. +tests/cases/compiler/typeMatch2.ts(34,26): error TS2322: Type '{ x: number; y: any; z: number; }' is not assignable to type '{ x: number; y: number; }'. Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. tests/cases/compiler/typeMatch2.ts(35,5): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: number; y: number; }'. Property 'y' is missing in type '{ x: number; }'. @@ -31,11 +31,11 @@ tests/cases/compiler/typeMatch2.ts(35,5): error TS2322: Type '{ x: number; }' is !!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: number; y: number; }'. !!! error TS2322: Property 'y' is missing in type '{ x: number; }'. a = { x: 1, y: 2, z: 3 }; - ~ + ~~~~ !!! error TS2322: Type '{ x: number; y: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. a = { x: 1, z: 3 }; // error - ~ + ~~~~ !!! error TS2322: Type '{ x: number; z: number; }' is not assignable to type '{ x: number; y: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. } @@ -75,7 +75,7 @@ tests/cases/compiler/typeMatch2.ts(35,5): error TS2322: Type '{ x: number; }' is a = { x: 1, y: undefined }; a = { x: 1, y: _any }; a = { x: 1, y: _any, z:1 }; - ~ + ~~~ !!! error TS2322: Type '{ x: number; y: any; z: number; }' is not assignable to type '{ x: number; y: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'z' does not exist in type '{ x: number; y: number; }'. a = { x: 1 }; // error diff --git a/tests/baselines/reference/typeOfThis.errors.txt b/tests/baselines/reference/typeOfThis.errors.txt index bc3e9754c09..83d450570fc 100644 --- a/tests/baselines/reference/typeOfThis.errors.txt +++ b/tests/baselines/reference/typeOfThis.errors.txt @@ -1,14 +1,24 @@ +tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(14,13): error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type 'this', but here has type 'MyTestClass'. +tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(18,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyTestClass'. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(22,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(24,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyTestClass'. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(27,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(29,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyTestClass'. +tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(37,13): error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type 'this', but here has type 'MyTestClass'. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(53,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(61,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(83,13): error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type 'this', but here has type 'MyGenericTestClass'. +tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(87,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyGenericTestClass'. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(91,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(93,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyGenericTestClass'. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(96,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(98,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyGenericTestClass'. +tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(106,13): error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type 'this', but here has type 'MyGenericTestClass'. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(122,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -==== tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts (8 errors) ==== +==== tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts (18 errors) ==== class MyTestClass { private canary: number; static staticCanary: number; @@ -23,10 +33,14 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 //type of 'this' in member function param list is the class instance type memberFunc(t = this) { var t: MyTestClass; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type 'this', but here has type 'MyTestClass'. //type of 'this' in member function body is the class instance type var p = this; var p: MyTestClass; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyTestClass'. } //type of 'this' in member accessor(get and set) body is the class instance type @@ -35,6 +49,8 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. var p = this; var p: MyTestClass; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyTestClass'. return this; } set prop(v) { @@ -42,6 +58,8 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. var p = this; var p: MyTestClass; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyTestClass'. p = v; v = p; } @@ -50,6 +68,8 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 //type of 'this' in member variable initializer is the class instance type var t = this; var t: MyTestClass; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type 'this', but here has type 'MyTestClass'. }; //type of 'this' in static function param list is constructor function type @@ -100,10 +120,14 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 //type of 'this' in member function param list is the class instance type memberFunc(t = this) { var t: MyGenericTestClass; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type 'this', but here has type 'MyGenericTestClass'. //type of 'this' in member function body is the class instance type var p = this; var p: MyGenericTestClass; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyGenericTestClass'. } //type of 'this' in member accessor(get and set) body is the class instance type @@ -112,6 +136,8 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. var p = this; var p: MyGenericTestClass; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyGenericTestClass'. return this; } set prop(v) { @@ -119,6 +145,8 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. var p = this; var p: MyGenericTestClass; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'this', but here has type 'MyGenericTestClass'. p = v; v = p; } @@ -127,6 +155,8 @@ tests/cases/conformance/expressions/thisKeyword/typeOfThis.ts(130,16): error TS1 //type of 'this' in member variable initializer is the class instance type var t = this; var t: MyGenericTestClass; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 't' must be of type 'this', but here has type 'MyGenericTestClass'. }; //type of 'this' in static function param list is constructor function type diff --git a/tests/baselines/reference/typeOfThisInMemberFunctions.types b/tests/baselines/reference/typeOfThisInMemberFunctions.types index 2be8af1ca75..7318bae2d32 100644 --- a/tests/baselines/reference/typeOfThisInMemberFunctions.types +++ b/tests/baselines/reference/typeOfThisInMemberFunctions.types @@ -6,8 +6,8 @@ class C { >foo : () => void var r = this; ->r : C ->this : C +>r : this +>this : this } static bar() { @@ -31,8 +31,8 @@ class D { >foo : () => void var r = this; ->r : D ->this : D +>r : this +>this : this } static bar() { @@ -57,8 +57,8 @@ class E { >foo : () => void var r = this; ->r : E ->this : E +>r : this +>this : this } static bar() { diff --git a/tests/baselines/reference/typeParameterExtendingUnion1.symbols b/tests/baselines/reference/typeParameterExtendingUnion1.symbols index 97d900b5d5e..39b67e6428c 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion1.symbols +++ b/tests/baselines/reference/typeParameterExtendingUnion1.symbols @@ -33,9 +33,9 @@ function f(a: T) { >T : Symbol(T, Decl(typeParameterExtendingUnion1.ts, 8, 11)) a.run(); ->a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion1.ts, 0, 14)) +>a.run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion1.ts, 8, 32)) ->run : Symbol(Animal.run, Decl(typeParameterExtendingUnion1.ts, 0, 14)) +>run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 0, 14), Decl(typeParameterExtendingUnion1.ts, 0, 14)) run(a); >run : Symbol(run, Decl(typeParameterExtendingUnion1.ts, 2, 33)) diff --git a/tests/baselines/reference/typeParameterExtendingUnion2.symbols b/tests/baselines/reference/typeParameterExtendingUnion2.symbols index 21866b3df92..44d47692a82 100644 --- a/tests/baselines/reference/typeParameterExtendingUnion2.symbols +++ b/tests/baselines/reference/typeParameterExtendingUnion2.symbols @@ -20,9 +20,9 @@ function run(a: Cat | Dog) { >Dog : Symbol(Dog, Decl(typeParameterExtendingUnion2.ts, 1, 33)) a.run(); ->a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>a.run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion2.ts, 4, 13)) ->run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) } function f(a: T) { @@ -34,9 +34,9 @@ function f(a: T) { >T : Symbol(T, Decl(typeParameterExtendingUnion2.ts, 8, 11)) a.run(); ->a.run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>a.run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) >a : Symbol(a, Decl(typeParameterExtendingUnion2.ts, 8, 32)) ->run : Symbol(Animal.run, Decl(typeParameterExtendingUnion2.ts, 0, 14)) +>run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 0, 14), Decl(typeParameterExtendingUnion2.ts, 0, 14)) run(a); >run : Symbol(run, Decl(typeParameterExtendingUnion2.ts, 2, 33)) diff --git a/tests/baselines/reference/typeRelationships.errors.txt b/tests/baselines/reference/typeRelationships.errors.txt new file mode 100644 index 00000000000..37954415778 --- /dev/null +++ b/tests/baselines/reference/typeRelationships.errors.txt @@ -0,0 +1,54 @@ +tests/cases/conformance/types/thisType/typeRelationships.ts(9,9): error TS2322: Type 'C' is not assignable to type 'this'. +tests/cases/conformance/types/thisType/typeRelationships.ts(35,9): error TS2322: Type 'C' is not assignable to type 'D'. + Property 'self1' is missing in type 'C'. +tests/cases/conformance/types/thisType/typeRelationships.ts(36,9): error TS2322: Type 'D' is not assignable to type 'this'. + + +==== tests/cases/conformance/types/thisType/typeRelationships.ts (3 errors) ==== + class C { + self = this; + c = new C(); + foo() { + return this; + } + f1() { + this.c = this.self; + this.self = this.c; // Error + ~~~~~~~~~ +!!! error TS2322: Type 'C' is not assignable to type 'this'. + } + f2() { + var a: C[]; + var a = [this, this.c]; // C[] since this is subtype of C + var b: this[]; + var b = [this, this.self, null, undefined]; + } + f3(b: boolean) { + return b ? this.c : this.self; // Should be C + } + } + + class D extends C { + self1 = this; + self2 = this.self; + self3 = this.foo(); + d = new D(); + bar() { + this.self = this.self1; + this.self = this.self2; + this.self = this.self3; + this.self1 = this.self; + this.self2 = this.self; + this.self3 = this.self; + this.d = this.self; + this.d = this.c; // Error + ~~~~~~ +!!! error TS2322: Type 'C' is not assignable to type 'D'. +!!! error TS2322: Property 'self1' is missing in type 'C'. + this.self = this.d; // Error + ~~~~~~~~~ +!!! error TS2322: Type 'D' is not assignable to type 'this'. + this.c = this.d; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/typeRelationships.js b/tests/baselines/reference/typeRelationships.js new file mode 100644 index 00000000000..1e31009f9b7 --- /dev/null +++ b/tests/baselines/reference/typeRelationships.js @@ -0,0 +1,94 @@ +//// [typeRelationships.ts] +class C { + self = this; + c = new C(); + foo() { + return this; + } + f1() { + this.c = this.self; + this.self = this.c; // Error + } + f2() { + var a: C[]; + var a = [this, this.c]; // C[] since this is subtype of C + var b: this[]; + var b = [this, this.self, null, undefined]; + } + f3(b: boolean) { + return b ? this.c : this.self; // Should be C + } +} + +class D extends C { + self1 = this; + self2 = this.self; + self3 = this.foo(); + d = new D(); + bar() { + this.self = this.self1; + this.self = this.self2; + this.self = this.self3; + this.self1 = this.self; + this.self2 = this.self; + this.self3 = this.self; + this.d = this.self; + this.d = this.c; // Error + this.self = this.d; // Error + this.c = this.d; + } +} + + +//// [typeRelationships.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var C = (function () { + function C() { + this.self = this; + this.c = new C(); + } + C.prototype.foo = function () { + return this; + }; + C.prototype.f1 = function () { + this.c = this.self; + this.self = this.c; // Error + }; + C.prototype.f2 = function () { + var a; + var a = [this, this.c]; // C[] since this is subtype of C + var b; + var b = [this, this.self, null, undefined]; + }; + C.prototype.f3 = function (b) { + return b ? this.c : this.self; // Should be C + }; + return C; +})(); +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + this.self1 = this; + this.self2 = this.self; + this.self3 = this.foo(); + this.d = new D(); + } + D.prototype.bar = function () { + this.self = this.self1; + this.self = this.self2; + this.self = this.self3; + this.self1 = this.self; + this.self2 = this.self; + this.self3 = this.self; + this.d = this.self; + this.d = this.c; // Error + this.self = this.d; // Error + this.c = this.d; + }; + return D; +})(C); diff --git a/tests/baselines/reference/typeResolution.symbols b/tests/baselines/reference/typeResolution.symbols index dadc38ad58e..aa0d611e52e 100644 --- a/tests/baselines/reference/typeResolution.symbols +++ b/tests/baselines/reference/typeResolution.symbols @@ -18,26 +18,26 @@ export module TopLevelModule1 { var a1: ClassA; a1.AisIn1_1_1(); >a1 : Symbol(a1, Decl(typeResolution.ts, 6, 23)) >ClassA : Symbol(ClassA, Decl(typeResolution.ts, 2, 37)) ->a1.AisIn1_1_1 : Symbol(AisIn1_1_1, Decl(typeResolution.ts, 3, 33)) +>a1.AisIn1_1_1 : Symbol(ClassA.AisIn1_1_1, Decl(typeResolution.ts, 3, 33)) >a1 : Symbol(a1, Decl(typeResolution.ts, 6, 23)) ->AisIn1_1_1 : Symbol(AisIn1_1_1, Decl(typeResolution.ts, 3, 33)) +>AisIn1_1_1 : Symbol(ClassA.AisIn1_1_1, Decl(typeResolution.ts, 3, 33)) var a2: SubSubModule1.ClassA; a2.AisIn1_1_1(); >a2 : Symbol(a2, Decl(typeResolution.ts, 7, 23)) >SubSubModule1 : Symbol(SubSubModule1, Decl(typeResolution.ts, 1, 30)) >ClassA : Symbol(ClassA, Decl(typeResolution.ts, 2, 37)) ->a2.AisIn1_1_1 : Symbol(AisIn1_1_1, Decl(typeResolution.ts, 3, 33)) +>a2.AisIn1_1_1 : Symbol(ClassA.AisIn1_1_1, Decl(typeResolution.ts, 3, 33)) >a2 : Symbol(a2, Decl(typeResolution.ts, 7, 23)) ->AisIn1_1_1 : Symbol(AisIn1_1_1, Decl(typeResolution.ts, 3, 33)) +>AisIn1_1_1 : Symbol(ClassA.AisIn1_1_1, Decl(typeResolution.ts, 3, 33)) var a3: SubModule1.SubSubModule1.ClassA; a3.AisIn1_1_1(); >a3 : Symbol(a3, Decl(typeResolution.ts, 8, 23)) >SubModule1 : Symbol(SubModule1, Decl(typeResolution.ts, 0, 31)) >SubSubModule1 : Symbol(SubSubModule1, Decl(typeResolution.ts, 1, 30)) >ClassA : Symbol(ClassA, Decl(typeResolution.ts, 2, 37)) ->a3.AisIn1_1_1 : Symbol(AisIn1_1_1, Decl(typeResolution.ts, 3, 33)) +>a3.AisIn1_1_1 : Symbol(ClassA.AisIn1_1_1, Decl(typeResolution.ts, 3, 33)) >a3 : Symbol(a3, Decl(typeResolution.ts, 8, 23)) ->AisIn1_1_1 : Symbol(AisIn1_1_1, Decl(typeResolution.ts, 3, 33)) +>AisIn1_1_1 : Symbol(ClassA.AisIn1_1_1, Decl(typeResolution.ts, 3, 33)) var a4: TopLevelModule1.SubModule1.SubSubModule1.ClassA; a4.AisIn1_1_1(); >a4 : Symbol(a4, Decl(typeResolution.ts, 9, 23)) @@ -45,9 +45,9 @@ export module TopLevelModule1 { >SubModule1 : Symbol(SubModule1, Decl(typeResolution.ts, 0, 31)) >SubSubModule1 : Symbol(SubSubModule1, Decl(typeResolution.ts, 1, 30)) >ClassA : Symbol(ClassA, Decl(typeResolution.ts, 2, 37)) ->a4.AisIn1_1_1 : Symbol(AisIn1_1_1, Decl(typeResolution.ts, 3, 33)) +>a4.AisIn1_1_1 : Symbol(ClassA.AisIn1_1_1, Decl(typeResolution.ts, 3, 33)) >a4 : Symbol(a4, Decl(typeResolution.ts, 9, 23)) ->AisIn1_1_1 : Symbol(AisIn1_1_1, Decl(typeResolution.ts, 3, 33)) +>AisIn1_1_1 : Symbol(ClassA.AisIn1_1_1, Decl(typeResolution.ts, 3, 33)) // Two variants of qualifying a peer type var b1: ClassB; b1.BisIn1_1_1(); @@ -142,9 +142,9 @@ export module TopLevelModule1 { var b1: ClassB; b1.BisIn1_1_1(); >b1 : Symbol(b1, Decl(typeResolution.ts, 34, 23)) >ClassB : Symbol(ClassB, Decl(typeResolution.ts, 22, 13)) ->b1.BisIn1_1_1 : Symbol(BisIn1_1_1, Decl(typeResolution.ts, 23, 33)) +>b1.BisIn1_1_1 : Symbol(ClassB.BisIn1_1_1, Decl(typeResolution.ts, 23, 33)) >b1 : Symbol(b1, Decl(typeResolution.ts, 34, 23)) ->BisIn1_1_1 : Symbol(BisIn1_1_1, Decl(typeResolution.ts, 23, 33)) +>BisIn1_1_1 : Symbol(ClassB.BisIn1_1_1, Decl(typeResolution.ts, 23, 33)) var b2: TopLevelModule1.SubModule1.SubSubModule1.ClassB; b2.BisIn1_1_1(); >b2 : Symbol(b2, Decl(typeResolution.ts, 35, 23)) @@ -152,9 +152,9 @@ export module TopLevelModule1 { >SubModule1 : Symbol(SubModule1, Decl(typeResolution.ts, 0, 31)) >SubSubModule1 : Symbol(SubSubModule1, Decl(typeResolution.ts, 1, 30)) >ClassB : Symbol(ClassB, Decl(typeResolution.ts, 22, 13)) ->b2.BisIn1_1_1 : Symbol(BisIn1_1_1, Decl(typeResolution.ts, 23, 33)) +>b2.BisIn1_1_1 : Symbol(ClassB.BisIn1_1_1, Decl(typeResolution.ts, 23, 33)) >b2 : Symbol(b2, Decl(typeResolution.ts, 35, 23)) ->BisIn1_1_1 : Symbol(BisIn1_1_1, Decl(typeResolution.ts, 23, 33)) +>BisIn1_1_1 : Symbol(ClassB.BisIn1_1_1, Decl(typeResolution.ts, 23, 33)) // Type only accessible from the root var c1: TopLevelModule1.SubModule2.SubSubModule2.ClassA; c1.AisIn1_2_2(); diff --git a/tests/baselines/reference/typedArrays.symbols b/tests/baselines/reference/typedArrays.symbols index 6b9842f6c81..41fbab91e3c 100644 --- a/tests/baselines/reference/typedArrays.symbols +++ b/tests/baselines/reference/typedArrays.symbols @@ -8,39 +8,39 @@ function CreateTypedArrayTypes() { typedArrays[0] = Int8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4731, 1)) typedArrays[1] = Uint8Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4763, 1)) typedArrays[2] = Int16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4831, 1)) typedArrays[3] = Uint16Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4867, 1)) typedArrays[4] = Int32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4899, 1)) typedArrays[5] = Uint32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4931, 1)) typedArrays[6] = Float32Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4963, 1)) typedArrays[7] = Float64Array; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4995, 1)) typedArrays[8] = Uint8ClampedArray; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4795, 1)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 2, 7)) @@ -55,47 +55,47 @@ function CreateTypedArrayInstancesFromLength(obj: number) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4731, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4763, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4831, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4867, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4899, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4931, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4963, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4995, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 17, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4795, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 16, 45)) return typedArrays; @@ -111,47 +111,47 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { typedArrays[0] = new Int8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4731, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[1] = new Uint8Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4763, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[2] = new Int16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4831, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[3] = new Uint16Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4867, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[4] = new Int32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4899, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[5] = new Uint32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4931, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[6] = new Float32Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4963, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[7] = new Float64Array(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4995, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) typedArrays[8] = new Uint8ClampedArray(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 32, 7)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4795, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 31, 44)) return typedArrays; @@ -167,65 +167,65 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4754, 48)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4731, 1)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4754, 48)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4786, 49)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4763, 1)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4786, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4858, 49)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4831, 1)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4858, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4890, 50)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4867, 1)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4890, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4922, 49)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4899, 1)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4922, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4954, 50)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4931, 1)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4954, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4986, 51)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4963, 1)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4986, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 5018, 51)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4995, 1)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 5018, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4821, 56)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4795, 1)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4821, 56)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) return typedArrays; @@ -235,72 +235,72 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >CreateIntegerTypedArraysFromArrayLike : Symbol(CreateIntegerTypedArraysFromArrayLike, Decl(typedArrays.ts, 59, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1447, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1198, 1)) var typedArrays = []; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4754, 48)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4731, 1)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4754, 48)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4786, 49)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4763, 1)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4786, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4858, 49)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4831, 1)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4858, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4890, 50)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4867, 1)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4890, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4922, 49)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4899, 1)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4922, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4954, 50)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4931, 1)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4954, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4986, 51)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4963, 1)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4986, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 5018, 51)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4995, 1)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 5018, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4821, 56)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4795, 1)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4821, 56)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) return typedArrays; @@ -332,57 +332,57 @@ function CreateTypedArraysOf2() { typedArrays[0] = Int8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2395, 30)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) ->of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 2395, 30)) +>Int8Array.of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 1635, 30)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4731, 1)) +>of : Symbol(Int8ArrayConstructor.of, Decl(lib.d.ts, 1635, 30)) typedArrays[1] = Uint8Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2685, 30)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) ->of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 2685, 30)) +>Uint8Array.of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 1909, 30)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4763, 1)) +>of : Symbol(Uint8ArrayConstructor.of, Decl(lib.d.ts, 1909, 30)) typedArrays[2] = Int16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3265, 30)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) ->of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 3265, 30)) +>Int16Array.of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 2456, 30)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4831, 1)) +>of : Symbol(Int16ArrayConstructor.of, Decl(lib.d.ts, 2456, 30)) typedArrays[3] = Uint16Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3555, 30)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) ->of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 3555, 30)) +>Uint16Array.of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 2730, 30)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4867, 1)) +>of : Symbol(Uint16ArrayConstructor.of, Decl(lib.d.ts, 2730, 30)) typedArrays[4] = Int32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3845, 30)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) ->of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3845, 30)) +>Int32Array.of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3003, 30)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4899, 1)) +>of : Symbol(Int32ArrayConstructor.of, Decl(lib.d.ts, 3003, 30)) typedArrays[5] = Uint32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4135, 30)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) ->of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 4135, 30)) +>Uint32Array.of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 3276, 30)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4931, 1)) +>of : Symbol(Uint32ArrayConstructor.of, Decl(lib.d.ts, 3276, 30)) typedArrays[6] = Float32Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4425, 30)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) ->of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 4425, 30)) +>Float32Array.of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 3549, 30)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4963, 1)) +>of : Symbol(Float32ArrayConstructor.of, Decl(lib.d.ts, 3549, 30)) typedArrays[7] = Float64Array.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4715, 30)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) ->of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 4715, 30)) +>Float64Array.of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 3823, 30)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4995, 1)) +>of : Symbol(Float64ArrayConstructor.of, Decl(lib.d.ts, 3823, 30)) typedArrays[8] = Uint8ClampedArray.of(1,2,3,4); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) ->Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2975, 30)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) ->of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2975, 30)) +>Uint8ClampedArray.of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2183, 30)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4795, 1)) +>of : Symbol(Uint8ClampedArrayConstructor.of, Decl(lib.d.ts, 2183, 30)) return typedArrays; >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 94, 7)) @@ -391,7 +391,7 @@ function CreateTypedArraysOf2() { function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { >CreateTypedArraysFromMapFn : Symbol(CreateTypedArraysFromMapFn, Decl(typedArrays.ts, 106, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1447, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1198, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) >n : Symbol(n, Decl(typedArrays.ts, 108, 67)) >v : Symbol(v, Decl(typedArrays.ts, 108, 76)) @@ -401,73 +401,73 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4754, 48)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4731, 1)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4754, 48)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4786, 49)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4763, 1)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4786, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4858, 49)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4831, 1)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4858, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4890, 50)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4867, 1)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4890, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4922, 49)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4899, 1)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4922, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4954, 50)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4931, 1)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4954, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4986, 51)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4963, 1)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4986, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 5018, 51)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4995, 1)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 5018, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 109, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4821, 56)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4795, 1)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4821, 56)) >obj : Symbol(obj, Decl(typedArrays.ts, 108, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 108, 58)) @@ -478,7 +478,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v:number)=> number, thisArg: {}) { >CreateTypedArraysFromThisObj : Symbol(CreateTypedArraysFromThisObj, Decl(typedArrays.ts, 121, 1)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) ->ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1447, 1)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.d.ts, 1198, 1)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >n : Symbol(n, Decl(typedArrays.ts, 123, 69)) >v : Symbol(v, Decl(typedArrays.ts, 123, 78)) @@ -489,81 +489,81 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) ->Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 2121, 42), Decl(lib.d.ts, 2411, 11)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 2401, 38)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4754, 48)) +>Int8Array : Symbol(Int8Array, Decl(lib.d.ts, 1379, 42), Decl(lib.d.ts, 1652, 11), Decl(lib.d.ts, 4731, 1)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.d.ts, 1641, 38), Decl(lib.d.ts, 4754, 48)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) ->Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 2411, 44), Decl(lib.d.ts, 2701, 11)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 2691, 39)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4786, 49)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.d.ts, 1652, 44), Decl(lib.d.ts, 1926, 11), Decl(lib.d.ts, 4763, 1)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.d.ts, 1915, 39), Decl(lib.d.ts, 4786, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) ->Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2991, 60), Decl(lib.d.ts, 3281, 11)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 3271, 39)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4858, 49)) +>Int16Array : Symbol(Int16Array, Decl(lib.d.ts, 2199, 60), Decl(lib.d.ts, 2473, 11), Decl(lib.d.ts, 4831, 1)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.d.ts, 2462, 39), Decl(lib.d.ts, 4858, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) ->Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 3281, 46), Decl(lib.d.ts, 3571, 11)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 3561, 40)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4890, 50)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.d.ts, 2473, 46), Decl(lib.d.ts, 2747, 11), Decl(lib.d.ts, 4867, 1)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.d.ts, 2736, 40), Decl(lib.d.ts, 4890, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) ->Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 3571, 48), Decl(lib.d.ts, 3861, 11)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3851, 39)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4922, 49)) +>Int32Array : Symbol(Int32Array, Decl(lib.d.ts, 2747, 48), Decl(lib.d.ts, 3019, 11), Decl(lib.d.ts, 4899, 1)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.d.ts, 3009, 39), Decl(lib.d.ts, 4922, 49)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) ->Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3861, 46), Decl(lib.d.ts, 4151, 11)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 4141, 40)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4954, 50)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.d.ts, 3019, 46), Decl(lib.d.ts, 3292, 11), Decl(lib.d.ts, 4931, 1)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.d.ts, 3282, 40), Decl(lib.d.ts, 4954, 50)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) ->Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 4151, 48), Decl(lib.d.ts, 4441, 11)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 4431, 41)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4986, 51)) +>Float32Array : Symbol(Float32Array, Decl(lib.d.ts, 3292, 48), Decl(lib.d.ts, 3566, 11), Decl(lib.d.ts, 4963, 1)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.d.ts, 3555, 41), Decl(lib.d.ts, 4986, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) ->Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 4441, 50), Decl(lib.d.ts, 4731, 11)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 4721, 41)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 5018, 51)) +>Float64Array : Symbol(Float64Array, Decl(lib.d.ts, 3566, 50), Decl(lib.d.ts, 3839, 11), Decl(lib.d.ts, 4995, 1)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.d.ts, 3829, 41), Decl(lib.d.ts, 5018, 51)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 124, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) ->Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 2701, 46), Decl(lib.d.ts, 2991, 11)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2981, 46)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4821, 56)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.d.ts, 1926, 46), Decl(lib.d.ts, 2199, 11), Decl(lib.d.ts, 4795, 1)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.d.ts, 2189, 46), Decl(lib.d.ts, 4821, 56)) >obj : Symbol(obj, Decl(typedArrays.ts, 123, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 123, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 123, 98)) diff --git a/tests/baselines/reference/typedArrays.types b/tests/baselines/reference/typedArrays.types index 33ae53f609d..9886982c0f2 100644 --- a/tests/baselines/reference/typedArrays.types +++ b/tests/baselines/reference/typedArrays.types @@ -274,9 +274,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >0 : number >Int8Array.from(obj) : Int8Array ->Int8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : number[] typedArrays[1] = Uint8Array.from(obj); @@ -285,9 +285,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >1 : number >Uint8Array.from(obj) : Uint8Array ->Uint8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : number[] typedArrays[2] = Int16Array.from(obj); @@ -296,9 +296,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >2 : number >Int16Array.from(obj) : Int16Array ->Int16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : number[] typedArrays[3] = Uint16Array.from(obj); @@ -307,9 +307,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >3 : number >Uint16Array.from(obj) : Uint16Array ->Uint16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : number[] typedArrays[4] = Int32Array.from(obj); @@ -318,9 +318,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >4 : number >Int32Array.from(obj) : Int32Array ->Int32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : number[] typedArrays[5] = Uint32Array.from(obj); @@ -329,9 +329,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >5 : number >Uint32Array.from(obj) : Uint32Array ->Uint32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : number[] typedArrays[6] = Float32Array.from(obj); @@ -340,9 +340,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >6 : number >Float32Array.from(obj) : Float32Array ->Float32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : number[] typedArrays[7] = Float64Array.from(obj); @@ -351,9 +351,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >7 : number >Float64Array.from(obj) : Float64Array ->Float64Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : number[] typedArrays[8] = Uint8ClampedArray.from(obj); @@ -362,9 +362,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >8 : number >Uint8ClampedArray.from(obj) : Uint8ClampedArray ->Uint8ClampedArray.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : number[] return typedArrays; @@ -386,9 +386,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >0 : number >Int8Array.from(obj) : Int8Array ->Int8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : ArrayLike typedArrays[1] = Uint8Array.from(obj); @@ -397,9 +397,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >1 : number >Uint8Array.from(obj) : Uint8Array ->Uint8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : ArrayLike typedArrays[2] = Int16Array.from(obj); @@ -408,9 +408,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >2 : number >Int16Array.from(obj) : Int16Array ->Int16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : ArrayLike typedArrays[3] = Uint16Array.from(obj); @@ -419,9 +419,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >3 : number >Uint16Array.from(obj) : Uint16Array ->Uint16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : ArrayLike typedArrays[4] = Int32Array.from(obj); @@ -430,9 +430,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >4 : number >Int32Array.from(obj) : Int32Array ->Int32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : ArrayLike typedArrays[5] = Uint32Array.from(obj); @@ -441,9 +441,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >5 : number >Uint32Array.from(obj) : Uint32Array ->Uint32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : ArrayLike typedArrays[6] = Float32Array.from(obj); @@ -452,9 +452,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >6 : number >Float32Array.from(obj) : Float32Array ->Float32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : ArrayLike typedArrays[7] = Float64Array.from(obj); @@ -463,9 +463,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >7 : number >Float64Array.from(obj) : Float64Array ->Float64Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : ArrayLike typedArrays[8] = Uint8ClampedArray.from(obj); @@ -474,9 +474,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >8 : number >Uint8ClampedArray.from(obj) : Uint8ClampedArray ->Uint8ClampedArray.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : ArrayLike return typedArrays; @@ -655,9 +655,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >0 : number >Int8Array.from(obj, mapFn) : Int8Array ->Int8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -667,9 +667,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >1 : number >Uint8Array.from(obj, mapFn) : Uint8Array ->Uint8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -679,9 +679,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >2 : number >Int16Array.from(obj, mapFn) : Int16Array ->Int16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -691,9 +691,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >3 : number >Uint16Array.from(obj, mapFn) : Uint16Array ->Uint16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -703,9 +703,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >4 : number >Int32Array.from(obj, mapFn) : Int32Array ->Int32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -715,9 +715,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >5 : number >Uint32Array.from(obj, mapFn) : Uint32Array ->Uint32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -727,9 +727,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >6 : number >Float32Array.from(obj, mapFn) : Float32Array ->Float32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -739,9 +739,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >7 : number >Float64Array.from(obj, mapFn) : Float64Array ->Float64Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -751,9 +751,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >8 : number >Uint8ClampedArray.from(obj, mapFn) : Uint8ClampedArray ->Uint8ClampedArray.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -780,9 +780,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >0 : number >Int8Array.from(obj, mapFn, thisArg) : Int8Array ->Int8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -793,9 +793,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >1 : number >Uint8Array.from(obj, mapFn, thisArg) : Uint8Array ->Uint8Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -806,9 +806,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >2 : number >Int16Array.from(obj, mapFn, thisArg) : Int16Array ->Int16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -819,9 +819,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >3 : number >Uint16Array.from(obj, mapFn, thisArg) : Uint16Array ->Uint16Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint16Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -832,9 +832,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >4 : number >Int32Array.from(obj, mapFn, thisArg) : Int32Array ->Int32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Int32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -845,9 +845,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >5 : number >Uint32Array.from(obj, mapFn, thisArg) : Uint32Array ->Uint32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -858,9 +858,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >6 : number >Float32Array.from(obj, mapFn, thisArg) : Float32Array ->Float32Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float32Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -871,9 +871,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >7 : number >Float64Array.from(obj, mapFn, thisArg) : Float64Array ->Float64Array.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Float64Array +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -884,9 +884,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >8 : number >Uint8ClampedArray.from(obj, mapFn, thisArg) : Uint8ClampedArray ->Uint8ClampedArray.from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : (arrayLike: ArrayLike | Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any) => Uint8ClampedArray +>from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} diff --git a/tests/baselines/reference/typeofAmbientExternalModules.errors.txt b/tests/baselines/reference/typeofAmbientExternalModules.errors.txt index cde3247b7cd..9046972c895 100644 --- a/tests/baselines/reference/typeofAmbientExternalModules.errors.txt +++ b/tests/baselines/reference/typeofAmbientExternalModules.errors.txt @@ -7,8 +7,8 @@ tests/cases/compiler/typeofAmbientExternalModules_2.ts(9,1): error TS2322: Type ==== tests/cases/compiler/typeofAmbientExternalModules_2.ts (2 errors) ==== /// /// - import ext = require('typeofAmbientExternalModules_0'); - import exp = require('typeofAmbientExternalModules_1'); + import ext = require('./typeofAmbientExternalModules_0'); + import exp = require('./typeofAmbientExternalModules_1'); var y1: typeof ext = ext; y1 = exp; diff --git a/tests/baselines/reference/typeofAmbientExternalModules.js b/tests/baselines/reference/typeofAmbientExternalModules.js index 1bfd549fb04..66e6d7d45ea 100644 --- a/tests/baselines/reference/typeofAmbientExternalModules.js +++ b/tests/baselines/reference/typeofAmbientExternalModules.js @@ -10,8 +10,8 @@ export = D; //// [typeofAmbientExternalModules_2.ts] /// /// -import ext = require('typeofAmbientExternalModules_0'); -import exp = require('typeofAmbientExternalModules_1'); +import ext = require('./typeofAmbientExternalModules_0'); +import exp = require('./typeofAmbientExternalModules_1'); var y1: typeof ext = ext; y1 = exp; @@ -35,8 +35,8 @@ module.exports = D; //// [typeofAmbientExternalModules_2.js] /// /// -var ext = require('typeofAmbientExternalModules_0'); -var exp = require('typeofAmbientExternalModules_1'); +var ext = require('./typeofAmbientExternalModules_0'); +var exp = require('./typeofAmbientExternalModules_1'); var y1 = ext; y1 = exp; var y2 = exp; diff --git a/tests/baselines/reference/typeofExternalModules.errors.txt b/tests/baselines/reference/typeofExternalModules.errors.txt index 05b56c9fe1b..0290a40c326 100644 --- a/tests/baselines/reference/typeofExternalModules.errors.txt +++ b/tests/baselines/reference/typeofExternalModules.errors.txt @@ -5,8 +5,8 @@ tests/cases/compiler/typeofExternalModules_core.ts(7,1): error TS2322: Type 'typ ==== tests/cases/compiler/typeofExternalModules_core.ts (2 errors) ==== - import ext = require('typeofExternalModules_external'); - import exp = require('typeofExternalModules_exportAssign'); + import ext = require('./typeofExternalModules_external'); + import exp = require('./typeofExternalModules_exportAssign'); var y1: typeof ext = ext; y1 = exp; diff --git a/tests/baselines/reference/typeofExternalModules.js b/tests/baselines/reference/typeofExternalModules.js index 8ffea8ca8ec..676f6f10b9f 100644 --- a/tests/baselines/reference/typeofExternalModules.js +++ b/tests/baselines/reference/typeofExternalModules.js @@ -8,8 +8,8 @@ class D { } export = D; //// [typeofExternalModules_core.ts] -import ext = require('typeofExternalModules_external'); -import exp = require('typeofExternalModules_exportAssign'); +import ext = require('./typeofExternalModules_external'); +import exp = require('./typeofExternalModules_exportAssign'); var y1: typeof ext = ext; y1 = exp; @@ -31,8 +31,8 @@ var D = (function () { })(); module.exports = D; //// [typeofExternalModules_core.js] -var ext = require('typeofExternalModules_external'); -var exp = require('typeofExternalModules_exportAssign'); +var ext = require('./typeofExternalModules_external'); +var exp = require('./typeofExternalModules_exportAssign'); var y1 = ext; y1 = exp; var y2 = exp; diff --git a/tests/baselines/reference/umdDependencyComment2.js b/tests/baselines/reference/umdDependencyComment2.js index cae34631517..f063df77308 100644 --- a/tests/baselines/reference/umdDependencyComment2.js +++ b/tests/baselines/reference/umdDependencyComment2.js @@ -7,14 +7,14 @@ m1.f(); //// [umdDependencyComment2.js] /// -(function (deps, factory) { +(function (factory) { if (typeof module === 'object' && typeof module.exports === 'object') { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === 'function' && define.amd) { - define(deps, factory); + define(["require", "exports", "bar", "m2"], factory); } -})(["require", "exports", "bar", "m2"], function (require, exports) { +})(function (require, exports) { var m1 = require("m2"); m1.f(); }); diff --git a/tests/baselines/reference/umdDependencyCommentName1.js b/tests/baselines/reference/umdDependencyCommentName1.js index 6cb87eb45f5..763e0523272 100644 --- a/tests/baselines/reference/umdDependencyCommentName1.js +++ b/tests/baselines/reference/umdDependencyCommentName1.js @@ -7,14 +7,14 @@ m1.f(); //// [umdDependencyCommentName1.js] /// -(function (deps, factory) { +(function (factory) { if (typeof module === 'object' && typeof module.exports === 'object') { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === 'function' && define.amd) { - define(deps, factory); + define(["require", "exports", "bar", "m2"], factory); } -})(["require", "exports", "bar", "m2"], function (require, exports, b) { +})(function (require, exports, b) { var m1 = require("m2"); m1.f(); }); diff --git a/tests/baselines/reference/umdDependencyCommentName2.js b/tests/baselines/reference/umdDependencyCommentName2.js index d474454936d..f749e4cc22d 100644 --- a/tests/baselines/reference/umdDependencyCommentName2.js +++ b/tests/baselines/reference/umdDependencyCommentName2.js @@ -11,14 +11,14 @@ m1.f(); /// /// /// -(function (deps, factory) { +(function (factory) { if (typeof module === 'object' && typeof module.exports === 'object') { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === 'function' && define.amd) { - define(deps, factory); + define(["require", "exports", "bar", "goo", "foo", "m2"], factory); } -})(["require", "exports", "bar", "goo", "foo", "m2"], function (require, exports, b, c) { +})(function (require, exports, b, c) { var m1 = require("m2"); m1.f(); }); diff --git a/tests/baselines/reference/underscoreMapFirst.types b/tests/baselines/reference/underscoreMapFirst.types index 4de320604bd..60cbcccda2b 100644 --- a/tests/baselines/reference/underscoreMapFirst.types +++ b/tests/baselines/reference/underscoreMapFirst.types @@ -124,7 +124,7 @@ class MyView extends View { >this.model.get("data") : any >this.model.get : any >this.model : any ->this : MyView +>this : this >model : any >get : any >"data" : string diff --git a/tests/baselines/reference/underscoreTest1.types b/tests/baselines/reference/underscoreTest1.types index 31b01c5f76e..7fe233c4490 100644 --- a/tests/baselines/reference/underscoreTest1.types +++ b/tests/baselines/reference/underscoreTest1.types @@ -547,7 +547,7 @@ _.flatten([1, [2], [3, [[4]]]]); >_.flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >_ : Underscore.Static >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } ->[1, [2], [3, [[4]]]] : (number | number[] | (number | number[][])[])[] +>[1, [2], [3, [[4]]]] : (number | (number | number[][])[])[] >1 : number >[2] : number[] >2 : number @@ -562,7 +562,7 @@ _.flatten([1, [2], [3, [[4]]]], true); >_.flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >_ : Underscore.Static >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } ->[1, [2], [3, [[4]]]] : (number | number[] | (number | number[][])[])[] +>[1, [2], [3, [[4]]]] : (number | (number | number[][])[])[] >1 : number >[2] : number[] >2 : number diff --git a/tests/baselines/reference/unionTypeFromArrayLiteral.types b/tests/baselines/reference/unionTypeFromArrayLiteral.types index 604925eb25f..63aefdd214c 100644 --- a/tests/baselines/reference/unionTypeFromArrayLiteral.types +++ b/tests/baselines/reference/unionTypeFromArrayLiteral.types @@ -83,15 +83,15 @@ var arr6 = [c, d]; // (C | D)[] >d : D var arr7 = [c, d, e]; // (C | D)[] ->arr7 : (C | D | E)[] ->[c, d, e] : (C | D | E)[] +>arr7 : (C | D)[] +>[c, d, e] : (C | D)[] >c : C >d : D >e : E var arr8 = [c, e]; // C[] ->arr8 : (C | E)[] ->[c, e] : (C | E)[] +>arr8 : C[] +>[c, e] : C[] >c : C >e : E diff --git a/tests/baselines/reference/unionTypeReduction.types b/tests/baselines/reference/unionTypeReduction.types index 8ecd9b33fb5..073d690162a 100644 --- a/tests/baselines/reference/unionTypeReduction.types +++ b/tests/baselines/reference/unionTypeReduction.types @@ -25,8 +25,8 @@ var e1: I2 | I3; >I3 : I3 var e2 = i2 || i3; // Type of e2 immediately reduced to I3 ->e2 : I2 | I3 ->i2 || i3 : I2 | I3 +>e2 : I3 +>i2 || i3 : I3 >i2 : I2 >i3 : I3 @@ -38,5 +38,5 @@ var r1 = e1(); // Type of e1 reduced to I3 upon accessing property or signature var r2 = e2(); >r2 : number >e2() : number ->e2 : I2 | I3 +>e2 : I3 diff --git a/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction1.types b/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction1.types index f609301c19c..caaa02b7b53 100644 --- a/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction1.types +++ b/tests/baselines/reference/unionTypeWithRecursiveSubtypeReduction1.types @@ -39,7 +39,7 @@ var t: Class | Property; >Property : Property t.parent; ->t.parent : Namespace | Module | Class +>t.parent : Namespace | Class >t : Class | Property ->parent : Namespace | Module | Class +>parent : Namespace | Class diff --git a/tests/baselines/reference/unusedImportDeclaration.js b/tests/baselines/reference/unusedImportDeclaration.js index 54885f09e36..04e897c081a 100644 --- a/tests/baselines/reference/unusedImportDeclaration.js +++ b/tests/baselines/reference/unusedImportDeclaration.js @@ -7,7 +7,7 @@ class TesterB { export = TesterB; //// [unusedImportDeclaration_testerA.ts] -import B = require("unusedImportDeclaration_testerB"); +import B = require("./unusedImportDeclaration_testerB"); var thingy: B = { me: "A" }; diff --git a/tests/baselines/reference/unusedImportDeclaration.symbols b/tests/baselines/reference/unusedImportDeclaration.symbols index 5506c4ad6b6..a298ba94631 100644 --- a/tests/baselines/reference/unusedImportDeclaration.symbols +++ b/tests/baselines/reference/unusedImportDeclaration.symbols @@ -1,5 +1,5 @@ === tests/cases/compiler/unusedImportDeclaration_testerA.ts === -import B = require("unusedImportDeclaration_testerB"); +import B = require("./unusedImportDeclaration_testerB"); >B : Symbol(B, Decl(unusedImportDeclaration_testerA.ts, 0, 0)) var thingy: B = { diff --git a/tests/baselines/reference/unusedImportDeclaration.types b/tests/baselines/reference/unusedImportDeclaration.types index dcedf3fd350..c14338756da 100644 --- a/tests/baselines/reference/unusedImportDeclaration.types +++ b/tests/baselines/reference/unusedImportDeclaration.types @@ -1,5 +1,5 @@ === tests/cases/compiler/unusedImportDeclaration_testerA.ts === -import B = require("unusedImportDeclaration_testerB"); +import B = require("./unusedImportDeclaration_testerB"); >B : typeof B var thingy: B = { diff --git a/tests/baselines/reference/validUseOfThisInSuper.types b/tests/baselines/reference/validUseOfThisInSuper.types index d7c882496e2..81b911dfdc9 100644 --- a/tests/baselines/reference/validUseOfThisInSuper.types +++ b/tests/baselines/reference/validUseOfThisInSuper.types @@ -15,9 +15,9 @@ class Super extends Base { super((() => this)()); // ok since this is not the case: The constructor declares parameter properties or the containing class declares instance member variables with initializers. >super((() => this)()) : void >super : typeof Base ->(() => this)() : Super ->(() => this) : () => Super ->() => this : () => Super ->this : Super +>(() => this)() : this +>(() => this) : () => this +>() => this : () => this +>this : this } } diff --git a/tests/baselines/reference/varArgsOnConstructorTypes.types b/tests/baselines/reference/varArgsOnConstructorTypes.types index 5ac9babd426..44987506101 100644 --- a/tests/baselines/reference/varArgsOnConstructorTypes.types +++ b/tests/baselines/reference/varArgsOnConstructorTypes.types @@ -28,14 +28,14 @@ export class B extends A { this.p1 = element; >this.p1 = element : any >this.p1 : number ->this : B +>this : this >p1 : number >element : any this.p2 = url; >this.p2 = url : string >this.p2 : string ->this : B +>this : this >p2 : string >url : string } diff --git a/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.js b/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.js index e3f60cfa17b..660a4017a7f 100644 --- a/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.js +++ b/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.js @@ -3,8 +3,8 @@ //// [visibilityOfCrossModuleTypeUsage_commands.ts] //visibilityOfCrossModuleTypeUsage -import fs = require('visibilityOfCrossModuleTypeUsage_fs'); -import server = require('visibilityOfCrossModuleTypeUsage_server'); +import fs = require('./visibilityOfCrossModuleTypeUsage_fs'); +import server = require('./visibilityOfCrossModuleTypeUsage_server'); export interface IConfiguration { workspace: server.IWorkspace; @@ -20,7 +20,7 @@ export interface IWorkspace { } //// [visibilityOfCrossModuleTypeUsage_fs.ts] -import commands = require('visibilityOfCrossModuleTypeUsage_commands'); +import commands = require('./visibilityOfCrossModuleTypeUsage_commands'); function run(configuration: commands.IConfiguration) { var absoluteWorkspacePath = configuration.workspace.toAbsolutePath(configuration.server); } diff --git a/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.symbols b/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.symbols index 0fdd5c4fbe1..d1132151097 100644 --- a/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.symbols +++ b/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.symbols @@ -1,12 +1,12 @@ === tests/cases/compiler/visibilityOfCrossModuleTypeUsage_fs.ts === -import commands = require('visibilityOfCrossModuleTypeUsage_commands'); +import commands = require('./visibilityOfCrossModuleTypeUsage_commands'); >commands : Symbol(commands, Decl(visibilityOfCrossModuleTypeUsage_fs.ts, 0, 0)) function run(configuration: commands.IConfiguration) { ->run : Symbol(run, Decl(visibilityOfCrossModuleTypeUsage_fs.ts, 0, 71)) +>run : Symbol(run, Decl(visibilityOfCrossModuleTypeUsage_fs.ts, 0, 73)) >configuration : Symbol(configuration, Decl(visibilityOfCrossModuleTypeUsage_fs.ts, 1, 13)) >commands : Symbol(commands, Decl(visibilityOfCrossModuleTypeUsage_fs.ts, 0, 0)) ->IConfiguration : Symbol(commands.IConfiguration, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 3, 67)) +>IConfiguration : Symbol(commands.IConfiguration, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 3, 69)) var absoluteWorkspacePath = configuration.workspace.toAbsolutePath(configuration.server); >absoluteWorkspacePath : Symbol(absoluteWorkspacePath, Decl(visibilityOfCrossModuleTypeUsage_fs.ts, 2, 7)) @@ -22,23 +22,23 @@ function run(configuration: commands.IConfiguration) { === tests/cases/compiler/visibilityOfCrossModuleTypeUsage_commands.ts === //visibilityOfCrossModuleTypeUsage -import fs = require('visibilityOfCrossModuleTypeUsage_fs'); +import fs = require('./visibilityOfCrossModuleTypeUsage_fs'); >fs : Symbol(fs, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 0, 0)) -import server = require('visibilityOfCrossModuleTypeUsage_server'); ->server : Symbol(server, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 2, 59)) +import server = require('./visibilityOfCrossModuleTypeUsage_server'); +>server : Symbol(server, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 2, 61)) export interface IConfiguration { ->IConfiguration : Symbol(IConfiguration, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 3, 67)) +>IConfiguration : Symbol(IConfiguration, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 3, 69)) workspace: server.IWorkspace; >workspace : Symbol(workspace, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 5, 33)) ->server : Symbol(server, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 2, 59)) +>server : Symbol(server, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 2, 61)) >IWorkspace : Symbol(server.IWorkspace, Decl(visibilityOfCrossModuleTypeUsage_server.ts, 1, 1)) server?: server.IServer; >server : Symbol(server, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 6, 33)) ->server : Symbol(server, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 2, 59)) +>server : Symbol(server, Decl(visibilityOfCrossModuleTypeUsage_commands.ts, 2, 61)) >IServer : Symbol(server.IServer, Decl(visibilityOfCrossModuleTypeUsage_server.ts, 0, 0)) } diff --git a/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.types b/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.types index 90cb54fe1e0..2ee7189a77c 100644 --- a/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.types +++ b/tests/baselines/reference/visibilityOfCrossModuleTypeUsage.types @@ -1,5 +1,5 @@ === tests/cases/compiler/visibilityOfCrossModuleTypeUsage_fs.ts === -import commands = require('visibilityOfCrossModuleTypeUsage_commands'); +import commands = require('./visibilityOfCrossModuleTypeUsage_commands'); >commands : typeof commands function run(configuration: commands.IConfiguration) { @@ -23,10 +23,10 @@ function run(configuration: commands.IConfiguration) { === tests/cases/compiler/visibilityOfCrossModuleTypeUsage_commands.ts === //visibilityOfCrossModuleTypeUsage -import fs = require('visibilityOfCrossModuleTypeUsage_fs'); +import fs = require('./visibilityOfCrossModuleTypeUsage_fs'); >fs : typeof fs -import server = require('visibilityOfCrossModuleTypeUsage_server'); +import server = require('./visibilityOfCrossModuleTypeUsage_server'); >server : typeof server export interface IConfiguration { diff --git a/tests/baselines/reference/voidAsNonAmbiguousReturnType.errors.txt b/tests/baselines/reference/voidAsNonAmbiguousReturnType.errors.txt index aa61a114145..ce8b52f316c 100644 --- a/tests/baselines/reference/voidAsNonAmbiguousReturnType.errors.txt +++ b/tests/baselines/reference/voidAsNonAmbiguousReturnType.errors.txt @@ -3,7 +3,7 @@ tests/cases/compiler/voidAsNonAmbiguousReturnType_0.ts(1,17): error TS2394: Over ==== tests/cases/compiler/voidAsNonAmbiguousReturnType_1.ts (0 errors) ==== /// - import fs = require("voidAsNonAmbiguousReturnType_0"); + import fs = require("./voidAsNonAmbiguousReturnType_0"); function main() { fs.mkdirSync('test'); // should not error - return types are the same diff --git a/tests/baselines/reference/voidAsNonAmbiguousReturnType.js b/tests/baselines/reference/voidAsNonAmbiguousReturnType.js index 713c4ffe47b..0ab15304493 100644 --- a/tests/baselines/reference/voidAsNonAmbiguousReturnType.js +++ b/tests/baselines/reference/voidAsNonAmbiguousReturnType.js @@ -6,7 +6,7 @@ export function mkdirSync(path: string, mode?: string): void {} //// [voidAsNonAmbiguousReturnType_1.ts] /// -import fs = require("voidAsNonAmbiguousReturnType_0"); +import fs = require("./voidAsNonAmbiguousReturnType_0"); function main() { fs.mkdirSync('test'); // should not error - return types are the same @@ -18,7 +18,7 @@ function mkdirSync(path, mode) { } exports.mkdirSync = mkdirSync; //// [voidAsNonAmbiguousReturnType_1.js] /// -var fs = require("voidAsNonAmbiguousReturnType_0"); +var fs = require("./voidAsNonAmbiguousReturnType_0"); function main() { fs.mkdirSync('test'); // should not error - return types are the same } diff --git a/tests/cases/compiler/APISample_compile.ts b/tests/cases/compiler/APISample_compile.ts index d3cc650dd2a..c63009f7d63 100644 --- a/tests/cases/compiler/APISample_compile.ts +++ b/tests/cases/compiler/APISample_compile.ts @@ -1,5 +1,5 @@ // @module: commonjs -// @includebuiltfile: typescript.d.ts +// @includebuiltfile: typescript_standalone.d.ts // @stripInternal:true /* diff --git a/tests/cases/compiler/APISample_linter.ts b/tests/cases/compiler/APISample_linter.ts index 9f9b55a0a67..8cb6934cee3 100644 --- a/tests/cases/compiler/APISample_linter.ts +++ b/tests/cases/compiler/APISample_linter.ts @@ -1,5 +1,5 @@ // @module: commonjs -// @includebuiltfile: typescript.d.ts +// @includebuiltfile: typescript_standalone.d.ts // @stripInternal:true /* diff --git a/tests/cases/compiler/APISample_transform.ts b/tests/cases/compiler/APISample_transform.ts index 48e27c4e008..88b9754536a 100644 --- a/tests/cases/compiler/APISample_transform.ts +++ b/tests/cases/compiler/APISample_transform.ts @@ -1,5 +1,5 @@ // @module: commonjs -// @includebuiltfile: typescript.d.ts +// @includebuiltfile: typescript_standalone.d.ts // @stripInternal:true /* diff --git a/tests/cases/compiler/APISample_watcher.ts b/tests/cases/compiler/APISample_watcher.ts index b152f86c378..9afa53ddf14 100644 --- a/tests/cases/compiler/APISample_watcher.ts +++ b/tests/cases/compiler/APISample_watcher.ts @@ -1,5 +1,5 @@ // @module: commonjs -// @includebuiltfile: typescript.d.ts +// @includebuiltfile: typescript_standalone.d.ts // @stripInternal:true /* diff --git a/tests/cases/compiler/aliasAssignments.ts b/tests/cases/compiler/aliasAssignments.ts index 4a83ee80da7..6a7ed9a9974 100644 --- a/tests/cases/compiler/aliasAssignments.ts +++ b/tests/cases/compiler/aliasAssignments.ts @@ -5,7 +5,7 @@ export class someClass { } // @Filename: aliasAssignments_1.ts -import moduleA = require("aliasAssignments_moduleA"); +import moduleA = require("./aliasAssignments_moduleA"); var x = moduleA; x = 1; // Should be error var y = 1; diff --git a/tests/cases/compiler/aliasUsageInAccessorsOfClass.ts b/tests/cases/compiler/aliasUsageInAccessorsOfClass.ts index 2aeddbad947..c6d1b1480c0 100644 --- a/tests/cases/compiler/aliasUsageInAccessorsOfClass.ts +++ b/tests/cases/compiler/aliasUsageInAccessorsOfClass.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @target: ES5 // @Filename: aliasUsage1_backbone.ts export class Model { @@ -6,14 +6,14 @@ export class Model { } // @Filename: aliasUsage1_moduleA.ts -import Backbone = require("aliasUsage1_backbone"); +import Backbone = require("./aliasUsage1_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsage1_main.ts -import Backbone = require("aliasUsage1_backbone"); -import moduleA = require("aliasUsage1_moduleA"); +import Backbone = require("./aliasUsage1_backbone"); +import moduleA = require("./aliasUsage1_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsageInArray.ts b/tests/cases/compiler/aliasUsageInArray.ts index 9c2e4e64e48..7f71b00e72a 100644 --- a/tests/cases/compiler/aliasUsageInArray.ts +++ b/tests/cases/compiler/aliasUsageInArray.ts @@ -5,14 +5,14 @@ export class Model { } // @Filename: aliasUsageInArray_moduleA.ts -import Backbone = require("aliasUsageInArray_backbone"); +import Backbone = require("./aliasUsageInArray_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsageInArray_main.ts -import Backbone = require("aliasUsageInArray_backbone"); -import moduleA = require("aliasUsageInArray_moduleA"); +import Backbone = require("./aliasUsageInArray_backbone"); +import moduleA = require("./aliasUsageInArray_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsageInFunctionExpression.ts b/tests/cases/compiler/aliasUsageInFunctionExpression.ts index 47b377c5b28..4c9a91b713b 100644 --- a/tests/cases/compiler/aliasUsageInFunctionExpression.ts +++ b/tests/cases/compiler/aliasUsageInFunctionExpression.ts @@ -1,18 +1,18 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasUsageInFunctionExpression_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInFunctionExpression_moduleA.ts -import Backbone = require("aliasUsageInFunctionExpression_backbone"); +import Backbone = require("./aliasUsageInFunctionExpression_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsageInFunctionExpression_main.ts -import Backbone = require("aliasUsageInFunctionExpression_backbone"); -import moduleA = require("aliasUsageInFunctionExpression_moduleA"); +import Backbone = require("./aliasUsageInFunctionExpression_backbone"); +import moduleA = require("./aliasUsageInFunctionExpression_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsageInGenericFunction.ts b/tests/cases/compiler/aliasUsageInGenericFunction.ts index d9966dbd299..f153195009c 100644 --- a/tests/cases/compiler/aliasUsageInGenericFunction.ts +++ b/tests/cases/compiler/aliasUsageInGenericFunction.ts @@ -1,18 +1,18 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasUsageInGenericFunction_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInGenericFunction_moduleA.ts -import Backbone = require("aliasUsageInGenericFunction_backbone"); +import Backbone = require("./aliasUsageInGenericFunction_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsageInGenericFunction_main.ts -import Backbone = require("aliasUsageInGenericFunction_backbone"); -import moduleA = require("aliasUsageInGenericFunction_moduleA"); +import Backbone = require("./aliasUsageInGenericFunction_backbone"); +import moduleA = require("./aliasUsageInGenericFunction_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsageInIndexerOfClass.ts b/tests/cases/compiler/aliasUsageInIndexerOfClass.ts index a6df86fbc99..a9aca7d2970 100644 --- a/tests/cases/compiler/aliasUsageInIndexerOfClass.ts +++ b/tests/cases/compiler/aliasUsageInIndexerOfClass.ts @@ -1,18 +1,18 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasUsageInIndexerOfClass_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInIndexerOfClass_moduleA.ts -import Backbone = require("aliasUsageInIndexerOfClass_backbone"); +import Backbone = require("./aliasUsageInIndexerOfClass_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsageInIndexerOfClass_main.ts -import Backbone = require("aliasUsageInIndexerOfClass_backbone"); -import moduleA = require("aliasUsageInIndexerOfClass_moduleA"); +import Backbone = require("./aliasUsageInIndexerOfClass_backbone"); +import moduleA = require("./aliasUsageInIndexerOfClass_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsageInObjectLiteral.ts b/tests/cases/compiler/aliasUsageInObjectLiteral.ts index a9d2017d50c..e16d5552fe6 100644 --- a/tests/cases/compiler/aliasUsageInObjectLiteral.ts +++ b/tests/cases/compiler/aliasUsageInObjectLiteral.ts @@ -1,18 +1,18 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasUsageInObjectLiteral_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInObjectLiteral_moduleA.ts -import Backbone = require("aliasUsageInObjectLiteral_backbone"); +import Backbone = require("./aliasUsageInObjectLiteral_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsageInObjectLiteral_main.ts -import Backbone = require("aliasUsageInObjectLiteral_backbone"); -import moduleA = require("aliasUsageInObjectLiteral_moduleA"); +import Backbone = require("./aliasUsageInObjectLiteral_backbone"); +import moduleA = require("./aliasUsageInObjectLiteral_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsageInOrExpression.ts b/tests/cases/compiler/aliasUsageInOrExpression.ts index e7ddd4014f0..540a3ae91c0 100644 --- a/tests/cases/compiler/aliasUsageInOrExpression.ts +++ b/tests/cases/compiler/aliasUsageInOrExpression.ts @@ -1,18 +1,18 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasUsageInOrExpression_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInOrExpression_moduleA.ts -import Backbone = require("aliasUsageInOrExpression_backbone"); +import Backbone = require("./aliasUsageInOrExpression_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsageInOrExpression_main.ts -import Backbone = require("aliasUsageInOrExpression_backbone"); -import moduleA = require("aliasUsageInOrExpression_moduleA"); +import Backbone = require("./aliasUsageInOrExpression_backbone"); +import moduleA = require("./aliasUsageInOrExpression_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause.ts b/tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause.ts index 548963ff123..c09c715ed3a 100644 --- a/tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause.ts +++ b/tests/cases/compiler/aliasUsageInTypeArgumentOfExtendsClause.ts @@ -1,18 +1,18 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasUsageInTypeArgumentOfExtendsClause_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInTypeArgumentOfExtendsClause_moduleA.ts -import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); +import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsageInTypeArgumentOfExtendsClause_main.ts -import Backbone = require("aliasUsageInTypeArgumentOfExtendsClause_backbone"); -import moduleA = require("aliasUsageInTypeArgumentOfExtendsClause_moduleA"); +import Backbone = require("./aliasUsageInTypeArgumentOfExtendsClause_backbone"); +import moduleA = require("./aliasUsageInTypeArgumentOfExtendsClause_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsageInVarAssignment.ts b/tests/cases/compiler/aliasUsageInVarAssignment.ts index 1644c825a4d..ed14d4241f5 100644 --- a/tests/cases/compiler/aliasUsageInVarAssignment.ts +++ b/tests/cases/compiler/aliasUsageInVarAssignment.ts @@ -1,18 +1,18 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasUsageInVarAssignment_backbone.ts export class Model { public someData: string; } // @Filename: aliasUsageInVarAssignment_moduleA.ts -import Backbone = require("aliasUsageInVarAssignment_backbone"); +import Backbone = require("./aliasUsageInVarAssignment_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: aliasUsageInVarAssignment_main.ts -import Backbone = require("aliasUsageInVarAssignment_backbone"); -import moduleA = require("aliasUsageInVarAssignment_moduleA"); +import Backbone = require("./aliasUsageInVarAssignment_backbone"); +import moduleA = require("./aliasUsageInVarAssignment_moduleA"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/aliasUsedAsNameValue.ts b/tests/cases/compiler/aliasUsedAsNameValue.ts index 20b60b53d1e..2426399252b 100644 --- a/tests/cases/compiler/aliasUsedAsNameValue.ts +++ b/tests/cases/compiler/aliasUsedAsNameValue.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasUsedAsNameValue_0.ts export var id: number; @@ -8,8 +8,8 @@ export function b(a: any): any { return null; } // @Filename: aliasUsedAsNameValue_2.ts /// /// -import mod = require("aliasUsedAsNameValue_0"); -import b = require("aliasUsedAsNameValue_1"); +import mod = require("./aliasUsedAsNameValue_0"); +import b = require("./aliasUsedAsNameValue_1"); export var a = function () { //var x = mod.id; // TODO needed hack that mod is loaded diff --git a/tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer.ts b/tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer.ts index f4d818d9562..37a6c42caee 100644 --- a/tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer.ts +++ b/tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: aliasWithInterfaceExportAssignmentUsedInVarInitializer_0.ts interface c { q3: number; @@ -6,5 +6,5 @@ interface c { export = c; // @Filename: aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.ts -import moduleA = require("aliasWithInterfaceExportAssignmentUsedInVarInitializer_0"); +import moduleA = require("./aliasWithInterfaceExportAssignmentUsedInVarInitializer_0"); var d = b.q3; \ No newline at end of file diff --git a/tests/cases/compiler/arrayOfExportedClass.ts b/tests/cases/compiler/arrayOfExportedClass.ts index 020be79408c..794a83fbd83 100644 --- a/tests/cases/compiler/arrayOfExportedClass.ts +++ b/tests/cases/compiler/arrayOfExportedClass.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: arrayOfExportedClass_0.ts class Car { foo: string; @@ -8,7 +8,7 @@ export = Car; // @Filename: arrayOfExportedClass_1.ts /// -import Car = require('arrayOfExportedClass_0'); +import Car = require('./arrayOfExportedClass_0'); class Road { diff --git a/tests/cases/compiler/asiAbstract.ts b/tests/cases/compiler/asiAbstract.ts new file mode 100644 index 00000000000..f9f36b12001 --- /dev/null +++ b/tests/cases/compiler/asiAbstract.ts @@ -0,0 +1,14 @@ +abstract +class NonAbstractClass { + abstract s(); +} + +class C2 { + abstract + nonAbstractFunction() { + } +} + +class C3 { + abstract +} diff --git a/tests/cases/compiler/asiPublicPrivateProtected.ts b/tests/cases/compiler/asiPublicPrivateProtected.ts new file mode 100644 index 00000000000..4ccd4c1c01b --- /dev/null +++ b/tests/cases/compiler/asiPublicPrivateProtected.ts @@ -0,0 +1,39 @@ +public +class NonPublicClass { + public s() { + } +} + +class NonPublicClass2 { + public + private nonPublicFunction() { + } +} +private +class NonPrivateClass { + private s() { + } +} + +class NonPrivateClass2 { + private + public nonPrivateFunction() { + } +} +protected +class NonProtectedClass { + protected s() { + } +} + +class NonProtectedClass2 { + protected + public nonProtectedFunction() { + } +} + +class ClassWithThreeMembers { + public + private + protected +} diff --git a/tests/cases/compiler/castExpressionParentheses.ts b/tests/cases/compiler/castExpressionParentheses.ts index 93b26ebaf4e..06908f39936 100644 --- a/tests/cases/compiler/castExpressionParentheses.ts +++ b/tests/cases/compiler/castExpressionParentheses.ts @@ -6,6 +6,11 @@ declare var a; ([1,3,]); ("string"); (23.0); +(1); +(1.); +(1.0); +(12e+34); +(0xff); (/regexp/g); (false); (true); @@ -22,6 +27,12 @@ declare var a; declare var A; // should keep the parentheses in emit +(1).foo; +(1.).foo; +(1.0).foo; +(12e+34).foo; +(0xff).foo; +((1.0)); (new A).foo; (typeof A).x; (-A).x; diff --git a/tests/cases/compiler/chainedImportAlias.ts b/tests/cases/compiler/chainedImportAlias.ts index 97bf28bf4a5..5b91c58f4bc 100644 --- a/tests/cases/compiler/chainedImportAlias.ts +++ b/tests/cases/compiler/chainedImportAlias.ts @@ -1,10 +1,10 @@ -//@module: commonjs +// @module: commonjs // @Filename: chainedImportAlias_file0.ts export module m { export function foo() { } } // @Filename: chainedImportAlias_file1.ts -import x = require('chainedImportAlias_file0'); +import x = require('./chainedImportAlias_file0'); import y = x; y.m.foo(); diff --git a/tests/cases/compiler/classExpressionExtendingAbstractClass.ts b/tests/cases/compiler/classExpressionExtendingAbstractClass.ts new file mode 100644 index 00000000000..aadec5be7a4 --- /dev/null +++ b/tests/cases/compiler/classExpressionExtendingAbstractClass.ts @@ -0,0 +1,7 @@ +abstract class A { + abstract foo(): void; +} + +var C = class extends A { // no error reported! +}; + diff --git a/tests/cases/compiler/commentInEmptyParameterList1.ts b/tests/cases/compiler/commentInEmptyParameterList1.ts index cae197735d5..65ddbca16dd 100644 --- a/tests/cases/compiler/commentInEmptyParameterList1.ts +++ b/tests/cases/compiler/commentInEmptyParameterList1.ts @@ -1,3 +1,3 @@ -// @comments:true +// @removeComments: false function foo(/** nothing */) { } \ No newline at end of file diff --git a/tests/cases/compiler/commentOnAmbientClass1.ts b/tests/cases/compiler/commentOnAmbientClass1.ts index c13e4193512..1c153e86bf2 100644 --- a/tests/cases/compiler/commentOnAmbientClass1.ts +++ b/tests/cases/compiler/commentOnAmbientClass1.ts @@ -1,5 +1,10 @@ //@filename: a.ts -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare class C { } diff --git a/tests/cases/compiler/commentOnAmbientEnum.ts b/tests/cases/compiler/commentOnAmbientEnum.ts index a9ebe107c98..20d89c1b70d 100644 --- a/tests/cases/compiler/commentOnAmbientEnum.ts +++ b/tests/cases/compiler/commentOnAmbientEnum.ts @@ -1,5 +1,10 @@ //@filename: a.ts -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare enum C { a, b, diff --git a/tests/cases/compiler/commentOnAmbientModule.ts b/tests/cases/compiler/commentOnAmbientModule.ts index 41e12a61902..a8aeab7efba 100644 --- a/tests/cases/compiler/commentOnAmbientModule.ts +++ b/tests/cases/compiler/commentOnAmbientModule.ts @@ -1,5 +1,10 @@ //@filename: a.ts -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare module C { function foo(); } diff --git a/tests/cases/compiler/commentOnAmbientVariable1.ts b/tests/cases/compiler/commentOnAmbientVariable1.ts index 0124be05053..ef539441bd2 100644 --- a/tests/cases/compiler/commentOnAmbientVariable1.ts +++ b/tests/cases/compiler/commentOnAmbientVariable1.ts @@ -1,4 +1,9 @@ -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare var v: number; // Don't keep this comment. diff --git a/tests/cases/compiler/commentOnAmbientfunction.ts b/tests/cases/compiler/commentOnAmbientfunction.ts index d549303fc4f..51f3b6194b5 100644 --- a/tests/cases/compiler/commentOnAmbientfunction.ts +++ b/tests/cases/compiler/commentOnAmbientfunction.ts @@ -1,5 +1,10 @@ //@filename: a.ts -/*! Keep this pinned comment */ +/*!========= + Keep this pinned comment + ========= +*/ + +/*! Don't keep this pinned comment */ declare function foo(); // Don't keep this comment. diff --git a/tests/cases/compiler/commentOnClassMethod1.ts b/tests/cases/compiler/commentOnClassMethod1.ts index 048e0de984c..a4cca2be8a2 100644 --- a/tests/cases/compiler/commentOnClassMethod1.ts +++ b/tests/cases/compiler/commentOnClassMethod1.ts @@ -1,4 +1,4 @@ -// @comments:true +// @removeComments: false class WebControls { /** * Render a control diff --git a/tests/cases/compiler/commentOnElidedModule1.ts b/tests/cases/compiler/commentOnElidedModule1.ts index 22014a86f5b..0cdb7694273 100644 --- a/tests/cases/compiler/commentOnElidedModule1.ts +++ b/tests/cases/compiler/commentOnElidedModule1.ts @@ -1,5 +1,10 @@ //@filename: a.ts -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ module ElidedModule { } diff --git a/tests/cases/compiler/commentOnExpressionStatement1.ts b/tests/cases/compiler/commentOnExpressionStatement1.ts index 430d226ff70..2f64fbcc08d 100644 --- a/tests/cases/compiler/commentOnExpressionStatement1.ts +++ b/tests/cases/compiler/commentOnExpressionStatement1.ts @@ -1,3 +1,3 @@ -// @comments: true +// @removeComments: false 1 + 1; // Comment. \ No newline at end of file diff --git a/tests/cases/compiler/commentOnIfStatement1.ts b/tests/cases/compiler/commentOnIfStatement1.ts index afff0000c86..295a0f513f7 100644 --- a/tests/cases/compiler/commentOnIfStatement1.ts +++ b/tests/cases/compiler/commentOnIfStatement1.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false // Test if (true) { diff --git a/tests/cases/compiler/commentOnImportStatement1.ts b/tests/cases/compiler/commentOnImportStatement1.ts index e26faf21fb6..597509075b3 100644 --- a/tests/cases/compiler/commentOnImportStatement1.ts +++ b/tests/cases/compiler/commentOnImportStatement1.ts @@ -1,5 +1,5 @@ -//@module: amd -// @comments: true +// @module: amd +// @removeComments: false /* Copyright */ import foo = require('./foo'); diff --git a/tests/cases/compiler/commentOnImportStatement2.ts b/tests/cases/compiler/commentOnImportStatement2.ts index 096041f3f5b..ccb5b57887a 100644 --- a/tests/cases/compiler/commentOnImportStatement2.ts +++ b/tests/cases/compiler/commentOnImportStatement2.ts @@ -1,4 +1,4 @@ -//@module: commonjs -// @comments: true +// @module: commonjs +// @removeComments: false /* not copyright */ import foo = require('./foo'); \ No newline at end of file diff --git a/tests/cases/compiler/commentOnImportStatement3.ts b/tests/cases/compiler/commentOnImportStatement3.ts index 0cfef3feeff..d60756ecf7e 100644 --- a/tests/cases/compiler/commentOnImportStatement3.ts +++ b/tests/cases/compiler/commentOnImportStatement3.ts @@ -1,5 +1,5 @@ -//@module: commonjs -// @comments: true +// @module: commonjs +// @removeComments: false /* copyright */ /* not copyright */ diff --git a/tests/cases/compiler/commentOnInterface1.ts b/tests/cases/compiler/commentOnInterface1.ts index a394da0dd2c..c22229b7ccf 100644 --- a/tests/cases/compiler/commentOnInterface1.ts +++ b/tests/cases/compiler/commentOnInterface1.ts @@ -1,5 +1,10 @@ //@filename: a.ts -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ interface I { } diff --git a/tests/cases/compiler/commentOnSignature1.ts b/tests/cases/compiler/commentOnSignature1.ts index 770c103a9fc..e8d2d831e8b 100644 --- a/tests/cases/compiler/commentOnSignature1.ts +++ b/tests/cases/compiler/commentOnSignature1.ts @@ -1,5 +1,10 @@ // @filename: a.ts -/*! Keep this pinned comment */ +/*!================= + Keep this pinned + ================= +*/ + +/*! Don't keep this pinned comment */ function foo(n: number): void; // Don't keep this comment. function foo(s: string): void; diff --git a/tests/cases/compiler/commentOnSimpleArrowFunctionBody1.ts b/tests/cases/compiler/commentOnSimpleArrowFunctionBody1.ts index 548548de3d6..b1edc61cb82 100644 --- a/tests/cases/compiler/commentOnSimpleArrowFunctionBody1.ts +++ b/tests/cases/compiler/commentOnSimpleArrowFunctionBody1.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false function Foo(x: any) { } diff --git a/tests/cases/compiler/commentsBeforeFunctionExpression1.ts b/tests/cases/compiler/commentsBeforeFunctionExpression1.ts index 64fe3b7b6ec..d3b21c18475 100644 --- a/tests/cases/compiler/commentsBeforeFunctionExpression1.ts +++ b/tests/cases/compiler/commentsBeforeFunctionExpression1.ts @@ -1,4 +1,4 @@ -// @comments:true +// @removeComments: false var v = { f: /**own f*/ (a) => 0 } diff --git a/tests/cases/compiler/commentsBeforeVariableStatement1.ts b/tests/cases/compiler/commentsBeforeVariableStatement1.ts index e6c49f17d7f..e4e019cef5e 100644 --- a/tests/cases/compiler/commentsBeforeVariableStatement1.ts +++ b/tests/cases/compiler/commentsBeforeVariableStatement1.ts @@ -1,4 +1,4 @@ -//@module: amd -// @comments: true +// @module: amd +// @removeComments: false /** b's comment*/ export var b: number; diff --git a/tests/cases/compiler/commentsClass.ts b/tests/cases/compiler/commentsClass.ts index e9a8f3cee1d..8823f5db6d2 100644 --- a/tests/cases/compiler/commentsClass.ts +++ b/tests/cases/compiler/commentsClass.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** This is class c2 without constuctor*/ class c2 { diff --git a/tests/cases/compiler/commentsClassMembers.ts b/tests/cases/compiler/commentsClassMembers.ts index 92a3a1356f2..414f560c2a7 100644 --- a/tests/cases/compiler/commentsClassMembers.ts +++ b/tests/cases/compiler/commentsClassMembers.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** This is comment for c1*/ class c1 { diff --git a/tests/cases/compiler/commentsCommentParsing.ts b/tests/cases/compiler/commentsCommentParsing.ts index 7bfc9de4fd2..a1fbf50c61f 100644 --- a/tests/cases/compiler/commentsCommentParsing.ts +++ b/tests/cases/compiler/commentsCommentParsing.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /// This is simple /// comments function simple() { diff --git a/tests/cases/compiler/commentsDottedModuleName.ts b/tests/cases/compiler/commentsDottedModuleName.ts index 136d189d1ac..55266931036 100644 --- a/tests/cases/compiler/commentsDottedModuleName.ts +++ b/tests/cases/compiler/commentsDottedModuleName.ts @@ -1,7 +1,7 @@ -//@module: amd +// @module: amd // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** this is multi declare module*/ export module outerModule.InnerModule { diff --git a/tests/cases/compiler/commentsEnums.ts b/tests/cases/compiler/commentsEnums.ts index 2d69c863f2d..d7d654c1e72 100644 --- a/tests/cases/compiler/commentsEnums.ts +++ b/tests/cases/compiler/commentsEnums.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** Enum of colors*/ enum Colors { diff --git a/tests/cases/compiler/commentsExternalModules.ts b/tests/cases/compiler/commentsExternalModules.ts index 86c6b2be8d3..04489611427 100644 --- a/tests/cases/compiler/commentsExternalModules.ts +++ b/tests/cases/compiler/commentsExternalModules.ts @@ -1,7 +1,7 @@ -//@module: amd +// @module: amd // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @Filename: commentsExternalModules_0.ts /** Module comment*/ diff --git a/tests/cases/compiler/commentsExternalModules2.ts b/tests/cases/compiler/commentsExternalModules2.ts index 354e74738be..b1dfb04902b 100644 --- a/tests/cases/compiler/commentsExternalModules2.ts +++ b/tests/cases/compiler/commentsExternalModules2.ts @@ -1,7 +1,7 @@ -//@module: amd +// @module: amd // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @Filename: commentsExternalModules2_0.ts /** Module comment*/ diff --git a/tests/cases/compiler/commentsExternalModules3.ts b/tests/cases/compiler/commentsExternalModules3.ts index 2f214c5d28c..a59458893ca 100644 --- a/tests/cases/compiler/commentsExternalModules3.ts +++ b/tests/cases/compiler/commentsExternalModules3.ts @@ -1,7 +1,7 @@ -//@module: commonjs +// @module: commonjs // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @Filename: commentsExternalModules2_0.ts /** Module comment*/ @@ -56,7 +56,7 @@ var myvar2 = new m4.m2.c(); // @Filename: commentsExternalModules_1.ts /**This is on import declaration*/ -import extMod = require("commentsExternalModules2_0"); // trailing comment 1 +import extMod = require("./commentsExternalModules2_0"); // trailing comment 1 extMod.m1.fooExport(); export var newVar = new extMod.m1.m2.c(); extMod.m4.fooExport(); diff --git a/tests/cases/compiler/commentsFormatting.ts b/tests/cases/compiler/commentsFormatting.ts index b413f0f92ea..c0f2d3093f9 100644 --- a/tests/cases/compiler/commentsFormatting.ts +++ b/tests/cases/compiler/commentsFormatting.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false module m { /** this is first line - aligned to class declaration diff --git a/tests/cases/compiler/commentsFunction.ts b/tests/cases/compiler/commentsFunction.ts index b71da4ae085..1b379fd15c6 100644 --- a/tests/cases/compiler/commentsFunction.ts +++ b/tests/cases/compiler/commentsFunction.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** This comment should appear for foo*/ function foo() { diff --git a/tests/cases/compiler/commentsInheritance.ts b/tests/cases/compiler/commentsInheritance.ts index aa4c54ee128..40924851766 100644 --- a/tests/cases/compiler/commentsInheritance.ts +++ b/tests/cases/compiler/commentsInheritance.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** i1 is interface with properties*/ interface i1 { diff --git a/tests/cases/compiler/commentsInterface.ts b/tests/cases/compiler/commentsInterface.ts index b6455e9235d..2e35a95f207 100644 --- a/tests/cases/compiler/commentsInterface.ts +++ b/tests/cases/compiler/commentsInterface.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** this is interface 1*/ interface i1 { } diff --git a/tests/cases/compiler/commentsModules.ts b/tests/cases/compiler/commentsModules.ts index 29ac0c22373..943ef640545 100644 --- a/tests/cases/compiler/commentsModules.ts +++ b/tests/cases/compiler/commentsModules.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** Module comment*/ module m1 { /** b's comment*/ diff --git a/tests/cases/compiler/commentsMultiModuleMultiFile.ts b/tests/cases/compiler/commentsMultiModuleMultiFile.ts index 2d19f775bda..04066b975ab 100644 --- a/tests/cases/compiler/commentsMultiModuleMultiFile.ts +++ b/tests/cases/compiler/commentsMultiModuleMultiFile.ts @@ -1,7 +1,7 @@ -//@module: amd +// @module: amd // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @Filename: commentsMultiModuleMultiFile_0.ts /** this is multi declare module*/ diff --git a/tests/cases/compiler/commentsMultiModuleSingleFile.ts b/tests/cases/compiler/commentsMultiModuleSingleFile.ts index a9871d31dbe..651a3cb07ba 100644 --- a/tests/cases/compiler/commentsMultiModuleSingleFile.ts +++ b/tests/cases/compiler/commentsMultiModuleSingleFile.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** this is multi declare module*/ module multiM { diff --git a/tests/cases/compiler/commentsOnObjectLiteral1.ts b/tests/cases/compiler/commentsOnObjectLiteral1.ts index 7bc92e8664e..79e5aa81205 100644 --- a/tests/cases/compiler/commentsOnObjectLiteral1.ts +++ b/tests/cases/compiler/commentsOnObjectLiteral1.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false var Person = makeClass( /** @scope Person diff --git a/tests/cases/compiler/commentsOnObjectLiteral2.ts b/tests/cases/compiler/commentsOnObjectLiteral2.ts index da2ee14b730..952df7ed969 100644 --- a/tests/cases/compiler/commentsOnObjectLiteral2.ts +++ b/tests/cases/compiler/commentsOnObjectLiteral2.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false var Person = makeClass( { /** diff --git a/tests/cases/compiler/commentsOnObjectLiteral3.ts b/tests/cases/compiler/commentsOnObjectLiteral3.ts index 6650b21e167..b983364bf1f 100644 --- a/tests/cases/compiler/commentsOnObjectLiteral3.ts +++ b/tests/cases/compiler/commentsOnObjectLiteral3.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false // @target: ES5 var v = { diff --git a/tests/cases/compiler/commentsOnObjectLiteral4.ts b/tests/cases/compiler/commentsOnObjectLiteral4.ts index e13668530c7..d685304f31e 100644 --- a/tests/cases/compiler/commentsOnObjectLiteral4.ts +++ b/tests/cases/compiler/commentsOnObjectLiteral4.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false // @target: ES5 var v = { diff --git a/tests/cases/compiler/commentsOnReturnStatement1.ts b/tests/cases/compiler/commentsOnReturnStatement1.ts index 966d66511b3..0f689fb4681 100644 --- a/tests/cases/compiler/commentsOnReturnStatement1.ts +++ b/tests/cases/compiler/commentsOnReturnStatement1.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false class DebugClass { public static debugFunc() { // Start Debugger Test Code diff --git a/tests/cases/compiler/commentsOnStaticMembers.ts b/tests/cases/compiler/commentsOnStaticMembers.ts index 7dc1a41c953..dd5169a972a 100644 --- a/tests/cases/compiler/commentsOnStaticMembers.ts +++ b/tests/cases/compiler/commentsOnStaticMembers.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false class test { /** diff --git a/tests/cases/compiler/commentsOverloads.ts b/tests/cases/compiler/commentsOverloads.ts index 85a1a9d8064..efb5d73df8f 100644 --- a/tests/cases/compiler/commentsOverloads.ts +++ b/tests/cases/compiler/commentsOverloads.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** this is signature 1*/ function f1(/**param a*/a: number): number; function f1(b: string): number; diff --git a/tests/cases/compiler/commentsPropertySignature1.ts b/tests/cases/compiler/commentsPropertySignature1.ts index b92b9c6ded7..48ba5c3fda1 100644 --- a/tests/cases/compiler/commentsPropertySignature1.ts +++ b/tests/cases/compiler/commentsPropertySignature1.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false var a = { /** own x*/ x: 0 diff --git a/tests/cases/compiler/commentsTypeParameters.ts b/tests/cases/compiler/commentsTypeParameters.ts index 4fc3a30a192..c1e49280ed0 100644 --- a/tests/cases/compiler/commentsTypeParameters.ts +++ b/tests/cases/compiler/commentsTypeParameters.ts @@ -1,5 +1,5 @@ // @declaration: true -// @comments: true +// @removeComments: false class C { method(a: U) { } diff --git a/tests/cases/compiler/commentsVarDecl.ts b/tests/cases/compiler/commentsVarDecl.ts index 3b7d56e4078..cb244e94365 100644 --- a/tests/cases/compiler/commentsVarDecl.ts +++ b/tests/cases/compiler/commentsVarDecl.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** Variable comments*/ var myVariable = 10; // This trailing Comment1 diff --git a/tests/cases/compiler/commentsVariableStatement1.ts b/tests/cases/compiler/commentsVariableStatement1.ts index 368115af17c..e9c9ca28a08 100644 --- a/tests/cases/compiler/commentsVariableStatement1.ts +++ b/tests/cases/compiler/commentsVariableStatement1.ts @@ -1,5 +1,5 @@ // @declaration: true -// @comments: true +// @removeComments: false /** Comment */ var v = 1; \ No newline at end of file diff --git a/tests/cases/compiler/commentsdoNotEmitComments.ts b/tests/cases/compiler/commentsdoNotEmitComments.ts index 6895f67b6b0..e2aaa269e1f 100644 --- a/tests/cases/compiler/commentsdoNotEmitComments.ts +++ b/tests/cases/compiler/commentsdoNotEmitComments.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: false +// @removeComments: true /** Variable comments*/ var myVariable = 10; diff --git a/tests/cases/compiler/commentsemitComments.ts b/tests/cases/compiler/commentsemitComments.ts index fdedb787739..b20fbb9641a 100644 --- a/tests/cases/compiler/commentsemitComments.ts +++ b/tests/cases/compiler/commentsemitComments.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false /** Variable comments*/ var myVariable = 10; diff --git a/tests/cases/compiler/commonjsSafeImport.ts b/tests/cases/compiler/commonjsSafeImport.ts new file mode 100644 index 00000000000..ce494ee54ad --- /dev/null +++ b/tests/cases/compiler/commonjsSafeImport.ts @@ -0,0 +1,11 @@ +// @target: ES5 +// @module: commonjs +// @declaration: true +// @filename: 10_lib.ts + +export function Foo() {} + +// @filename: main.ts +import { Foo } from './10_lib'; + +Foo(); diff --git a/tests/cases/compiler/constEnumToStringNoComments.ts b/tests/cases/compiler/constEnumToStringNoComments.ts index 802ee9068bb..f98ae8d509e 100644 --- a/tests/cases/compiler/constEnumToStringNoComments.ts +++ b/tests/cases/compiler/constEnumToStringNoComments.ts @@ -1,4 +1,4 @@ -// @comments: false +// @removeComments: true const enum Foo { X = 100, Y = 0.5, diff --git a/tests/cases/compiler/constEnumToStringWithComments.ts b/tests/cases/compiler/constEnumToStringWithComments.ts index e10c3591131..ce85d8b256f 100644 --- a/tests/cases/compiler/constEnumToStringWithComments.ts +++ b/tests/cases/compiler/constEnumToStringWithComments.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false const enum Foo { X = 100, Y = 0.5, diff --git a/tests/cases/compiler/declFileAccessors.ts b/tests/cases/compiler/declFileAccessors.ts index ea9b05f2fef..bc41722f77d 100644 --- a/tests/cases/compiler/declFileAccessors.ts +++ b/tests/cases/compiler/declFileAccessors.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @module: commonjs // @Filename: declFileAccessors_0.ts diff --git a/tests/cases/compiler/declFileAliasUseBeforeDeclaration.ts b/tests/cases/compiler/declFileAliasUseBeforeDeclaration.ts index c803f65cf7c..63cd2761a9e 100644 --- a/tests/cases/compiler/declFileAliasUseBeforeDeclaration.ts +++ b/tests/cases/compiler/declFileAliasUseBeforeDeclaration.ts @@ -1,9 +1,9 @@ -//@module: commonjs -//@declaration: true +// @module: commonjs +// @declaration: true // @Filename: declFileAliasUseBeforeDeclaration_foo.ts export class Foo { } // @Filename: declFileAliasUseBeforeDeclaration_test.ts export function bar(a: foo.Foo) { } -import foo = require("declFileAliasUseBeforeDeclaration_foo"); \ No newline at end of file +import foo = require("./declFileAliasUseBeforeDeclaration_foo"); \ No newline at end of file diff --git a/tests/cases/compiler/declFileCallSignatures.ts b/tests/cases/compiler/declFileCallSignatures.ts index 9ff74730fbf..4225c580755 100644 --- a/tests/cases/compiler/declFileCallSignatures.ts +++ b/tests/cases/compiler/declFileCallSignatures.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @module: commonjs // @Filename: declFileCallSignatures_0.ts diff --git a/tests/cases/compiler/declFileClassExtendsNull.ts b/tests/cases/compiler/declFileClassExtendsNull.ts new file mode 100644 index 00000000000..d21fd5d3805 --- /dev/null +++ b/tests/cases/compiler/declFileClassExtendsNull.ts @@ -0,0 +1,5 @@ +// @target: ES5 +// @declaration: true + +class ExtendsNull extends null { +} \ No newline at end of file diff --git a/tests/cases/compiler/declFileConstructSignatures.ts b/tests/cases/compiler/declFileConstructSignatures.ts index b81e4f831ea..717619e8b2f 100644 --- a/tests/cases/compiler/declFileConstructSignatures.ts +++ b/tests/cases/compiler/declFileConstructSignatures.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @module: commonjs // @Filename: declFileConstructSignatures_0.ts diff --git a/tests/cases/compiler/declFileConstructors.ts b/tests/cases/compiler/declFileConstructors.ts index c1f4862e44c..8a6a8a6c473 100644 --- a/tests/cases/compiler/declFileConstructors.ts +++ b/tests/cases/compiler/declFileConstructors.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @module: commonjs // @Filename: declFileConstructors_0.ts diff --git a/tests/cases/compiler/declFileForExportedImport.ts b/tests/cases/compiler/declFileForExportedImport.ts index ec286c2711e..8809d0baa37 100644 --- a/tests/cases/compiler/declFileForExportedImport.ts +++ b/tests/cases/compiler/declFileForExportedImport.ts @@ -5,7 +5,7 @@ export var x: number; // @Filename: declFileForExportedImport_1.ts /// -export import a = require('declFileForExportedImport_0'); +export import a = require('./declFileForExportedImport_0'); var y = a.x; export import b = a; diff --git a/tests/cases/compiler/declFileFunctions.ts b/tests/cases/compiler/declFileFunctions.ts index 7b9c55e9214..4217fdf6e95 100644 --- a/tests/cases/compiler/declFileFunctions.ts +++ b/tests/cases/compiler/declFileFunctions.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @module: commonjs // @Filename: declFileFunctions_0.ts diff --git a/tests/cases/compiler/declFileImportModuleWithExportAssignment.ts b/tests/cases/compiler/declFileImportModuleWithExportAssignment.ts index 3e00557eec5..3a619905768 100644 --- a/tests/cases/compiler/declFileImportModuleWithExportAssignment.ts +++ b/tests/cases/compiler/declFileImportModuleWithExportAssignment.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @declaration: true // @Filename: declFileImportModuleWithExportAssignment_0.ts @@ -21,6 +21,6 @@ export = m2; // @Filename: declFileImportModuleWithExportAssignment_1.ts /**This is on import declaration*/ -import a1 = require("declFileImportModuleWithExportAssignment_0"); +import a1 = require("./declFileImportModuleWithExportAssignment_0"); export var a = a1; a.test1(null, null, null); diff --git a/tests/cases/compiler/declFileIndexSignatures.ts b/tests/cases/compiler/declFileIndexSignatures.ts index 3c9aaf34bfc..efc43f80e1f 100644 --- a/tests/cases/compiler/declFileIndexSignatures.ts +++ b/tests/cases/compiler/declFileIndexSignatures.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @module: commonjs // @Filename: declFileIndexSignatures_0.ts diff --git a/tests/cases/compiler/declFileMethods.ts b/tests/cases/compiler/declFileMethods.ts index a5c31728ccd..50add66d97c 100644 --- a/tests/cases/compiler/declFileMethods.ts +++ b/tests/cases/compiler/declFileMethods.ts @@ -1,6 +1,6 @@ // @target: ES5 // @declaration: true -// @comments: true +// @removeComments: false // @module: commonjs // @Filename: declFileMethods_0.ts diff --git a/tests/cases/compiler/declarationEmit_exportAssignment.ts b/tests/cases/compiler/declarationEmit_exportAssignment.ts index 166f4abe8e7..bf9e443c85a 100644 --- a/tests/cases/compiler/declarationEmit_exportAssignment.ts +++ b/tests/cases/compiler/declarationEmit_exportAssignment.ts @@ -8,5 +8,5 @@ export function bar() { } export interface Buzz { } // @filename: index.ts -import {foo} from "utils"; +import {foo} from "./utils"; export = foo; \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmit_exportDeclaration.ts b/tests/cases/compiler/declarationEmit_exportDeclaration.ts index a9e0bda761f..c7cff923b08 100644 --- a/tests/cases/compiler/declarationEmit_exportDeclaration.ts +++ b/tests/cases/compiler/declarationEmit_exportDeclaration.ts @@ -8,7 +8,7 @@ export function bar() { } export interface Buzz { } // @filename: index.ts -import {foo, bar, Buzz} from "utils"; +import {foo, bar, Buzz} from "./utils"; foo(); let obj: Buzz; diff --git a/tests/cases/compiler/declarationEmit_nameConflicts.ts b/tests/cases/compiler/declarationEmit_nameConflicts.ts index 66eb732ddae..a30f4b2ff1b 100644 --- a/tests/cases/compiler/declarationEmit_nameConflicts.ts +++ b/tests/cases/compiler/declarationEmit_nameConflicts.ts @@ -5,7 +5,7 @@ module f { export class c { } } export = f; // @Filename: declarationEmit_nameConflicts_0.ts -import im = require('declarationEmit_nameConflicts_1'); +import im = require('./declarationEmit_nameConflicts_1'); export module M { export function f() { } export class C { } diff --git a/tests/cases/compiler/decoratorMetadataOnInferredType.ts b/tests/cases/compiler/decoratorMetadataOnInferredType.ts new file mode 100644 index 00000000000..170afe3b3e5 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataOnInferredType.ts @@ -0,0 +1,21 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs + +declare var console: { + log(msg: string): void; +}; + +class A { + constructor() { console.log('new A'); } +} + +function decorator(target: Object, propertyKey: string) { +} + +export class B { + @decorator + x = new A(); +} diff --git a/tests/cases/compiler/decoratorMetadataWithConstructorType.ts b/tests/cases/compiler/decoratorMetadataWithConstructorType.ts new file mode 100644 index 00000000000..31c42ee9b43 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithConstructorType.ts @@ -0,0 +1,21 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs + +declare var console: { + log(msg: string): void; +}; + +class A { + constructor() { console.log('new A'); } +} + +function decorator(target: Object, propertyKey: string) { +} + +export class B { + @decorator + x: A = new A(); +} diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision.ts new file mode 100644 index 00000000000..8d198e44752 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export class db { + public doSomething() { + } +} + +// @filename: service.ts +import {db} from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db; + + constructor(db: db) { + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision2.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision2.ts new file mode 100644 index 00000000000..ac097dd3ba4 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision2.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export class db { + public doSomething() { + } +} + +// @filename: service.ts +import {db as Database} from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: Database; + + constructor(db: Database) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision3.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision3.ts new file mode 100644 index 00000000000..e15570cb5ba --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision3.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export class db { + public doSomething() { + } +} + +// @filename: service.ts +import db = require('./db'); +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; + + constructor(db: db.db) { // collision with namespace of external module db + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision4.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision4.ts new file mode 100644 index 00000000000..d04d1300531 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision4.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export class db { + public doSomething() { + } +} + +// @filename: service.ts +import db from './db'; // error no default export +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; + + constructor(db: db.db) { + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision5.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision5.ts new file mode 100644 index 00000000000..24934963b3e --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision5.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export default class db { + public doSomething() { + } +} + +// @filename: service.ts +import db from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db; + + constructor(db: db) { // collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision6.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision6.ts new file mode 100644 index 00000000000..2043279c4aa --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision6.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export default class db { + public doSomething() { + } +} + +// @filename: service.ts +import database from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: database; + + constructor(db: database) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts new file mode 100644 index 00000000000..bbedf61c6df --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export default class db { + public doSomething() { + } +} + +// @filename: service.ts +import db from './db'; +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: db.db; //error + + constructor(db: db.db) { // error + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision8.ts b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision8.ts new file mode 100644 index 00000000000..e3318d813a8 --- /dev/null +++ b/tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision8.ts @@ -0,0 +1,26 @@ +// @noemithelpers: true +// @experimentaldecorators: true +// @emitdecoratormetadata: true +// @target: es5 +// @module: commonjs +// @filename: db.ts +export class db { + public doSomething() { + } +} + +// @filename: service.ts +import database = require('./db'); +function someDecorator(target) { + return target; +} +@someDecorator +class MyClass { + db: database.db; + + constructor(db: database.db) { // no collision + this.db = db; + this.db.doSomething(); + } +} +export {MyClass}; diff --git a/tests/cases/compiler/destructuringWithGenericParameter.ts b/tests/cases/compiler/destructuringWithGenericParameter.ts new file mode 100644 index 00000000000..99b5bfade36 --- /dev/null +++ b/tests/cases/compiler/destructuringWithGenericParameter.ts @@ -0,0 +1,13 @@ +class GenericClass { + payload: T; +} + +var genericObject = new GenericClass<{ greeting: string }>(); + +function genericFunction(object: GenericClass, callback: (payload: T) => void) { + callback(object.payload); +} + +genericFunction(genericObject, ({greeting}) => { + var s = greeting.toLocaleLowerCase(); // Greeting should be of type string +}); diff --git a/tests/cases/compiler/doNotEmitDetachedComments.ts b/tests/cases/compiler/doNotEmitDetachedComments.ts new file mode 100644 index 00000000000..13facb6625e --- /dev/null +++ b/tests/cases/compiler/doNotEmitDetachedComments.ts @@ -0,0 +1,27 @@ +// @removeComments: true +/* + + multi line + comment +*/ + +var x = 10; + +// Single Line comment + +function foo() { } + + +/* + multi-line comment + +*/ + + +//======================== + + +function bar() { } + + +//======================== diff --git a/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts new file mode 100644 index 00000000000..094d624df40 --- /dev/null +++ b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts @@ -0,0 +1,38 @@ +// @removeComments: true +class A { + constructor() { + // Single Line Comment + + var x = 10; + } +} + +class B { + constructor() { + /* + Multi-line comment + */ + + var y = 10; + } +} + +class C { + constructor() { + // Single Line Comment with more than one blank line + + + var x = 10; + } +} + +class D { + constructor() { + /* + Multi-line comment with more than one blank line + */ + + + var y = 10; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts new file mode 100644 index 00000000000..83dd8716df2 --- /dev/null +++ b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts @@ -0,0 +1,33 @@ +// @removeComments: true +function foo1() { + // Single line comment + + return 42; +} + +function foo2() { + /* + + multi line + comment + */ + + return 42; +} + +function foo3() { + // Single line comment with more than one blank line + + + return 42; +} + +function foo4() { + /* + + multi line comment with more than one blank line + */ + + return 42; +} + diff --git a/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts new file mode 100644 index 00000000000..be6cd7b37ce --- /dev/null +++ b/tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts @@ -0,0 +1,30 @@ +// @removeComments: true +() => { + // Single line comment + + return 0; +} + +() => { + /* + multi-line comment + */ + + return 0; +} + +() => { + // Single line comment with more than one blank line + + + return 0; +} + +() => { + /* + multi-line comment with more than one blank line + */ + + + return 0; +} diff --git a/tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts b/tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts new file mode 100644 index 00000000000..bae1654af87 --- /dev/null +++ b/tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts @@ -0,0 +1,10 @@ +// @removeComments: true +var x = 10; + +/*! + + multi line + comment +*/ + +var x = 10; \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts b/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts new file mode 100644 index 00000000000..23a1000fa11 --- /dev/null +++ b/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts @@ -0,0 +1,13 @@ +// @removeComments: true + +class C { + /*! remove pinned comment anywhere else */ + public foo(x: string, y: any) + public foo(x: string, y: number) { } +} + +// @Filename: file1.ts +var x = 10; + +/*! remove pinned comment anywhere else */ +declare var OData: any; \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts b/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts new file mode 100644 index 00000000000..27c5c5f6b7b --- /dev/null +++ b/tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts @@ -0,0 +1,10 @@ +// @removeComments: true + +class C { + /*! remove pinned comment anywhere else */ + public foo(x: string, y: any) + public foo(x: string, y: number) { } +} + +/*! remove pinned comment anywhere else */ +declare var OData: any; \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitPinnedDetachedComments.ts b/tests/cases/compiler/doNotEmitPinnedDetachedComments.ts new file mode 100644 index 00000000000..f30dc9299ee --- /dev/null +++ b/tests/cases/compiler/doNotEmitPinnedDetachedComments.ts @@ -0,0 +1,32 @@ +// @removeComments: true +var x = 10; + +/*! Single Line comment */ + +function baz() { } + + +/*! + multi-line comment + +*/ + + +//======================== + + +function bar() { + /*! + Remove this comment + */ + +} + +function foo() { + /*! Remove this */ + + return 0; +} + + +//======================== diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts new file mode 100644 index 00000000000..357ce67dbed --- /dev/null +++ b/tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts @@ -0,0 +1,10 @@ +// @removeComments: true + +// @Filename: file0.ts + +// @Filename: file1.ts + +// @Filename: file2.ts +/// +/// +/// \ No newline at end of file diff --git a/tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts b/tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts new file mode 100644 index 00000000000..bfa5c5ffc67 --- /dev/null +++ b/tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts @@ -0,0 +1,10 @@ +// @removeComments: true + +// @Filename: file0.ts +/// +declare var OData: any; + +// @Filename: file1.ts +/// +interface F { } + diff --git a/tests/cases/compiler/doNotemitTripleSlashComments.ts b/tests/cases/compiler/doNotemitTripleSlashComments.ts new file mode 100644 index 00000000000..14fdfda2d72 --- /dev/null +++ b/tests/cases/compiler/doNotemitTripleSlashComments.ts @@ -0,0 +1,35 @@ +// @removeComments: true + +// @Filename: file0.ts +/// +/// +/// +var x = 10; + +/// +var y = "hello"; + + +/// + +// @Filename: file1.ts +/// + +function foo() { } + + +/// + + +var z = "world"; + +// @Filename: file2.ts +/// + + +/// ==================================== + + +function bar() { } + + diff --git a/tests/cases/compiler/elidingImportNames.ts b/tests/cases/compiler/elidingImportNames.ts index b5893461664..f9cbf457d53 100644 --- a/tests/cases/compiler/elidingImportNames.ts +++ b/tests/cases/compiler/elidingImportNames.ts @@ -1,10 +1,10 @@ // @module: commonjs // @Filename: elidingImportNames_test.ts -import a = require('elidingImportNames_main'); // alias used in typeof +import a = require('./elidingImportNames_main'); // alias used in typeof var b = a; var x: typeof a; -import a2 = require('elidingImportNames_main1'); // alias not used in typeof +import a2 = require('./elidingImportNames_main1'); // alias not used in typeof var b2 = a2; diff --git a/tests/cases/compiler/emitCommentsOnlyFile.ts b/tests/cases/compiler/emitCommentsOnlyFile.ts index 9ded82be8e9..bcdf34c57b8 100644 --- a/tests/cases/compiler/emitCommentsOnlyFile.ts +++ b/tests/cases/compiler/emitCommentsOnlyFile.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false /** * @name Foo diff --git a/tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts b/tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts new file mode 100644 index 00000000000..985a5f638b8 --- /dev/null +++ b/tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts @@ -0,0 +1,8 @@ +// @removeComments: true +/*! + + multi line + comment +*/ + +var x = 10; \ No newline at end of file diff --git a/tests/cases/compiler/emitPostComments.ts b/tests/cases/compiler/emitPostComments.ts index b76f8dcb2bb..767bf033295 100644 --- a/tests/cases/compiler/emitPostComments.ts +++ b/tests/cases/compiler/emitPostComments.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false var y = 10; /** diff --git a/tests/cases/compiler/emitPreComments.ts b/tests/cases/compiler/emitPreComments.ts index e43c4baaa3b..2d98231e000 100644 --- a/tests/cases/compiler/emitPreComments.ts +++ b/tests/cases/compiler/emitPreComments.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false // This is pre comment var y = 10; diff --git a/tests/cases/compiler/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.ts b/tests/cases/compiler/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.ts new file mode 100644 index 00000000000..56f7814104d --- /dev/null +++ b/tests/cases/compiler/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.ts @@ -0,0 +1,13 @@ +// @removeComments: false + +// @Filename: file0.ts +var x = 10 + +// @Filename: file1.ts +/// +declare var OData: any; + +/// +interface F { } + + diff --git a/tests/cases/compiler/emptyModuleName.ts b/tests/cases/compiler/emptyModuleName.ts new file mode 100644 index 00000000000..d82ff2ba608 --- /dev/null +++ b/tests/cases/compiler/emptyModuleName.ts @@ -0,0 +1,4 @@ +// @module: commonjs +import * as A from ""; +class B extends A { +} \ No newline at end of file diff --git a/tests/cases/compiler/enumFromExternalModule.ts b/tests/cases/compiler/enumFromExternalModule.ts index 3047dd52db3..2e943caf413 100644 --- a/tests/cases/compiler/enumFromExternalModule.ts +++ b/tests/cases/compiler/enumFromExternalModule.ts @@ -1,9 +1,9 @@ -//@module: commonjs +// @module: commonjs // @Filename: enumFromExternalModule_0.ts export enum Mode { Open } // @Filename: enumFromExternalModule_1.ts /// -import f = require('enumFromExternalModule_0'); +import f = require('./enumFromExternalModule_0'); var x = f.Mode.Open; diff --git a/tests/cases/compiler/errorWithTruncatedType.ts b/tests/cases/compiler/errorWithTruncatedType.ts index 307ff642ed9..c615ff928e4 100644 --- a/tests/cases/compiler/errorWithTruncatedType.ts +++ b/tests/cases/compiler/errorWithTruncatedType.ts @@ -1,4 +1,4 @@ -// @errortruncation: true +// @noErrorTruncation: false var x: { propertyWithAnExceedinglyLongName1: string; diff --git a/tests/cases/compiler/errorsOnImportedSymbol.ts b/tests/cases/compiler/errorsOnImportedSymbol.ts index 17f3e5fb92c..b3da9da162e 100644 --- a/tests/cases/compiler/errorsOnImportedSymbol.ts +++ b/tests/cases/compiler/errorsOnImportedSymbol.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @target: ES5 // @Filename: errorsOnImportedSymbol_0.ts @@ -9,7 +9,7 @@ interface Sammy { export = Sammy; // @Filename: errorsOnImportedSymbol_1.ts -import Sammy = require("errorsOnImportedSymbol_0"); +import Sammy = require("./errorsOnImportedSymbol_0"); var x = new Sammy.Sammy(); var y = Sammy.Sammy(); - + diff --git a/tests/cases/compiler/es3defaultAliasIsQuoted.ts b/tests/cases/compiler/es3defaultAliasIsQuoted.ts new file mode 100644 index 00000000000..ccaa0268906 --- /dev/null +++ b/tests/cases/compiler/es3defaultAliasIsQuoted.ts @@ -0,0 +1,15 @@ +// @module: commonjs +// @target: es3 + +// @Filename: es3defaultAliasQuoted_file0.ts +export class Foo { + static CONSTANT = "Foo"; +} + +export default function assert(value: boolean) { + if (!value) throw new Error("Assertion failed!"); +} + +// @Filename: es3defaultAliasQuoted_file1.ts +import {Foo, default as assert} from "./es3defaultAliasQuoted_file0"; +assert(Foo.CONSTANT === "Foo"); \ No newline at end of file diff --git a/tests/cases/compiler/es5andes6module.ts b/tests/cases/compiler/es5andes6module.ts new file mode 100644 index 00000000000..0fbff3c23d2 --- /dev/null +++ b/tests/cases/compiler/es5andes6module.ts @@ -0,0 +1,17 @@ +// @target: ES5 +// @sourcemap: false +// @declaration: false +// @module: es6 + +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} diff --git a/tests/cases/compiler/es6ExportAllInEs5.ts b/tests/cases/compiler/es6ExportAllInEs5.ts index ed754e5cacb..3ee95e1a217 100644 --- a/tests/cases/compiler/es6ExportAllInEs5.ts +++ b/tests/cases/compiler/es6ExportAllInEs5.ts @@ -15,4 +15,4 @@ export module uninstantiated { } // @filename: client.ts -export * from "server"; \ No newline at end of file +export * from "./server"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifierInEs5.ts b/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifierInEs5.ts index 6361c013367..24dbc77e98f 100644 --- a/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifierInEs5.ts +++ b/tests/cases/compiler/es6ExportClauseWithoutModuleSpecifierInEs5.ts @@ -15,8 +15,8 @@ export module uninstantiated { } // @filename: client.ts -export { c } from "server"; -export { c as c2 } from "server"; -export { i, m as instantiatedModule } from "server"; -export { uninstantiated } from "server"; -export { x } from "server"; \ No newline at end of file +export { c } from "./server"; +export { c as c2 } from "./server"; +export { i, m as instantiatedModule } from "./server"; +export { uninstantiated } from "./server"; +export { x } from "./server"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingDts.ts b/tests/cases/compiler/es6ImportDefaultBindingDts.ts index 8b8a9787fdd..b4b82768691 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingDts.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingDts.ts @@ -7,6 +7,6 @@ class c { } export default c; // @filename: client.ts -import defaultBinding from "server"; +import defaultBinding from "./server"; export var x = new defaultBinding(); -import defaultBinding2 from "server"; // elide this import since defaultBinding2 is not used +import defaultBinding2 from "./server"; // elide this import since defaultBinding2 is not used diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts index 9a6e1a8ebf5..cb84036af5e 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts @@ -9,15 +9,15 @@ export var m = a; export default {}; // @filename: es6ImportDefaultBindingFollowedWithNamedImport_1.ts -import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; -import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = a; -import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = b; -import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = x; var x1: number = y; -import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = z; -import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0"; +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport_0"; var x1: number = m; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts index d5c9a6a395d..fc13b26e737 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.ts @@ -7,15 +7,15 @@ var a = 10; export default a; // @filename: es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.ts -import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding1; -import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding2; -import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding3; -import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding4; -import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding5; -import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"; var x: number = defaultBinding6; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.ts index 23ec8767d94..ca2b0561433 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.ts @@ -7,15 +7,15 @@ var a = 10; export default a; // @filename: client.ts -export import defaultBinding1, { } from "server"; +export import defaultBinding1, { } from "./server"; export var x1: number = defaultBinding1; -export import defaultBinding2, { a } from "server"; +export import defaultBinding2, { a } from "./server"; export var x1: number = defaultBinding2; -export import defaultBinding3, { a as b } from "server"; +export import defaultBinding3, { a as b } from "./server"; export var x1: number = defaultBinding3; -export import defaultBinding4, { x, a as y } from "server"; +export import defaultBinding4, { x, a as y } from "./server"; export var x1: number = defaultBinding4; -export import defaultBinding5, { x as z, } from "server"; +export import defaultBinding5, { x as z, } from "./server"; export var x1: number = defaultBinding5; -export import defaultBinding6, { m, } from "server"; +export import defaultBinding6, { m, } from "./server"; export var x1: number = defaultBinding6; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts index a84dab94033..87782d66aff 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts @@ -10,15 +10,15 @@ export class a12 { } export class x11 { } // @filename: client.ts -import defaultBinding1, { } from "server"; -import defaultBinding2, { a } from "server"; +import defaultBinding1, { } from "./server"; +import defaultBinding2, { a } from "./server"; export var x1 = new a(); -import defaultBinding3, { a11 as b } from "server"; +import defaultBinding3, { a11 as b } from "./server"; export var x2 = new b(); -import defaultBinding4, { x, a12 as y } from "server"; +import defaultBinding4, { x, a12 as y } from "./server"; export var x4 = new x(); export var x5 = new y(); -import defaultBinding5, { x11 as z, } from "server"; +import defaultBinding5, { x11 as z, } from "./server"; export var x3 = new z(); -import defaultBinding6, { m, } from "server"; +import defaultBinding6, { m, } from "./server"; export var x6 = new m(); diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts index 7940f211ec7..64e771bebd1 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts1.ts @@ -7,15 +7,15 @@ class a { } export default a; // @filename: client.ts -import defaultBinding1, { } from "server"; +import defaultBinding1, { } from "./server"; export var x1 = new defaultBinding1(); -import defaultBinding2, { a } from "server"; +import defaultBinding2, { a } from "./server"; export var x2 = new defaultBinding2(); -import defaultBinding3, { a as b } from "server"; +import defaultBinding3, { a as b } from "./server"; export var x3 = new defaultBinding3(); -import defaultBinding4, { x, a as y } from "server"; +import defaultBinding4, { x, a as y } from "./server"; export var x4 = new defaultBinding4(); -import defaultBinding5, { x as z, } from "server"; +import defaultBinding5, { x as z, } from "./server"; export var x5 = new defaultBinding5(); -import defaultBinding6, { m, } from "server"; +import defaultBinding6, { m, } from "./server"; export var x6 = new defaultBinding6(); \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.ts index 6e42898d1bc..9a7902d66a0 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.ts @@ -8,15 +8,15 @@ export var x = a; export var m = a; // @filename: es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts -import defaultBinding1, { } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -import defaultBinding2, { a } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = a; -import defaultBinding3, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = b; -import defaultBinding4, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = x; var x1: number = y; -import defaultBinding5, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = z; -import defaultBinding6, { m, } from "es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; +import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; var x1: number = m; diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts index 6195b279f72..133abf147cb 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.ts @@ -7,5 +7,5 @@ var a = 10; export default a; // @filename: es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; var x: number = defaultBinding; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts index 732f7ef7ba0..c9bb1a6dd10 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.ts @@ -5,5 +5,5 @@ export class a { } // @filename: client.ts -import defaultBinding, * as nameSpaceBinding from "server"; +import defaultBinding, * as nameSpaceBinding from "./server"; export var x = new nameSpaceBinding.a(); \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.ts index c58ba286e0a..cdc1590ec8f 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.ts @@ -6,5 +6,5 @@ export var a = 10; // @filename: es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts -import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; +import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.ts b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.ts index cafcace08a0..768386f67f6 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.ts @@ -5,5 +5,5 @@ export var a = 10; // @filename: client.ts -export import defaultBinding, * as nameSpaceBinding from "server"; +export import defaultBinding, * as nameSpaceBinding from "./server"; export var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingInEs5.ts b/tests/cases/compiler/es6ImportDefaultBindingInEs5.ts index e0877bd74c1..261c1b6079c 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingInEs5.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingInEs5.ts @@ -7,4 +7,4 @@ var a = 10; export = a; // @filename: es6ImportDefaultBindingInEs5_1.ts -import defaultBinding from "es6ImportDefaultBindingInEs5_0"; \ No newline at end of file +import defaultBinding from "./es6ImportDefaultBindingInEs5_0"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts b/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts index 1d87fde5784..3d637abd798 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts @@ -6,11 +6,11 @@ var a = 10; export default a; // @filename: es6ImportDefaultBindingMergeErrors_1.ts -import defaultBinding from "es6ImportDefaultBindingMergeErrors_0"; +import defaultBinding from "./es6ImportDefaultBindingMergeErrors_0"; interface defaultBinding { // This is ok } var x = defaultBinding; -import defaultBinding2 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error +import defaultBinding2 from "./es6ImportDefaultBindingMergeErrors_0"; // Should be error var defaultBinding2 = "hello world"; -import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // Should be error -import defaultBinding3 from "es6ImportDefaultBindingMergeErrors_0"; // SHould be error +import defaultBinding3 from "./es6ImportDefaultBindingMergeErrors_0"; // Should be error +import defaultBinding3 from "./es6ImportDefaultBindingMergeErrors_0"; // SHould be error diff --git a/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts b/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts index 5ab1c743721..74b2abfa83c 100644 --- a/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts +++ b/tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts @@ -4,4 +4,4 @@ export var a = 10; // @filename: es6ImportDefaultBindingNoDefaultProperty_1.ts -import defaultBinding from "es6ImportDefaultBindingNoDefaultProperty_0"; +import defaultBinding from "./es6ImportDefaultBindingNoDefaultProperty_0"; diff --git a/tests/cases/compiler/es6ImportNameSpaceImport.ts b/tests/cases/compiler/es6ImportNameSpaceImport.ts index 0c831d323d1..87fc59fdbaa 100644 --- a/tests/cases/compiler/es6ImportNameSpaceImport.ts +++ b/tests/cases/compiler/es6ImportNameSpaceImport.ts @@ -6,6 +6,6 @@ export var a = 10; // @filename: es6ImportNameSpaceImport_1.ts -import * as nameSpaceBinding from "es6ImportNameSpaceImport_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0"; var x = nameSpaceBinding.a; -import * as nameSpaceBinding2 from "es6ImportNameSpaceImport_0"; // elide this +import * as nameSpaceBinding2 from "./es6ImportNameSpaceImport_0"; // elide this diff --git a/tests/cases/compiler/es6ImportNameSpaceImportDts.ts b/tests/cases/compiler/es6ImportNameSpaceImportDts.ts index 95b85e53edc..77e65123e78 100644 --- a/tests/cases/compiler/es6ImportNameSpaceImportDts.ts +++ b/tests/cases/compiler/es6ImportNameSpaceImportDts.ts @@ -5,6 +5,6 @@ export class c { }; // @filename: client.ts -import * as nameSpaceBinding from "server"; +import * as nameSpaceBinding from "./server"; export var x = new nameSpaceBinding.c(); -import * as nameSpaceBinding2 from "server"; // unreferenced \ No newline at end of file +import * as nameSpaceBinding2 from "./server"; // unreferenced \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNameSpaceImportInEs5.ts b/tests/cases/compiler/es6ImportNameSpaceImportInEs5.ts index 8104fe8b3c0..7900e5b5a2b 100644 --- a/tests/cases/compiler/es6ImportNameSpaceImportInEs5.ts +++ b/tests/cases/compiler/es6ImportNameSpaceImportInEs5.ts @@ -6,6 +6,6 @@ export var a = 10; // @filename: es6ImportNameSpaceImportInEs5_1.ts -import * as nameSpaceBinding from "es6ImportNameSpaceImportInEs5_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImportInEs5_0"; var x = nameSpaceBinding.a; -import * as nameSpaceBinding2 from "es6ImportNameSpaceImportInEs5_0"; // elide this +import * as nameSpaceBinding2 from "./es6ImportNameSpaceImportInEs5_0"; // elide this diff --git a/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts b/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts index d4b69e8bcf4..cdedbe3fe9b 100644 --- a/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts +++ b/tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts @@ -5,11 +5,11 @@ export var a = 10; // @filename: es6ImportNameSpaceImportMergeErrors_1.ts -import * as nameSpaceBinding from "es6ImportNameSpaceImportMergeErrors_0"; +import * as nameSpaceBinding from "./es6ImportNameSpaceImportMergeErrors_0"; interface nameSpaceBinding { } // this should be ok -import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error -import * as nameSpaceBinding1 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error +import * as nameSpaceBinding1 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error +import * as nameSpaceBinding1 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error -import * as nameSpaceBinding3 from "es6ImportNameSpaceImportMergeErrors_0"; // should be error +import * as nameSpaceBinding3 from "./es6ImportNameSpaceImportMergeErrors_0"; // should be error var nameSpaceBinding3 = 10; diff --git a/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts b/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts index 7d3bdcec94c..fe471dbc6c7 100644 --- a/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts +++ b/tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts @@ -6,4 +6,4 @@ var a = 10; export = a; // @filename: es6ImportNameSpaceImportNoNamedExports_1.ts -import * as nameSpaceBinding from "es6ImportNameSpaceImportNoNamedExports_0"; // error \ No newline at end of file +import * as nameSpaceBinding from "./es6ImportNameSpaceImportNoNamedExports_0"; // error \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImport.ts b/tests/cases/compiler/es6ImportNamedImport.ts index 0a12e10169b..d71b27eeede 100644 --- a/tests/cases/compiler/es6ImportNamedImport.ts +++ b/tests/cases/compiler/es6ImportNamedImport.ts @@ -13,30 +13,30 @@ export var z2 = 10; export var aaaa = 10; // @filename: es6ImportNamedImport_1.ts -import { } from "es6ImportNamedImport_0"; -import { a } from "es6ImportNamedImport_0"; +import { } from "./es6ImportNamedImport_0"; +import { a } from "./es6ImportNamedImport_0"; var xxxx = a; -import { a as b } from "es6ImportNamedImport_0"; +import { a as b } from "./es6ImportNamedImport_0"; var xxxx = b; -import { x, a as y } from "es6ImportNamedImport_0"; +import { x, a as y } from "./es6ImportNamedImport_0"; var xxxx = x; var xxxx = y; -import { x as z, } from "es6ImportNamedImport_0"; +import { x as z, } from "./es6ImportNamedImport_0"; var xxxx = z; -import { m, } from "es6ImportNamedImport_0"; +import { m, } from "./es6ImportNamedImport_0"; var xxxx = m; -import { a1, x1 } from "es6ImportNamedImport_0"; +import { a1, x1 } from "./es6ImportNamedImport_0"; var xxxx = a1; var xxxx = x1; -import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0"; +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImport_0"; var xxxx = a11; var xxxx = x11; -import { z1 } from "es6ImportNamedImport_0"; +import { z1 } from "./es6ImportNamedImport_0"; var z111 = z1; -import { z2 as z3 } from "es6ImportNamedImport_0"; +import { z2 as z3 } from "./es6ImportNamedImport_0"; var z2 = z3; // z2 shouldn't give redeclare error // These are elided -import { aaaa } from "es6ImportNamedImport_0"; +import { aaaa } from "./es6ImportNamedImport_0"; // These are elided -import { aaaa as bbbb } from "es6ImportNamedImport_0"; +import { aaaa as bbbb } from "./es6ImportNamedImport_0"; diff --git a/tests/cases/compiler/es6ImportNamedImportDts.ts b/tests/cases/compiler/es6ImportNamedImportDts.ts index d83672f3754..b98a20ecfa1 100644 --- a/tests/cases/compiler/es6ImportNamedImportDts.ts +++ b/tests/cases/compiler/es6ImportNamedImportDts.ts @@ -18,29 +18,29 @@ export class aaaa { } export class aaaa1 { } // @filename: client.ts -import { } from "server"; -import { a } from "server"; +import { } from "./server"; +import { a } from "./server"; export var xxxx = new a(); -import { a11 as b } from "server"; +import { a11 as b } from "./server"; export var xxxx1 = new b(); -import { x, a12 as y } from "server"; +import { x, a12 as y } from "./server"; export var xxxx2 = new x(); export var xxxx3 = new y(); -import { x11 as z, } from "server"; +import { x11 as z, } from "./server"; export var xxxx4 = new z(); -import { m, } from "server"; +import { m, } from "./server"; export var xxxx5 = new m(); -import { a1, x1 } from "server"; +import { a1, x1 } from "./server"; export var xxxx6 = new a1(); export var xxxx7 = new x1(); -import { a111 as a11, x111 as x11 } from "server"; +import { a111 as a11, x111 as x11 } from "./server"; export var xxxx8 = new a11(); export var xxxx9 = new x11(); -import { z1 } from "server"; +import { z1 } from "./server"; export var z111 = new z1(); -import { z2 as z3 } from "server"; +import { z2 as z3 } from "./server"; export var z2 = new z3(); // z2 shouldn't give redeclare error // not referenced -import { aaaa } from "server"; -import { aaaa1 as bbbb } from "server"; +import { aaaa } from "./server"; +import { aaaa1 as bbbb } from "./server"; diff --git a/tests/cases/compiler/es6ImportNamedImportInEs5.ts b/tests/cases/compiler/es6ImportNamedImportInEs5.ts index e12a8d032d3..428ad235329 100644 --- a/tests/cases/compiler/es6ImportNamedImportInEs5.ts +++ b/tests/cases/compiler/es6ImportNamedImportInEs5.ts @@ -13,30 +13,30 @@ export var z2 = 10; export var aaaa = 10; // @filename: es6ImportNamedImportInEs5_1.ts -import { } from "es6ImportNamedImportInEs5_0"; -import { a } from "es6ImportNamedImportInEs5_0"; +import { } from "./es6ImportNamedImportInEs5_0"; +import { a } from "./es6ImportNamedImportInEs5_0"; var xxxx = a; -import { a as b } from "es6ImportNamedImportInEs5_0"; +import { a as b } from "./es6ImportNamedImportInEs5_0"; var xxxx = b; -import { x, a as y } from "es6ImportNamedImportInEs5_0"; +import { x, a as y } from "./es6ImportNamedImportInEs5_0"; var xxxx = x; var xxxx = y; -import { x as z, } from "es6ImportNamedImportInEs5_0"; +import { x as z, } from "./es6ImportNamedImportInEs5_0"; var xxxx = z; -import { m, } from "es6ImportNamedImportInEs5_0"; +import { m, } from "./es6ImportNamedImportInEs5_0"; var xxxx = m; -import { a1, x1 } from "es6ImportNamedImportInEs5_0"; +import { a1, x1 } from "./es6ImportNamedImportInEs5_0"; var xxxx = a1; var xxxx = x1; -import { a1 as a11, x1 as x11 } from "es6ImportNamedImportInEs5_0"; +import { a1 as a11, x1 as x11 } from "./es6ImportNamedImportInEs5_0"; var xxxx = a11; var xxxx = x11; -import { z1 } from "es6ImportNamedImportInEs5_0"; +import { z1 } from "./es6ImportNamedImportInEs5_0"; var z111 = z1; -import { z2 as z3 } from "es6ImportNamedImportInEs5_0"; +import { z2 as z3 } from "./es6ImportNamedImportInEs5_0"; var z2 = z3; // z2 shouldn't give redeclare error // These are elided -import { aaaa } from "es6ImportNamedImportInEs5_0"; +import { aaaa } from "./es6ImportNamedImportInEs5_0"; // These are elided -import { aaaa as bbbb } from "es6ImportNamedImportInEs5_0"; +import { aaaa as bbbb } from "./es6ImportNamedImportInEs5_0"; diff --git a/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts b/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts index 7a4519c68bb..e3f64e1e747 100644 --- a/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts +++ b/tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts @@ -6,5 +6,5 @@ export var a = 10; // @filename: es6ImportNamedImportInExportAssignment_1.ts -import { a } from "es6ImportNamedImportInExportAssignment_0"; +import { a } from "./es6ImportNamedImportInExportAssignment_0"; export = a; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts b/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts index 16d11d4e19f..381a21f58ea 100644 --- a/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts +++ b/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts @@ -8,6 +8,6 @@ export module a { } // @filename: es6ImportNamedImportInIndirectExportAssignment_1.ts -import { a } from "es6ImportNamedImportInIndirectExportAssignment_0"; +import { a } from "./es6ImportNamedImportInIndirectExportAssignment_0"; import x = a; export = x; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts b/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts index 54e30be1e23..60f13d51355 100644 --- a/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts +++ b/tests/cases/compiler/es6ImportNamedImportMergeErrors.ts @@ -7,13 +7,13 @@ export var z = a; export var z1 = a; // @filename: es6ImportNamedImportMergeErrors_1.ts -import { a } from "es6ImportNamedImportMergeErrors_0"; +import { a } from "./es6ImportNamedImportMergeErrors_0"; interface a { } // shouldnt be error -import { x as x1 } from "es6ImportNamedImportMergeErrors_0"; +import { x as x1 } from "./es6ImportNamedImportMergeErrors_0"; interface x1 { } // shouldnt be error -import { x } from "es6ImportNamedImportMergeErrors_0"; // should be error +import { x } from "./es6ImportNamedImportMergeErrors_0"; // should be error var x = 10; -import { x as x44 } from "es6ImportNamedImportMergeErrors_0"; // should be error +import { x as x44 } from "./es6ImportNamedImportMergeErrors_0"; // should be error var x44 = 10; -import { z } from "es6ImportNamedImportMergeErrors_0"; // should be error -import { z1 as z } from "es6ImportNamedImportMergeErrors_0"; // should be error +import { z } from "./es6ImportNamedImportMergeErrors_0"; // should be error +import { z1 as z } from "./es6ImportNamedImportMergeErrors_0"; // should be error diff --git a/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts b/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts index bd507308d8d..48f8036a753 100644 --- a/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts +++ b/tests/cases/compiler/es6ImportNamedImportNoExportMember.ts @@ -5,5 +5,5 @@ export var a = 10; export var x = a; // @filename: es6ImportNamedImport_1.ts -import { a1 } from "es6ImportNamedImportNoExportMember_0"; -import { x1 as x } from "es6ImportNamedImportNoExportMember_0"; \ No newline at end of file +import { a1 } from "./es6ImportNamedImportNoExportMember_0"; +import { x1 as x } from "./es6ImportNamedImportNoExportMember_0"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts b/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts index 9dd243ff36d..9e46253cc9c 100644 --- a/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts +++ b/tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts @@ -6,5 +6,5 @@ var a = 10; export = a; // @filename: es6ImportNamedImportNoNamedExports_1.ts -import { a } from "es6ImportNamedImportNoNamedExports_0"; -import { a as x } from "es6ImportNamedImportNoNamedExports_0"; \ No newline at end of file +import { a } from "./es6ImportNamedImportNoNamedExports_0"; +import { a as x } from "./es6ImportNamedImportNoNamedExports_0"; \ No newline at end of file diff --git a/tests/cases/compiler/es6ImportNamedImportWithExport.ts b/tests/cases/compiler/es6ImportNamedImportWithExport.ts index f25a3779b99..9643a82b9b9 100644 --- a/tests/cases/compiler/es6ImportNamedImportWithExport.ts +++ b/tests/cases/compiler/es6ImportNamedImportWithExport.ts @@ -12,29 +12,29 @@ export var z2 = 10; export var aaaa = 10; // @filename: client.ts -export import { } from "server"; -export import { a } from "server"; +export import { } from "./server"; +export import { a } from "./server"; export var xxxx = a; -export import { a as b } from "server"; +export import { a as b } from "./server"; export var xxxx = b; -export import { x, a as y } from "server"; +export import { x, a as y } from "./server"; export var xxxx = x; export var xxxx = y; -export import { x as z, } from "server"; +export import { x as z, } from "./server"; export var xxxx = z; -export import { m, } from "server"; +export import { m, } from "./server"; export var xxxx = m; -export import { a1, x1 } from "server"; +export import { a1, x1 } from "./server"; export var xxxx = a1; export var xxxx = x1; -export import { a1 as a11, x1 as x11 } from "server"; +export import { a1 as a11, x1 as x11 } from "./server"; export var xxxx = a11; export var xxxx = x11; -export import { z1 } from "server"; +export import { z1 } from "./server"; export var z111 = z1; -export import { z2 as z3 } from "server"; +export import { z2 as z3 } from "./server"; export var z2 = z3; // z2 shouldn't give redeclare error // Non referenced imports -export import { aaaa } from "server"; -export import { aaaa as bbbb } from "server"; +export import { aaaa } from "./server"; +export import { aaaa as bbbb } from "./server"; diff --git a/tests/cases/compiler/es6ImportNamedImportWithTypesAndValues.ts b/tests/cases/compiler/es6ImportNamedImportWithTypesAndValues.ts index 08294e57232..4b5a2f17ab0 100644 --- a/tests/cases/compiler/es6ImportNamedImportWithTypesAndValues.ts +++ b/tests/cases/compiler/es6ImportNamedImportWithTypesAndValues.ts @@ -16,6 +16,6 @@ export class C2 implements I2 { } // @filename: client.ts -import { C, I, C2 } from "server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file +import { C, I, C2 } from "./server"; // Shouldnt emit I and C2 into the js file and emit C and I in .d.ts file export type cValInterface = I; export var cVal = new C(); \ No newline at end of file diff --git a/tests/cases/compiler/es6modulekind.ts b/tests/cases/compiler/es6modulekind.ts new file mode 100644 index 00000000000..0722e1690a3 --- /dev/null +++ b/tests/cases/compiler/es6modulekind.ts @@ -0,0 +1,17 @@ +// @target: ES6 +// @sourcemap: false +// @declaration: false +// @module: es6 + +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/excessPropertyErrorsSuppressed.ts b/tests/cases/compiler/excessPropertyErrorsSuppressed.ts new file mode 100644 index 00000000000..21bfee420c1 --- /dev/null +++ b/tests/cases/compiler/excessPropertyErrorsSuppressed.ts @@ -0,0 +1,3 @@ +//@suppressExcessPropertyErrors: true + +var x: { a: string } = { a: "hello", b: 42 }; // No error diff --git a/tests/cases/compiler/exportAssignClassAndModule.ts b/tests/cases/compiler/exportAssignClassAndModule.ts index 1124234ae8d..0ac65454b00 100644 --- a/tests/cases/compiler/exportAssignClassAndModule.ts +++ b/tests/cases/compiler/exportAssignClassAndModule.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: exportAssignClassAndModule_0.ts class Foo { x: Foo.Bar; @@ -11,7 +11,7 @@ export = Foo; // @Filename: exportAssignClassAndModule_1.ts /// -import Foo = require('exportAssignClassAndModule_0'); +import Foo = require('./exportAssignClassAndModule_0'); var z: Foo.Bar; var zz: Foo; diff --git a/tests/cases/compiler/exportAssignmentEnum.ts b/tests/cases/compiler/exportAssignmentEnum.ts index debaab1e5e8..dff61fdb5df 100644 --- a/tests/cases/compiler/exportAssignmentEnum.ts +++ b/tests/cases/compiler/exportAssignmentEnum.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: exportAssignmentEnum_A.ts enum E { A, @@ -9,7 +9,7 @@ enum E { export = E; // @Filename: exportAssignmentEnum_B.ts -import EnumE = require("exportAssignmentEnum_A"); +import EnumE = require("./exportAssignmentEnum_A"); var a = EnumE.A; var b = EnumE.B; diff --git a/tests/cases/compiler/exportAssignmentOfDeclaredExternalModule.ts b/tests/cases/compiler/exportAssignmentOfDeclaredExternalModule.ts index 63c1f01eb28..fd6b55c9c08 100644 --- a/tests/cases/compiler/exportAssignmentOfDeclaredExternalModule.ts +++ b/tests/cases/compiler/exportAssignmentOfDeclaredExternalModule.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: exportAssignmentOfDeclaredExternalModule_0.ts interface Sammy { new (): any; // a constructor signature @@ -8,7 +8,7 @@ export = Sammy; // @Filename: exportAssignmentOfDeclaredExternalModule_1.ts /// -import Sammy = require('exportAssignmentOfDeclaredExternalModule_0'); +import Sammy = require('./exportAssignmentOfDeclaredExternalModule_0'); var x = new Sammy(); // error to use as constructor as there is not constructor symbol var y = Sammy(); // error to use interface name as call target var z: Sammy; // no error - z is of type interface Sammy from module 'M' diff --git a/tests/cases/compiler/exportAssignmentVariable.ts b/tests/cases/compiler/exportAssignmentVariable.ts index b1ba2452884..9bb53a7c89d 100644 --- a/tests/cases/compiler/exportAssignmentVariable.ts +++ b/tests/cases/compiler/exportAssignmentVariable.ts @@ -1,10 +1,10 @@ -//@module: commonjs +// @module: commonjs // @Filename: exportAssignmentVariable_A.ts var x = 0; export = x; // @Filename: exportAssignmentVariable_B.ts -import y = require("exportAssignmentVariable_A"); +import y = require("./exportAssignmentVariable_A"); var n: number = y; \ No newline at end of file diff --git a/tests/cases/compiler/exportEqualMemberMissing.ts b/tests/cases/compiler/exportEqualMemberMissing.ts index 6f916b65260..89b328f0536 100644 --- a/tests/cases/compiler/exportEqualMemberMissing.ts +++ b/tests/cases/compiler/exportEqualMemberMissing.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: exportEqualMemberMissing_0.ts module server { export interface connectModule { @@ -16,5 +16,5 @@ export = server; // @Filename: exportEqualMemberMissing_1.ts /// -import connect = require('exportEqualMemberMissing_0'); +import connect = require('./exportEqualMemberMissing_0'); connect().use(connect.static('foo')); // Error 1 The property 'static' does not exist on value of type ''. diff --git a/tests/cases/compiler/exportStarFromEmptyModule.ts b/tests/cases/compiler/exportStarFromEmptyModule.ts index 163576f1c08..8e4ea8a7b21 100644 --- a/tests/cases/compiler/exportStarFromEmptyModule.ts +++ b/tests/cases/compiler/exportStarFromEmptyModule.ts @@ -11,15 +11,15 @@ export class A { // empty // @filename: exportStarFromEmptyModule_module3.ts -export * from "exportStarFromEmptyModule_module2"; -export * from "exportStarFromEmptyModule_module1"; +export * from "./exportStarFromEmptyModule_module2"; +export * from "./exportStarFromEmptyModule_module1"; export class A { static q; } // @filename: exportStarFromEmptyModule_module4.ts -import * as X from "exportStarFromEmptyModule_module3"; +import * as X from "./exportStarFromEmptyModule_module3"; var s: X.A; X.A.q; X.A.r; // Error \ No newline at end of file diff --git a/tests/cases/compiler/exportsInAmbientModules1.ts b/tests/cases/compiler/exportsInAmbientModules1.ts new file mode 100644 index 00000000000..53e169fcf5d --- /dev/null +++ b/tests/cases/compiler/exportsInAmbientModules1.ts @@ -0,0 +1,10 @@ +// @module: amd + +// @filename: external.d.ts +export var x: number + +// @filename: main.ts + +declare module "M" { + export {x} from "external" +} \ No newline at end of file diff --git a/tests/cases/compiler/exportsInAmbientModules2.ts b/tests/cases/compiler/exportsInAmbientModules2.ts new file mode 100644 index 00000000000..0fbfa022d13 --- /dev/null +++ b/tests/cases/compiler/exportsInAmbientModules2.ts @@ -0,0 +1,10 @@ +// @module: amd + +// @filename: external.d.ts +export default class C {} + +// @filename: main.ts + +declare module "M" { + export * from "external" +} \ No newline at end of file diff --git a/tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer.ts b/tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer.ts index 9cd73deb90d..4e5a67665d9 100644 --- a/tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer.ts +++ b/tests/cases/compiler/extendingClassFromAliasAndUsageInIndexer.ts @@ -1,25 +1,25 @@ -//@module: commonjs +// @module: commonjs // @Filename: extendingClassFromAliasAndUsageInIndexer_backbone.ts export class Model { public someData: string; } // @Filename: extendingClassFromAliasAndUsageInIndexer_moduleA.ts -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); export class VisualizationModel extends Backbone.Model { // interesting stuff here } // @Filename: extendingClassFromAliasAndUsageInIndexer_moduleB.ts -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); export class VisualizationModel extends Backbone.Model { // different interesting stuff here } // @Filename: extendingClassFromAliasAndUsageInIndexer_main.ts -import Backbone = require("extendingClassFromAliasAndUsageInIndexer_backbone"); -import moduleA = require("extendingClassFromAliasAndUsageInIndexer_moduleA"); -import moduleB = require("extendingClassFromAliasAndUsageInIndexer_moduleB"); +import Backbone = require("./extendingClassFromAliasAndUsageInIndexer_backbone"); +import moduleA = require("./extendingClassFromAliasAndUsageInIndexer_moduleA"); +import moduleB = require("./extendingClassFromAliasAndUsageInIndexer_moduleB"); interface IHasVisualizationModel { VisualizationModel: typeof Backbone.Model; } diff --git a/tests/cases/compiler/externalModuleExportingGenericClass.ts b/tests/cases/compiler/externalModuleExportingGenericClass.ts index 882dd1c5603..b20afb56013 100644 --- a/tests/cases/compiler/externalModuleExportingGenericClass.ts +++ b/tests/cases/compiler/externalModuleExportingGenericClass.ts @@ -8,7 +8,7 @@ export = C; // @Filename: externalModuleExportingGenericClass_file1.ts -import a = require('externalModuleExportingGenericClass_file0'); +import a = require('./externalModuleExportingGenericClass_file0'); var v: a; // this should report error var v2: any = (new a()).foo; var v3: number = (new a()).foo; diff --git a/tests/cases/compiler/externalModuleImmutableBindings.ts b/tests/cases/compiler/externalModuleImmutableBindings.ts index 2321961f6f8..33e1b9894e1 100644 --- a/tests/cases/compiler/externalModuleImmutableBindings.ts +++ b/tests/cases/compiler/externalModuleImmutableBindings.ts @@ -5,7 +5,7 @@ export var x = 1; // @Filename: f2.ts // all mutations below are illegal and should be fixed -import * as stuff from 'f1'; +import * as stuff from './f1'; var n = 'baz'; diff --git a/tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration.ts b/tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration.ts index 79cf425bdda..55922da6ca8 100644 --- a/tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration.ts +++ b/tests/cases/compiler/externalModuleRefernceResolutionOrderInImportDeclaration.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: externalModuleRefernceResolutionOrderInImportDeclaration_file1.ts export function foo() { }; @@ -10,7 +10,7 @@ declare module "externalModuleRefernceResolutionOrderInImportDeclaration_file1" // @Filename: externalModuleRefernceResolutionOrderInImportDeclaration_file3.ts /// -import file1 = require('externalModuleRefernceResolutionOrderInImportDeclaration_file1'); +import file1 = require('./externalModuleRefernceResolutionOrderInImportDeclaration_file1'); file1.foo(); file1.bar(); diff --git a/tests/cases/compiler/externalModuleWithoutCompilerFlag1.ts b/tests/cases/compiler/externalModuleWithoutCompilerFlag1.ts index 4283e3d32a9..875e3205407 100644 --- a/tests/cases/compiler/externalModuleWithoutCompilerFlag1.ts +++ b/tests/cases/compiler/externalModuleWithoutCompilerFlag1.ts @@ -1,4 +1,3 @@ -// @module: unspecified // Not on line 0 because we want to verify the error is placed in the appropriate location. export module M { diff --git a/tests/cases/compiler/forwardRefInEnum.ts b/tests/cases/compiler/forwardRefInEnum.ts new file mode 100644 index 00000000000..97bc1819d7b --- /dev/null +++ b/tests/cases/compiler/forwardRefInEnum.ts @@ -0,0 +1,13 @@ +enum E1 { + // illegal case + // forward reference to the element of the same enum + X = Y, + X1 = E1["Y"], + // forward reference to the element of the same enum + Y = E1.Z, + Y1 = E1["Z"] +} + +enum E1 { + Z = 4 +} diff --git a/tests/cases/compiler/implementsInClassExpression.ts b/tests/cases/compiler/implementsInClassExpression.ts new file mode 100644 index 00000000000..4504c6a2622 --- /dev/null +++ b/tests/cases/compiler/implementsInClassExpression.ts @@ -0,0 +1,7 @@ +interface Foo { + doThing(): void; +} + +let cls = class implements Foo { + doThing() { } +} \ No newline at end of file diff --git a/tests/cases/compiler/importAsBaseClass.ts b/tests/cases/compiler/importAsBaseClass.ts index b533453773c..4077ca952b9 100644 --- a/tests/cases/compiler/importAsBaseClass.ts +++ b/tests/cases/compiler/importAsBaseClass.ts @@ -1,9 +1,9 @@ -//@module: commonjs +// @module: commonjs // @Filename: importAsBaseClass_0.ts export class Greeter { greet() { return 'greet' } } // @Filename: importAsBaseClass_1.ts -import Greeter = require("importAsBaseClass_0"); +import Greeter = require("./importAsBaseClass_0"); class Hello extends Greeter { } diff --git a/tests/cases/compiler/importDecl.ts b/tests/cases/compiler/importDecl.ts index c28b332eb43..e7c3a0789ce 100644 --- a/tests/cases/compiler/importDecl.ts +++ b/tests/cases/compiler/importDecl.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @declaration: true // @Filename: importDecl_require.ts export class d { @@ -29,7 +29,7 @@ export var x: d; export function foo(): d { return null; } // @Filename: importDecl_require4.ts -import m4 = require("importDecl_require"); +import m4 = require("./importDecl_require"); export function foo2(): m4.d { return null; } // @Filename: importDecl_1.ts @@ -38,7 +38,7 @@ export function foo2(): m4.d { return null; } /// /// /// -import m4 = require("importDecl_require"); // Emit used +import m4 = require("./importDecl_require"); // Emit used export var x4 = m4.x; export var d4 = m4.d; export var f4 = m4.foo(); @@ -54,16 +54,16 @@ export module m1 { } //Emit global only usage -import glo_m4 = require("importDecl_require1"); +import glo_m4 = require("./importDecl_require1"); export var useGlo_m4_d4 = glo_m4.d; export var useGlo_m4_f4 = glo_m4.foo(); //Emit even when used just in function type -import fncOnly_m4 = require("importDecl_require2"); +import fncOnly_m4 = require("./importDecl_require2"); export var useFncOnly_m4_f4 = fncOnly_m4.foo(); // only used privately no need to emit -import private_m4 = require("importDecl_require3"); +import private_m4 = require("./importDecl_require3"); export module usePrivate_m4_m1 { var x3 = private_m4.x; var d3 = private_m4.d; @@ -71,11 +71,11 @@ export module usePrivate_m4_m1 { } // Do not emit unused import -import m5 = require("importDecl_require4"); +import m5 = require("./importDecl_require4"); export var d = m5.foo2(); // Do not emit multiple used import statements -import multiImport_m4 = require("importDecl_require"); // Emit used +import multiImport_m4 = require("./importDecl_require"); // Emit used export var useMultiImport_m4_x4 = multiImport_m4.x; export var useMultiImport_m4_d4 = multiImport_m4.d; export var useMultiImport_m4_f4 = multiImport_m4.foo(); diff --git a/tests/cases/compiler/importDeclarationUsedAsTypeQuery.ts b/tests/cases/compiler/importDeclarationUsedAsTypeQuery.ts index aea205dd447..5fc77ca1a8e 100644 --- a/tests/cases/compiler/importDeclarationUsedAsTypeQuery.ts +++ b/tests/cases/compiler/importDeclarationUsedAsTypeQuery.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @declaration: true // @Filename: importDeclarationUsedAsTypeQuery_require.ts export class B { @@ -7,5 +7,5 @@ export class B { // @Filename: importDeclarationUsedAsTypeQuery_1.ts /// -import a = require('importDeclarationUsedAsTypeQuery_require'); +import a = require('./importDeclarationUsedAsTypeQuery_require'); export var x: typeof a; diff --git a/tests/cases/compiler/importUsedInExtendsList1.ts b/tests/cases/compiler/importUsedInExtendsList1.ts index f76ccc874c9..f5e3b77f1e3 100644 --- a/tests/cases/compiler/importUsedInExtendsList1.ts +++ b/tests/cases/compiler/importUsedInExtendsList1.ts @@ -1,10 +1,10 @@ -//@module: commonjs +// @module: commonjs // @Filename: importUsedInExtendsList1_require.ts export class Super { foo: string; } // @Filename: importUsedInExtendsList1_1.ts /// -import foo = require('importUsedInExtendsList1_require'); +import foo = require('./importUsedInExtendsList1_require'); class Sub extends foo.Super { } var s: Sub; var r: string = s.foo; diff --git a/tests/cases/compiler/importsInAmbientModules1.ts b/tests/cases/compiler/importsInAmbientModules1.ts new file mode 100644 index 00000000000..afd3b071af6 --- /dev/null +++ b/tests/cases/compiler/importsInAmbientModules1.ts @@ -0,0 +1,10 @@ +// @module: amd + +// @filename: external.d.ts +export var x: number + +// @filename: main.ts + +declare module "M" { + import {x} from "external" +} \ No newline at end of file diff --git a/tests/cases/compiler/importsInAmbientModules2.ts b/tests/cases/compiler/importsInAmbientModules2.ts new file mode 100644 index 00000000000..587d7d2069d --- /dev/null +++ b/tests/cases/compiler/importsInAmbientModules2.ts @@ -0,0 +1,10 @@ +// @module: amd + +// @filename: external.d.ts +export default class C {} + +// @filename: main.ts + +declare module "M" { + import C from "external" +} \ No newline at end of file diff --git a/tests/cases/compiler/importsInAmbientModules3.ts b/tests/cases/compiler/importsInAmbientModules3.ts new file mode 100644 index 00000000000..cae5b404b9c --- /dev/null +++ b/tests/cases/compiler/importsInAmbientModules3.ts @@ -0,0 +1,10 @@ +// @module: amd + +// @filename: external.d.ts +export default class C {} + +// @filename: main.ts + +declare module "M" { + import C = require("external"); +} \ No newline at end of file diff --git a/tests/cases/compiler/initializersInAmbientEnums.ts b/tests/cases/compiler/initializersInAmbientEnums.ts new file mode 100644 index 00000000000..728fc881903 --- /dev/null +++ b/tests/cases/compiler/initializersInAmbientEnums.ts @@ -0,0 +1,5 @@ +declare enum E { + a = 10, + b = a, + e = 10 << 2 * 8, +} \ No newline at end of file diff --git a/tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx b/tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx new file mode 100644 index 00000000000..dc32ef7a0ca --- /dev/null +++ b/tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx @@ -0,0 +1,4 @@ +//@jsx: preserve + +declare var React: any; + \ No newline at end of file diff --git a/tests/cases/compiler/keywordInJsxIdentifier.tsx b/tests/cases/compiler/keywordInJsxIdentifier.tsx new file mode 100644 index 00000000000..ce858edae5d --- /dev/null +++ b/tests/cases/compiler/keywordInJsxIdentifier.tsx @@ -0,0 +1,7 @@ +//@jsx: react + +declare var React: any; +; +; +; +; diff --git a/tests/cases/compiler/lambdaASIEmit.ts b/tests/cases/compiler/lambdaASIEmit.ts index 44ee992ff47..c803b87411d 100644 --- a/tests/cases/compiler/lambdaASIEmit.ts +++ b/tests/cases/compiler/lambdaASIEmit.ts @@ -1,4 +1,4 @@ -// @comments: true +// @removeComments: false function Foo(x: any) { diff --git a/tests/cases/compiler/localAliasExportAssignment.ts b/tests/cases/compiler/localAliasExportAssignment.ts index 8e6df40403b..9fe29ba91d1 100644 --- a/tests/cases/compiler/localAliasExportAssignment.ts +++ b/tests/cases/compiler/localAliasExportAssignment.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: localAliasExportAssignment_0.ts var server: { (): any; @@ -8,7 +8,7 @@ export = server; // @Filename: localAliasExportAssignment_1.ts /// -import connect = require('localAliasExportAssignment_0'); +import connect = require('./localAliasExportAssignment_0'); connect(); diff --git a/tests/cases/compiler/missingPropertiesOfClassExpression.ts b/tests/cases/compiler/missingPropertiesOfClassExpression.ts new file mode 100644 index 00000000000..a1d91355365 --- /dev/null +++ b/tests/cases/compiler/missingPropertiesOfClassExpression.ts @@ -0,0 +1,5 @@ +class George extends class { reset() { return this.y; } } { + constructor() { + super(); + } +} diff --git a/tests/cases/compiler/moduleInTypePosition1.ts b/tests/cases/compiler/moduleInTypePosition1.ts index 170afc1f876..51481a5c0ea 100644 --- a/tests/cases/compiler/moduleInTypePosition1.ts +++ b/tests/cases/compiler/moduleInTypePosition1.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: moduleInTypePosition1_0.ts export class Promise { foo: string; @@ -6,5 +6,5 @@ export class Promise { // @Filename: moduleInTypePosition1_1.ts /// -import WinJS = require('moduleInTypePosition1_0'); +import WinJS = require('./moduleInTypePosition1_0'); var x = (w1: WinJS) => { }; diff --git a/tests/cases/compiler/modulePrologueAMD.ts b/tests/cases/compiler/modulePrologueAMD.ts new file mode 100644 index 00000000000..d5473798ee0 --- /dev/null +++ b/tests/cases/compiler/modulePrologueAMD.ts @@ -0,0 +1,4 @@ +// @module: amd +"use strict"; + +export class Foo {} \ No newline at end of file diff --git a/tests/cases/compiler/modulePrologueCommonjs.ts b/tests/cases/compiler/modulePrologueCommonjs.ts new file mode 100644 index 00000000000..d6ef5e820a3 --- /dev/null +++ b/tests/cases/compiler/modulePrologueCommonjs.ts @@ -0,0 +1,4 @@ +// @module: commonjs +"use strict"; + +export class Foo {} \ No newline at end of file diff --git a/tests/cases/compiler/modulePrologueES6.ts b/tests/cases/compiler/modulePrologueES6.ts new file mode 100644 index 00000000000..a0782891cba --- /dev/null +++ b/tests/cases/compiler/modulePrologueES6.ts @@ -0,0 +1,5 @@ +// @module: es6 +// @target: es6 +"use strict"; + +export class Foo {} \ No newline at end of file diff --git a/tests/cases/compiler/modulePrologueSystem.ts b/tests/cases/compiler/modulePrologueSystem.ts new file mode 100644 index 00000000000..d336bdb8950 --- /dev/null +++ b/tests/cases/compiler/modulePrologueSystem.ts @@ -0,0 +1,4 @@ +// @module: system +"use strict"; + +export class Foo {} \ No newline at end of file diff --git a/tests/cases/compiler/modulePrologueUmd.ts b/tests/cases/compiler/modulePrologueUmd.ts new file mode 100644 index 00000000000..2660ca75081 --- /dev/null +++ b/tests/cases/compiler/modulePrologueUmd.ts @@ -0,0 +1,4 @@ +// @module: umd +"use strict"; + +export class Foo {} \ No newline at end of file diff --git a/tests/cases/compiler/moduleResolutionNoResolve.ts b/tests/cases/compiler/moduleResolutionNoResolve.ts new file mode 100644 index 00000000000..aea0208b5d6 --- /dev/null +++ b/tests/cases/compiler/moduleResolutionNoResolve.ts @@ -0,0 +1,8 @@ +// @module:commonjs +// @noResolve: true + +// @filename: a.ts +import a = require('./b'); + +// @filename: b.ts +export var c = ''; diff --git a/tests/cases/compiler/multiImportExport.ts b/tests/cases/compiler/multiImportExport.ts index 939a6e1061e..fe253e282ad 100644 --- a/tests/cases/compiler/multiImportExport.ts +++ b/tests/cases/compiler/multiImportExport.ts @@ -5,10 +5,10 @@ import Drawing = require('./Drawing'); var addr = new Drawing.Math.Adder(); // @Filename: Drawing.ts -export import Math = require('Math/Math') +export import Math = require('./Math/Math') // @Filename: Math/Math.ts -import Adder = require('Math/Adder'); +import Adder = require('./Adder'); var Math = { Adder:Adder diff --git a/tests/cases/compiler/nodeResolution1.ts b/tests/cases/compiler/nodeResolution1.ts new file mode 100644 index 00000000000..19316ef251b --- /dev/null +++ b/tests/cases/compiler/nodeResolution1.ts @@ -0,0 +1,8 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: a.ts +export var x = 1; + +// @filename: b.ts +import y = require("./a"); \ No newline at end of file diff --git a/tests/cases/compiler/nodeResolution2.ts b/tests/cases/compiler/nodeResolution2.ts new file mode 100644 index 00000000000..9d1972c7239 --- /dev/null +++ b/tests/cases/compiler/nodeResolution2.ts @@ -0,0 +1,8 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: node_modules/a.d.ts +export var x: number; + +// @filename: b.ts +import y = require("a"); \ No newline at end of file diff --git a/tests/cases/compiler/nodeResolution3.ts b/tests/cases/compiler/nodeResolution3.ts new file mode 100644 index 00000000000..ede8f76dbbe --- /dev/null +++ b/tests/cases/compiler/nodeResolution3.ts @@ -0,0 +1,8 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: node_modules/b/index.d.ts +export var x: number; + +// @filename: a.ts +import y = require("b"); \ No newline at end of file diff --git a/tests/cases/compiler/nodeResolution4.ts b/tests/cases/compiler/nodeResolution4.ts new file mode 100644 index 00000000000..247546c3f0c --- /dev/null +++ b/tests/cases/compiler/nodeResolution4.ts @@ -0,0 +1,12 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: ref.ts +var x = 1; + +// @filename: a.ts +/// +export var y; + +// @filename: b.ts +import y = require("./a"); \ No newline at end of file diff --git a/tests/cases/compiler/nodeResolution5.ts b/tests/cases/compiler/nodeResolution5.ts new file mode 100644 index 00000000000..313dabd7899 --- /dev/null +++ b/tests/cases/compiler/nodeResolution5.ts @@ -0,0 +1,10 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: node_modules/a.d.ts +declare module "a" { + var x: number; +} + +// @filename: b.ts +import y = require("a"); diff --git a/tests/cases/compiler/nodeResolution6.ts b/tests/cases/compiler/nodeResolution6.ts new file mode 100644 index 00000000000..3f6dc81c847 --- /dev/null +++ b/tests/cases/compiler/nodeResolution6.ts @@ -0,0 +1,13 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: node_modules/ref.ts +var x = 1; + +// @filename: node_modules/a.d.ts +/// +export declare var y; + + +// @filename: b.ts +import y = require("a"); diff --git a/tests/cases/compiler/nodeResolution7.ts b/tests/cases/compiler/nodeResolution7.ts new file mode 100644 index 00000000000..b4283edb76a --- /dev/null +++ b/tests/cases/compiler/nodeResolution7.ts @@ -0,0 +1,10 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: node_modules/a/index.d.ts +declare module "a" { + var x: number; +} + +// @filename: b.ts +import y = require("a"); diff --git a/tests/cases/compiler/nodeResolution8.ts b/tests/cases/compiler/nodeResolution8.ts new file mode 100644 index 00000000000..0a6e528f20a --- /dev/null +++ b/tests/cases/compiler/nodeResolution8.ts @@ -0,0 +1,13 @@ +// @module: commonjs +// @moduleResolution: node + +// @filename: node_modules/a/ref.ts +var x = 1; + +// @filename: node_modules/a/index.d.ts +/// +export declare var y; + + +// @filename: b.ts +import y = require("a"); \ No newline at end of file diff --git a/tests/cases/compiler/out-flag.ts b/tests/cases/compiler/out-flag.ts index 45a8d92805c..07cd55224a5 100644 --- a/tests/cases/compiler/out-flag.ts +++ b/tests/cases/compiler/out-flag.ts @@ -3,7 +3,7 @@ // @declaration: true // @module: commonjs //// @out: bin\ -// @comments: true +// @removeComments: false // my class comments class MyClass diff --git a/tests/cases/compiler/out-flag2.ts b/tests/cases/compiler/out-flag2.ts new file mode 100644 index 00000000000..d3349563a9f --- /dev/null +++ b/tests/cases/compiler/out-flag2.ts @@ -0,0 +1,11 @@ +// @target: ES5 +// @sourcemap: true +// @declaration: true +// @module: commonjs +// @outFile: c.js + +// @Filename: a.ts +class A { } + +// @Filename: b.ts +class B { } \ No newline at end of file diff --git a/tests/cases/compiler/out-flag3.ts b/tests/cases/compiler/out-flag3.ts new file mode 100644 index 00000000000..cb3c6819811 --- /dev/null +++ b/tests/cases/compiler/out-flag3.ts @@ -0,0 +1,14 @@ +// @target: ES5 +// @sourcemap: true +// @declaration: true +// @module: commonjs +// @outFile: c.js +// @out: d.js + +// --out and --outFile error + +// @Filename: a.ts +class A { } + +// @Filename: b.ts +class B { } \ No newline at end of file diff --git a/tests/cases/compiler/pinnedComments1.ts b/tests/cases/compiler/pinnedComments1.ts index 474769e9b20..1bf99943c5b 100644 --- a/tests/cases/compiler/pinnedComments1.ts +++ b/tests/cases/compiler/pinnedComments1.ts @@ -1,6 +1,10 @@ -// @comments: false +// @removeComments: true +/*!========= + Keep this pinned comment + ========= +*/ /* unpinned comment */ -/*! pinned comment */ +/*! pinned comment that need to be removed */ class C { } \ No newline at end of file diff --git a/tests/cases/compiler/privacyCannotNameAccessorDeclFile.ts b/tests/cases/compiler/privacyCannotNameAccessorDeclFile.ts index 1150cf963bf..70369c47895 100644 --- a/tests/cases/compiler/privacyCannotNameAccessorDeclFile.ts +++ b/tests/cases/compiler/privacyCannotNameAccessorDeclFile.ts @@ -36,7 +36,7 @@ export module SpecializedWidget { // @Filename:privacyCannotNameAccessorDeclFile_exporter.ts /// -import Widgets = require("privacyCannotNameAccessorDeclFile_Widgets"); +import Widgets = require("./privacyCannotNameAccessorDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); @@ -52,7 +52,7 @@ export function createExportedWidget4() { } // @Filename:privacyCannotNameAccessorDeclFile_consumer.ts -import exporter = require("privacyCannotNameAccessorDeclFile_exporter"); +import exporter = require("./privacyCannotNameAccessorDeclFile_exporter"); export class publicClassWithWithPrivateGetAccessorTypes { static get myPublicStaticMethod() { // Error return exporter.createExportedWidget1(); diff --git a/tests/cases/compiler/privacyCannotNameVarTypeDeclFile.ts b/tests/cases/compiler/privacyCannotNameVarTypeDeclFile.ts index e49d31946c6..1135e3c86f4 100644 --- a/tests/cases/compiler/privacyCannotNameVarTypeDeclFile.ts +++ b/tests/cases/compiler/privacyCannotNameVarTypeDeclFile.ts @@ -36,7 +36,7 @@ export module SpecializedWidget { // @Filename:privacyCannotNameVarTypeDeclFile_exporter.ts /// -import Widgets = require("privacyCannotNameVarTypeDeclFile_Widgets"); +import Widgets = require("./privacyCannotNameVarTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); @@ -52,7 +52,7 @@ export function createExportedWidget4() { } // @Filename:privacyCannotNameVarTypeDeclFile_consumer.ts -import exporter = require("privacyCannotNameVarTypeDeclFile_exporter"); +import exporter = require("./privacyCannotNameVarTypeDeclFile_exporter"); export class publicClassWithWithPrivatePropertyTypes { static myPublicStaticProperty = exporter.createExportedWidget1(); // Error private static myPrivateStaticProperty = exporter.createExportedWidget1(); diff --git a/tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass.ts b/tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass.ts index b412622ad40..a214104fafb 100644 --- a/tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass.ts +++ b/tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass.ts @@ -1,5 +1,5 @@ -//@module: commonjs -//@declaration: true +// @module: commonjs +// @declaration: true // @Filename: privacyCheckExternalModuleExportAssignmentOfGenericClass_0.ts export = Foo; class Foo { @@ -7,7 +7,7 @@ class Foo { } // @Filename: privacyCheckExternalModuleExportAssignmentOfGenericClass_1.ts -import Foo = require("privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); +import Foo = require("./privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); export = Bar; interface Bar { foo: Foo; diff --git a/tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile.ts b/tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile.ts index f24ed8ea32b..dd5eaf82bdf 100644 --- a/tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile.ts +++ b/tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile.ts @@ -36,7 +36,7 @@ export module SpecializedWidget { // @Filename:privacyFunctionCannotNameParameterTypeDeclFile_exporter.ts /// -import Widgets = require("privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); +import Widgets = require("./privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); @@ -52,7 +52,7 @@ export function createExportedWidget4() { } // @Filename:privacyFunctionCannotNameParameterTypeDeclFile_consumer.ts -import exporter = require("privacyFunctionCannotNameParameterTypeDeclFile_exporter"); +import exporter = require("./privacyFunctionCannotNameParameterTypeDeclFile_exporter"); export class publicClassWithWithPrivateParmeterTypes { static myPublicStaticMethod(param = exporter.createExportedWidget1()) { // Error } diff --git a/tests/cases/compiler/privacyFunctionCannotNameReturnTypeDeclFile.ts b/tests/cases/compiler/privacyFunctionCannotNameReturnTypeDeclFile.ts index 2eff22327b5..cb1993286a4 100644 --- a/tests/cases/compiler/privacyFunctionCannotNameReturnTypeDeclFile.ts +++ b/tests/cases/compiler/privacyFunctionCannotNameReturnTypeDeclFile.ts @@ -36,7 +36,7 @@ export module SpecializedWidget { // @Filename:privacyFunctionReturnTypeDeclFile_exporter.ts /// -import Widgets = require("privacyFunctionReturnTypeDeclFile_Widgets"); +import Widgets = require("./privacyFunctionReturnTypeDeclFile_Widgets"); import Widgets1 = require("GlobalWidgets"); export function createExportedWidget1() { return Widgets.createWidget1(); @@ -52,7 +52,7 @@ export function createExportedWidget4() { } // @Filename:privacyFunctionReturnTypeDeclFile_consumer.ts -import exporter = require("privacyFunctionReturnTypeDeclFile_exporter"); +import exporter = require("./privacyFunctionReturnTypeDeclFile_exporter"); export class publicClassWithWithPrivateParmeterTypes { static myPublicStaticMethod() { // Error return exporter.createExportedWidget1(); diff --git a/tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport.ts b/tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport.ts index 16c6e19fb59..1ea30d1f3c4 100644 --- a/tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport.ts +++ b/tests/cases/compiler/privacyTopLevelAmbientExternalModuleImportWithExport.ts @@ -1,5 +1,5 @@ -//@module: commonjs -//@declaration: true +// @module: commonjs +// @declaration: true // @Filename: privacyTopLevelAmbientExternalModuleImportWithExport_require.ts // Public elements export class c_public { @@ -32,8 +32,8 @@ declare module 'm2' { /// /// // Privacy errors - importing private elements -export import im_public_mi_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require"); -export import im_public_mu_private = require("privacyTopLevelAmbientExternalModuleImportWithExport_require1"); +export import im_public_mi_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require"); +export import im_public_mu_private = require("./privacyTopLevelAmbientExternalModuleImportWithExport_require1"); export import im_public_mi_public = require("m"); export import im_public_mu_public = require("m2"); diff --git a/tests/cases/compiler/recursiveGenericUnionType1.ts b/tests/cases/compiler/recursiveGenericUnionType1.ts new file mode 100644 index 00000000000..c1c7b3e81ad --- /dev/null +++ b/tests/cases/compiler/recursiveGenericUnionType1.ts @@ -0,0 +1,20 @@ +declare module Test1 { + export type Container = T | { + [i: string]: Container; + }; + export type IStringContainer = Container; +} + +declare module Test2 { + export type Container = T | { + [i: string]: Container; + }; + export type IStringContainer = Container; +} + +var x: Test1.Container; + +var s1: Test1.IStringContainer; +var s2: Test2.IStringContainer; +s1 = s2; +s2 = s1; diff --git a/tests/cases/compiler/recursiveGenericUnionType2.ts b/tests/cases/compiler/recursiveGenericUnionType2.ts new file mode 100644 index 00000000000..784ddefeb1f --- /dev/null +++ b/tests/cases/compiler/recursiveGenericUnionType2.ts @@ -0,0 +1,20 @@ +declare module Test1 { + export type Container = T | { + [i: string]: Container[]; + }; + export type IStringContainer = Container; +} + +declare module Test2 { + export type Container = T | { + [i: string]: Container[]; + }; + export type IStringContainer = Container; +} + +var x: Test1.Container; + +var s1: Test1.IStringContainer; +var s2: Test2.IStringContainer; +s1 = s2; +s2 = s1; diff --git a/tests/cases/compiler/recursiveTupleTypes1.ts b/tests/cases/compiler/recursiveTupleTypes1.ts new file mode 100644 index 00000000000..82559eccfad --- /dev/null +++ b/tests/cases/compiler/recursiveTupleTypes1.ts @@ -0,0 +1,12 @@ +interface Tree1 { + children: [Tree1, Tree2]; +} + +interface Tree2 { + children: [Tree2, Tree1]; +} + +let tree1: Tree1; +let tree2: Tree2; +tree1 = tree2; +tree2 = tree1; diff --git a/tests/cases/compiler/recursiveTupleTypes2.ts b/tests/cases/compiler/recursiveTupleTypes2.ts new file mode 100644 index 00000000000..78c8efa82a4 --- /dev/null +++ b/tests/cases/compiler/recursiveTupleTypes2.ts @@ -0,0 +1,12 @@ +interface Tree1 { + children: [Tree1, Tree2]; +} + +interface Tree2 { + children: [Tree2, Tree2]; +} + +let tree1: Tree1; +let tree2: Tree2; +tree1 = tree2; +tree2 = tree1; diff --git a/tests/cases/compiler/requireOfAnEmptyFile1.ts b/tests/cases/compiler/requireOfAnEmptyFile1.ts index 365817f1339..98d5003ad67 100644 --- a/tests/cases/compiler/requireOfAnEmptyFile1.ts +++ b/tests/cases/compiler/requireOfAnEmptyFile1.ts @@ -1,7 +1,7 @@ -//@module: commonjs +// @module: commonjs //requireOfAnEmptyFile1 // @Filename: requireOfAnEmptyFile1_a.ts -import fs = require('requireOfAnEmptyFile1_b'); +import fs = require('./requireOfAnEmptyFile1_b'); // @Filename: requireOfAnEmptyFile1_b.ts diff --git a/tests/cases/compiler/reuseInnerModuleMember.ts b/tests/cases/compiler/reuseInnerModuleMember.ts index ebffcad6060..e2f9900e73f 100644 --- a/tests/cases/compiler/reuseInnerModuleMember.ts +++ b/tests/cases/compiler/reuseInnerModuleMember.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: reuseInnerModuleMember_0.ts export module M { } @@ -8,7 +8,7 @@ declare module bar { interface alpha { } } -import f = require('reuseInnerModuleMember_0'); +import f = require('./reuseInnerModuleMember_0'); module bar { var x: alpha; } diff --git a/tests/cases/compiler/sourceMap-FileWithComments.ts b/tests/cases/compiler/sourceMap-FileWithComments.ts index a3e5930d7c1..5dcf602c3de 100644 --- a/tests/cases/compiler/sourceMap-FileWithComments.ts +++ b/tests/cases/compiler/sourceMap-FileWithComments.ts @@ -1,5 +1,5 @@ // @sourcemap: true -// @comments: true +// @removeComments: false // Interface interface IPoint { diff --git a/tests/cases/compiler/staticInstanceResolution3.ts b/tests/cases/compiler/staticInstanceResolution3.ts index ae8cefc8102..bc4586b2adf 100644 --- a/tests/cases/compiler/staticInstanceResolution3.ts +++ b/tests/cases/compiler/staticInstanceResolution3.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: staticInstanceResolution3_0.ts export class Promise { static timeout(delay: number): Promise { @@ -8,5 +8,5 @@ export class Promise { // @Filename: staticInstanceResolution3_1.ts /// -import WinJS = require('staticInstanceResolution3_0'); +import WinJS = require('./staticInstanceResolution3_0'); WinJS.Promise.timeout(10); \ No newline at end of file diff --git a/tests/cases/compiler/systemModule17.ts b/tests/cases/compiler/systemModule17.ts new file mode 100644 index 00000000000..f6b6d6ea2f2 --- /dev/null +++ b/tests/cases/compiler/systemModule17.ts @@ -0,0 +1,41 @@ +// @module: system + +// @filename: f1.ts + +export class A {} +export interface I {} + +// @filename: f2.ts + +var x = 1; +interface I { } + +namespace N { + export var x = 1; + export interface I { } +} + +import IX = N.x; +import II = N.I; +import { A, A as EA, I as EI } from "f1"; + +export {x}; +export {x as x1}; + +export {I}; +export {I as I1}; + +export {A}; +export {A as A1}; + +export {EA}; +export {EA as EA1}; + +export {EI }; +export {EI as EI1}; + +export {IX}; +export {IX as IX1}; + +export {II}; +export {II as II1}; \ No newline at end of file diff --git a/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts b/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts new file mode 100644 index 00000000000..cffb7654834 --- /dev/null +++ b/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts @@ -0,0 +1,7 @@ +type TreeNode = { + name: string; + parent: TreeNode; +} + +var nodes: TreeNode[]; +nodes.map(n => n.name); diff --git a/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts b/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts new file mode 100644 index 00000000000..4ca5c9fc663 --- /dev/null +++ b/tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts @@ -0,0 +1,12 @@ +type TreeNode = { + name: string; + parent: TreeNode; +} + +type TreeNodeMiddleman = { + name: string; + parent: TreeNode; +} + +var nodes: TreeNodeMiddleman[]; +nodes.map(n => n.name); diff --git a/tests/cases/compiler/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.ts b/tests/cases/compiler/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.ts index 28a9e821131..70be28f74eb 100644 --- a/tests/cases/compiler/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.ts +++ b/tests/cases/compiler/typeCheckObjectCreationExpressionWithUndefinedCallResolutionData.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @declaration: true // @Filename: file1.ts export function foo() { @@ -7,5 +7,5 @@ var classes = undefined; } // @Filename: file2.ts -import f = require('file1'); +import f = require('./file1'); f.foo(); diff --git a/tests/cases/compiler/typeofAmbientExternalModules.ts b/tests/cases/compiler/typeofAmbientExternalModules.ts index df3283bfb45..b6b8237dac6 100644 --- a/tests/cases/compiler/typeofAmbientExternalModules.ts +++ b/tests/cases/compiler/typeofAmbientExternalModules.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: typeofAmbientExternalModules_0.ts export class C { foo: string; } @@ -9,8 +9,8 @@ export = D; // @Filename: typeofAmbientExternalModules_2.ts /// /// -import ext = require('typeofAmbientExternalModules_0'); -import exp = require('typeofAmbientExternalModules_1'); +import ext = require('./typeofAmbientExternalModules_0'); +import exp = require('./typeofAmbientExternalModules_1'); var y1: typeof ext = ext; y1 = exp; diff --git a/tests/cases/compiler/typeofExternalModules.ts b/tests/cases/compiler/typeofExternalModules.ts index fe3dfad5d86..32475215e24 100644 --- a/tests/cases/compiler/typeofExternalModules.ts +++ b/tests/cases/compiler/typeofExternalModules.ts @@ -1,4 +1,4 @@ -//@module: commonjs +// @module: commonjs // @Filename: typeofExternalModules_external.ts export class C { } @@ -7,8 +7,8 @@ class D { } export = D; // @Filename: typeofExternalModules_core.ts -import ext = require('typeofExternalModules_external'); -import exp = require('typeofExternalModules_exportAssign'); +import ext = require('./typeofExternalModules_external'); +import exp = require('./typeofExternalModules_exportAssign'); var y1: typeof ext = ext; y1 = exp; diff --git a/tests/cases/compiler/unusedImportDeclaration.ts b/tests/cases/compiler/unusedImportDeclaration.ts index 263b355f69c..71fe5aae5a3 100644 --- a/tests/cases/compiler/unusedImportDeclaration.ts +++ b/tests/cases/compiler/unusedImportDeclaration.ts @@ -1,5 +1,5 @@ -//@module: commonjs -//@declaration: true +// @module: commonjs +// @declaration: true // @Filename: unusedImportDeclaration_testerB.ts class TesterB { me: string; @@ -7,7 +7,7 @@ class TesterB { export = TesterB; // @Filename: unusedImportDeclaration_testerA.ts -import B = require("unusedImportDeclaration_testerB"); +import B = require("./unusedImportDeclaration_testerB"); var thingy: B = { me: "A" }; diff --git a/tests/cases/compiler/visibilityOfCrossModuleTypeUsage.ts b/tests/cases/compiler/visibilityOfCrossModuleTypeUsage.ts index ff9610a2f65..ee22e3a4172 100644 --- a/tests/cases/compiler/visibilityOfCrossModuleTypeUsage.ts +++ b/tests/cases/compiler/visibilityOfCrossModuleTypeUsage.ts @@ -1,9 +1,9 @@ -//@module: commonjs +// @module: commonjs //visibilityOfCrossModuleTypeUsage // @Filename: visibilityOfCrossModuleTypeUsage_commands.ts -import fs = require('visibilityOfCrossModuleTypeUsage_fs'); -import server = require('visibilityOfCrossModuleTypeUsage_server'); +import fs = require('./visibilityOfCrossModuleTypeUsage_fs'); +import server = require('./visibilityOfCrossModuleTypeUsage_server'); export interface IConfiguration { workspace: server.IWorkspace; @@ -19,7 +19,7 @@ export interface IWorkspace { } // @Filename: visibilityOfCrossModuleTypeUsage_fs.ts -import commands = require('visibilityOfCrossModuleTypeUsage_commands'); +import commands = require('./visibilityOfCrossModuleTypeUsage_commands'); function run(configuration: commands.IConfiguration) { var absoluteWorkspacePath = configuration.workspace.toAbsolutePath(configuration.server); } \ No newline at end of file diff --git a/tests/cases/compiler/voidAsNonAmbiguousReturnType.ts b/tests/cases/compiler/voidAsNonAmbiguousReturnType.ts index d20f9941fbf..c00ef99e1aa 100644 --- a/tests/cases/compiler/voidAsNonAmbiguousReturnType.ts +++ b/tests/cases/compiler/voidAsNonAmbiguousReturnType.ts @@ -1,11 +1,11 @@ -//@module: commonjs +// @module: commonjs // @Filename: voidAsNonAmbiguousReturnType_0.ts export function mkdirSync(path: string, mode?: number): void; export function mkdirSync(path: string, mode?: string): void {} // @Filename: voidAsNonAmbiguousReturnType_1.ts /// -import fs = require("voidAsNonAmbiguousReturnType_0"); +import fs = require("./voidAsNonAmbiguousReturnType_0"); function main() { fs.mkdirSync('test'); // should not error - return types are the same diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSingleLineDecl.ts similarity index 100% rename from tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts rename to tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSingleLineDecl.ts diff --git a/tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts b/tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts index 2202a482f8b..69b7462cd03 100644 --- a/tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts +++ b/tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts @@ -2,8 +2,8 @@ function f0() { var [] = [1, "hello"]; var [x] = [1, "hello"]; var [x, y] = [1, "hello"]; - var [x, y, z] = [1, "hello"]; // Error - var [,, z] = [0, 1, 2]; + var [x, y, z] = [1, "hello"]; + var [,, x] = [0, 1, 2]; var x: number; var y: string; } @@ -19,14 +19,14 @@ function f1() { } function f2() { - var { } = { x: 5, y: "hello" }; - var { x } = { x: 5, y: "hello" }; - var { y } = { x: 5, y: "hello" }; + var { } = { x: 5, y: "hello" }; // Error, no x and y in target + var { x } = { x: 5, y: "hello" }; // Error, no y in target + var { y } = { x: 5, y: "hello" }; // Error, no x in target var { x, y } = { x: 5, y: "hello" }; var x: number; var y: string; - var { x: a } = { x: 5, y: "hello" }; - var { y: b } = { x: 5, y: "hello" }; + var { x: a } = { x: 5, y: "hello" }; // Error, no y in target + var { y: b } = { x: 5, y: "hello" }; // Error, no x in target var { x: a, y: b } = { x: 5, y: "hello" }; var a: number; var b: string; diff --git a/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts b/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts new file mode 100644 index 00000000000..17de6dd2858 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringWithLiteralInitializers.ts @@ -0,0 +1,65 @@ +// (arg: { x: any, y: any }) => void +function f1({ x, y }) { } +f1({ x: 1, y: 1 }); + +// (arg: { x: any, y?: number }) => void +function f2({ x, y = 0 }) { } +f2({ x: 1 }); +f2({ x: 1, y: 1 }); + +// (arg: { x?: number, y?: number }) => void +function f3({ x = 0, y = 0 }) { } +f3({}); +f3({ x: 1 }); +f3({ y: 1 }); +f3({ x: 1, y: 1 }); + +// (arg?: { x: number, y: number }) => void +function f4({ x, y } = { x: 0, y: 0 }) { } +f4(); +f4({ x: 1, y: 1 }); + +// (arg?: { x: number, y?: number }) => void +function f5({ x, y = 0 } = { x: 0 }) { } +f5(); +f5({ x: 1 }); +f5({ x: 1, y: 1 }); + +// (arg?: { x?: number, y?: number }) => void +function f6({ x = 0, y = 0 } = {}) { } +f6(); +f6({}); +f6({ x: 1 }); +f6({ y: 1 }); +f6({ x: 1, y: 1 }); + +// (arg?: { a: { x?: number, y?: number } }) => void +function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } +f7(); +f7({ a: {} }); +f7({ a: { x: 1 } }); +f7({ a: { y: 1 } }); +f7({ a: { x: 1, y: 1 } }); + +// (arg: [any, any]) => void +function g1([x, y]) { } +g1([1, 1]); + +// (arg: [number, number]) => void +function g2([x = 0, y = 0]) { } +g2([1, 1]); + +// (arg?: [number, number]) => void +function g3([x, y] = [0, 0]) { } +g3(); +g3([1, 1]); + +// (arg?: [number, number]) => void +function g4([x, y = 0] = [0]) { } +g4(); +g4([1, 1]); + +// (arg?: [number, number]) => void +function g5([x = 0, y = 0] = []) { } +g5(); +g5([1, 1]); diff --git a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts index 64b198b0916..90e25765847 100644 --- a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts +++ b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter01.ts @@ -1,4 +1,4 @@ - +// @declaration: true function f([]) { var x, y, z; diff --git a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts index 39663a4bed7..e9e99c6d0eb 100644 --- a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts +++ b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter02.ts @@ -1,4 +1,4 @@ - +// @declaration: true function f(a, []) { var x, y, z; diff --git a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts index 39663a4bed7..e9e99c6d0eb 100644 --- a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts +++ b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter03.ts @@ -1,4 +1,4 @@ - +// @declaration: true function f(a, []) { var x, y, z; diff --git a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts index 313d4fe6708..7f57c6a6acf 100644 --- a/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts +++ b/tests/cases/conformance/es6/destructuring/emptyArrayBindingPatternParameter04.ts @@ -1,4 +1,4 @@ - +// @declaration: true function f([] = [1,2,3,4]) { var x, y, z; diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5.ts index dd10e552615..44175dbb63a 100644 --- a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5.ts +++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5.ts @@ -1,4 +1,5 @@ // @target: es5 +// @declaration: true var a: any; diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES6.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES6.ts index 043f0cf1108..4f367ee8853 100644 --- a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES6.ts +++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES6.ts @@ -1,4 +1,5 @@ // @target: es6 +// @declaration: true var a: any; diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5.ts index 60fe89758d6..1d291425e67 100644 --- a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5.ts +++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5.ts @@ -1,4 +1,5 @@ // @target: es5 +// @declaration: true var a: any; let x, y, z, a1, a2, a3; diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES6.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES6.ts index 295401545d4..b156883f7d2 100644 --- a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES6.ts +++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES6.ts @@ -1,4 +1,5 @@ // @target: es6 +// @declaration: true var a: any; let x, y, z, a1, a2, a3; diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES5.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES5.ts index 080c828ad62..dbe79355cd8 100644 --- a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES5.ts +++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES5.ts @@ -1,4 +1,5 @@ // @target: es5 +// @declaration: true var a: any; diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES6.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES6.ts index 10d67254cd8..d86f01f5c79 100644 --- a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES6.ts +++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns03_ES6.ts @@ -1,4 +1,5 @@ // @target: es6 +// @declaration: true var a: any; diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES5.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES5.ts index 0233ddcda70..ac79e87a11c 100644 --- a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES5.ts +++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES5.ts @@ -1,4 +1,5 @@ // @target: es5 +// @declaration: true var a: any; let x, y, z, a1, a2, a3; diff --git a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES6.ts b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES6.ts index 3380a56aaa7..25e56c353b9 100644 --- a/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES6.ts +++ b/tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns04_ES6.ts @@ -1,4 +1,5 @@ // @target: es6 +// @declaration: true var a: any; let x, y, z, a1, a2, a3; diff --git a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts index 01aa5b54230..270d7f10227 100644 --- a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts +++ b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter01.ts @@ -1,4 +1,4 @@ - +// @declaration: true function f({}) { var x, y, z; diff --git a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts index f34503c1152..79d026eac9e 100644 --- a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts +++ b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter02.ts @@ -1,4 +1,4 @@ - +// @declaration: true function f(a, {}) { var x, y, z; diff --git a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts index a940c659703..c5d51b20cfa 100644 --- a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts +++ b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter03.ts @@ -1,4 +1,4 @@ - +// @declaration: true function f({}, a) { var x, y, z; diff --git a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts index da05e5cb428..0273e174de0 100644 --- a/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts +++ b/tests/cases/conformance/es6/destructuring/emptyObjectBindingPatternParameter04.ts @@ -1,4 +1,4 @@ - +// @declaration: true function f({} = {a: 1, b: "2", c: true}) { var x, y, z; diff --git a/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5.ts b/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5.ts new file mode 100644 index 00000000000..bc7a729fd1e --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES5.ts @@ -0,0 +1,50 @@ +// @target: es5 + +(function () { + var a: any; + + var {} = a; + let {} = a; + const {} = a; + + var [] = a; + let [] = a; + const [] = a; + + var {} = a, [] = a; + let {} = a, [] = a; + const {} = a, [] = a; + + var { p1: {}, p2: [] } = a; + let { p1: {}, p2: [] } = a; + const { p1: {}, p2: [] } = a; + + for (var {} = {}, {} = {}; false; void 0) { + } + + function f({} = a, [] = a, { p: {} = a} = a) { + return ({} = a, [] = a, { p: {} = a } = a) => a; + } +})(); + +(function () { + const ns: number[][] = []; + + for (var {} of ns) { + } + + for (let {} of ns) { + } + + for (const {} of ns) { + } + + for (var [] of ns) { + } + + for (let [] of ns) { + } + + for (const [] of ns) { + } +})(); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES6.ts b/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES6.ts new file mode 100644 index 00000000000..9f2a9905480 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns01_ES6.ts @@ -0,0 +1,50 @@ +// @target: es6 + +(function () { + var a: any; + + var {} = a; + let {} = a; + const {} = a; + + var [] = a; + let [] = a; + const [] = a; + + var {} = a, [] = a; + let {} = a, [] = a; + const {} = a, [] = a; + + var { p1: {}, p2: [] } = a; + let { p1: {}, p2: [] } = a; + const { p1: {}, p2: [] } = a; + + for (var {} = {}, {} = {}; false; void 0) { + } + + function f({} = a, [] = a, { p: {} = a} = a) { + return ({} = a, [] = a, { p: {} = a } = a) => a; + } +})(); + +(function () { + const ns: number[][] = []; + + for (var {} of ns) { + } + + for (let {} of ns) { + } + + for (const {} of ns) { + } + + for (var [] of ns) { + } + + for (let [] of ns) { + } + + for (const [] of ns) { + } +})(); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts b/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts new file mode 100644 index 00000000000..34c05e1838f --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES5.ts @@ -0,0 +1,12 @@ +// @target: es5 +// @declaration: true + +(function () { + var {}; + let {}; + const {}; + + var []; + let []; + const []; +})(); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts b/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts new file mode 100644 index 00000000000..3146fec4cb7 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/emptyVariableDeclarationBindingPatterns02_ES6.ts @@ -0,0 +1,12 @@ +// @target: es6 +// @declaration: true + +(function () { + var {}; + let {}; + const {}; + + var []; + let []; + const []; +})(); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts b/tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts new file mode 100644 index 00000000000..ef91b8249da --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/missingAndExcessProperties.ts @@ -0,0 +1,33 @@ +// Missing properties +function f1() { + var { x, y } = {}; + var { x = 1, y } = {}; + var { x, y = 1 } = {}; + var { x = 1, y = 1 } = {}; +} + +// Missing properties +function f2() { + var x: number, y: number; + ({ x, y } = {}); + ({ x: x = 1, y } = {}); + ({ x, y: y = 1 } = {}); + ({ x: x = 1, y: y = 1 } = {}); +} + +// Excess properties +function f3() { + var { } = { x: 0, y: 0 }; + var { x } = { x: 0, y: 0 }; + var { y } = { x: 0, y: 0 }; + var { x, y } = { x: 0, y: 0 }; +} + +// Excess properties +function f4() { + var x: number, y: number; + ({ } = { x: 0, y: 0 }); + ({ x } = { x: 0, y: 0 }); + ({ y } = { x: 0, y: 0 }); + ({ x, y } = { x: 0, y: 0 }); +} diff --git a/tests/cases/conformance/es6/modules/multipleDefaultExports01.ts b/tests/cases/conformance/es6/modules/multipleDefaultExports01.ts index 84172248e93..e6a467820b4 100644 --- a/tests/cases/conformance/es6/modules/multipleDefaultExports01.ts +++ b/tests/cases/conformance/es6/modules/multipleDefaultExports01.ts @@ -14,6 +14,6 @@ var x = 10; export default x; // @filename: m2.ts -import Entity from "m1" +import Entity from "./m1" Entity(); \ No newline at end of file diff --git a/tests/cases/conformance/es6/modules/multipleDefaultExports02.ts b/tests/cases/conformance/es6/modules/multipleDefaultExports02.ts index 1e9c8dabc13..d642b72b6f3 100644 --- a/tests/cases/conformance/es6/modules/multipleDefaultExports02.ts +++ b/tests/cases/conformance/es6/modules/multipleDefaultExports02.ts @@ -11,6 +11,6 @@ export default function bar() { } // @filename: m2.ts -import Entity from "m1" +import Entity from "./m1" Entity(); \ No newline at end of file diff --git a/tests/cases/conformance/expressions/asOperator/asOperator4.ts b/tests/cases/conformance/expressions/asOperator/asOperator4.ts new file mode 100644 index 00000000000..33fcbf920a1 --- /dev/null +++ b/tests/cases/conformance/expressions/asOperator/asOperator4.ts @@ -0,0 +1,11 @@ +//@module: commonjs +//@filename: foo.ts + +export function foo() { } + +//@filename: bar.ts +import { foo } from './foo'; + +// These should emit identically +foo; +(foo as any); diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts index 1b1e3cfab6c..f72845c18a4 100644 --- a/tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts @@ -1,8 +1,8 @@ -// In the true branch statement of an ‘if’ statement, -// the type of a variable or parameter is narrowed by any type guard in the ‘if’ condition when true, +// In the true branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true, // provided the true branch statement contains no assignments to the variable or parameter. -// In the false branch statement of an ‘if’ statement, -// the type of a variable or parameter is narrowed by any type guard in the ‘if’ condition when false, +// In the false branch statement of an 'if' statement, +// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when false, // provided the false branch statement contains no assignments to the variable or parameter function foo(x: number | string) { if (typeof x === "string") { diff --git a/tests/cases/conformance/externalModules/topLevelFileModule.ts b/tests/cases/conformance/externalModules/topLevelFileModule.ts index 7f694f6f98d..e6680889d26 100644 --- a/tests/cases/conformance/externalModules/topLevelFileModule.ts +++ b/tests/cases/conformance/externalModules/topLevelFileModule.ts @@ -6,6 +6,6 @@ export var x: number; export declare var y: number; // @Filename: foo_1.ts -import foo = require("vs/foo_0"); -import fum = require("vs/fum"); +import foo = require("./vs/foo_0"); +import fum = require("./vs/fum"); var z = foo.x + fum.y; diff --git a/tests/cases/conformance/externalModules/topLevelModuleDeclarationAndFile.ts b/tests/cases/conformance/externalModules/topLevelModuleDeclarationAndFile.ts index db0e2ce742c..456527acfae 100644 --- a/tests/cases/conformance/externalModules/topLevelModuleDeclarationAndFile.ts +++ b/tests/cases/conformance/externalModules/topLevelModuleDeclarationAndFile.ts @@ -1,5 +1,5 @@ // @module: commonjs -// @Filename: vs/foo_0.ts +// @Filename: vs/foo_0/index.ts export var x: number = 42; // @Filename: foo_1.ts diff --git a/tests/cases/conformance/jsx/tsxParseTests2.tsx b/tests/cases/conformance/jsx/tsxParseTests2.tsx new file mode 100644 index 00000000000..9ced9b93b79 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxParseTests2.tsx @@ -0,0 +1,8 @@ +//@filename: file.tsx +//@jsx: preserve +declare module JSX { + interface Element { } + interface IntrinsicElements { div; span; } +} + +var x =
; diff --git a/tests/cases/conformance/jsx/tsxPreserveEmit1.tsx b/tests/cases/conformance/jsx/tsxPreserveEmit1.tsx new file mode 100644 index 00000000000..e75a1dbfde2 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxPreserveEmit1.tsx @@ -0,0 +1,26 @@ +//@module: amd +//@jsx: preserve +//@target: ES5 + +//@Filename: react.d.ts +declare module 'react' { + var x: any; + export = x; +} + +declare module ReactRouter { + var Route: any; + interface Thing { } +} +declare module 'react-router' { + export = ReactRouter; +} + +//@Filename: test.tsx +// Should emit 'react-router' in the AMD dependency list +import React = require('react'); +import ReactRouter = require('react-router'); + +import Route = ReactRouter.Route; + +var routes = ; diff --git a/tests/cases/conformance/jsx/tsxReactEmit5.tsx b/tests/cases/conformance/jsx/tsxReactEmit5.tsx new file mode 100644 index 00000000000..c961a23ecfc --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit5.tsx @@ -0,0 +1,20 @@ +//@jsx: react +//@module: commonjs + +//@filename: file.tsx +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +//@filename: test.d.ts +export var React; + +//@filename: react-consumer.tsx +import {React} from "./test"; +// Should emit test_1.React.createElement +// and React.__spread +var foo; +var spread1 =
; diff --git a/tests/cases/conformance/jsx/tsxReactEmit6.tsx b/tests/cases/conformance/jsx/tsxReactEmit6.tsx new file mode 100644 index 00000000000..2782f90e503 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmit6.tsx @@ -0,0 +1,22 @@ +//@jsx: react +//@module: commonjs + +//@filename: file.tsx +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} + +//@filename: react-consumer.tsx +namespace M { + export var React: any; +} + +namespace M { + // Should emit M.React.createElement + // and M.React.__spread + var foo; + var spread1 =
; +} diff --git a/tests/cases/conformance/jsx/tsxReactEmitEntities.tsx b/tests/cases/conformance/jsx/tsxReactEmitEntities.tsx new file mode 100644 index 00000000000..4b7dc5780f8 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmitEntities.tsx @@ -0,0 +1,11 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +
Dot goes here: · ¬AnEntity;
; diff --git a/tests/cases/conformance/jsx/tsxReactEmitWhitespace2.tsx b/tests/cases/conformance/jsx/tsxReactEmitWhitespace2.tsx new file mode 100644 index 00000000000..964064979ec --- /dev/null +++ b/tests/cases/conformance/jsx/tsxReactEmitWhitespace2.tsx @@ -0,0 +1,17 @@ +//@filename: file.tsx +//@jsx: react +declare module JSX { + interface Element { } + interface IntrinsicElements { + [s: string]: any; + } +} +declare var React: any; + +// Emit ' word' in the last string +
word code word
; +// Same here +
code word
; +// And here +
word
; + diff --git a/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts b/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts new file mode 100644 index 00000000000..7ceb5bd34bc --- /dev/null +++ b/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration01.ts @@ -0,0 +1,47 @@ +// @noImplicitAny: true + +interface A { + numProp: number; +} + +interface B { + strProp: string; +} + +interface Foo { + method1(arg: A): void; + method2(arg: B): void; +} + +function getFoo1(): Foo { + return class { + static method1(arg) { + arg.numProp = 10; + } + static method2(arg) { + arg.strProp = "hello"; + } + } +} + +function getFoo2(): Foo { + return class { + static method1 = (arg) => { + arg.numProp = 10; + } + static method2 = (arg) => { + arg.strProp = "hello"; + } + } +} + +function getFoo3(): Foo { + return class { + static method1 = function (arg) { + arg.numProp = 10; + } + static method2 = function (arg) { + arg.strProp = "hello"; + } + } +} \ No newline at end of file diff --git a/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts b/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts new file mode 100644 index 00000000000..2f1f6f079c8 --- /dev/null +++ b/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedClassExpressionMethodDeclaration02.ts @@ -0,0 +1,51 @@ +// @noImplicitAny: true + +interface A { + numProp: number; +} + +interface B { + strProp: string; +} + +interface Foo { + new (): Bar; +} + +interface Bar { + method1(arg: A): void; + method2(arg: B): void; +} + +function getFoo1(): Foo { + return class { + method1(arg) { + arg.numProp = 10; + } + method2(arg) { + arg.strProp = "hello"; + } + } +} + +function getFoo2(): Foo { + return class { + method1 = (arg) => { + arg.numProp = 10; + } + method2 = (arg) => { + arg.strProp = "hello"; + } + } +} + +function getFoo3(): Foo { + return class { + method1 = function (arg) { + arg.numProp = 10; + } + method2 = function (arg) { + arg.strProp = "hello"; + } + } +} \ No newline at end of file diff --git a/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedObjectLiteralMethodDeclaration01.ts b/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedObjectLiteralMethodDeclaration01.ts new file mode 100644 index 00000000000..ed8912317fe --- /dev/null +++ b/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedObjectLiteralMethodDeclaration01.ts @@ -0,0 +1,47 @@ +// @noImplicitAny: true + +interface A { + numProp: number; +} + +interface B { + strProp: string; +} + +interface Foo { + method1(arg: A): void; + method2(arg: B): void; +} + +function getFoo1(): Foo { + return { + method1(arg) { + arg.numProp = 10; + }, + method2(arg) { + arg.strProp = "hello"; + } + } +} + +function getFoo2(): Foo { + return { + method1: (arg) => { + arg.numProp = 10; + }, + method2: (arg) => { + arg.strProp = "hello"; + } + } +} + +function getFoo3(): Foo { + return { + method1: function (arg) { + arg.numProp = 10; + }, + method2: function (arg) { + arg.strProp = "hello"; + } + } +} \ No newline at end of file diff --git a/tests/cases/conformance/types/thisType/contextualThisType.ts b/tests/cases/conformance/types/thisType/contextualThisType.ts new file mode 100644 index 00000000000..fdda5494b5e --- /dev/null +++ b/tests/cases/conformance/types/thisType/contextualThisType.ts @@ -0,0 +1,14 @@ +interface X { + a: (p: this) => this; +} + +interface Y extends X { +} + +var x: Y = { + a(p) { + return p; + } +} + +var y = x.a(x); diff --git a/tests/cases/conformance/types/thisType/declarationFiles.ts b/tests/cases/conformance/types/thisType/declarationFiles.ts new file mode 100644 index 00000000000..462e497a90e --- /dev/null +++ b/tests/cases/conformance/types/thisType/declarationFiles.ts @@ -0,0 +1,48 @@ +// @declaration: true + +class C1 { + x: this; + f(x: this): this { return undefined; } + constructor(x: this) { } +} + +class C2 { + [x: string]: this; +} + +interface Foo { + x: T; + y: this; +} + +class C3 { + a: this[]; + b: [this, this]; + c: this | Date; + d: this & Date; + e: (((this))); + f: (x: this) => this; + g: new (x: this) => this; + h: Foo; + i: Foo this)>; + j: (x: any) => x is this; +} + +class C4 { + x1 = { a: this }; + x2 = [this]; + x3 = [{ a: this }]; + x4 = () => this; + f1() { + return { a: this }; + } + f2() { + return [this]; + } + f3() { + return [{ a: this }]; + } + f4() { + return () => this; + } +} diff --git a/tests/cases/conformance/types/thisType/fluentClasses.ts b/tests/cases/conformance/types/thisType/fluentClasses.ts new file mode 100644 index 00000000000..c9e791cb6f1 --- /dev/null +++ b/tests/cases/conformance/types/thisType/fluentClasses.ts @@ -0,0 +1,17 @@ +class A { + foo() { + return this; + } +} +class B extends A { + bar() { + return this; + } +} +class C extends B { + baz() { + return this; + } +} +var c: C; +var z = c.foo().bar().baz(); // Fluent pattern diff --git a/tests/cases/conformance/types/thisType/fluentInterfaces.ts b/tests/cases/conformance/types/thisType/fluentInterfaces.ts new file mode 100644 index 00000000000..d5fabd56bf9 --- /dev/null +++ b/tests/cases/conformance/types/thisType/fluentInterfaces.ts @@ -0,0 +1,11 @@ +interface A { + foo(): this; +} +interface B extends A { + bar(): this; +} +interface C extends B { + baz(): this; +} +var c: C; +var z = c.foo().bar().baz(); // Fluent pattern diff --git a/tests/cases/conformance/types/thisType/thisTypeErrors.ts b/tests/cases/conformance/types/thisType/thisTypeErrors.ts new file mode 100644 index 00000000000..a7e4a46493d --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeErrors.ts @@ -0,0 +1,55 @@ +var x1: this; +var x2: { a: this }; +var x3: this[]; + +function f1(x: this): this { + var y: this; + return this; +} + +interface I1 { + a: { x: this }; + b: { (): this }; + c: { new (): this }; + d: { [x: string]: this }; + e: { f(x: this): this }; +} + +class C1 { + a: { x: this }; + b: { (): this }; + c: { new (): this }; + d: { [x: string]: this }; + e: { f(x: this): this }; +} + +class C2 { + static x: this; + static y = undefined; + static foo(x: this): this { + return undefined; + } +} + +namespace N1 { + export var x: this; + export var y = this; +} + +class C3 { + x1 = { + g(x: this): this { + return undefined; + } + } + f() { + function g(x: this): this { + return undefined; + } + let x2 = { + h(x: this): this { + return undefined; + } + } + } +} diff --git a/tests/cases/conformance/types/thisType/thisTypeInClasses.ts b/tests/cases/conformance/types/thisType/thisTypeInClasses.ts new file mode 100644 index 00000000000..17dc13cf558 --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeInClasses.ts @@ -0,0 +1,50 @@ +class C1 { + x: this; + f(x: this): this { return undefined; } + constructor(x: this) { } +} + +class C2 { + [x: string]: this; +} + +interface Foo { + x: T; + y: this; +} + +class C3 { + a: this[]; + b: [this, this]; + c: this | Date; + d: this & Date; + e: (((this))); + f: (x: this) => this; + g: new (x: this) => this; + h: Foo; + i: Foo this)>; + j: (x: any) => x is this; +} + +declare class C4 { + x: this; + f(x: this): this; +} + +class C5 { + foo() { + let f1 = (x: this): this => this; + let f2 = (x: this) => this; + let f3 = (x: this) => (y: this) => this; + let f4 = (x: this) => { + let g = (y: this) => { + return () => this; + } + return g(this); + } + } + bar() { + let x1 = undefined; + let x2 = undefined as this; + } +} diff --git a/tests/cases/conformance/types/thisType/thisTypeInInterfaces.ts b/tests/cases/conformance/types/thisType/thisTypeInInterfaces.ts new file mode 100644 index 00000000000..c1f48ad8f15 --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeInInterfaces.ts @@ -0,0 +1,28 @@ +interface I1 { + x: this; + f(x: this): this; +} + +interface I2 { + (x: this): this; + new (x: this): this; + [x: string]: this; +} + +interface Foo { + x: T; + y: this; +} + +interface I3 { + a: this[]; + b: [this, this]; + c: this | Date; + d: this & Date; + e: (((this))); + f: (x: this) => this; + g: new (x: this) => this; + h: Foo; + i: Foo this)>; + j: (x: any) => x is this; +} diff --git a/tests/cases/conformance/types/thisType/thisTypeInTuples.ts b/tests/cases/conformance/types/thisType/thisTypeInTuples.ts new file mode 100644 index 00000000000..f7f4084a1a9 --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeInTuples.ts @@ -0,0 +1,8 @@ +interface Array { + slice(): this; +} + +let t: [number, string] = [42, "hello"]; +let a = t.slice(); +let b = t.slice(1); +let c = t.slice(0, 1); diff --git a/tests/cases/conformance/types/thisType/typeRelationships.ts b/tests/cases/conformance/types/thisType/typeRelationships.ts new file mode 100644 index 00000000000..c3ca6f3ef70 --- /dev/null +++ b/tests/cases/conformance/types/thisType/typeRelationships.ts @@ -0,0 +1,39 @@ +class C { + self = this; + c = new C(); + foo() { + return this; + } + f1() { + this.c = this.self; + this.self = this.c; // Error + } + f2() { + var a: C[]; + var a = [this, this.c]; // C[] since this is subtype of C + var b: this[]; + var b = [this, this.self, null, undefined]; + } + f3(b: boolean) { + return b ? this.c : this.self; // Should be C + } +} + +class D extends C { + self1 = this; + self2 = this.self; + self3 = this.foo(); + d = new D(); + bar() { + this.self = this.self1; + this.self = this.self2; + this.self = this.self3; + this.self1 = this.self; + this.self2 = this.self; + this.self3 = this.self; + this.d = this.self; + this.d = this.c; // Error + this.self = this.d; // Error + this.c = this.d; + } +} diff --git a/tests/cases/fourslash/asOperatorCompletion.ts b/tests/cases/fourslash/asOperatorCompletion.ts new file mode 100644 index 00000000000..2eaaae7e75d --- /dev/null +++ b/tests/cases/fourslash/asOperatorCompletion.ts @@ -0,0 +1,8 @@ +/// + +//// type T = number; +//// var x; +//// var y = x as /**/ + +goTo.marker(); +verify.completionListContains('T'); diff --git a/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts b/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts index d7ccbe73f33..5a8f661789c 100644 --- a/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts +++ b/tests/cases/fourslash/bestCommonTypeObjectLiterals1.ts @@ -24,7 +24,7 @@ goTo.marker('1'); verify.quickInfoIs('var c: {\n name: string;\n age: number;\n}[]'); goTo.marker('2'); -verify.quickInfoIs('var c1: ({\n name: string;\n age: number;\n} | {\n name: string;\n age: number;\n dob: Date;\n})[]'); +verify.quickInfoIs('var c1: {\n name: string;\n age: number;\n}[]'); goTo.marker('3'); verify.quickInfoIs('var c2: ({\n\ diff --git a/tests/cases/fourslash/commentsOverloads.ts b/tests/cases/fourslash/commentsOverloads.ts index 878ea8ea004..d32c35b0508 100644 --- a/tests/cases/fourslash/commentsOverloads.ts +++ b/tests/cases/fourslash/commentsOverloads.ts @@ -482,8 +482,8 @@ verify.quickInfoIs("(method) c.prop1(a: number): number (+1 overload)", ""); goTo.marker('46'); verify.currentSignatureHelpDocCommentIs(""); verify.currentParameterHelpArgumentDocCommentIs(""); -goTo.marker('46q'); -verify.quickInfoIs("(method) c.prop1(b: string): number (+1 overload)", ""); +//goTo.marker('46q'); +//verify.quickInfoIs("(method) c.prop1(b: string): number (+1 overload)", ""); goTo.marker('47'); verify.currentSignatureHelpDocCommentIs("prop2 1"); @@ -494,8 +494,8 @@ verify.quickInfoIs("(method) c.prop2(a: number): number (+1 overload)", "prop2 1 goTo.marker('48'); verify.currentSignatureHelpDocCommentIs(""); verify.currentParameterHelpArgumentDocCommentIs(""); -goTo.marker('48q'); -verify.quickInfoIs("(method) c.prop2(b: string): number (+1 overload)", ""); +//goTo.marker('48q'); +//verify.quickInfoIs("(method) c.prop2(b: string): number (+1 overload)", ""); goTo.marker('49'); verify.currentSignatureHelpDocCommentIs(""); @@ -506,8 +506,8 @@ verify.quickInfoIs("(method) c.prop3(a: number): number (+1 overload)", ""); goTo.marker('50'); verify.currentSignatureHelpDocCommentIs("prop3 2"); verify.currentParameterHelpArgumentDocCommentIs(""); -goTo.marker('50q'); -verify.quickInfoIs("(method) c.prop3(b: string): number (+1 overload)", "prop3 2"); +//goTo.marker('50q'); +//verify.quickInfoIs("(method) c.prop3(b: string): number (+1 overload)", "prop3 2"); goTo.marker('51'); verify.currentSignatureHelpDocCommentIs("prop4 1"); @@ -518,8 +518,8 @@ verify.quickInfoIs("(method) c.prop4(a: number): number (+1 overload)", "prop4 1 goTo.marker('52'); verify.currentSignatureHelpDocCommentIs("prop4 2"); verify.currentParameterHelpArgumentDocCommentIs(""); -goTo.marker('52q'); -verify.quickInfoIs("(method) c.prop4(b: string): number (+1 overload)", "prop4 2"); +//goTo.marker('52q'); +//verify.quickInfoIs("(method) c.prop4(b: string): number (+1 overload)", "prop4 2"); goTo.marker('53'); verify.currentSignatureHelpDocCommentIs("prop5 1"); @@ -530,8 +530,8 @@ verify.quickInfoIs("(method) c.prop5(a: number): number (+1 overload)", "prop5 1 goTo.marker('54'); verify.currentSignatureHelpDocCommentIs("prop5 2"); verify.currentParameterHelpArgumentDocCommentIs(""); -goTo.marker('54q'); -verify.quickInfoIs("(method) c.prop5(b: string): number (+1 overload)", "prop5 2"); +//goTo.marker('54q'); +//verify.quickInfoIs("(method) c.prop5(b: string): number (+1 overload)", "prop5 2"); goTo.marker('55'); verify.currentSignatureHelpDocCommentIs(""); diff --git a/tests/cases/fourslash/completionEntryForUnionProperty2.ts b/tests/cases/fourslash/completionEntryForUnionProperty2.ts index aa5bc40b5e3..c2d7bc406a5 100644 --- a/tests/cases/fourslash/completionEntryForUnionProperty2.ts +++ b/tests/cases/fourslash/completionEntryForUnionProperty2.ts @@ -1,12 +1,12 @@ /// ////interface One { -//// commonProperty: number; +//// commonProperty: string; //// commonFunction(): number; ////} //// ////interface Two { -//// commonProperty: string +//// commonProperty: number; //// commonFunction(): number; ////} //// @@ -16,5 +16,5 @@ goTo.marker(); verify.memberListContains("toString", "(method) toString(): string"); -verify.memberListContains("valueOf", "(method) valueOf(): number | string"); +verify.memberListContains("valueOf", "(method) valueOf(): string | number"); verify.memberListCount(2); \ No newline at end of file diff --git a/tests/cases/fourslash/completionInJsDoc.ts b/tests/cases/fourslash/completionInJsDoc.ts new file mode 100644 index 00000000000..5424c8e79fa --- /dev/null +++ b/tests/cases/fourslash/completionInJsDoc.ts @@ -0,0 +1,62 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +/////** @/*1*/ */ +////var v1; +//// +/////** @p/*2*/ */ +////var v2; +//// +/////** @param /*3*/ */ +////var v3; +//// +/////** @param { n/*4*/ } bar */ +////var v4; +//// +/////** @type { n/*5*/ } */ +////var v5; +//// +////// @/*6*/ +////var v6; +//// +////// @pa/*7*/ +////var v7; +//// +/////** @param { n/*8*/ } */ +////var v8; +//// +/////** @return { n/*9*/ } */ +////var v9; + +goTo.marker('1'); +verify.completionListContains("constructor"); +verify.completionListContains("param"); +verify.completionListContains("type"); + +goTo.marker('2'); +verify.completionListContains("constructor"); +verify.completionListContains("param"); +verify.completionListContains("type"); + +goTo.marker('3'); +verify.completionListIsEmpty(); + +goTo.marker('4'); +verify.completionListContains('number'); + +goTo.marker('5'); +verify.completionListContains('number'); + +goTo.marker('6'); +verify.completionListIsEmpty(); + +goTo.marker('7'); +verify.completionListIsEmpty(); + +goTo.marker('8'); +verify.completionListContains('number'); + +goTo.marker('9'); +verify.completionListContains('number'); + diff --git a/tests/cases/fourslash/completionInsideFunctionContainsArguments.ts b/tests/cases/fourslash/completionInsideFunctionContainsArguments.ts new file mode 100644 index 00000000000..903253b1a09 --- /dev/null +++ b/tests/cases/fourslash/completionInsideFunctionContainsArguments.ts @@ -0,0 +1,22 @@ +/// + +////function testArguments() {/*1*/} +/////*2*/ +////function testNestedArguments() { +//// function nestedfunction(){/*3*/} +////} +////function f() { +//// let g = () => /*4*/ +////} +////let g = () => /*5*/ + +goTo.marker('1'); +verify.completionListContains("arguments"); +goTo.marker('2'); +verify.not.completionListContains("arguments"); +goTo.marker('3'); +verify.completionListContains("arguments"); +goTo.marker('4'); +verify.completionListContains("arguments"); +goTo.marker('5'); +verify.not.completionListContains("arguments"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInTypeParameterOfClassExpression1.ts b/tests/cases/fourslash/completionListInTypeParameterOfClassExpression1.ts new file mode 100644 index 00000000000..f8afcdc418c --- /dev/null +++ b/tests/cases/fourslash/completionListInTypeParameterOfClassExpression1.ts @@ -0,0 +1,18 @@ +/// + +////var C0 = class D {} +////var C3 = class D{} +////var C5 = class D{} + +goTo.marker("0"); +verify.completionListIsEmpty(); +goTo.marker("1"); +verify.completionListIsEmpty(); +goTo.marker("2"); +verify.completionListIsEmpty(); +goTo.marker("3"); +verify.completionListIsEmpty(); +goTo.marker("4"); +verify.not.completionListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias1.ts b/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias1.ts new file mode 100644 index 00000000000..e6017eedbfc --- /dev/null +++ b/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias1.ts @@ -0,0 +1,17 @@ +/// + +////type List1 = T[]; +////type List4 = /*2*/T[]; +////type List3 = /*3*/; + +goTo.marker("0"); +verify.completionListIsEmpty(); +goTo.marker("1"); +verify.not.completionListIsEmpty(); +goTo.marker("2"); +verify.completionListContains("T"); +goTo.marker("3"); +verify.not.completionListIsEmpty(); +verify.not.completionListContains("T"); +verify.completionListContains("T1"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias2.ts b/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias2.ts new file mode 100644 index 00000000000..80a910da798 --- /dev/null +++ b/tests/cases/fourslash/completionListInTypeParameterOfTypeAlias2.ts @@ -0,0 +1,19 @@ +/// + +////type Map1 = []; +////type Map1 = /*2*/[]; +////type Map1 = + +// @noImplicitAny: true + +////interface A { +//// numProp: number; +////} +//// +////interface B { +//// strProp: string; +////} +//// +////interface Foo { +//// method1(arg: A): void; +//// method2(arg: B): void; +////} +//// +////function getFoo1(): Foo { +//// return { +//// method1(/*param1*/arg) { +//// arg.numProp = 10; +//// }, +//// method2(/*param2*/arg) { +//// arg.strProp = "hello"; +//// } +//// } +////} + +goTo.marker("param1"); +verify.quickInfoIs("(parameter) arg: A") +goTo.marker("param2"); +verify.quickInfoIs("(parameter) arg: B") diff --git a/tests/cases/fourslash/docCommentTemplateClassDecl01.ts b/tests/cases/fourslash/docCommentTemplateClassDecl01.ts new file mode 100644 index 00000000000..958a8c60fa4 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateClassDecl01.ts @@ -0,0 +1,36 @@ +/// + +const CRLF = "\r\n"; +/** + * @returns the given value with '\n' normalized to '\r\n' and with no leading newline + */ +function useCRLFAndStripLeadingNewline(str: string): string { + str = str.replace(/\r?\n/g, CRLF); + if (str.indexOf(CRLF) === 0) { + str = str.slice(CRLF.length); + } + return str; +} + +function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, template: string): void { + goTo.marker(markerName); + const normalized = useCRLFAndStripLeadingNewline(template); + verify.DocCommentTemplate(normalized, newTextOffset); +} + +/////*decl*/class C { +//// private p; +//// constructor(a, b, c, d); +//// constructor(public a, private b, protected c, d, e?) { +//// } +//// +//// foo(); +//// foo(a?, b?, ...args) { +//// } +////} + +confirmNormalizedJsDoc("decl", /*newTextOffset*/ 8, ` +/** + * + */ +`); diff --git a/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts b/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts new file mode 100644 index 00000000000..da407b632ef --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts @@ -0,0 +1,79 @@ +/// + +const CRLF = "\r\n"; +/** + * @returns the given value with '\n' normalized to '\r\n' and with no leading newline + */ +function useCRLFAndStripLeadingNewline(str: string): string { + str = str.replace(/\r?\n/g, CRLF); + if (str.indexOf(CRLF) === 0) { + str = str.slice(CRLF.length); + } + return str; +} + +function confirmNormalizedJsDoc(markerName: string, indentation: number, template: string): void { + goTo.marker(markerName); + const normalized = useCRLFAndStripLeadingNewline(template); + verify.DocCommentTemplate(normalized, indentation); +} + +const enum Indentation { + Standard = 8, + Indented = 12, +} + + +////class C { +/////*0*/ /*1*/ +//// foo(); +//// /*2*/foo(a); +//// /*3*/foo(a, b); +//// /*4*/ foo(a, {x: string}, [c]); +//// /*5*/foo(a?, b?, ...args) { +//// } +////} + +confirmNormalizedJsDoc("0", Indentation.Standard, ` +/** + * + */`); + + +confirmNormalizedJsDoc("1", Indentation.Indented, + `/** + * + */`); + + +confirmNormalizedJsDoc("2", Indentation.Indented, + `/** + * + * @param a + */ + `); + +confirmNormalizedJsDoc("3", Indentation.Indented, + `/** + * + * @param a + * @param b + */ + `); + +confirmNormalizedJsDoc("4", Indentation.Indented, + `/** + * + * @param a + * @param param1 + * @param param2 + */`); + +confirmNormalizedJsDoc("5", Indentation.Indented, + `/** + * + * @param a + * @param b + * @param args + */ + `); diff --git a/tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts b/tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts new file mode 100644 index 00000000000..99392cf3855 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts @@ -0,0 +1,46 @@ +/// + +const CRLF = "\r\n"; +/** + * @returns the given value with '\n' normalized to '\r\n' and with no leading newline + */ +function useCRLFAndStripLeadingNewline(str: string): string { + str = str.replace(/\r?\n/g, CRLF); + if (str.indexOf(CRLF) === 0) { + str = str.slice(CRLF.length); + } + return str; +} + +function confirmNormalizedJsDoc(markerName: string, indentation: number, template: string): void { + goTo.marker(markerName); + const normalized = useCRLFAndStripLeadingNewline(template); + verify.DocCommentTemplate(normalized, indentation); +} + +const enum Indentation { + Indented = 12, +} + + +////class C { +//// /*0*/ +//// [Symbol.iterator]() { +//// return undefined; +//// } +//// /*1*/ +//// [1 + 2 + 3 + Math.rand()](x: number, y: string, z = true) { } +////} + +confirmNormalizedJsDoc("0", Indentation.Indented, + `/** + * + */`); + +confirmNormalizedJsDoc("1", Indentation.Indented, + `/** + * + * @param x + * @param y + * @param z + */`); \ No newline at end of file diff --git a/tests/cases/fourslash/docCommentTemplateConstructor01.ts b/tests/cases/fourslash/docCommentTemplateConstructor01.ts new file mode 100644 index 00000000000..b26ece7a5e6 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateConstructor01.ts @@ -0,0 +1,52 @@ +/// + +const CRLF = "\r\n"; +/** + * @returns the given value with '\n' normalized to '\r\n' and with no leading newline + */ +function useCRLFAndStripLeadingNewline(str: string): string { + str = str.replace(/\r?\n/g, CRLF); + if (str.indexOf(CRLF) === 0) { + str = str.slice(CRLF.length); + } + return str; +} + +function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, template: string): void { + goTo.marker(markerName); + const normalized = useCRLFAndStripLeadingNewline(template); + verify.DocCommentTemplate(normalized, newTextOffset); +} + +////class C { +//// private p; +//// /*0*/ +//// constructor(a, b, c, d); +//// /*1*/ +//// constructor(public a, private b, protected c, d, e?) { +//// } +//// +//// foo(); +//// foo(a?, b?, ...args) { +//// } +////} + +const newTextOffset = 12; +confirmNormalizedJsDoc("0", /*newTextOffset*/ newTextOffset, + `/** + * + * @param a + * @param b + * @param c + * @param d + */`); + +confirmNormalizedJsDoc("1", /*newTextOffset*/ newTextOffset, + `/** + * + * @param a + * @param b + * @param c + * @param d + * @param e + */`); diff --git a/tests/cases/fourslash/docCommentTemplateNamespacesAndModules01.ts b/tests/cases/fourslash/docCommentTemplateNamespacesAndModules01.ts new file mode 100644 index 00000000000..4d9fb987be5 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateNamespacesAndModules01.ts @@ -0,0 +1,46 @@ +/// + +const CRLF = "\r\n"; +/** + * @returns the given value with '\n' normalized to '\r\n' and with no leading newline + */ +function useCRLFAndStripLeadingNewline(str: string): string { + str = str.replace(/\r?\n/g, CRLF); + if (str.indexOf(CRLF) === 0) { + str = str.slice(CRLF.length); + } + return str; +} + +function confirmNormalizedJsDoc(markerName: string, charOffset: number, template: string): void { + goTo.marker(markerName); + const normalized = useCRLFAndStripLeadingNewline(template); + verify.DocCommentTemplate(normalized, charOffset); +} + +/////*namespaceN*/ +////namespace n { +////} +//// +/////*namespaceM*/ +////module m { +////} +//// +/////*ambientModule*/ +////module "ambientModule" { +////} + +confirmNormalizedJsDoc("namespaceN", /*indentation*/ 8, ` +/** + * + */`); + +confirmNormalizedJsDoc("namespaceM", /*indentation*/ 8, ` +/** + * + */`); + +confirmNormalizedJsDoc("namespaceM", /*indentation*/ 8, ` +/** + * + */`); diff --git a/tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts b/tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts new file mode 100644 index 00000000000..e59b16d6163 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts @@ -0,0 +1,36 @@ +/// + +const CRLF = "\r\n"; +/** + * @returns the given value with '\n' normalized to '\r\n' and with no leading newline + */ +function useCRLFAndStripLeadingNewline(str: string): string { + str = str.replace(/\r?\n/g, CRLF); + if (str.indexOf(CRLF) === 0) { + str = str.slice(CRLF.length); + } + return str; +} + +function confirmNormalizedJsDoc(markerName: string, charOffset: number, template: string): void { + goTo.marker(markerName); + const normalized = useCRLFAndStripLeadingNewline(template); + verify.DocCommentTemplate(normalized, charOffset); +} + +/////*top*/ +////namespace n1. +//// /*n2*/ n2. +//// /*n3*/ n3 { +////} + +confirmNormalizedJsDoc("top", /*indentation*/ 8, ` +/** + * + */`); + +goTo.marker("n2"); +verify.noDocCommentTemplate(); + +goTo.marker("n3"); +verify.noDocCommentTemplate(); \ No newline at end of file diff --git a/tests/cases/fourslash/docCommentTemplateObjectLiteralMethods01.ts b/tests/cases/fourslash/docCommentTemplateObjectLiteralMethods01.ts new file mode 100644 index 00000000000..4af1b60c698 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateObjectLiteralMethods01.ts @@ -0,0 +1,46 @@ +/// + +const CRLF = "\r\n"; +/** + * @returns the given value with '\n' normalized to '\r\n' and with no leading newline + */ +function useCRLFAndStripLeadingNewline(str: string): string { + str = str.replace(/\r?\n/g, CRLF); + if (str.indexOf(CRLF) === 0) { + str = str.slice(CRLF.length); + } + return str; +} + +function confirmNormalizedJsDoc(markerName: string, indentation: number, template: string): void { + goTo.marker(markerName); + const normalized = useCRLFAndStripLeadingNewline(template); + verify.DocCommentTemplate(normalized, indentation); +} + +const enum Indentation { + Indented = 12, +} + + +////var x = { +//// /*0*/ +//// foo() { +//// return undefined; +//// } +//// /*1*/ +//// [1 + 2 + 3 + Math.rand()](x: number, y: string, z = true) { } +////} + +confirmNormalizedJsDoc("0", Indentation.Indented, + `/** + * + */`); + +confirmNormalizedJsDoc("1", Indentation.Indented, + `/** + * + * @param x + * @param y + * @param z + */`); \ No newline at end of file diff --git a/tests/cases/fourslash/docCommentTemplateVariableStatements01.ts b/tests/cases/fourslash/docCommentTemplateVariableStatements01.ts new file mode 100644 index 00000000000..b901919fa1f --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateVariableStatements01.ts @@ -0,0 +1,70 @@ +/// + +const CRLF = "\r\n"; +/** + * @returns the given value with '\n' normalized to '\r\n' and with no leading newline + */ +function useCRLFAndStripLeadingNewline(str: string): string { + str = str.replace(/\r?\n/g, CRLF); + if (str.indexOf(CRLF) === 0) { + str = str.slice(CRLF.length); + } + return str; +} + +function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, template: string): void { + goTo.marker(markerName); + const normalized = useCRLFAndStripLeadingNewline(template); + verify.DocCommentTemplate(normalized, newTextOffset); +} + +/////*a*/ +////var a = 10; +//// +/////*b*/ +////let b = ""; +//// +/////*c*/ +////const c = 30; +//// +/////*d*/ +////let d = { +//// foo: 10, +//// bar: "20" +////}; +//// +/////*e*/ +////let e = function e(x, y, z) { +//// return +(x + y + z); +////}; +//// +/////*f*/ +////let f = class F { +//// constructor(a, b, c) { +//// this.a = a; +//// this.b = b || (this.c = c); +//// } +////} + +for (const varName of "abcd".split("")) { + confirmNormalizedJsDoc(varName, /*newTextOffset*/ 8, ` +/** + * + */`); +} + +confirmNormalizedJsDoc("e", /*newTextOffset*/ 8, ` +/** + * + * @param x + * @param y + * @param z + */`); + +confirmNormalizedJsDoc("f", /*newTextOffset*/ 8, ` +/** + * + * @param a + * @param b + * @param c + */`); \ No newline at end of file diff --git a/tests/cases/fourslash/docCommentTemplateVariableStatements02.ts b/tests/cases/fourslash/docCommentTemplateVariableStatements02.ts new file mode 100644 index 00000000000..9339e703570 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateVariableStatements02.ts @@ -0,0 +1,54 @@ +/// + +const CRLF = "\r\n"; +/** + * @returns the given value with '\n' normalized to '\r\n' and with no leading newline + */ +function useCRLFAndStripLeadingNewline(str: string): string { + str = str.replace(/\r?\n/g, CRLF); + if (str.indexOf(CRLF) === 0) { + str = str.slice(CRLF.length); + } + return str; +} + +function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, template: string): void { + goTo.marker(markerName); + const normalized = useCRLFAndStripLeadingNewline(template); + verify.DocCommentTemplate(normalized, newTextOffset); +} + +/////*a*/ +////var a1 = 10, a2 = 20; +//// +/////*b*/ +////let b1 = "", b2 = true; +//// +/////*c*/ +////const c1 = 30, c2 = 40; +//// +/////*d*/ +////let d1 = function d(x, y, z) { +//// return +(x + y + z); +////}, d2 = 50; +//// +/////*e*/ +////let e1 = class E { +//// constructor(a, b, c) { +//// this.a = a; +//// this.b = b || (this.c = c); +//// } +////}, e2 = () => 100; +//// +/////*f*/ +////let f1 = { +//// foo: 10, +//// bar: "20" +////}, f2 = null; + +for (const varName of "abcdef".split("")) { + confirmNormalizedJsDoc(varName, /*newTextOffset*/ 8, ` +/** + * + */`); +} diff --git a/tests/cases/fourslash/docCommentTemplateVariableStatements03.ts b/tests/cases/fourslash/docCommentTemplateVariableStatements03.ts new file mode 100644 index 00000000000..e473cb798b7 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateVariableStatements03.ts @@ -0,0 +1,90 @@ +/// + +const CRLF = "\r\n"; +/** + * @returns the given value with '\n' normalized to '\r\n' and with no leading newline + */ +function useCRLFAndStripLeadingNewline(str: string): string { + str = str.replace(/\r?\n/g, CRLF); + if (str.indexOf(CRLF) === 0) { + str = str.slice(CRLF.length); + } + return str; +} + +function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, template: string): void { + goTo.marker(markerName); + const normalized = useCRLFAndStripLeadingNewline(template); + verify.DocCommentTemplate(normalized, newTextOffset); +} + +/////*a*/ +////var a = x => x +//// +/////*b*/ +////let b = (x,y,z) => x + y + z; +//// +/////*c*/ +////const c = ((x => +x)) +//// +/////*d*/ +////let d = (function () { }) +//// +/////*e*/ +////let e = function e([a,b,c]) { +//// return "hello" +////}; +//// +/////*f*/ +////let f = class { +////} +//// +/////*g*/ +////const g = ((class G { +//// constructor(private x); +//// constructor(x,y,z); +//// constructor(x,y,z, ...okayThatsEnough) { +//// } +////})) + +confirmNormalizedJsDoc("a", /*newTextOffset*/ 8, ` +/** + * + * @param x + */`); + +confirmNormalizedJsDoc("b", /*newTextOffset*/ 8, ` +/** + * + * @param x + * @param y + * @param z + */`); + +confirmNormalizedJsDoc("c", /*newTextOffset*/ 8, ` +/** + * + * @param x + */`); + +confirmNormalizedJsDoc("d", /*newTextOffset*/ 8, ` +/** + * + */`); + +confirmNormalizedJsDoc("e", /*newTextOffset*/ 8, ` +/** + * + * @param param0 + */`); + +confirmNormalizedJsDoc("f", /*newTextOffset*/ 8, ` +/** + * + */`); + +confirmNormalizedJsDoc("g", /*newTextOffset*/ 8, ` +/** + * + * @param x + */`); \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsForVariableInExtendsClause01.ts b/tests/cases/fourslash/findAllRefsForVariableInExtendsClause01.ts new file mode 100644 index 00000000000..1ec144d7e82 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForVariableInExtendsClause01.ts @@ -0,0 +1,15 @@ +/// + + +////var [|Base|] = class { }; +////class C extends [|Base|] { } + +let ranges = test.ranges(); +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsForVariableInExtendsClause02.ts b/tests/cases/fourslash/findAllRefsForVariableInExtendsClause02.ts new file mode 100644 index 00000000000..0f06a3c4202 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForVariableInExtendsClause02.ts @@ -0,0 +1,17 @@ +/// + +////interface [|Base|] { } +////namespace n { +//// var Base = class { }; +//// interface I extends [|Base|] { } +////} + +let ranges = test.ranges(); +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsForVariableInImplementsClause01.ts b/tests/cases/fourslash/findAllRefsForVariableInImplementsClause01.ts new file mode 100644 index 00000000000..93f8cec8109 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForVariableInImplementsClause01.ts @@ -0,0 +1,10 @@ +/// + + +////var Base = class { }; +////class C extends Base implements [|Base|] { } + +let ranges = test.ranges(); +for (let range of ranges) { + verify.referencesCountIs(0); +} \ No newline at end of file diff --git a/tests/cases/fourslash/formatAsyncAwait.ts b/tests/cases/fourslash/formatAsyncAwait.ts new file mode 100644 index 00000000000..0530f868f91 --- /dev/null +++ b/tests/cases/fourslash/formatAsyncAwait.ts @@ -0,0 +1,19 @@ +/// + +////async function asyncFunction() {/*asyncKeyword*/ +//// await +/////*awaitExpressionIndent*/ +//// Promise.resolve("await");/*awaitExpressionAutoformat*/ +//// return await Promise.resolve("completed");/*awaitKeyword*/ +////} + +format.document(); + +goTo.marker("asyncKeyword"); +verify.currentLineContentIs("async function asyncFunction() {"); +goTo.marker("awaitExpressionIndent"); +verify.indentationIs(8); +goTo.marker("awaitExpressionAutoformat"); +verify.currentLineContentIs(' Promise.resolve("await");'); +goTo.marker("awaitKeyword"); +verify.currentLineContentIs(' return await Promise.resolve("completed");'); \ No newline at end of file diff --git a/tests/cases/fourslash/formatClassExpression.ts b/tests/cases/fourslash/formatClassExpression.ts new file mode 100644 index 00000000000..0a00203e77f --- /dev/null +++ b/tests/cases/fourslash/formatClassExpression.ts @@ -0,0 +1,23 @@ +/// + +////class Thing extends ( +//// class/*classOpenBrace*/ +//// { +/////*classIndent*/ +//// protected doThing() {/*methodAutoformat*/ +/////*methodIndent*/ +//// } +//// } +////) { +////} + +format.document(); + +goTo.marker("classOpenBrace"); +verify.currentLineContentIs(" class {"); +goTo.marker("classIndent"); +verify.indentationIs(8); +goTo.marker("methodAutoformat"); +verify.currentLineContentIs(" protected doThing() {"); +goTo.marker("methodIndent"); +verify.indentationIs(12); \ No newline at end of file diff --git a/tests/cases/fourslash/formatComments.ts b/tests/cases/fourslash/formatComments.ts new file mode 100644 index 00000000000..083ba6c078d --- /dev/null +++ b/tests/cases/fourslash/formatComments.ts @@ -0,0 +1,24 @@ +/// + +////_.chain() +////// wow/*callChain1*/ +//// .then() +////// waa/*callChain2*/ +//// .then(); +////wow( +//// 3, +////// uaa/*argument1*/ +//// 4 +////// wua/*argument2*/ +////); + +format.document(); + +goTo.marker("callChain1"); +verify.currentLineContentIs(" // wow"); +goTo.marker("callChain2"); +verify.currentLineContentIs(" // waa"); +goTo.marker("argument1"); +verify.currentLineContentIs(" // uaa"); +goTo.marker("argument2"); +verify.currentLineContentIs(" // wua"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatFunctionAndConstructorType.ts b/tests/cases/fourslash/formatFunctionAndConstructorType.ts new file mode 100644 index 00000000000..1b9655143f9 --- /dev/null +++ b/tests/cases/fourslash/formatFunctionAndConstructorType.ts @@ -0,0 +1,32 @@ +/// + +////function renderElement( +//// element: Element, +//// renderNode: +////(/*funcAutoformat*/ +//// node: Node/*funcParamAutoformat*/ +/////*funcIndent*/ +//// ) => void, +////newNode: +////new(/*constrAutoformat*/ +//// name: string/*constrParamAutoformat*/ +/////*constrIndent*/ +////) => Node +////): void { +////} + +format.document(); + +goTo.marker("funcAutoformat"); +verify.currentLineContentIs(" ("); +goTo.marker("funcParamAutoformat"); +verify.currentLineContentIs(" node: Node"); +goTo.marker("funcIndent"); +verify.indentationIs(12); + +goTo.marker("constrAutoformat"); +verify.currentLineContentIs(" new ("); +goTo.marker("constrParamAutoformat"); +verify.currentLineContentIs(" name: string"); +goTo.marker("constrIndent"); +verify.indentationIs(12); \ No newline at end of file diff --git a/tests/cases/fourslash/formatInTsxFiles.ts b/tests/cases/fourslash/formatInTsxFiles.ts new file mode 100644 index 00000000000..2585520305c --- /dev/null +++ b/tests/cases/fourslash/formatInTsxFiles.ts @@ -0,0 +1,8 @@ +/// + +//@Filename: file.tsx +////interface I { +//// next: I + +////function foo( +//// first: +//// number,/*first*/ +//// second: ( +//// string/*second*/ +//// ), +//// third: +//// ( +//// boolean/*third*/ +//// ) +////) { +////} + +format.document(); + +goTo.marker("first"); +verify.currentLineContentIs(" number,"); +goTo.marker("second"); +verify.currentLineContentIs(" string"); +goTo.marker("third"); +verify.currentLineContentIs(" boolean"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatSignatures.ts b/tests/cases/fourslash/formatSignatures.ts new file mode 100644 index 00000000000..f850ab48ef9 --- /dev/null +++ b/tests/cases/fourslash/formatSignatures.ts @@ -0,0 +1,31 @@ +/// + +////type Foo = { +//// ( +//// call: any/*callAutoformat*/ +/////*callIndent*/ +//// ): void; +//// new ( +//// constr: any/*constrAutoformat*/ +/////*constrIndent*/ +//// ): void; +//// method( +//// whatever: any/*methodAutoformat*/ +/////*methodIndent*/ +//// ): void; +////}; + +format.document(); + +goTo.marker("callAutoformat"); +verify.currentLineContentIs(" call: any"); +goTo.marker("callIndent"); +verify.indentationIs(8); +goTo.marker("constrAutoformat"); +verify.currentLineContentIs(" constr: any"); +goTo.marker("constrIndent"); +verify.indentationIs(8); +goTo.marker("methodAutoformat"); +verify.currentLineContentIs(" whatever: any"); +goTo.marker("methodIndent"); +verify.indentationIs(8); \ No newline at end of file diff --git a/tests/cases/fourslash/formatTemplateLiteral.ts b/tests/cases/fourslash/formatTemplateLiteral.ts index a1f5ef963da..68f2c8c9469 100644 --- a/tests/cases/fourslash/formatTemplateLiteral.ts +++ b/tests/cases/fourslash/formatTemplateLiteral.ts @@ -2,6 +2,16 @@ ////var x = `sadasdasdasdasfegsfd /////*1*/rasdesgeryt35t35y35 e4 ergt er 35t 3535 `; ////var y = `1${2}/*2*/3`; +//// +/////*formatStart*/ +////let z= `foo`;/*3*/ +////let w= `bar${3}`;/*4*/ +////String.raw +//// `template`;/*5*/ +////String.raw`foo`;/*6*/ +////String.raw `bar${3}`;/*7*/ +////`Write ${ JSON.stringify("") } and ${ (765) } and ${ 346 }`;/*spaceInside*/ +/////*formatEnd*/ goTo.marker("1"); @@ -10,4 +20,21 @@ edit.insert("\r\n"); // edit will trigger formatting - should succeeed goTo.marker("2"); edit.insert("\r\n"); verify.indentationIs(0); -verify.currentLineContentIs("3`;") \ No newline at end of file +verify.currentLineContentIs("3`;") + +format.selection("formatStart", "formatEnd"); + +goTo.marker("3"); +verify.currentLineContentIs("let z = `foo`;"); +goTo.marker("4"); +verify.currentLineContentIs("let w = `bar${3}`;"); + +goTo.marker("5"); +verify.currentLineContentIs(" `template`;"); +goTo.marker("6"); +verify.currentLineContentIs("String.raw `foo`;"); +goTo.marker("7"); +verify.currentLineContentIs("String.raw `bar${3}`;"); + +goTo.marker("spaceInside"); +verify.currentLineContentIs('`Write ${JSON.stringify("")} and ${(765)} and ${346}`;'); \ No newline at end of file diff --git a/tests/cases/fourslash/formatTypeAlias.ts b/tests/cases/fourslash/formatTypeAlias.ts new file mode 100644 index 00000000000..c97a868c1f1 --- /dev/null +++ b/tests/cases/fourslash/formatTypeAlias.ts @@ -0,0 +1,14 @@ +/// + +////type Alias = /*typeKeyword*/ +/////*indent*/ +////number;/*autoformat*/ + +format.document(); + +goTo.marker("typeKeyword"); +verify.currentLineContentIs("type Alias ="); +goTo.marker("indent"); +verify.indentationIs(4); +goTo.marker("autoformat"); +verify.currentLineContentIs(" number;"); diff --git a/tests/cases/fourslash/formatTypeOperation.ts b/tests/cases/fourslash/formatTypeOperation.ts new file mode 100644 index 00000000000..956508f7290 --- /dev/null +++ b/tests/cases/fourslash/formatTypeOperation.ts @@ -0,0 +1,26 @@ +/// + +////type Union = number | {}/*formatBarOperator*/ +/////*indent*/ +////|string/*autoformat*/ +////type Intersection = Foo & Bar;/*formatAmpersandOperator*/ +////type Complexed = +//// Foo& +//// Bar|/*unionTypeNoIndent*/ +//// Baz;/*intersectionTypeNoIndent*/ + +format.document(); + +goTo.marker("formatBarOperator"); +verify.currentLineContentIs("type Union = number | {}"); +goTo.marker("indent"); +verify.indentationIs(4); +goTo.marker("autoformat"); +verify.currentLineContentIs(" | string"); +goTo.marker("formatAmpersandOperator"); +verify.currentLineContentIs("type Intersection = Foo & Bar;"); + +goTo.marker("unionTypeNoIndent"); +verify.currentLineContentIs(" Bar |"); +goTo.marker("intersectionTypeNoIndent"); +verify.currentLineContentIs(" Baz;"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatVariableAssignments.ts b/tests/cases/fourslash/formatVariableAssignments.ts new file mode 100644 index 00000000000..989f2c5e6ca --- /dev/null +++ b/tests/cases/fourslash/formatVariableAssignments.ts @@ -0,0 +1,35 @@ +/// + +////let t: number; +////t +/////*nextlineWithEqual*/=2+2; +////t= +/////*nextlineWithoutEqual*/2 +/////*nextline2*/+2; +////t +/////*addition*/+= 22 +/////*nextlineSemicolon*/; +////t +////=t +/////*chained*/=t+ 4; + +format.document(); + +goTo.marker("nextlineWithEqual"); +verify.indentationIs(4); +verify.currentLineContentIs(" = 2 + 2;"); +goTo.marker("nextlineWithoutEqual"); +verify.indentationIs(4); +verify.currentLineContentIs(" 2"); +goTo.marker("nextline2"); +verify.indentationIs(4); +verify.currentLineContentIs(" + 2;"); +goTo.marker("addition"); +verify.indentationIs(4); +verify.currentLineContentIs(" += 22"); +goTo.marker("nextlineSemicolon"); +verify.indentationIs(4); +verify.currentLineContentIs(" ;"); +goTo.marker("chained"); +verify.indentationIs(4); +verify.currentLineContentIs(" = t + 4;"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingJsxElements.ts b/tests/cases/fourslash/formattingJsxElements.ts index d0c77804ed5..fd4ccc504a4 100644 --- a/tests/cases/fourslash/formattingJsxElements.ts +++ b/tests/cases/fourslash/formattingJsxElements.ts @@ -1,7 +1,7 @@ /// //@Filename: file.tsx -////function () { +////function foo0() { //// return ( ////
////Hello, World!/*autoformat*/ @@ -10,10 +10,76 @@ //// ) ////} //// +////function foo1() { +//// return ( +////
+////Hello, World!/*autoformat1*/ +/////*indent1*/ +////
+//// ) +////} +//// +////function foo2() { +//// return ( +////
/*2*/ +////Hello, World!/*autoformat2*/ +/////*indent2*/ +////
+//// ) +////} +////function foo3() { +//// return ( +//// /*4*/ +//// Hello, World!/*autoformat3*/ +//// /*indent3*/ +//// +//// ) +////} +////function foo4() { +//// return ( +//// /*6*/ +//// ) +////} format.document(); goTo.marker("autoformat"); verify.currentLineContentIs(' Hello, World!'); goTo.marker("indent"); -verify.indentationIs(12); \ No newline at end of file +verify.indentationIs(12); + +goTo.marker("autoformat1"); +verify.currentLineContentIs(' Hello, World!'); +goTo.marker("indent1"); +verify.indentationIs(12); + +goTo.marker("1"); +verify.currentLineContentIs(' class1= {'); +goTo.marker("2"); +verify.currentLineContentIs(' }>'); + +goTo.marker("autoformat2"); +verify.currentLineContentIs(' Hello, World!'); +goTo.marker("indent2"); +verify.indentationIs(12); + +goTo.marker("3"); +verify.currentLineContentIs(' class2= {'); +goTo.marker("4"); +verify.currentLineContentIs(' }>'); + +goTo.marker("autoformat3"); +verify.currentLineContentIs(' Hello, World!'); +goTo.marker("indent3"); +verify.indentationIs(12); + +goTo.marker("5"); +verify.currentLineContentIs(' class3= {'); +goTo.marker("6"); +verify.currentLineContentIs(' }/>'); diff --git a/tests/cases/fourslash/formattingOnStatementsWithNoSemicolon.ts b/tests/cases/fourslash/formattingOnStatementsWithNoSemicolon.ts index e33298a5a3b..6dfa61cf294 100644 --- a/tests/cases/fourslash/formattingOnStatementsWithNoSemicolon.ts +++ b/tests/cases/fourslash/formattingOnStatementsWithNoSemicolon.ts @@ -155,7 +155,7 @@ verify.currentLineContentIs(" else"); goTo.marker("61"); verify.currentLineContentIs(" x += 2"); goTo.marker("62"); -verify.currentLineContentIs(" ;"); +verify.currentLineContentIs(" ;"); goTo.marker("63"); verify.currentLineContentIs("do do do do"); goTo.marker("64"); diff --git a/tests/cases/fourslash/genericTypeAliasIntersectionCompletions.ts b/tests/cases/fourslash/genericTypeAliasIntersectionCompletions.ts new file mode 100644 index 00000000000..0b2646291da --- /dev/null +++ b/tests/cases/fourslash/genericTypeAliasIntersectionCompletions.ts @@ -0,0 +1,33 @@ +/// + +//// type MixinCtor = new () => A & B & { constructor: MixinCtor }; +//// function merge(a: { prototype: A }, b: { prototype: B }): MixinCtor { +//// let merged = function() { } +//// Object.assign(merged.prototype, a.prototype, b.prototype); +//// return >merged; +//// } +//// +//// class TreeNode { +//// value: any; +//// } +//// +//// abstract class LeftSideNode extends TreeNode { +//// abstract right(): TreeNode; +//// left(): TreeNode { +//// return null; +//// } +//// } +//// +//// abstract class RightSideNode extends TreeNode { +//// abstract left(): TreeNode; +//// right(): TreeNode { +//// return null; +//// }; +//// } +//// +//// var obj = new (merge(LeftSideNode, RightSideNode))(); +//// obj./**/ + +goTo.marker(); +verify.completionListContains("left"); +verify.completionListContains("right"); diff --git a/tests/cases/fourslash/getEmitOutputOutFile.ts b/tests/cases/fourslash/getEmitOutputOutFile.ts new file mode 100644 index 00000000000..4a9439737ea --- /dev/null +++ b/tests/cases/fourslash/getEmitOutputOutFile.ts @@ -0,0 +1,22 @@ +/// + +// @BaselineFile: getEmitOutputOutFile.baseline +// @declaration: true +// @outFile: outFile.js + +// @Filename: inputFile1.ts +// @emitThisFile: true +//// var x: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.ts +//// var x1: string = "hello world"; +//// class Foo{ +//// x : string; +//// y : number; +//// } + +verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputTsxFile_Preserve.ts b/tests/cases/fourslash/getEmitOutputTsxFile_Preserve.ts new file mode 100644 index 00000000000..19eda2ad111 --- /dev/null +++ b/tests/cases/fourslash/getEmitOutputTsxFile_Preserve.ts @@ -0,0 +1,22 @@ +/// + +// @BaselineFile: getEmitOutputTsxFile_Preserve.baseline +// @declaration: true +// @sourceMap: true +// @jsx: preserve + +// @Filename: inputFile1.ts +// @emitThisFile: true +////// regular ts file +//// var t: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.tsx +// @emitThisFile: true +//// var y = "my div"; +//// var x =
+ +verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getEmitOutputTsxFile_React.ts b/tests/cases/fourslash/getEmitOutputTsxFile_React.ts new file mode 100644 index 00000000000..ccfa3bcc0c2 --- /dev/null +++ b/tests/cases/fourslash/getEmitOutputTsxFile_React.ts @@ -0,0 +1,22 @@ +/// + +// @BaselineFile: getEmitOutputTsxFile_React.baseline +// @declaration: true +// @sourceMap: true +// @jsx: react + +// @Filename: inputFile1.ts +// @emitThisFile: true +////// regular ts file +//// var t: number = 5; +//// class Bar { +//// x : string; +//// y : number +//// } + +// @Filename: inputFile2.tsx +// @emitThisFile: true +//// var y = "my div"; +//// var x =
+ +verify.baselineGetEmitOutput(); \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesClassExpressionStaticThis.ts b/tests/cases/fourslash/getOccurrencesClassExpressionStaticThis.ts new file mode 100644 index 00000000000..5444ab9acdd --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesClassExpressionStaticThis.ts @@ -0,0 +1,56 @@ +/// + +////var x = class C { +//// public x; +//// public y; +//// public z; +//// public staticX; +//// constructor() { +//// this; +//// this.x; +//// this.y; +//// this.z; +//// } +//// foo() { +//// this; +//// () => this; +//// () => { +//// if (this) { +//// this; +//// } +//// } +//// function inside() { +//// this; +//// (function (_) { +//// this; +//// })(this); +//// } +//// return this.x; +//// } +//// +//// static bar() { +//// [|this|]; +//// [|this|].staticX; +//// () => [|this|]; +//// () => { +//// if ([|this|]) { +//// [|this|]; +//// } +//// } +//// function inside() { +//// this; +//// (function (_) { +//// this; +//// })(this); +//// } +//// } +////} + +const ranges = test.ranges(); +for (let r of ranges) { + goTo.position(r.start); + + for (let range of ranges) { + verify.occurrencesAtPositionContains(range, false); + } +} diff --git a/tests/cases/fourslash/getOccurrencesClassExpressionThis.ts b/tests/cases/fourslash/getOccurrencesClassExpressionThis.ts new file mode 100644 index 00000000000..ed8f8cb1d0e --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesClassExpressionThis.ts @@ -0,0 +1,54 @@ +/// + +////var x = class C { +//// public x; +//// public y; +//// public z; +//// constructor() { +//// [|this|]; +//// [|this|].x; +//// [|this|].y; +//// [|this|].z; +//// } +//// foo() { +//// [|this|]; +//// () => [|this|]; +//// () => { +//// if ([|this|]) { +//// [|this|]; +//// } +//// } +//// function inside() { +//// this; +//// (function (_) { +//// this; +//// })(this); +//// } +//// return [|this|].x; +//// } +//// +//// static bar() { +//// this; +//// () => this; +//// () => { +//// if (this) { +//// this; +//// } +//// } +//// function inside() { +//// this; +//// (function (_) { +//// this; +//// })(this); +//// } +//// } +////} + +const ranges = test.ranges(); +for (let r of ranges) { + goTo.position(r.start); + + for (let range of ranges) { + verify.occurrencesAtPositionContains(range, false); + } +} diff --git a/tests/cases/fourslash/goToDefinitionConstructorOfClassExpression01.ts b/tests/cases/fourslash/goToDefinitionConstructorOfClassExpression01.ts new file mode 100644 index 00000000000..aa96400a397 --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionConstructorOfClassExpression01.ts @@ -0,0 +1,11 @@ +/// + +////var x = class C { +//// /*definition*/constructor() { +//// var other = new /*usage*/C; +//// } +////} + +goTo.marker("usage"); +goTo.definition(); +verify.caretAtMarker("definition"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01.ts b/tests/cases/fourslash/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01.ts new file mode 100644 index 00000000000..dc5c362772c --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionConstructorOfClassWhenClassIsPrecededByNamespace01.ts @@ -0,0 +1,16 @@ +/// + +////namespace Foo { +//// export var x; +////} +//// +////class Foo { +//// /*definition*/constructor() { +//// } +////} +//// +////var x = new /*usage*/Foo(); + +goTo.marker("usage"); +goTo.definition(); +verify.caretAtMarker("definition"); \ No newline at end of file diff --git a/tests/cases/fourslash/indentationInJsx1.ts b/tests/cases/fourslash/indentationInJsx1.ts new file mode 100644 index 00000000000..5343c7a7c10 --- /dev/null +++ b/tests/cases/fourslash/indentationInJsx1.ts @@ -0,0 +1,17 @@ +/// + +//@Filename: file.tsx +////(function () { +//// return ( +////
+////
+////
+//// /*indent2*/ +////
+//// ) +////}) + + +format.document(); +goTo.marker("indent2"); +verify.indentationIs(12); \ No newline at end of file diff --git a/tests/cases/fourslash/indentationInJsx2.ts b/tests/cases/fourslash/indentationInJsx2.ts new file mode 100644 index 00000000000..f23a14f68cc --- /dev/null +++ b/tests/cases/fourslash/indentationInJsx2.ts @@ -0,0 +1,7 @@ +/// + +//@Filename: file.tsx +////
/*1*/ +goTo.marker("1"); +edit.insert("\n"); +verify.indentationIs(0); diff --git a/tests/cases/fourslash/jsxSpreadReference.ts b/tests/cases/fourslash/jsxSpreadReference.ts new file mode 100644 index 00000000000..64ab03e6ab9 --- /dev/null +++ b/tests/cases/fourslash/jsxSpreadReference.ts @@ -0,0 +1,25 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// } +//// interface ElementAttributesProperty { props } +//// } +//// class MyClass { +//// props: { +//// name?: string; +//// size?: number; +//// } +//// } +//// +//// var [|/*dst*/nn|]: {name?: string; size?: number}; +//// var x = ; + +goTo.marker('src'); +goTo.definition(); +verify.caretAtMarker('dst'); + +goTo.marker('src'); +verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); diff --git a/tests/cases/fourslash/parameterWithDestructuring.ts b/tests/cases/fourslash/parameterWithDestructuring.ts new file mode 100644 index 00000000000..72dfefd553a --- /dev/null +++ b/tests/cases/fourslash/parameterWithDestructuring.ts @@ -0,0 +1,22 @@ +/// + +// Repros from issues #4949 and #4818 + +////const result = [{ foo: 'hello' }] +//// .map(({ /*1*/foo }) => /*2*/foo) +//// .map(foo => foo); +//// +////const f = (foo: (bar: string[]) => void) => { }; +//// +////f(([a, b]) => { +//// /*3*/a.charAt(0); // Not okay: inferred as `any` +////}); + +goTo.marker('1'); +verify.quickInfoIs('var foo: string'); + +goTo.marker('2'); +verify.quickInfoIs('var foo: string'); + +goTo.marker('3'); +verify.quickInfoIs('var a: string'); diff --git a/tests/cases/fourslash/quickInfoDisplayPartsTypeParameterInTypeAlias.ts b/tests/cases/fourslash/quickInfoDisplayPartsTypeParameterInTypeAlias.ts new file mode 100644 index 00000000000..b6a10e086c2 --- /dev/null +++ b/tests/cases/fourslash/quickInfoDisplayPartsTypeParameterInTypeAlias.ts @@ -0,0 +1,44 @@ +/// + +////type /*0*/List = /*2*/T[] +////type /*3*/List2 = /*5*/T[]; + +type List2 = T[]; + +type L = T[] +let typeAliashDisplayParts = [{ text: "type", kind: "keyword" }, { text: " ", kind: "space" }, { text: "List", kind: "aliasName" }, + { text: "<", kind: "punctuation" }, { text: "T", kind: "typeParameterName" }, { text: ">", kind: "punctuation" }]; + +let typeAliashDisplayParts2 = [{ text: "type", kind: "keyword" }, { text: " ", kind: "space" }, { text: "List2", kind: "aliasName" }, + { text: "<", kind: "punctuation" }, { text: "T", kind: "typeParameterName" }, { text: " ", kind: "space" }, { text: "extends", kind: "keyword" }, + { text: " ", kind: "space" }, { text: "string", kind: "keyword" }, { text: ">", kind: "punctuation" }]; + +let typeParameterDisplayParts = [{ text: "(", kind: "punctuation" }, { text: "type parameter", kind: "text" }, { text: ")", kind: "punctuation" }, { text: " ", kind: "space" }, + { text: "T", kind: "typeParameterName" }, { text: " ", kind: "space" }, { text: "in", kind: "keyword" }, { text: " ", kind: "space" } ] + + +goTo.marker('0'); +verify.verifyQuickInfoDisplayParts("type", "", { start: test.markerByName("0").position, length: "List".length }, + typeAliashDisplayParts.concat([{ text: " ", kind: "space" }, { text: "=", kind: "operator" }, { "text": " ", "kind": "space" }, { text: "T", kind: "typeParameterName" }, + { text: "[", kind: "punctuation" }, { text: "]", kind: "punctuation" }]), []); + +goTo.marker('1'); +verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("1").position, length: "T".length }, + typeParameterDisplayParts.concat(typeAliashDisplayParts), []); + +goTo.marker('2'); +verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("2").position, length: "T".length }, + typeParameterDisplayParts.concat(typeAliashDisplayParts), []); + +goTo.marker('3'); +verify.verifyQuickInfoDisplayParts("type", "", { start: test.markerByName("3").position, length: "List2".length }, + typeAliashDisplayParts2.concat([{ text: " ", kind: "space" }, { text: "=", kind: "operator" }, { "text": " ", "kind": "space" }, { text: "T", kind: "typeParameterName" }, + { text: "[", kind: "punctuation" }, { text: "]", kind: "punctuation" }]), []); + +goTo.marker('4'); +verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("4").position, length: "T".length }, + typeParameterDisplayParts.concat(typeAliashDisplayParts2), []); + +goTo.marker('5'); +verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("5").position, length: "T".length }, + typeParameterDisplayParts.concat(typeAliashDisplayParts2), []); \ No newline at end of file diff --git a/tests/cases/fourslash/semanticClassificationClassExpression.ts b/tests/cases/fourslash/semanticClassificationClassExpression.ts new file mode 100644 index 00000000000..f067265df29 --- /dev/null +++ b/tests/cases/fourslash/semanticClassificationClassExpression.ts @@ -0,0 +1,12 @@ +/// + +//// var x = class /*0*/C {} +//// class /*1*/C {} +//// class /*2*/D extends class /*3*/B{} { } +var c = classification; +verify.semanticClassificationsAre( + c.className("C", test.marker("0").position), + c.className("C", test.marker("1").position), + c.className("D", test.marker("2").position), + c.className("B", test.marker("3").position) +); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts index 3931433e51f..2cfd27f2e3b 100644 --- a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts +++ b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts @@ -12,6 +12,6 @@ function verifyIndentationAfterNewLine(marker: string, indentation: number): voi verifyIndentationAfterNewLine("1", 4); verifyIndentationAfterNewLine("2", 4); verifyIndentationAfterNewLine("3", 4); -verifyIndentationAfterNewLine("4", 4); +verifyIndentationAfterNewLine("4", 8); verifyIndentationAfterNewLine("5", 4); verifyIndentationAfterNewLine("6", 4); \ No newline at end of file diff --git a/tests/cases/fourslash/tsxCompletion8.ts b/tests/cases/fourslash/tsxCompletion8.ts new file mode 100644 index 00000000000..59ad8385b9d --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion8.ts @@ -0,0 +1,19 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { ONE: string; TWO: number; } +//// } +//// } +//// var x =
; + + +goTo.marker('1'); +verify.completionListContains("ONE"); +verify.not.completionListAllowsNewIdentifier(); + +goTo.marker('2'); +verify.completionListContains("ONE"); +verify.not.completionListAllowsNewIdentifier(); diff --git a/tests/cases/fourslash/tsxRename5.ts b/tests/cases/fourslash/tsxRename5.ts new file mode 100644 index 00000000000..cc18d6287c3 --- /dev/null +++ b/tests/cases/fourslash/tsxRename5.ts @@ -0,0 +1,20 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// } +//// interface ElementAttributesProperty { props } +//// } +//// class MyClass { +//// props: { +//// name?: string; +//// size?: number; +//// } +//// +//// var [|nn|]: string; +//// var x = ; + +goTo.marker(); +verify.renameLocations(false, false); diff --git a/tests/cases/fourslash/whiteSpaceTrimming2.ts b/tests/cases/fourslash/whiteSpaceTrimming2.ts new file mode 100644 index 00000000000..de7bd0ae446 --- /dev/null +++ b/tests/cases/fourslash/whiteSpaceTrimming2.ts @@ -0,0 +1,21 @@ +/// + +////let noSubTemplate = `/* /*1*/`; +////let templateHead = `/* /*2*/${1 + 2}`; +////let templateMiddle = `/* ${1 + 2 /*3*/}`; +////let templateTail = `/* ${1 + 2} /*4*/`; + +goTo.marker('1'); +edit.insert("\n"); + +goTo.marker('2'); +edit.insert("\n"); + +goTo.marker('3'); +edit.insert("\n"); + +goTo.marker('4'); +edit.insert("\n"); + + +verify.currentFileContentIs("let noSubTemplate = `/* \n`;\nlet templateHead = `/* \n${1 + 2}`;\nlet templateMiddle = `/* ${1 + 2\n }`;\nlet templateTail = `/* ${1 + 2} \n`;"); diff --git a/tests/cases/fourslash/whiteSpaceTrimming3.ts b/tests/cases/fourslash/whiteSpaceTrimming3.ts new file mode 100644 index 00000000000..93d236773e4 --- /dev/null +++ b/tests/cases/fourslash/whiteSpaceTrimming3.ts @@ -0,0 +1,10 @@ +/// + +////let t = "foo \ +////bar \ +////"/*1*/ + +goTo.marker('1'); +edit.insert(";"); + +verify.currentFileContentIs("let t = \"foo \\\nbar \\ \n\";"); diff --git a/tests/cases/fourslash/whiteSpaceTrimming4.ts b/tests/cases/fourslash/whiteSpaceTrimming4.ts new file mode 100644 index 00000000000..59223197681 --- /dev/null +++ b/tests/cases/fourslash/whiteSpaceTrimming4.ts @@ -0,0 +1,8 @@ +/// + +////var re = /\w+ /*1*//; + +goTo.marker('1'); +edit.insert("\n"); + +verify.currentFileContentIs("var re = /\\w+ \n /;"); diff --git a/tests/cases/unittests/moduleResolution.ts b/tests/cases/unittests/moduleResolution.ts new file mode 100644 index 00000000000..809782bae6f --- /dev/null +++ b/tests/cases/unittests/moduleResolution.ts @@ -0,0 +1,232 @@ +/// +/// + +declare namespace chai.assert { + function deepEqual(actual: any, expected: any): void; +} + +module ts { + + interface File { + name: string + content?: string + } + + function createModuleResolutionHost(...files: File[]): ModuleResolutionHost { + let map = arrayToMap(files, f => f.name); + + return { fileExists, readFile }; + + function fileExists(path: string): boolean { + return hasProperty(map, path); + } + + function readFile(path: string): string { + return hasProperty(map, path) ? map[path].content : undefined; + } + } + + function splitPath(path: string): { dir: string; rel: string } { + let index = path.indexOf(directorySeparator); + return index === -1 + ? { dir: path, rel: undefined } + : { dir: path.substr(0, index), rel: path.substr(index + 1) }; + } + + describe("Node module resolution - relative paths", () => { + + function testLoadAsFile(containingFileName: string, moduleFileNameNoExt: string, moduleName: string): void { + for (let ext of supportedExtensions) { + let containingFile = { name: containingFileName } + let moduleFile = { name: moduleFileNameNoExt + ext } + let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); + assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); + assert.equal(!!resolution.resolvedModule.isExternalLibraryImport, false); + + let failedLookupLocations: string[] = []; + let dir = getDirectoryPath(containingFileName); + for (let e of supportedExtensions) { + if (e === ext) { + break; + } + else { + failedLookupLocations.push(normalizePath(getRootLength(moduleName) === 0 ? combinePaths(dir, moduleName) : moduleName) + e); + } + } + + assert.deepEqual(resolution.failedLookupLocations, failedLookupLocations); + } + } + + it("module name that starts with './' resolved as relative file name", () => { + testLoadAsFile("/foo/bar/baz.ts", "/foo/bar/foo", "./foo"); + }); + + it("module name that starts with '../' resolved as relative file name", () => { + testLoadAsFile("/foo/bar/baz.ts", "/foo/foo", "../foo"); + }); + + it("module name that starts with '/' script extension resolved as relative file name", () => { + testLoadAsFile("/foo/bar/baz.ts", "/foo", "/foo"); + }); + + it("module name that starts with 'c:/' script extension resolved as relative file name", () => { + testLoadAsFile("c:/foo/bar/baz.ts", "c:/foo", "c:/foo"); + }); + + function testLoadingFromPackageJson(containingFileName: string, packageJsonFileName: string, fieldRef: string, moduleFileName: string, moduleName: string): void { + let containingFile = { name: containingFileName }; + let packageJson = { name: packageJsonFileName, content: JSON.stringify({ "typings": fieldRef }) }; + let moduleFile = { name: moduleFileName }; + let resolution = nodeModuleNameResolver(moduleName, containingFile.name, createModuleResolutionHost(containingFile, packageJson, moduleFile)); + assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); + assert.equal(!!resolution.resolvedModule.isExternalLibraryImport, false); + // expect three failed lookup location - attempt to load module as file with all supported extensions + assert.equal(resolution.failedLookupLocations.length, 3); + } + + it("module name as directory - load from typings", () => { + testLoadingFromPackageJson("/a/b/c/d.ts", "/a/b/c/bar/package.json", "c/d/e.d.ts", "/a/b/c/bar/c/d/e.d.ts", "./bar"); + testLoadingFromPackageJson("/a/b/c/d.ts", "/a/bar/package.json", "e.d.ts", "/a/bar/e.d.ts", "../../bar"); + testLoadingFromPackageJson("/a/b/c/d.ts", "/bar/package.json", "e.d.ts", "/bar/e.d.ts", "/bar"); + testLoadingFromPackageJson("c:/a/b/c/d.ts", "c:/bar/package.json", "e.d.ts", "c:/bar/e.d.ts", "c:/bar"); + }); + + it ("module name as directory - load index.d.ts", () => { + let containingFile = {name: "/a/b/c.ts"}; + let packageJson = {name: "/a/b/foo/package.json", content: JSON.stringify({main: "/c/d"})}; + let indexFile = { name: "/a/b/foo/index.d.ts" }; + let resolution = nodeModuleNameResolver("./foo", containingFile.name, createModuleResolutionHost(containingFile, packageJson, indexFile)); + assert.equal(resolution.resolvedModule.resolvedFileName, indexFile.name); + assert.equal(!!resolution.resolvedModule.isExternalLibraryImport, false); + assert.deepEqual(resolution.failedLookupLocations, [ + "/a/b/foo.ts", + "/a/b/foo.tsx", + "/a/b/foo.d.ts", + "/a/b/foo/index.ts", + "/a/b/foo/index.tsx", + ]); + }); + }); + + describe("Node module resolution - non-relative paths", () => { + it("load module as file - ts files not loaded", () => { + let containingFile = { name: "/a/b/c/d/e.ts" }; + let moduleFile = { name: "/a/b/node_modules/foo.ts" }; + let resolution = nodeModuleNameResolver("foo", containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); + assert.equal(resolution.resolvedModule, undefined); + assert.deepEqual(resolution.failedLookupLocations, [ + "/a/b/c/d/node_modules/foo.d.ts", + "/a/b/c/d/node_modules/foo/package.json", + "/a/b/c/d/node_modules/foo/index.d.ts", + "/a/b/c/node_modules/foo.d.ts", + "/a/b/c/node_modules/foo/package.json", + "/a/b/c/node_modules/foo/index.d.ts", + "/a/b/node_modules/foo.d.ts", + "/a/b/node_modules/foo/package.json", + "/a/b/node_modules/foo/index.d.ts", + "/a/node_modules/foo.d.ts", + "/a/node_modules/foo/package.json", + "/a/node_modules/foo/index.d.ts", + "/node_modules/foo.d.ts", + "/node_modules/foo/package.json", + "/node_modules/foo/index.d.ts" + ]) + }); + + it("load module as file", () => { + let containingFile = { name: "/a/b/c/d/e.ts" }; + let moduleFile = { name: "/a/b/node_modules/foo.d.ts" }; + let resolution = nodeModuleNameResolver("foo", containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); + assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); + assert.equal(resolution.resolvedModule.isExternalLibraryImport, true); + }); + + it("load module as directory", () => { + let containingFile = { name: "/a/node_modules/b/c/node_modules/d/e.ts" }; + let moduleFile = { name: "/a/node_modules/foo/index.d.ts" }; + let resolution = nodeModuleNameResolver("foo", containingFile.name, createModuleResolutionHost(containingFile, moduleFile)); + assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name); + assert.equal(resolution.resolvedModule.isExternalLibraryImport, true); + assert.deepEqual(resolution.failedLookupLocations, [ + "/a/node_modules/b/c/node_modules/d/node_modules/foo.d.ts", + "/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json", + "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.d.ts", + "/a/node_modules/b/c/node_modules/foo.d.ts", + "/a/node_modules/b/c/node_modules/foo/package.json", + "/a/node_modules/b/c/node_modules/foo/index.d.ts", + "/a/node_modules/b/node_modules/foo.d.ts", + "/a/node_modules/b/node_modules/foo/package.json", + "/a/node_modules/b/node_modules/foo/index.d.ts", + "/a/node_modules/foo.d.ts", + "/a/node_modules/foo/package.json" + ]); + }); + }); + + describe("Module resolution - relative imports", () => { + it("should find all modules", () => { + const options: CompilerOptions = { module: ModuleKind.CommonJS }; + const files: Map = { + "/a/b/c/first/shared.ts": ` +class A {} +export = A`, + "/a/b/c/first/second/class_a.ts": ` +import Shared = require('../shared'); +import C = require('../../third/class_c'); +class B {} +export = B;`, + "/a/b/c/third/class_c.ts":` +import Shared = require('../first/shared'); +class C {} +export = C; + ` + }; + const currentDirectory = "/a/b/c/first/second"; + const host: CompilerHost = { + getSourceFile: (fileName: string, languageVersion: ScriptTarget) => { + let path = normalizePath(combinePaths(currentDirectory, fileName)); + return hasProperty(files, path) ? createSourceFile(fileName, files[path], languageVersion) : undefined; + }, + getDefaultLibFileName: () => "lib.d.ts", + writeFile: (fileName, content): void => { throw new Error("NotImplemented"); }, + getCurrentDirectory: () => currentDirectory, + getCanonicalFileName: fileName => fileName.toLowerCase(), + getNewLine: () => "\r\n", + useCaseSensitiveFileNames: () => false, + fileExists: fileName => { + let path = normalizePath(combinePaths(currentDirectory, fileName)); + return hasProperty(files, path); + }, + readFile: (fileName): string => { throw new Error("NotImplemented"); } + }; + + const program = createProgram(["class_a.ts"], options, host); + + assert.equal(program.getSourceFiles().length, 3); + const syntacticDiagnostics = program.getSyntacticDiagnostics(); + assert.equal(syntacticDiagnostics.length, 0, `expect no syntactic diagnostics, got: ${JSON.stringify(syntacticDiagnostics.map(diagnosticToString))}`); + const semanticDiagnostics = program.getSemanticDiagnostics(); + assert.equal(semanticDiagnostics.length, 0, `expect no semantic diagnostics, got: ${JSON.stringify(semanticDiagnostics.map(diagnosticToString))}`); + + // try to get file using a relative name + const fileC = program.getSourceFile("../../../c/third/class_c.ts"); + assert.isTrue(fileC !== undefined, `expected to get file by relative name, got ${fileC}`); + }); + + function diagnosticToString(diagnostic: Diagnostic) { + let output = ""; + + if (diagnostic.file) { + let loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); + + output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `; + } + + let category = DiagnosticCategory[diagnostic.category].toLowerCase(); + output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`; + + return output; + } + }); +} \ No newline at end of file diff --git a/tests/cases/unittests/reuseProgramStructure.ts b/tests/cases/unittests/reuseProgramStructure.ts index 6c043299c8f..5f313eeae2b 100644 --- a/tests/cases/unittests/reuseProgramStructure.ts +++ b/tests/cases/unittests/reuseProgramStructure.ts @@ -160,7 +160,7 @@ module ts { return size; } - function checkResolvedModulesCache(program: Program, fileName: string, expectedContent: Map): void { + function checkResolvedModulesCache(program: Program, fileName: string, expectedContent: Map): void { let file = program.getSourceFile(fileName); assert.isTrue(file !== undefined, `cannot find file ${fileName}`); if (expectedContent === undefined) { @@ -175,7 +175,16 @@ module ts { for (let id in expectedContent) { if (hasProperty(expectedContent, id)) { assert.isTrue(hasProperty(file.resolvedModules, id), `expected ${id} to be found in resolved modules`); - assert.isTrue(expectedContent[id] === file.resolvedModules[id], `expected '${expectedContent[id]}' to be equal to '${file.resolvedModules[id]}'`); + if (expectedContent[id]) { + const expected = expectedContent[id]; + const actual = file.resolvedModules[id]; + assert.isTrue(actual !== undefined); + assert.isTrue(expected.resolvedFileName === actual.resolvedFileName, `'resolvedFileName': expected '${expected.resolvedFileName}' to be equal to '${actual.resolvedFileName}'`); + assert.isTrue(expected.isExternalLibraryImport === actual.isExternalLibraryImport, `'shouldBeProperExternalModule': expected '${expected.isExternalLibraryImport}' to be equal to '${actual.isExternalLibraryImport}'`); + } + else { + assert.isTrue(file.resolvedModules[id] === undefined); + } } } } @@ -184,7 +193,11 @@ module ts { describe("Reuse program structure", () => { let target = ScriptTarget.Latest; let files = [ - { name: "a.ts", text: SourceText.New(`/// `, "", `var x = 1`) }, + { name: "a.ts", text: SourceText.New( + ` +/// +/// +`, "",`var x = 1`) }, { name: "b.ts", text: SourceText.New(`/// `, "", `var y = 2`) }, { name: "c.ts", text: SourceText.New("", "", `var z = 1;`) }, ] @@ -195,6 +208,9 @@ module ts { files[0].text = files[0].text.updateProgram("var x = 100"); }); assert.isTrue(program_1.structureIsReused); + let program1Diagnostics = program_1.getSemanticDiagnostics(program_1.getSourceFile("a.ts")) + let program2Diagnostics = program_2.getSemanticDiagnostics(program_1.getSourceFile("a.ts")) + assert.equal(program1Diagnostics.length, program2Diagnostics.length); }); it("fails if change affects tripleslash references", () => { @@ -230,7 +246,7 @@ module ts { var options: CompilerOptions = { target }; var program_1 = newProgram(files, ["a.ts"], options); - checkResolvedModulesCache(program_1, "a.ts", { "b": "b.ts" }); + checkResolvedModulesCache(program_1, "a.ts", { "b": { resolvedFileName: "b.ts" } }); checkResolvedModulesCache(program_1, "b.ts", undefined); var program_2 = updateProgram(program_1, ["a.ts"], options, files => { @@ -239,7 +255,7 @@ module ts { assert.isTrue(program_1.structureIsReused); // content of resolution cache should not change - checkResolvedModulesCache(program_1, "a.ts", { "b": "b.ts" }); + checkResolvedModulesCache(program_1, "a.ts", { "b": { resolvedFileName: "b.ts" } }); checkResolvedModulesCache(program_1, "b.ts", undefined); // imports has changed - program is not reused @@ -256,7 +272,7 @@ module ts { files[0].text = files[0].text.updateImportsAndExports(newImports); }); assert.isTrue(!program_3.structureIsReused); - checkResolvedModulesCache(program_4, "a.ts", { "b": "b.ts", "c": undefined }); + checkResolvedModulesCache(program_4, "a.ts", { "b": { resolvedFileName: "b.ts" }, "c": undefined }); }); }) } \ No newline at end of file diff --git a/tests/cases/unittests/services/preProcessFile.ts b/tests/cases/unittests/services/preProcessFile.ts index 982c45f0f2d..a3f8db5528f 100644 --- a/tests/cases/unittests/services/preProcessFile.ts +++ b/tests/cases/unittests/services/preProcessFile.ts @@ -173,6 +173,20 @@ describe('PreProcessFile:', function () { isLibFile: false }) }); + + it("Correctly handles export import declarations", function () { + test("export import a = require(\"m1\");", + true, + { + referencedFiles: [], + importedFiles: [ + { fileName: "m1", pos: 26, end: 28 } + ], + ambientExternalModules: undefined, + isLibFile: false + }) + }); + }); }); diff --git a/tests/cases/unittests/transpile.ts b/tests/cases/unittests/transpile.ts index b3806c4f675..ca7d1faa4a9 100644 --- a/tests/cases/unittests/transpile.ts +++ b/tests/cases/unittests/transpile.ts @@ -23,6 +23,13 @@ module ts { function test(input: string, testSettings: TranspileTestSettings): void { let transpileOptions: TranspileOptions = testSettings.options || {}; + if (!transpileOptions.compilerOptions) { + transpileOptions.compilerOptions = {}; + } + if(transpileOptions.compilerOptions.newLine === undefined) { + // use \r\n as default new line + transpileOptions.compilerOptions.newLine = ts.NewLineKind.CarriageReturnLineFeed; + } let canUseOldTranspile = !transpileOptions.renamedDependencies; @@ -57,8 +64,8 @@ module ts { let transpileModuleResultWithSourceMap = transpileModule(input, transpileOptions); assert.isTrue(transpileModuleResultWithSourceMap.sourceMapText !== undefined); - let expectedSourceMapFileName = removeFileExtension(transpileOptions.fileName) + ".js.map"; - let expectedSourceMappingUrlLine = `//# sourceMappingURL=${expectedSourceMapFileName}`; + let expectedSourceMapFileName = removeFileExtension(getBaseFileName(normalizeSlashes(transpileOptions.fileName))) + ".js.map"; + let expectedSourceMappingUrlLine = `//# sourceMappingURL=${expectedSourceMapFileName}`; if (testSettings.expectedOutput !== undefined) { assert.equal(transpileModuleResultWithSourceMap.outputText, testSettings.expectedOutput + expectedSourceMappingUrlLine); @@ -195,14 +202,14 @@ var x = 0;`, `declare function use(a: any);\n` + `use(foo);` let output = - `(function (deps, factory) {\n` + + `(function (factory) {\n` + ` if (typeof module === 'object' && typeof module.exports === 'object') {\n` + ` var v = factory(require, exports); if (v !== undefined) module.exports = v;\n` + ` }\n` + ` else if (typeof define === 'function' && define.amd) {\n` + - ` define(deps, factory);\n` + + ` define(["require", "exports", "SomeOtherName"], factory);\n` + ` }\n` + - `})(["require", "exports", "SomeOtherName"], function (require, exports) {\n` + + `})(function (require, exports) {\n` + ` var SomeName_1 = require("SomeOtherName");\n` + ` use(SomeName_1.foo);\n` + `});\n`; @@ -213,6 +220,59 @@ var x = 0;`, expectedOutput: output }); }); + + it("Transpile with emit decorators and emit metadata", () => { + let input = + `import {db} from './db';\n` + + `function someDecorator(target) {\n` + + ` return target;\n` + + `} \n` + + `@someDecorator\n` + + `class MyClass {\n` + + ` db: db;\n` + + ` constructor(db: db) {\n` + + ` this.db = db;\n` + + ` this.db.doSomething(); \n` + + ` }\n` + + `}\n` + + `export {MyClass}; \n` + let output = + `var db_1 = require(\'./db\');\n` + + `function someDecorator(target) {\n` + + ` return target;\n` + + `}\n` + + `var MyClass = (function () {\n` + + ` function MyClass(db) {\n` + + ` this.db = db;\n` + + ` this.db.doSomething();\n` + + ` }\n` + + ` MyClass = __decorate([\n` + + ` someDecorator, \n` + + ` __metadata(\'design:paramtypes\', [(typeof (_a = typeof db_1.db !== \'undefined\' && db_1.db) === \'function\' && _a) || Object])\n` + + ` ], MyClass);\n` + + ` return MyClass;\n` + + ` var _a;\n` + + `})();\n` + + `exports.MyClass = MyClass;\n`; + test(input, + { + options: { + compilerOptions: { + module: ModuleKind.CommonJS, + newLine: NewLineKind.LineFeed, + noEmitHelpers: true, + emitDecoratorMetadata: true, + experimentalDecorators: true, + target: ScriptTarget.ES5, + } + }, + expectedOutput: output + }); + }); + + it("Supports backslashes in file name", () => { + test("var x", { expectedOutput: "var x;\r\n", options: { fileName: "a\\b.ts" }}); + }); }); } diff --git a/tslint.json b/tslint.json index 71dc6730de4..19ccd30ca9f 100644 --- a/tslint.json +++ b/tslint.json @@ -8,10 +8,9 @@ "spaces" ], "one-line": [true, - "check-open-brace" + "check-open-brace", + "check-whitespace" ], - "no-unreachable": true, - "no-use-before-declare": true, "no-var-keyword": true, "quotemark": [true, "double" @@ -21,7 +20,8 @@ "check-branch", "check-operator", "check-separator", - "check-type" + "check-type", + "check-module" ], "typedef-whitespace": [true, { "call-signature": "nospace", @@ -29,6 +29,15 @@ "parameter": "nospace", "property-declaration": "nospace", "variable-declaration": "nospace" - }] + }], + "next-line": [true, + "check-catch", + "check-else" + ], + "no-internal-module": true, + "no-trailing-whitespace": true, + "no-inferrable-types": true, + "no-null": true, + "boolean-trivia": true } }